		var enProceso2 = false;
		var http2 = false;
		var enProceso3 = false;
		var http3 = false;
function getHTTPObject() {
			var xmlhttp;
			try {

				if (window.XMLHttpRequest) {
					xmlhttp= new XMLHttpRequest();
					if (xmlhttp.overrideMimeType) {
						xmlhttp.overrideMimeType('text/xml');
					}
					return xmlhttp;
				}
				else if (window.ActiveXObject) {
					try {

						xmlhttp= new ActiveXObject("Msxml2.XMLHTTP");
						return xmlhttp;
					}
					catch (e) {
						try {
							xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
							return xmlhttp;
						}
						catch (e) {
							alert(e);
						}
					}
				}
			}
			catch(e) {
				alert( e);
			}
		}



		function GetWebServices() {
			var nRandom = Math.random() * 10;
    		enProceso2 = false;
			http2 = getHTTPObject();
			if (!enProceso2 && http2) {
				enProceso2 = true;
			   var url = "Ajax/WebServices.asp?t=" + nRandom + "&Method=SetMapView&sid=" + eval("document.MapForm.hUserRandom.value") ;
//		  	   alert(url);
			   http2.open("GET", url, true);
			   http2.onreadystatechange = hdlWebServices;
			   http2.send(null);
			}
			else
			{
				alert("PROCESS" + enProceso2 + '  '   + http2);
			}
		}
		
		function hdlWebServices() {
		if (http2.readyState == 4) {
		   if (http2.status == 200) {
			  if (http2.responseText.indexOf('invalid') == -1) {
				 results = http2.responseText;
				//alert(results);
				 enProceso2 = false;
				  }
			   }
			}
		}

		function Map24Location(Longitude, Latitude, Text) {
			var nRandom = Math.random() * 10;
    		enProceso2 = false;
			http2 = getHTTPObject();
			if (!enProceso2 && http2) {
				enProceso2 = true;

			   var url = "Ajax/WebServices.asp?t=" + nRandom + "&Method=Map24Location&sid=" + eval("document.MapForm.hUserRandom.value") + "&Longitude="+ Longitude + "&Latitude=" + Latitude + "&Text=" + Text ;
//			   alert(url);
			   http2.open("GET", url, true);
			   http2.onreadystatechange = hdlWebServices;
			   http2.send(null);
			}
			else
			{
				alert("PROCESS" + enProceso2 + '  '   + http2);
			}
		}

	function MapObjectGroup(UnitId, StartDate, EndDate, sGMT, sTypeReport) {
			var nRandom = Math.random() * 10;

    		enProceso2 = false;
			http2 = getHTTPObject();
			if (!enProceso2 && http2) {
				enProceso2 = true;
				LoadingText(true,2);
				clearTimeout(sTimeOut );

		   		var url = "Ajax/WebServices.asp?t=" + nRandom + "&Method=MapObjectGroup&sid=" + eval("document.MapForm.hUserRandom.value") + "&UnitId=" + UnitId + "&GMT=" + sGMT + "&StartDate=" + StartDate + "&EndDate=" + EndDate + "&TypeReport=" + sTypeReport;
			  //alert(url);
			   http2.open("GET", url, true);
			   http2.onreadystatechange = hdlMapObjectGroup;
			   http2.send(null);
			}
			else
			{
				alert("PROCESS" + enProceso2 + '  '   + http2);
			}
		}
		
	function hdlMapObjectGroup() {
		var Datos;
		var sType;
			if (http2.readyState == 4) {
			   if (http2.status == 200) {
				  if (http2.responseText.indexOf('invalid') == -1) {
					 results = http2.responseText;
					 LoadingText(false,"");
					// alert(results)
					 Datos = http2.responseText;
					 sType = Datos.substring(0,1);
					 Datos = Datos.substring(1,Datos.length);					 
					if (sType == 0){
					alert("No Locations!");
					LoadingText(false,"");
					sTimeOut =setTimeout("PreLastPosition();",30000);
					 enProceso2 = false;
					 http2=null;
					}
					//alert(results);
					 ///sTimeOut =setTimeout("GetPosition();",30000);
					 enProceso2 = false;
					  }
				   }
				}
			}

	function LocateNow(UnitId) {
		var nRandom = Math.random() * 10;
		enProceso2 = false;
		http2 = getHTTPObject();
		if (!enProceso2 && http2) {
			enProceso2 = true;
			var url = "Ajax/WebServices.asp?t=" + nRandom + "&Method=LocateNow&sid=" + eval("document.MapForm.hUserRandom.value") + "&UnitId=" + UnitId ;
			   http2.open("GET", url, true);
			   http2.onreadystatechange = hdlLocateNow;
			   http2.send(null);
			}
			else
			{
				alert("PROCESS" + enProceso2 + '  '   + http2);
			}
	}
	function hdlLocateNow() {
		var sType;
		var Datos;
		if (http2.readyState == 4) {
		   if (http2.status == 200) {
			  if (http2.responseText.indexOf('invalid') == -1) {
				 results = http2.responseText;
//				alert(results);
				 Datos = http2.responseText;
				 sType = Datos.substring(0,1);
				 Datos = Datos.substring(1,Datos.length);
				if (sType == 3 ) {
					alert(Datos);
					LoadingText(false,"");
					sTimeOut =setTimeout("PreLastPosition();",15000);
 				 enProceso2 = false;
				 http2=null;
				}
				 enProceso2 = false;
				  }
			   }
			}
		}
		
	function ValidUserAjax(UserName) {
			var nRandom = Math.random() * 10;
    		enProceso3 = false;
			http3 = getHTTPObject();
			
			if (!enProceso3 && http3) {
				enProceso3 = true;
			   var url = "../Ajax/WebServices.asp?t=" + nRandom + "&sid=1&Method=ValidUser&UserName=" + UserName;
			   
			   http3.open("GET", url, false);
			   http3.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			  
			   http3.send(null);
				if (http3.readyState == 4) {
				   if (http3.status == 200) {
					
						 results = http3.responseText;
						    enProceso3 = false;
							return  results;
					   }
					}
			}

		}


			
	function LastPosition(UnitId, sGMT) {
		var nRandom = Math.random() * 10;
		enProceso2 = false;
		http2 = getHTTPObject();
		if (!enProceso2 && http2) {
			enProceso2 = true;
			var url = "Ajax/WebServices.asp?t=" + nRandom + "&Method=LastPosition&sid=" + eval("document.MapForm.hUserRandom.value") + "&UnitId=" + UnitId + "&GMT=" + sGMT ;
//alert(url);
			   http2.open("GET", url, true); 
			   http2.onreadystatechange = hdlLastPosition;
			   http2.send(null);
			}
			else
			{
				alert("PROCESS" + enProceso2 + '  '   + http2);
			}
	}
	function hdlLastPosition() {
		var sType;
		var Datos;
		if (http2.readyState == 4) {
		   if (http2.status == 200) {
			  if (http2.responseText.indexOf('invalid') == -1) {
				 results =http2.responseText.split(",");
				 //alert(http2.responseText);
  				 if (parseFloat(results[0]) != 0) {
   			     	clearTimeout(sTimeOut );
				 	sTimeOut =setTimeout("PreLastPosition();",30000);
					 enProceso2 = false;
					 http2=null;
				 	GetAddress(results[0], results[1], results[2]);
				 }
				  }
			   }
			}
		}
		
		
	function TDView(iShow,sTypeControl) {
		var nRandom = Math.random() * 10;
		enProceso2 = false;
		http2 = getHTTPObject();
		if (!enProceso2 && http2) {
			enProceso2 = true;
			var url = "Ajax/WebServices.asp?t=" + nRandom + "&Method=TDView&sid=" + eval("document.MapForm.hUserRandom.value") + "&Show=" + iShow + "&TypeControl=" + sTypeControl;
//alert(url);
			   http2.open("GET", url, true); 
			   http2.onreadystatechange = hdlTDView;
			   http2.send(null);
			}
			else
			{
				alert("PROCESS" + enProceso2 + '  '   + http2);
			}
	}
	function hdlTDView() {
		var sType;
		var Datos;
		if (http2.readyState == 4) {
		   if (http2.status == 200) {
			  if (http2.responseText.indexOf('invalid') == -1) {
					 enProceso2 = false;
					 http2=null;
				 }
			 }
			   
			}
		}
		

		
		
		function GetAddress(longitude, latitude, DataUnit) {
    		enProceso3 = false;
			http3 = getHTTPObject();
			if (!enProceso3 && http3) {
				enProceso3 = true;
			   var url = "Ajax/ReverseGeocodeAddress.asp?longitude=" + longitude + "&latitude=" + latitude + "&DataUnit=" + DataUnit + "&sid=" + eval("document.MapForm.hUserRandom.value") ;
			   //alert(url);
			 MapForm.txtPosition.value = results[3];
			   http3.open("GET", url, true);
			   http3.onreadystatechange = handleHttpResponseAddress;
			   http3.send(null);
			}
			else
			{
				alert("PROCESS" + enProceso3 + '  '   + http3);
			}
		}

		function handleHttpResponseAddress() {
		if (http3.readyState == 4) {
		   if (http3.status == 200) {
			  if (http3.responseText.indexOf('invalid') == -1) {
				 // Armamos un array, usando la coma para separar elementos
				 results = http3.responseText;
				 //alert(results);
				MapForm.txtAddress.value= results;
				 enProceso3 = false;
				 http3=null;
				  }
			   }
			}
		}