// Global variables

xMousePos = 0;

yMousePos = 0;

xMousePosMax = 0;

yMousePosMax = 0;

zPos = 0;



if (ns4) {

	/*

		function to capture the event of the mouse moving 

		for each of the different browsers

	*/

    	document.captureEvents(Event.MOUSEMOVE);

    	document.onmousemove = captureMousePosition;

} else if ((ie4) || (dom)) {

    	document.onmousemove = captureMousePosition;

}





function captureMousePosition(e) {

	/*

		function to actually capture the mouse position 

		based on the type of browser sets the global 

		variables 

	*/

	if (ns4) {

		xMousePos = e.pageX;

		yMousePos = e.pageY;

		xMousePosMax = window.innerWidth+window.pageXOffset;

		yMousePosMax = window.innerHeight+window.pageYOffset;

	} else if (ie4) {

		xMousePos = window.event.x+document.body.scrollLeft;

		yMousePos = window.event.y+document.body.scrollTop;

		xMousePosMax = document.body.clientWidth+document.body.scrollLeft;

		yMousePosMax = document.body.clientHeight+document.body.scrollTop;

	} else if (dom) {

		xMousePos = e.pageX;

		yMousePos = e.pageY;

		xMousePosMax = window.innerWidth+window.pageXOffset;

		yMousePosMax = window.innerHeight+window.pageYOffset;

	}

}





function toggleSelectboxes(selectboxes,mode) {

	//alert(selectboxes);

	splitboxes = selectboxes.split("|");

	for(x=0; x < splitboxes.length; x++){

	 obj = getObject(splitboxes[x]);

	 if(!obj){return;}

     if(mode=='hide'){obj.style.visibility = "hidden";}

	 else{obj.style.visibility = "visible";}

	}

	return;

}



function closeInfo(iID, selectboxes) {

	toggleInfo(iID);

	toggleSelectboxes(selectboxes,'show');	

}



function toggleInfo(iID, width, height, position, selectboxes) {

	/*

		function for the info boxes

			call it with the width and height of the layer

			and the position if you want to position it

			left, right, top, bottom, 

			topleft, topright, bottomleft, bottomright

			

		there is no way of placing it over select boxes 

		so position and use with care

	*/

	

	var leftSub = 8, topSub = 8,

	leftBuffer = 8, topBuffer = 8,

	defaultWidth = 220, defaultHeight = 140;

	

	





	

	obj = getObject(iID);

	if (!obj)

		return;

	

	zPos++;

	

	

	if (!width)

		width = defaultWidth;

		

	if (!height)

		height = defaultHeight;

	

	width = width / 2;

	height = height / 2;

	

	if (position) {

		switch(position) {

			case "left" :

				leftSub = - width + leftSub;

				break;

			case "right" :

				leftSub = width - leftSub;

				break;

			case "top" :

				topSub = - height + topSub;

				break;

			case "bottom" :

				topSub = height - topSub;

				break;

			case "topleft" :

				leftSub = - width + leftSub;

				topSub = - height + topSub;

				break;

			case "topright" :

				leftSub = width - leftSub;				

				topSub = - height + topSub;

				break;

			case "bottomleft" :

				leftSub = - width + leftSub;

				topSub = height - topSub;

				break;

			case "bottomright" :

				leftSub = width - leftSub;

				topSub = height - topSub;

				break;				

		}		

	} else {

		leftSub = width - leftSub;				

		topSub = - height + topSub;

	}

	

	newLeft = ((xMousePos - width) + leftSub);

	newTop = ((yMousePos - height) + topSub);

			

	obj.style.left = newLeft;

	obj.style.top = newTop;

	

	if (obj.style.display == "block") {

		obj.style.display = "none";

		obj.style.zIndex = 0;

		if (selectboxes) {

			if(ie4)

				toggleSelectboxes(selectboxes,'show');

		}

		//toggleSelectboxes(selectboxes,'show');

	} else {

		obj.style.display = "block";

		obj.style.zIndex = zPos;

		if (selectboxes) {

			if(ie4)

				toggleSelectboxes(selectboxes,'hide');

		}

		//toggleSelectboxes(selectboxes,'hide');

	}

	//alert(obj.style.left + " " +obj.style.top);

	

}





function showCoords() {

	/*

		for debugging shows all of the mouse position 

		variables

	*/

	alert("xMousePos=" + xMousePos + ", yMousePos=" + yMousePos + " xMousePosMax=" + xMousePosMax + ", yMousePosMax=" + yMousePosMax)

}
