// JavaScript Document
var X;
var Y;
   if (document.images)
    {
      preload_image_object = new Image();
      // set image url
      image_url = new Array();
      image_url[0] = "/images/closebtn.jpg";
      image_url[1] = "/images/closebtnhvr.jpg";

       var i = 0;
       for(i=0; i<=1; i++) 
         preload_image_object.src = image_url[i];
    }

if (window.attachEvent)
{
    document.attachEvent("onmousemove",MouseMv);
}
else
{
    document.addEventListener("mousemove",MouseMv,false);
}


function MouseMv(e) 
{
	if (!e) e = window.event;
	
	if (typeof e.pageY == "number")
	{
		X = e.pageX;
		Y = e.pageY;
	}
	else
	{
		X = e.clientX;
		Y = e.clientY;
	}
}

function hideMoreInfo()
{
	if (document.getElementById)
	{
		//document.getElementById("MoreInfo").style.visibility = "hidden";
		//scrollposition = getScrollingPosition();
		document.getElementById("MoreInfo").style.display = "none";
		//window.scrollTo(scrollposition[0], scrollposition[1]);
	}
}

function showMoreInfo(title, description)
{
	if (document.getElementById)
	{
		//scrollposition = getScrollingPosition();
		document.getElementById("MoreInfo").style.left = X;
		document.getElementById("MoreInfo").style.top = Y;
		//document.getElementById("MoreInfo").style.visibility = "visible";
		document.getElementById("MoreInfo").style.display = "block";
		document.getElementById("MoreInfoTitle").innerHTML = title;
		document.getElementById("MoreInfoText").innerHTML = description;
		//window.scrollTo(scrollposition[0], scrollposition[1]);
		var windowsize = getWindowSize();
		var scrolling = getScrollXY();
		var Xdivright = parseInt(X) + parseInt(document.getElementById("MoreInfo").style.width);
		var Ydivbottom = parseInt(Y) + parseInt(document.getElementById("MoreInfo").style.height);
		var browser = whatBrowser();
		if(browser[0] == "IE")
		{
			var ieX = parseInt(scrolling[0]) + parseInt(X);
			var amountpastwindow = (parseInt(X) + parseInt(document.getElementById("MoreInfo").style.width) ) - parseInt(windowsize[0]);
			document.getElementById("MoreInfo").style.left = ieX;
			if(amountpastwindow > 0)
			{
				document.getElementById("MoreInfo").style.left = parseInt(ieX) - amountpastwindow;
			}

			var ieY = parseInt(scrolling[1]) + parseInt(Y);
			var amountpastwindow = (parseInt(Y) + parseInt(document.getElementById("MoreInfo").style.height) ) - parseInt(windowsize[1]);
			document.getElementById("MoreInfo").style.top = ieY;
			if(amountpastwindow > 0)
			{
				document.getElementById("MoreInfo").style.top = parseInt(ieY) - amountpastwindow;
			}
		}
		else
		{//browswer is ff which works so don't touch!
		
			if(Xdivright > (parseInt(windowsize[0]) + parseInt(scrolling[0]) - 20 ))
			{
				document.getElementById("MoreInfo").style.left = parseInt(X) - (parseInt(Xdivright) - (parseInt(windowsize[0]) + parseInt(scrolling[0])) + 20);
			}
			if(Ydivbottom > (parseInt(windowsize[1]) + parseInt(scrolling[1]) - 20 ))
			{
				document.getElementById("MoreInfo").style.top = parseInt(Y) - (parseInt(Ydivbottom) - (parseInt(windowsize[1]) + parseInt(scrolling[1])) + 20);
			}
		}
	}
}

function whatBrowser()
{
	var agent= navigator.userAgent.toLowerCase();
	var ver = parseInt(navigator.appVersion);
	 
	var ie = agent.indexOf("msie")>=0;
	var ie6=ie && agent.indexOf("msie 6")>=0;
	var ie7=ie && agent.indexOf("msie 7")>=0;
	 
	var ff=!ie && agent.indexOf("mozilla")>=0;
	var ff2=ff && ver==4;
	var ff3=ff && ver==5;
	if(ie) return ["IE", ver];
	if(ff) return ["FF", ver];
}


function getWindowSize()
{
	var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
	return [ myWidth, myHeight ];
}
function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}

function brightCloseBtn()
{
	if (document.getElementById)
	{
		document.getElementById("closebtn").src = "/images/closebtnhvr.jpg";
	}
}

function dimCloseBtn()
{
	if (document.getElementById)
	{
		document.getElementById("closebtn").src = "/images/closebtn.jpg";
	}
}

function getScrollingPosition()
{
var position = [0, 0];
if (typeof window.pageYOffset != 'undefined')
{
position = [
window.pageXOffset,
window.pageYOffset
];
}
else if (typeof document.documentElement.scrollTop
!= 'undefined' && document.documentElement.scrollTop > 0)
{
position = [
document.documentElement.scrollLeft,
document.documentElement.scrollTop
];
}
else if (typeof document.body.scrollTop != 'undefined')
{
position = [
document.body.scrollLeft,
document.body.scrollTop
];
}
return position;
}