/* X-ray mouse script by Paul Anderson, copyright 2001 CNET Builder.com.
   May be freely used with attribution. Not for resale. */

var divX,divY,swtDiv,showWidth,showHeight;
showWidth=60;
showHeight=60;

function initEvents(size) {
	if (size == 'small') {
		showWidth = 50;
		showHeight = 40;
	}
	swtDiv=document.getElementById?document.getElementById("swtHidden"):document.all?document.all["swtHidden"]:document.layers?document.layers["swtHidden"]:null;
	if (document.layers) {
		swtDiv.style=swtDiv;
		document.captureEvents(Event.MOUSEMOVE);
		}
	if (swtDiv) {
		document.onmousemove=doMouse;
		}
	}
window.onload=initEvents;

function doMouse(arg) {
	ev=arg?arg:event;
	divX=(ev.pageX?ev.pageX:ev.clientX)-parseInt(swtDiv.style.left);
	divY=(ev.pageY?ev.pageY:ev.clientY)-parseInt(swtDiv.style.top);
	if (swtDiv.clip) {
		/* Nav 4 bugs addresed here: clip outside layer deactivates links,
		 event.pageX|pageY of zero evaluates as NaN. Go figure. */
		swtDiv.clip.left=(divX>showWidth/2)?divX-showWidth/2:0;
		swtDiv.clip.top=(divY>showHeight/2)?divY-showHeight/2:0;
		newRight=(isNaN(divX)?0:divX)+showWidth/2;
		maxRight=swtDiv.document.images[0].width;
		swtDiv.clip.right=(newRight<maxRight)?newRight:maxRight;
		newBottom=(isNaN(divY)?0:divY)+showHeight/2;
		maxBottom=swtDiv.document.images[0].height;
		swtDiv.clip.bottom=(newBottom<maxBottom)?newBottom:maxBottom;
	} else {
		swtDiv.style.clip="rect("+(divY-showHeight/2)+"px "+(divX+showWidth/2)+"px "+(divY+showHeight/2)+"px "+(divX-showWidth/2)+"px)";
	}
}
