
var sControlName = "AjaxMap1_" ;
var bImageIsLoading = false;

//  element by ID population
function fnAjax(scriptURL) {
	
  // open url
	var xmlhttp = false;
	try {
		xmlhttp = new XMLHttpRequest();
	}
	catch (trymicrosoft) {
		try {
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (othermicrosoft) {
			try {
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (failed) {
				xmlhttp = false;
			}
		}
	}

	if (!xmlhttp)
		{
			alert("Error initializing XMLHttpRequest!");
		}
	else
	{
		document.getElementById("loadingImage").style.visibility = "";
		bImageIsLoading = true;
	
		xmlhttp.open("GET", scriptURL, true); 
	     
		// Watch state of connection and respond accordingly
		xmlhttp.onreadystatechange = function() {    
			
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {    
			
				// get response from server and grab error codes and messages   
				var result = xmlhttp.responseText;
				   
				//alert(result);
				document.getElementById(sControlName +"imgMap").src = result;
				
			   document.getElementById("loadingImage").style.visibility = "hidden";
				bImageIsLoading = false;
				
			} else {
				//alert(xmlhttp.responseText);
				//errortarg.innerHTML = '<p class="error critical">404: page not found</p>';
			}
			
		}

		xmlhttp.send(null);
	     
	}
	 
} 



		function CreateScriptUrl()
		{
			var Latitude = document.getElementById(sControlName +"hdDealerLatitude").value ;
			var Longitude = document.getElementById(sControlName +"hdDealerLongitude").value ;
			var PanV =  document.getElementById(sControlName +"hdPanV").value ;
			var PanH = document.getElementById(sControlName +"hdPanH").value ;
			var Zoom =  document.getElementById(sControlName+'hdZoom').value ;
			var DataSource =  document.getElementById(sControlName +"hdDataSource").value ;
			var Height = document.getElementById(sControlName +"hdHeight").value ;
			var Width = document.getElementById(sControlName +"hdWidth").value ;
			var sUrl = "Response.aspx?sLatitude="+ Latitude + "&sLongitude="+Longitude+ "&sDealerName="+"DealerName" +"&sCountry=" +"UK" + "&sDataSource=" + DataSource +"&sHeight="+Height +"&sWidth="+Width + "&sPanV="+ PanV +"&sPanH="+ PanH +"&sZoom="+ Zoom ;
			fnAjax(sUrl);
		}

		function East()
		{
			if (bImageIsLoading) return;
			var Zoom = document.getElementById(sControlName+'hdZoom').value;
			var valuePan = 0.25;
			//if( Zoom  < 1 )
			valuePan =  valuePan * Zoom ;
			document.getElementById(sControlName+'hdPanH').value = parseFloat(document.getElementById(sControlName+'hdPanH').value) + valuePan ;
			CreateScriptUrl() ;
		}
		function South()
		{
			if (bImageIsLoading) return;
			var Zoom = document.getElementById(sControlName+'hdZoom').value;
			var valuePan = 0.25 ;
			//if( Zoom  < 1 )
			valuePan =  valuePan * Zoom ;
			document.getElementById(sControlName+'hdPanV').value = parseFloat(document.getElementById(sControlName+'hdPanV').value) - valuePan ;
			CreateScriptUrl() ;
		}
		function West()
		{
			if (bImageIsLoading) return;
			var Zoom =  document.getElementById(sControlName+'hdZoom').value;
			var valuePan = 0.25 ;
			//if( Zoom  < 1 )
			valuePan =  valuePan * Zoom ;
			document.getElementById(sControlName+'hdPanH').value = parseFloat(document.getElementById(sControlName+'hdPanH').value) - valuePan ;
			CreateScriptUrl() ;
		}
		function North()
		{
			if (bImageIsLoading) return;
			var Zoom =  document.getElementById(sControlName+'hdZoom').value;
			var valuePan = 0.25 ;
			//if( Zoom  < 1 )
			valuePan =  valuePan * Zoom ;
			document.getElementById(sControlName+'hdPanV').value = parseFloat(document.getElementById(sControlName+'hdPanV').value) + valuePan ;
			CreateScriptUrl() ;
		}
		function ZoomOut()
		{
			if (bImageIsLoading) return;
			//document.getElementById(sControlName+'hdZoom').value =  document.getElementById(sControlName+'hdZoom').value * 1.25 ;
			if (document.getElementById("drpZoom").selectedIndex > 0) {
				document.getElementById("drpZoom").selectedIndex = document.getElementById("drpZoom").selectedIndex - 1;
			}else{
				return;
			}
			Zoom();
		}
		function Zoom()
		{
			if (bImageIsLoading) return;
			document.getElementById(sControlName+'hdZoom').value = document.getElementById("drpZoom").options[document.getElementById("drpZoom").selectedIndex].value;
			CreateScriptUrl() ;
		}
		function ZoomIn()
		{
			if (bImageIsLoading) return;
			if (document.getElementById("drpZoom").selectedIndex < (document.getElementById("drpZoom").options.length - 1)) {
				document.getElementById("drpZoom").selectedIndex = document.getElementById("drpZoom").selectedIndex + 1;
			}else{
				return;
			}
			Zoom();
		}
