//When the mouse moves over the element switch the CSS Class Name
//When the mouse moves out of the element switch the CSS Class back
function switchClass(toggle, className){
	if(toggle){
		event.srcElement.className = className;
	}
	else {
		event.srcElement.className = "";
	}
}

//Function that fades the top image = object.children
 function fadeTop(image){ 
        image.filters("blendTrans").apply();
        image.style.visibility = "hidden";
        image.filters("blendTrans").play();
        //move(testCont.children);
}

// These are all the images in the div container
function move(images){ 
        var top = 0;
        var next = 0; // Delcares a variable to hold the next top image
        var idx = 0; //zIndex value
        var sOut = "";
        for(var i = images.length - 1; i >= 0 ; i-- ){
            idx = images[i].style.zIndex;
            if (idx != images.length -1){
                    images[i].style.zIndex += 1;
                    if(next < idx){
                            next = i;
                    }
            }
            else {
                    top = i;

            }
        }
        //Put the top image to the back of the stack
        images[top].style.zIndex -= (images.length -1);
        //Make the image visible again
        images[top].style.visibility = "visible";
        //Start the fading process over with the new top image
        var smFun = "";
        smFun = "fadeTop(" + images[next].id +")";
        //Wait 3 seconds then fade the first image
        window.setTimeout(smFun, 3000);
}
function start(image){
    //Wait 1 second then fade the first image
    var smFun = "fadeTop(" + image.id +")";
    window.setTimeout(smFun, 1000);
}
function underline(obj){
    obj.style.textDecoration = "underline";
}
function openWin(iName, iTitle){
    var pWidth = 750;
    var pHeight = 200;
    var pLeft = (screen.width - pWidth) / 2;
    var pTop = (screen.height - pHeight) / 2;
    //var url = "preview.jsp?image=" + iName + "&imageWidth=" + pWidth + "px&imageHeight=" + pHeight + "px";
    var url = "preview.jsp?image=" + iName + "&title=" + iTitle;
    window.open(url,null,"width=" + pWidth + ",height=" + pHeight + ",left=" + pLeft + ",top=" + pTop
                + ",location=no,menubar=no,resizeable=no,scrollbars=no,status=no,toolbar=no");
}

function switchPic(pic){
	if(document.all){
	zoomPic.innerHTML = "<img src=' " + pic + " ' style='margin: 15px auto'/>"
	}
	if(document.getElementById){
	document.getElementById("zoomPic").innerHTML = "<img src=' " + pic + " ' style='margin: 15px auto'/>"
	}
}

//**************

function positionIt(){
//define universal reference to "staticcontent"
var crossobj=document.all? document.all.zoomPicDiv : document.getElementById("zoomPicDiv")

//define reference to the body object in IE
var iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body

//define universal dsoc left point
var dsocleft=document.all? iebody.scrollLeft : pageXOffset
//define universal dsoc top point
var dsoctop=document.all? iebody.scrollTop : pageYOffset

//if the user is using IE 4+ or Firefox/ NS6+
if (document.all||document.getElementById){
crossobj.style.left=parseInt(dsocleft)+5+"px"
crossobj.style.top=dsoctop+"px"
}
}
//**************

// Script Source: CodeLifter.com
// Copyright 2003
// Do not remove this header

isIE=document.all;
isNN=!document.all&&document.getElementById;
isN4=document.layers;
isHot=false;

function ddInit(e){
  topDog=isIE ? "BODY" : "HTML";
  whichDog=isIE ? document.all.zoomPicDiv : document.getElementById("zoomPicDiv");  
  hotDog=isIE ? event.srcElement : e.target;  
  while (hotDog.id!="titleBar"&&hotDog.tagName!=topDog){
    hotDog=isIE ? hotDog.parentElement : hotDog.parentNode;
  }  
  if (hotDog.id=="titleBar"){
    offsetx=isIE ? event.clientX : e.clientX;
    offsety=isIE ? event.clientY : e.clientY;
    nowX=parseInt(whichDog.style.left);
    nowY=parseInt(whichDog.style.top);
    ddEnabled=true;
    document.onmousemove=dd;
  }
}

function dd(e){
  if (!ddEnabled) return;
  whichDog.style.left=isIE ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx; 
  whichDog.style.top=isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety;
  return false;  
}

function ddN4(whatDog){
  if (!isN4) return;
  N4=eval(whatDog);
  N4.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
  N4.onmousedown=function(e){
    N4.captureEvents(Event.MOUSEMOVE);
    N4x=e.x;
    N4y=e.y;
  }
  N4.onmousemove=function(e){
    if (isHot){
      N4.moveBy(e.x-N4x,e.y-N4y);
      return false;
    }
  }
  N4.onmouseup=function(){
    N4.releaseEvents(Event.MOUSEMOVE);
  }
}

function hideMe(){
  if (isIE||isNN) whichDog.style.visibility="hidden";
  else if (isN4) document.theLayer.visibility="hide";
}

function showMe(){
  if (isIE||isNN) whichDog.style.visibility="visible";
  else if (isN4) document.theLayer.visibility="show";
}

document.onmousedown=ddInit;
document.onmouseup=Function("ddEnabled=false");

// End Code lifter functions
