// JavaScript Document

/*
function printAjax (str) {
	var moz;
	var ie;
	
	if(navigator.appName == "Microsoft Internet Explorer") {
		ie = true;
		moz = false;
	} else {
		moz = !window.opera && !/Apple/.test(navigator.vendor);  
	}

	// Watch for writing out closing tags, we just  
	// ignore these (as we auto-generate our own)  
	if ( str.match(/^<\//) ) return;

	// Make sure & are formatted properly, but Opera  
	// messes this up and just ignores it  
	if ( ie || !window.opera )  
		str = str.replace(/&(?![#a-z0-9]+;)/g, "&");  
	
	// Watch for when no closing tag is provided  
	// (Only does one element, quite weak)  
	str = str.replace(/<([a-z]+)(.*[^\/])>$/, "<$1$2></$1>");  
	
   // Mozilla assumes that everything in <acronym title="Extensible HyperText Markup Language">XHTML</acronym> innerHTML  
   // is actually <acronym title="Extensible HyperText Markup Language">XHTML</acronym> - Opera and Safari assume that it's <acronym title="Extensible Markup Language">XML</acronym>  
   if ( !moz )  
	   str = str.replace(/(<[a-z]+)/g, "$1 xmlns='http://www.w3.org/1999/xhtml'");  
	  
   // The HTML needs to be within a XHTML element  
   var div = createElement("div");
   div.innerHTML = str;  
   
   // Find the last element in the document  
   var pos;  
	 
   // Opera and Safari treat getElementsByTagName("*") accurately  
   // always including the last element on the page  
   if ( !moz ) {  
	   pos = document.getElementsByTagName("*");  
	   pos = pos[pos.length - 1];  
		 
	// Mozilla does not, we have to traverse manually  
   } else {  
	   pos = document;  
	   while ( pos.lastChild && pos.lastChild.nodeType == 1 )  
		   pos = pos.lastChild;  
   }  
	 
   // Add all the nodes in that position  
   var nodes = div.childNodes;  
   while ( nodes.length )  
	pos.parentNode.appendChild( nodes[0] );
}

function ajaxRequest(){
 var activexmodes=["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"] //activeX versions to check for in IE
 if (window.ActiveXObject){ //Test for support for ActiveXObject in IE first (as XMLHttpRequest in IE7 is broken)
  for (var i=0; i<activexmodes.length; i++){
   try{
    return new ActiveXObject(activexmodes[i])
   }
   catch(e){
    //suppress error
   }
  }
 }
 else if (window.XMLHttpRequest) // if Mozilla, Safari etc
  return new XMLHttpRequest()
 else
  return false
}

function HttpRequest(url) {
	var pageRequest = false;
	
	if (!pageRequest && typeof ajaxRequest != 'undefined') {
	   pageRequest = new ajaxRequest();
	}
	
	if (pageRequest) {
	   pageRequest.open('GET', url, false);
	   pageRequest.send(null);
	   return embedpage(pageRequest);
	}
	
	return "";
}

function createElement(element) {
  if (typeof document.createElementNS != 'undefined') {
    return document.createElementNS('http://www.w3.org/1999/xhtml', element);
  }
  if (typeof document.createElement != 'undefined') {
    return document.createElement(element);
  }
  return false;
}
	
function embedpage(request) {
	if (window.location.href.indexOf("http")==-1 || request.status==200) {
	   return (request.responseText);
	}
}

function procesarScriptRespuestaAjax(url) {
	var resultado = HttpRequest(url);
	eval(resultado);
}







function cargarEspacioTemporalesEnMapa() {
	cargarEspacioTemporalesEnMapa("chupito");
}

var cargandoEspacioTemporalesEnMapa = false;
function cargarEspacioTemporalesEnMapa(consulta) {
	if(!cargandoEspacioTemporalesEnMapa) {
		cargandoEspacioTemporalesEnMapa = true;
		procesarScriptRespuestaAjax("espacioTemporales/cargarEspacioTemporalesEnMapa.php?consulta=" + escape(encodeURI(consulta)));
		cargandoEspacioTemporalesEnMapa = false;
	} else {
		alert("Espere por favor mientras la pagina termina de cargar los datos anteriores.");
	}
}


/*
var proximaCargaEspacioTemporales = "";
function cargarEspacioTemporalesEnMapa(lat1,lat2,lng1,lng2) {
	if(!cargandoEspacioTemporalesEnMapa) {
		cargandoEspacioTemporalesEnMapa = true;
		
		procesarScriptRespuestaAjax("espacioTemporales/cargarEspacioTemporalesEnMapa.php?lat1=" + lat1 + "&lat2=" + lat2 + "&lng1=" + lng1+ "&lng2=" + lng2);
		cargandoEspacioTemporalesEnMapa = false;
		
		if(proximaCargaEspacioTemporales != "") {
			setTimeout(proximaCargaEspacioTemporales,100);
			proximaCargaEspacioTemporales = "";
		}
	} else {
		proximaCargaEspacioTemporales = "cargarEspacioTemporalesEnMapa("+lat1+","+lat2+","+lng1+","+lng2+");";
	}
}
*/