// Ajax functions

// This function is used to load site information
// for the markers in Google Maps
function ajaxLoadMapContent(url,div)
{
	document.getElementById(div).innerHTML = "Loading...";
	var xmlHttp;
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	} catch (e) {
		// Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4)  {
			document.getElementById(div).innerHTML = xmlHttp.responseText;

		}
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

// This function is used to load LINK information
// for the lines/links between sites in Google Maps
function ajaxLoadMapLink(point,url)
{
	var xmlHttp;
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	} catch (e) {
		// Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4)  {
			//document.myForm.time.value=xmlHttp.responseText;
			var content = xmlHttp.responseText;
			map.openInfoWindowHtml(point,xmlHttp.responseText);
			//map.openInfoWindowHtml(point, "test");
		}
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}




function ajaxLoadRadioContent(id,element)
{
	document.getElementById(element).innerHTML = "<div style='position:absolute;background:#FFFFFF;'>"
		+ "Loading...</div>" + document.getElementById(element).innerHTML;
	var xmlHttp;
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	} catch (e) {
		// Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4)  {
			//document.myForm.time.value=xmlHttp.responseText;
			document.getElementById(element).innerHTML = xmlHttp.responseText;
		}
	}
	xmlHttp.open("GET","ajax_site_radio.php?id=" + id,true);
	xmlHttp.send(null);
}



function ajaxLoadMapData(minTime,maxTime)
{
	// document.getElementById('ajaxDataSpan').innerHTML = "Loading " + minTime + " to " + maxTime + "...";
	var xmlHttp;
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	} catch (e) {
		// Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==0)  {
			document.getElementById('ajaxDataSpan').innerHTML = "Request not initialized.";
		}
		if(xmlHttp.readyState==1)  { // Request set up
			document.getElementById('ajaxDataSpan').innerHTML = "Loading...";
		}
		if(xmlHttp.readyState==4)  {
			/*
			   var script = document.createElement('script');
			   script.setAttribute('type','text/javascript');
			   script.innerHTML = xmlHttp.responseText;
			   */
			document.getElementById('ajaxDataSpan').innerHTML = xmlHttp.responseText;
			parseScript(document.getElementById('ajaxDataSpan').innerHTML);
		}
	}
	xmlHttp.open("GET","map_data.php?mintime=" + minTime + "&maxtime=" + maxTime,true);
	xmlHttp.send(null);
}
