// JavaScript Document
// JavaScript Document
// Credit: codelifter.com
// Mouse position script: http://www.codelifter.com/main/javascript/capturemouseposition1.html

// Main function to retrieve mouse x-y pos.s
function getMouseXY(e) { 	
	
  if (IE) { // grab the x-y pos.s if browser is IE
 
 	 tempY = event.clientY
	 tempX = event.clientX
 
  	if (document.documentElement && document.documentElement.scrollTop)
		tempY += document.documentElement.scrollTop
	if (document.body && document.body.scrollTop)
    	tempY += document.body.scrollTop
		
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  

  return true; 
}

function killCurrDiv() {
	
	if (currDiv) {
		document.body.removeChild(currDiv); 
	}	
	currDiv=null;
}

function displayThumb(n) {
	if (n==1) {
		return "<img src='/images/maplefarms_small.jpg' width='123' height='95' alt='Maple Farms'>"; 
	}
	else if (n==2) {
		return "<img src='/images/longleaf-pines-web.jpg' width='123' height='95' alt='Longleaf Pines'>"; 
	}
	else if (n==3) {
		return "<img src='/images/forest-run-web.jpg' width='123' height='95' alt='Forest Run'>"; 
	}
	else if (n==4) {
		return "<img src='/images/craeberne.jpg' width='123' height='95' alt='Craeberne Forest'>"; 
	}
}

function popUpOverlay(n,i) {

	di = document.createElement("div"); 
    di.style.position="absolute"; 
	
	di.style.left=tempX-150+"px"; 
   	di.style.top=tempY-121+"px";
   
   	di.style.width="145px";
    di.style.height="116px"; 
	di.style.className="overlaydiv"; 
    di.style.zIndex=5;
	di.style.backgroundImage="url('/images/rollover_map.png')"; 
	di.style.backgroundPosition="top left"; 
	di.style.backgroundRepeat="no-repeat"; 
	di.onclick=function() { window.location='/neighborhood_viewer.php?n='+i; }
	di.innerHTML="<div style='padding:10px;'>"+displayThumb(n)+"</div>";
	
	currDiv=di; 
	document.body.appendChild(di);
}

var currDiv=null;
var tempX = 0
var tempY = 0

var IE = document.all?true:false

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;
