var gbIsNav;
var oIMG;

function BodyOnLoad(){
	GetObjectRefs();
	
	if (document.all){
		SetIEBrowser();
	}else{
		SetNavBrowser();
	}

	try{
		HideTT(); // clear any tooltip DIV
	}
	catch(e){}

	ClearTitles();

	parent.iMapIMGOffsetX = oIMG.offsetLeft;
	parent.iMapIMGOffsetY = oIMG.offsetTop;

	document.onmouseover = HandleMouseOver;
	document.onmouseout = HandleMouseOut;
	
	document.onclick = HandleOnclick;
}

function BodyOnUnLoad(){
}

function GetObjectRefs(){
	oIMG = document.getElementById("mapIMG");
}

function SetIEBrowser(){
	var sProtoPrefix = "ip_";
	gbIsNav = false;

	document.onmousemove = GetIECoords;
	
	// set onclick-event prototype
	HandleOnclick = ip_HandleOnclick;
}

function SetNavBrowser(){
	var sProtoPrefix = "np_";
	gbIsNav = true;
	
	document.addEventListener("mousemove", GetNavCoords, false);
	// capture the onclick event
	document.captureEvents(Event.CLICK);
	// set onclick-event prototype
	HandleOnclick = np_HandleOnclick;
}


function GetIECoords(){
	parent.iCursorX = event.clientX;
	parent.iCursorY = event.clientY;
	parent.MoveDivPopUp();
}

function GetNavCoords(e){
	parent.iCursorX = e.pageX;
	parent.iCursorY = e.pageY;
	parent.MoveDivPopUp();
}

function ClearTitles(){
	// do nothing for unidentified browsers
	if (gbIsNav==undefined){return}
	//Copy titles to new property and clear out existing to stop browser default tooltip
	var aAreas = document.getElementsByTagName("area");
	
	for (var i=0; i<aAreas.length; i++){
		aAreas[i].jsTitle = aAreas[i].title;
		aAreas[i].title = "";
	}
}

function ShowTT(oThis){
	parent.ShowTT(oThis.jsTitle);
}

function HideTT(){
	parent.HideTT();
}

function GetSrcElement(e){
	if (gbIsNav){
		return e.target;
	}else{
		return event.srcElement;
	}		
}

function HandleMouseOver(e){
	// do nothing for unidentified browsers
	// alert(e.srcElement.id);
	if (gbIsNav==undefined){return}

	var oSrcElement = GetSrcElement(e);
	var bReturn = true;
	try{
		switch(oSrcElement.tagName.toString().toLowerCase()){
			case "area" :{
				ShowTT(oSrcElement);
				break;
			}
		}
	}catch(ex){}
}

function HandleMouseOut(e){
	// do nothing for unidentified browsers
	if (gbIsNav==undefined){return}

	var oSrcElement = GetSrcElement(e);
	try{
		switch(oSrcElement.tagName.toString().toLowerCase()){
			case "area" :{
				HideTT();
				break;
			}
		}
	}catch(ex){}
}
