var ajax = new sack();
var updatewhat;
var updatewhat2;
var last_id;
var showMessage = "";
var arrayOfClicks = new Array(100); 
var LastMapPointId = 0;


var IE = document.all?true:false;
if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;
var mouseX = 0;
var mouseY = 0;
function getMouseXY(e) {
	if (IE) { // grab the x-y pos.s if browser is IE
		mouseX = event.clientX + document.body.scrollLeft;
		mouseY = event.clientY + document.body.scrollTop;
	} else {  // grab the x-y pos.s if browser is NS
		mouseX = e.pageX;
		mouseY = e.pageY;
	}  
	if (mouseX < 0){mouseX = 0;}
	if (mouseY < 0){mouseY = 0;}  
	return true;
}


function GetRandMapPoint(mapnum)
{
		var mx = mouseX - 246;
		var my = mouseY - 22;
		ajax.requestFile = '_ajax_process.php?rand_map='+mapnum+'&mx='+mx+'&my='+my;	
		ajax.onCompletion = GetRandMapPoint_complete;	// Specify function that will be executed after
		updatewhat = "moreDetails";
		ajax.runAJAX();		// Execute AJAX function
}
function GetRandMapPoint_complete()
{
	var obj = document.getElementById(updatewhat);
	obj.innerHTML = ajax.response;
	// now get the map point id from the hidden field from the ajax call.
	if(document.getElementById("MapPointId").value) {
		ajax.reset();
		LastMapPointId = document.getElementById("MapPointId").value;
		GetPushPinContent(LastMapPointId);
		//alert(mp[LastMapPointId][0]);  // use array to get name
		return;
	}
}	

function GetMapPointInfo(mp)
{
		ajax.requestFile = '_ajax_process.php?map_point_info='+mp;	
		ajax.onCompletion = GetMapPointInfo_complete;	// Specify function that will be executed after
		updatewhat = "moreDetails";
		ajax.runAJAX();		// Execute AJAX function
}
function GetMapPointInfo_complete()
{
	var obj = document.getElementById(updatewhat);
	obj.innerHTML = ajax.response;
	// now get the map point id from the hidden field from the ajax call.
	if(document.getElementById("MapPointId").value) {
		ajax.reset();
		LastMapPointId = document.getElementById("MapPointId").value;
		GetPushPinContent(LastMapPointId);
		return;
	}
}	


function GetPushPinContent(mappoint)
{
		ajax.requestFile = '_ajax_process.php?showpushpin='+mappoint;	
		ajax.onCompletion = GetPushPinContent_complete;	// Specify function that will be executed after
		ajax.runAJAX();		// Execute AJAX function
		return;
}
function GetPushPinContent_complete()
{
	var obj = document.getElementById("theGlobeCell");
	obj.innerHTML = ajax.response;
	ShowIt("pushPin");
	return;
}	

function loadNextAd(current,max) {
		next = current + 1;
		if(next>max) next = 1;
		ajax.requestFile = '_ads_right'+next+'.php';	
		ajax.onCompletion = loadNextAd_complete;	// Specify function that will be executed after
		ajax.runAJAX();		// Execute AJAX function
		return next;
}
function loadNextAd_complete()
{
	var obj = document.getElementById("apDiv3");
	obj.innerHTML = ajax.response;
	return;
}	


