var popup = new Array();

var mouseTop = 0;				/* mouse position x */
var mouseLeft = 0;				/* mouse position y */
//var pageHeight = 0;				/* actual page height */
//var pageWidth = 0;				/* actual page width */
var offsetWidth = 7;			/* +/- offset from calculated x */
var offsetHeight = 250;			/* +/- offset from calculated y */
var borderWidth = 320;			/* width allowance before flipping popup postion (horizontal) */
var borderHeight = 240;			/* heigh allowance before flipping popup position (verticle) */

var regionCurrent = null;
var regionContainer = 'container';

var AdImages = new Array();

function preLoadAdHovers(adpath, startnum, endnum)
{
    if (document.images)
    {
      preload_image_object = new Image();

	  var i=0;
	  
	  for(i=startnum; i<=endnum; i++)
	  {
		AdImages[i] = adpath + "/" + i + ".jpg";
		preload_image_object.src = AdImages[i];
	  }
    }
  	
}

var IsNN = false;
var IsIE = false;

if( document.layers ) IsNN = true;
else if( document.all ) IsIE = true;
else if( document.getElementById ) IsNN = true;

var Changed;


function PopUpEnable( region )
{
	if(regionCurrent != region)
	{
		regionCurrent = region;
		Changed=true;
	}
	
	if( document.layers ) { document.captureEvents(Event.MOUSEMOVE); document.onmousemove = PopUpDisplay; } 
	else if( document.all )  document.onmousemove = PopUpDisplay;
	else if( document.getElementById ) document.onmousemove = PopUpDisplay;
}

function PopUpDisable()
{
	regionCurrent = null; 
	document.onmousemove = null;

	if( document.layers && document.layers[regionContainer] != null ) 
	{
//		document.getElementById(regionContainer).visibility = 'hide';
		document.layers[regionContainer].visibility = 'hide';
	}
	else if(IsNN==true)
	{
		document.getElementById(regionContainer).style.visibility = 'hidden';
	}
	else if( document.all ) 
	{
		document.getElementById(regionContainer).style.visibility = 'hidden'; 
	}
	window.status = "";
}

function PopUpDisplay(evt )
{
	// Update Positions

	if( IsNN )
	{
		mouseLeft = evt.pageX +5; 
		mouseTop = evt.pageY + 5;

		calcCoordinates();

		if(Changed==true)
		{
			document.getElementById(regionContainer).style.visibility = 'visible';
			document.getElementById(regionContainer).innerHTML = '<img border=2 src="' + AdImages[regionCurrent] + '">';
		}
//		document.layers[regionContainer].left = mouseLeft; document.layers[regionContainer].top = mouseTop;
		
		document.getElementById(regionContainer).style.left = mouseLeft + "px"; 
		document.getElementById(regionContainer).style.top = mouseTop + "px";
		
		window.status = mouseLeft + ' ' + mouseTop;

	}
	else if( IsIE )
	{
//		mouseLeft = window.event.x + document.body.scrollLeft; 
//		mouseTop = window.event.y + document.body.scrollTop;
		mouseLeft =	mouseX(evt) +5;
		mouseTop = mouseY(evt) + 5;
		
		calcCoordinates();
		
		document.all[regionContainer].style.left = mouseLeft; 
		document.all[regionContainer].style.top = mouseTop;


		document.all[regionContainer].style.visibility = 'visible';
		ex = document.getElementById(regionContainer).style;
		ex.display='block';
		if(Changed==true)
		{
			document.all[regionContainer].innerHTML = "<img border=2 src=\"" + AdImages[regionCurrent] + "\">";
		}

	}
	
	Changed=false;
}

// no changes required below this line
function mouseX(evt) 
{
	if (!evt) evt = window.event; 
	if (evt.pageX) 
		return evt.pageX; 
	else if (evt.clientX)
		return evt.clientX + (document.documentElement.scrollLeft ?  document.documentElement.scrollLeft : document.body.scrollLeft); 
	else return 0;

} 

function mouseY(evt) 
{
	if (!evt) evt = window.event; 
		if (evt.pageY) 
			return evt.pageY; 
		else if (evt.clientY)
			return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop); 
		else return 0;
}


// Browser Window Size and Position
// copyright Stephen Chapman, 3rd Jan 2005, 8th Dec 2005
// you may copy these functions but please keep the copyright notice as well
function pageWidth() {return window.innerWidth != null? window.innerWidth: document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth:document.body != null? document.body.clientWidth:null;}
function pageHeight() {return window.innerHeight != null? window.innerHeight: document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight:document.body != null? document.body.clientHeight:null;}
function posLeft() {return typeof window.pageXOffset != 'undefined' ? window.pageXOffset:document.documentElement && document.documentElement.scrollLeft? document.documentElement.scrollLeft:document.body.scrollLeft? document.body.scrollLeft:0;}
function posTop() {return typeof window.pageYOffset != 'undefined' ? window.pageYOffset:document.documentElement && document.documentElement.scrollTop? document.documentElement.scrollTop: document.body.scrollTop?document.body.scrollTop:0;}
function posRight() {return posLeft()+pageWidth();}
function posBottom() {return posTop()+pageHeight();}

function calcCoordinates()
{
	if(mouseLeft + borderWidth > posRight()) mouseLeft = mouseLeft-borderWidth-10;
	
	if(mouseTop + borderHeight > posBottom()) mouseTop = mouseTop-borderHeight-10;

}	
