// JavaScript Document
var now = new Date(); //now hace falta en los calendarios
now.setDate(now.getDate());
var sTomorrow = new Date();
sTomorrow.setDate(sTomorrow.getDate() + 1);

function enviaramigo() {
	document.location.href="http://www.tarifasdehoteles.com/enviaramigo.htm?" + document.location.href;
}
function mailnobot(nm,dm)
{
   mailurl = "mailto:" + nm + "@" + dm;
   window.location = mailurl;
}
function agregar(){
   if ((navigator.appName=="Microsoft Internet Explorer") && 
         (parseInt(navigator.appVersion)>=4)) {
      var url="http://www.tarifasdehoteles.com/"; 
      var titulo="Central de Reservas de Hoteles Internacional - Grupo Elige Hoteles";
      window.external.AddFavorite(url,titulo);
   } else { 
      if(navigator.appName == "Netscape") 
         alert("Presione Crtl+D para agregar este sitio a sus Bookmarks"); 
   }
}
function Right(str, n)
/***
		IN: str - the string we are RIGHTing
			n - the number of characters we want to return

		RETVAL: n characters from the right side of the string
***/
{
		if (n <= 0)     // Invalid bound, return blank string
		   return "";
		else if (n > String(str).length)   // Invalid bound, return
		   return str;                     // entire string
		else { // Valid bound, return appropriate substring
		   var iLen = String(str).length;
		   return String(str).substring(iLen, iLen - n);
		}
}
/*a partir de aquí la función AJAX de carga de ciudades de ña base de datos*/
function CrearObjetoAjax(){		//Creacion del objeto AJAX
	if(typeof(XMLHttpRequest) != 'undefined'){
		try{
			var satelite = new XMLHttpRequest();
		}catch(e){ }
	}else{
		try{
			var satelite = new ActiveXObject('Microsoft.XMLHTTP');
		}catch(e){
			var satelite = new ActiveXObject('Msxml2.XMLHTTP');
		}
	}
	return satelite;
}
var ajax_ciudades= CrearObjetoAjax();
function cargaciudades(o){
	if(o.value.length>3){
		document.getElementById('divciudades').style.visibility = "visible";
		var camino="http://www.tarifasdehoteles.com/xmlrpc/GetCities.php?destino=" + o.value;
		ajax_ciudades.open('get',camino,true);
		ajax_ciudades.onreadystatechange = writeCities;
		ajax_ciudades.send(null);
	} else {
		document.getElementById('divciudades').style.visibility = "hidden";
		document.getElementById('divciudades').innerHTML="";
	}
	//alert(o.value.length);
}
function writeCities(){
	if(ajax_ciudades.readyState == 4) {	
		if (ajax_ciudades.status == 200) {
			var txtCiudades = ajax_ciudades.responseText;
			document.getElementById('divciudades').innerHTML=txtCiudades;
		}
	}
}

////////para la carga de hoteles //////////
var ajax_hoteles= CrearObjetoAjax();

function cerrar(){
	setTimeout("ocultarHoteles()", 300);
}

function cargahoteles(o,id_idioma){
	
	if(o.value.length>0){
	
		document.getElementById('divhoteles').style.visibility = "visible";
		document.getElementById('divhoteles').style.display = "block";
		

		var camino="xmlrpc/GetHoteles.php?destino=" + o.value+"&id_idioma=0&id_alojamiento=0";

		ajax_hoteles.open('get',camino,true);

		ajax_hoteles.onreadystatechange = writeHoteles;

		ajax_hoteles.send(null);

	} else {
		

		document.getElementById('divhoteles').style.visibility = "hidden";

		document.getElementById('divhoteles').innerHTML="";

	}

	//alert(o.value.length);

}

function writeHoteles(){

	if(ajax_hoteles.readyState == 4) {	

		if (ajax_hoteles.status == 200) {

			var txtHoteles = ajax_hoteles.responseText;

			document.getElementById('divhoteles').innerHTML=txtHoteles;

		}

	}

}


function ocultarHoteles(){
		if(chiv==0){
			document.getElementById('divhoteles').style.visibility = "hidden";
		}
}

function habilitarHoteles(){
	chiv=0;
	document.getElementById('divhoteles').style.visibility = "visible";
}



