Xoff= 20;
Yoff= 15;

var show,old,skn,iex=(document.all),yyy=-1000, timer;
var zoom, zoomed, zoomImage, zoomImageHref, zoomedLeft, zoomedTop, zoomedHeight, zoomedWidth;
var allowkill = 1;

show=0;

var ns4=document.layers
var ns6=document.getElementById&&!document.all
var ie4=document.all

if (ns4)
skn=document.dek
else if (ns6)
skn=document.getElementById("dek").style
else if (ie4){
skn=document.all.dek.style
}
if(ns4)document.captureEvents(Event.MOUSEMOVE);
else{
skn.visibility="visible"
skn.display="none"
}
document.onmousemove=get_mouse;

function getwidth() {
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    return window.innerWidth;
  } else {
    if( document.documentElement && document.documentElement.clientWidth ) {
      //IE 6+ in 'standards compliant mode'
      return document.documentElement.clientWidth;
    } else {
      if( document.body && document.body.clientWidth ) {
        //IE 4 compatible
        return document.body.clientWidth;
      }
    }
	}
}

function getheight() {
  if( typeof( window.innerHeight ) == 'number' ) {
    //Non-IE
    return window.innerHeight;
  } else {
    if( document.documentElement && document.documentElement.clientHeight ) {
      //IE 6+ in 'standards compliant mode'
      return document.documentElement.clientHeight;
    } else {
      if( document.body && document.body.clientHeight ) {
        //IE 4 compatible
        return document.body.clientHeight;
      }
    }
	}
}	

function get_mouse(e){
	if (show > 0) {
		var x=(ns4||ns6)?e.pageX:event.x+document.body.scrollLeft;
		var y=(ns4||ns6)?e.pageY:event.y+document.body.scrollTop;

		var w=getwidth();
		var h=getheight();
		
		var ow, oh, newleft, newtop;
		
		if (zoomed) {
			ow = 360;
			oh = 235;
		}
		else {
			ow = 420;
		}
		
		if (x + Xoff + ow > w)
			newleft = x - Xoff - ow;
		else
			newleft = x + Xoff;

		if (oh) {
			if (y + yyy + oh > h+document.body.scrollTop)
				newtop = (h+document.body.scrollTop) - ((yyy + oh) * 2);
			else
				newtop = y + yyy;
		}
		else
			newtop = y + yyy;
		
		skn.left=newleft;
		skn.top=newtop;

		if (zoom) {
			x -= 4; // compensate for 2px border around zoomed
			y -= 4;
			
			xPos = -Math.round( ( 750 * (parseFloat(x - zoomedLeft) / parseFloat(zoomedWidth)) ) - 165 );
			yPos = -Math.round( ( 951 * (parseFloat(y - zoomedTop) / parseFloat(zoomedHeight)) ) - 107 );
			
			xPos = (xPos>0) ? 0 : xPos;
			yPos = (yPos>0) ? 0 : yPos;
			
			xPos = (xPos < -500) ? -500 : xPos;
			yPos = (yPos < -736) ? -736 : yPos;
			
			zoom.style.left = xPos + 'px';
			zoom.style.top = yPos + 'px';
		}

	}
}
		
function showdek() {
	if (show==1) {
		show=2;	// 2=showing
		if(ns4){skn.visibility="visible"}
		if(ie4||ns6){skn.display=''}
	}
}



function popupZoom(e,msg) {
	if (show==0) {
		var c =
			"<table width=330 height=225 style='border: 2px solid orange' cellpadding=1 cellspacing=0 bgcolor=white>" +
			"<tr><td width=330 height=215><div style='overflow:hidden; width:330px; height:215px;'>" + 
			"<img src='/images/spacer.gif' width=750 height=914 id='zoomimg' style='position:relative; top:0px; left:0px'>" +
			"</div></td></tr><tr><td style='background: #ffffea;border-top:2px solid black'><font size=1><center>" + msg + "</td></tr></table>" ;
		
		Xoff = 30;
		Yoff = -115;
		yyy=Yoff;

		if(ns4){skn.document.write(c);skn.document.close()}
		if(ns6){document.getElementById("dek").innerHTML=c}
		if(ie4){document.all("dek").innerHTML=c}

		zoomed = e;
		var container;
		zoomedLeft = zoomedTop = 0;
		
		container = zoomed;
		while (container) {
			zoomedLeft += container.offsetLeft;
			zoomedTop += container.offsetTop;
			container = container.offsetParent;
		}
		
		zoomedHeight = zoomed.height;
		zoomedWidth = zoomed.width;
		
		zoomImageHref = getImgUrl('750',zoomed.cid,zoomed.pg,zoomed.flip);
		
		zoomImage = new Image(750,951);
		zoomImage.src = zoomImageHref;

		zoom = document.all("zoomimg");
		zoom.src = zoomImage.src;
		
		show=1; // 1=show on timeout
		timer = setTimeout("showdek()", 750);
	}
}

function popupGlossary(word,msg,newXoff,newYoff,icon,width){
	if (show==0) {
		if (word=='Legend')
			var c="<TABLE WIDTH="+width+" CELLPADDING=8 bgcolor=white CELLSPACING=0 style=\"border: 4px solid black\"><TR><TD><font size=2>"+msg+"</TD></TR></TABLE>";
		else {
			var c=
				"<TABLE WIDTH="+width+" STYLE=\"border: 1px solid black\" CELLPADDING=3 CELLSPACING=0 BGCOLOR=#FFFFEE>" +
				"<TR><TD width=30 valign=top align=center>"
			
			if(icon) c+="<font size=1><BR><nobr>&nbsp;<img src=\""+icon+"\">&nbsp;<BR><BR>";
			else c+="&nbsp;<font color=#003366 size=6><B>?"
			
			c+=
				"</td><TD valign=middle ALIGN=left STYLE=\"padding-top: 8px\">" +
				"<FONT SIZE=2><B>"+word+":</B> "+msg+"<BR><img src=\"/images/spacer.gif\" height=4 width=1></FONT></TD></TR></TABLE>";
		}
		
		if (newXoff) Xoff = newXoff;
		if (newYoff) Yoff = newYoff;
		
		yyy=Yoff;

		if(ns4){skn.document.write(c);skn.document.close()}
		if(ns6){document.getElementById("dek").innerHTML=c}
		if(ie4){document.all("dek").innerHTML=c}
		
		show=1; // 1=show on timeout
		timer = setTimeout("showdek()", (word=='Legend')?50:250);
	}
}


function kill(){
	show=0;
	yyy=-1000;
	if(ns4) {
		skn.visibility="hidden";
	}
	else if (ns6||ie4)
		skn.display="none";
	zoom = null;
	clearTimeout(timer);
	
}

