/*
script to capture and process mouse click for pixel advertisement orders

Marc R. Grosso, Ph.D. 
Janaury 25, 2006
*/

	var pad1=null;
	dimsArray = new Array();
	var length =0;
	var width =0;
	var posx =0;
	var posy =0;
	var x = 0;
	var y = 0;
	var heightOK = false;  // FALSE
	var widthOK = false;  // FALSE
	var width1 = 0;
	var height1 = 0;
	var width2 = 0;
	var height2 = 0;

var ie=document.all;
var ns6=document.getElementById && !document.all;
var showForm=false;
if (ie||ns6)  {
 	var orform1=document.all? document.all["orderform1"] : document.getElementById? document.getElementById("orderform1") : "";
 	var tad1=document.all? document.all["tempAd"] : document.getElementById? document.getElementById("tempAd") : "";
 	var orform2=document.all? document.all["orderform2"] : document.getElementById? document.getElementById("orderform2") : "";
}

	window.onload=function(){  
	var pxad=document.getElementById("track");  

	var mouseRouter=new jsEvent.EventRouter(pxad,"onclick");  
	mouseRouter.addListener(catchPixels);  
}	

	function setVisible(obj){
// see if it's a document id, if it's not, then it must be an obj reference
	if(typeof obj == "string") {
		obj = document.getElementById(obj);
	}
	if(obj.style.visibility != 'hidden') {
			obj.style.visibility = 'hidden';
		}
// the user chose true, or omitted the second parameter.
//see if the object is visible. If it isn't, the show it.
	else { 
		if(obj.style.visibility != 'visible');
		obj.style.visibility = 'visible';
	}
}	

	function catchPixels(e) {
		 posx = 0;
		 posy = 0;
		 x = 0;
		 y = 0;
		if (!e) var e = window.event;
		if (self.pageYOffset) // all except Explorer
		{
			x = self.pageXOffset;
			y = self.pageYOffset;
		}
		else if (document.documentElement && document.documentElement.scrollTop)
			// Explorer 6 Strict
		{
			x = document.documentElement.scrollLeft;
			y = document.documentElement.scrollTop;
		}
		else if (document.body) // all other Explorers
		{
			x = document.body.scrollLeft;
			y = document.body.scrollTop;
		}

		if (e.pageX || e.pageY)
		{
			posx = e.pageX;
			posy = e.pageY;
		}
		else if (e.clientX || e.clientY)
		{
			posx = e.clientX + document.body.scrollLeft;
			posy = e.clientY + document.body.scrollTop;
			posx = e.clientX + document.documentElement.scrollLeft;
			posy = e.clientY + document.documentElement.scrollTop;
		}
			posx2 = (Math.floor((posx)/10)+1);
			posy2 = (Math.floor((posy)/10)-6);   

			document.whereAd.x.value = posx2;
	        document.whereAd.y.value = posy2;
			document.whereAd.submit();   // need to have the NAME atttribute in the FORM for this to work!

			var lanesOn=document.getElementById("lanes");
			setVisible(lanesOn);

			ordform1=document.getElementById("orderform1");
			ordform1.style.visibility = 'visible';
			return;
    }
	
function cancel_order () {	
			ordform1=document.getElementById("orderform1");
			alert('cancel order: ' + ordform1);
			ordform1.style.backgroundColor = "transparent";

}
	
/*   
	Set location, size, and visibility of temporary advertisement
	This is displayed while the client is placing the order.
*/

function tempAd(atop, aleft, awidth, aheight) {
	tad1.style.top = atop;
	tad1.style.left = aleft;
	tad1.style.width = awidth;
	tad1.style.height = aheight;
	tad1.style.visibility = 'visible';
}
