/* GENERALES 
	Estas funciones se usan en el sitio en general
*/
function idioma(cual)
{
	parent.document.location = "../" + cual + "/index.php";
}
/* Pre cargar imagenes */
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function precargar()
{
	MM_preloadImages('');
}
function ajaxFunction(){
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	return ajaxRequest;
}
function acentos(x) {
	// version 040623
	// Spanish - Español
	// Portuguese - Portugués - Português
	// Italian - Italiano
	// French - Francés - Français
	// Also accepts and converts single and double quotation marks, square and angle brackets
	// and miscelaneous symbols.
	// Also accepts and converts html entities for all the above.
//	if (navigator.appVersion.toLowerCase().indexOf("windows") != -1) {return x}
	x = x.replace(/¡/g,"\xA1");	x = x.replace(/&iexcl;/g,"\xA1")
	x = x.replace(/¿/g,"\xBF");	x = x.replace(/&iquest;/g,"\xBF")
	x = x.replace(/À/g,"\xC0");	x = x.replace(/&Agrave;/g,"\xC0")
	x = x.replace(/à/g,"\xE0");	x = x.replace(/&agrave;/g,"\xE0")
	x = x.replace(/Á/g,"\xC1");	x = x.replace(/&Aacute;/g,"\xC1")
	x = x.replace(/á/g,"\xE1");	x = x.replace(/&aacute;/g,"\xE1")
	x = x.replace(/Â/g,"\xC2");	x = x.replace(/&Acirc;/g,"\xC2")
	x = x.replace(/â/g,"\xE2");	x = x.replace(/&acirc;/g,"\xE2")
	x = x.replace(/Ã/g,"\xC3");	x = x.replace(/&Atilde;/g,"\xC3")
	x = x.replace(/ã/g,"\xE3");	x = x.replace(/&atilde;/g,"\xE3")
	x = x.replace(/Ä/g,"\xC4");	x = x.replace(/&Auml;/g,"\xC4")
	x = x.replace(/ä/g,"\xE4");	x = x.replace(/&auml;/g,"\xE4")
	x = x.replace(/Å/g,"\xC5");	x = x.replace(/&Aring;/g,"\xC5")
	x = x.replace(/å/g,"\xE5");	x = x.replace(/&aring;/g,"\xE5")
	x = x.replace(/Æ/g,"\xC6");	x = x.replace(/&AElig;/g,"\xC6")
	x = x.replace(/æ/g,"\xE6");	x = x.replace(/&aelig;/g,"\xE6")
	x = x.replace(/Ç/g,"\xC7");	x = x.replace(/&Ccedil;/g,"\xC7")
	x = x.replace(/ç/g,"\xE7");	x = x.replace(/&ccedil;/g,"\xE7")
	x = x.replace(/È/g,"\xC8");	x = x.replace(/&Egrave;/g,"\xC8")
	x = x.replace(/è/g,"\xE8");	x = x.replace(/&egrave;/g,"\xE8")
	x = x.replace(/É/g,"\xC9");	x = x.replace(/&Eacute;/g,"\xC9")
	x = x.replace(/é/g,"\xE9");	x = x.replace(/&eacute;/g,"\xE9")
	x = x.replace(/Ê/g,"\xCA");	x = x.replace(/&Ecirc;/g,"\xCA")
	x = x.replace(/ê/g,"\xEA");	x = x.replace(/&ecirc;/g,"\xEA")
	x = x.replace(/Ë/g,"\xCB");	x = x.replace(/&Euml;/g,"\xCB")
	x = x.replace(/ë/g,"\xEB");	x = x.replace(/&euml;/g,"\xEB")
	x = x.replace(/Ì/g,"\xCC");	x = x.replace(/&Igrave;/g,"\xCC")
	x = x.replace(/ì/g,"\xEC");	x = x.replace(/&igrave;/g,"\xEC")
	x = x.replace(/Í/g,"\xCD");	x = x.replace(/&Iacute;/g,"\xCD")
	x = x.replace(/í/g,"\xED");	x = x.replace(/&iacute;/g,"\xED")
	x = x.replace(/Î/g,"\xCE");	x = x.replace(/&Icirc;/g,"\xCE")
	x = x.replace(/î/g,"\xEE");	x = x.replace(/&icirc;/g,"\xEE")
	x = x.replace(/Ï/g,"\xCF");	x = x.replace(/&Iuml;/g,"\xCF")
	x = x.replace(/ï/g,"\xEF");	x = x.replace(/&iuml;/g,"\xEF")
	x = x.replace(/Ñ/g,"\xD1");	x = x.replace(/&Ntilde;/g,"\xD1")
	x = x.replace(/ñ/g,"\xF1");	x = x.replace(/&ntilde;/g,"\xF1")
	x = x.replace(/Ò/g,"\xD2");	x = x.replace(/&Ograve;/g,"\xD2")
	x = x.replace(/ò/g,"\xF2");	x = x.replace(/&ograve;/g,"\xF2")
	x = x.replace(/Ó/g,"\xD3");	x = x.replace(/&Oacute;/g,"\xD3")
	x = x.replace(/ó/g,"\xF3");	x = x.replace(/&oacute;/g,"\xF3")
	x = x.replace(/Ô/g,"\xD4");	x = x.replace(/&Ocirc;/g,"\xD4")
	x = x.replace(/ô/g,"\xF4");	x = x.replace(/&ocirc;/g,"\xF4")
	x = x.replace(/Õ/g,"\xD5");	x = x.replace(/&Otilde;/g,"\xD5")
	x = x.replace(/õ/g,"\xF5");	x = x.replace(/&otilde;/g,"\xF5")
	x = x.replace(/Ö/g,"\xD6");	x = x.replace(/&Ouml;/g,"\xD6")
	x = x.replace(/ö/g,"\xF6");	x = x.replace(/&ouml;/g,"\xF6")
	x = x.replace(/Ø/g,"\xD8");	x = x.replace(/&Oslash;/g,"\xD8")
	x = x.replace(/ø/g,"\xF8");	x = x.replace(/&oslash;/g,"\xF8")
	x = x.replace(/Ù/g,"\xD9");	x = x.replace(/&Ugrave;/g,"\xD9")
	x = x.replace(/ù/g,"\xF9");	x = x.replace(/&ugrave;/g,"\xF9")
	x = x.replace(/Ú/g,"\xDA");	x = x.replace(/&Uacute;/g,"\xDA")
	x = x.replace(/ú/g,"\xFA");	x = x.replace(/&uacute;/g,"\xFA")
	x = x.replace(/Û/g,"\xDB");	x = x.replace(/&Ucirc;/g,"\xDB")
	x = x.replace(/û/g,"\xFB");	x = x.replace(/&ucirc;/g,"\xFB")
	x = x.replace(/Ü/g,"\xDC");	x = x.replace(/&Uuml;/g,"\xDC")
	x = x.replace(/ü/g,"\xFC");	x = x.replace(/&uuml;/g,"\xFC")
	
	x = x.replace(/\"/g,"\x22")
	x = x.replace(/\'/g,"\x27")
	x = x.replace(/\</g,"\x3C")
	x = x.replace(/\>/g,"\x3E")
	x = x.replace(/\[/g,"\x5B")
	x = x.replace(/\]/g,"\x5D")

	x = x.replace(/¢/g,"\xA2");	x = x.replace(/&cent;/g,"\xA2") 
	x = x.replace(/£/g,"\xA3");	x = x.replace(/&pound;/g,"\xA3")
	x = x.replace(/€/g,"\u20AC");	x = x.replace(/&euro;/g,"\u20AC") 
	x = x.replace(/©/g,"\xA9");	x = x.replace(/&copy;/g,"\xA9") 
	x = x.replace(/®/g,"\xAE");	x = x.replace(/&reg;/g,"\xAE") 
	x = x.replace(/ª/g,"\xAA");	x = x.replace(/&ordf;/g,"\xAA") 
	x = x.replace(/º/g,"\xBA");	x = x.replace(/&ordm;/g,"\xBA") 
	x = x.replace(/°/g,"\xB0");	x = x.replace(/&deg;/g,"\xB0") 
	x = x.replace(/±/g,"\xB1");	x = x.replace(/&plusmn;/g,"\xB1")
	x = x.replace(/×/g,"\xD7");	x = x.replace(/&times;/g,"\xD7") 
	
		
	return x
}

function acentos2(cual)
{
	 cual = cual.replace('á','\u00e1');
     cual = cual.replace('é','\u00e9');
     cual = cual.replace('í','\u00ed');
     cual = cual.replace('ó','\u00f3');
     cual = cual.replace('ú','\u00fa');
     cual = cual.replace('Á','\u00c1');
     cual = cual.replace('É','\u00c9');
     cual = cual.replace('Í','\u00cd');
     cual = cual.replace('Ó','\u00d3');
     cual = cual.replace('Ú','\u00da');
     cual = cual.replace('ñ','\u00f1');
     cual = cual.replace('Ñ','\u00d1');
	 return cual;
}

function alerta1(x)
{
	alert(acentos2(x));
}

/* MENÚ 
   Funciones del menú
*/
function over_menu(x)
{
	if (current != x)
	{
		document.getElementById(x).className = "Texto12 TextoColor3";
	}
}
function out_menu(x)
{
	if (current != x)
	{
		document.getElementById(x).className = "Texto12 TextoColor2";
	}
}

function goTopFrame()
{
    if(window != window.top)
    {
        window.open(window.location.href,"_parent");
    }
}

/* BUSCADOR
Funciones del buscador */
function buscador_carga()
{
	if (document.all)
	{
		document.getElementById("drp_1").onchange  = function() {
		fill_regions();
		}
		document.getElementById("drp_2").onchange  = function() {
		fill_zonas();
		}
	}
	else
	{
		document.getElementById("drp_1").setAttribute('onchange', 'fill_regions()'); 
		document.getElementById("drp_2").setAttribute('onchange', 'fill_zonas()'); 
	}
}
function fill_regions()
{
	// Create a function that will receive data sent from the server
	var ajaxRequest = ajaxFunction();
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var ajaxDisplay = document.getElementById('ajaxDiv');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
			if (document.all)
			{
				document.getElementById("drp_2").onchange  = function() {
				fill_zonas();
				}
			}
			else
			{
				document.getElementById("drp_2").setAttribute('onchange', 'fill_zonas()'); 
			}
			var x = '<select name="drp_3" id="drp_3"><option>Zona</option>';
			var ajaxDisplay = document.getElementById('ajaxDiv3');
			ajaxDisplay.innerHTML =x;
		}
	}
	var tabla = "ciudad";
	var campo = "region";
	var id = document.getElementById('drp_1').value;
	var nombre = "drp_2";
	var queryString = "?tabla=" + tabla + "&campo=" + campo + "&id=" + id + "&nombre=" + nombre;
	ajaxRequest.open("GET", "drop.php" + queryString, true);
	ajaxRequest.send(null); 
}
function fill_zonas()
{
	// Create a function that will receive data sent from the server
	var ajaxRequest = ajaxFunction();
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var ajaxDisplay = document.getElementById('ajaxDiv3');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
			
		}
	}
	var tabla = "zona";
	var campo = "ciudad";
	var id = document.getElementById('drp_2').value;
	var nombre = "drp_3";
	var queryString = "?tabla=" + tabla + "&campo=" + campo + "&id=" + id + "&nombre=" + nombre;
	ajaxRequest.open("GET", "drop.php" + queryString, true);
	ajaxRequest.send(null); 
}

function vacio(text){
    for(i=0; i<text.length; i++){
        if(text.charAt(i)!=" "){
            return true;
        }
    }
    return false;
}
function valida(idioma){
	var x = arregloBuscador(idioma);
	var formulario = document.form1;/*
    if(vacio(formulario.txt_1.value)==false || vacio(formulario.txt_2.value)==false || vacio(formulario.txt_3.value)==false
		|| formulario.txt_1.value == "Día"|| formulario.txt_2.value == "Mes"|| formulario.txt_3.value == "Año"){
        alerta1(x[0]);
        formulario.txt_1.focus();
        return false;
    } 
	if(vacio(formulario.txt_4.value)==false || vacio(formulario.txt_5.value)==false || vacio(formulario.txt_6.value)==false
		|| formulario.txt_4.value == "Día"|| formulario.txt_5.value == "Mes"|| formulario.txt_6.value == "Año"){
        alerta1(x[1]);
        formulario.txt_4.focus();
        return false;
    } */
	document.form1.submit();
	return true;
}

function limpiarValores()
{
	document.getElementById("drp_1").selectedIndex = 0;
	fill_regions();
	document.getElementById("txt_1").value = "D\u00eda";
	document.getElementById("txt_2").value = "Mes";
	document.getElementById("txt_3").value = "A\u00f1o";
	document.getElementById("txt_4").value = "D\u00eda";
	document.getElementById("txt_5").value = "Mes";
	document.getElementById("txt_6").value = "A\u00f1o";
	// Create a function that will receive data sent from the server
	var ajaxRequest = ajaxFunction();
	ajaxRequest.open("GET", "cookies/delete_cookie.php", true);
	ajaxRequest.send(null); 
}

function limpiarValoresEN()
{
	document.getElementById("drp_1").selectedIndex = 0;
	fill_regions();
	document.getElementById("txt_1").value = "Day";
	document.getElementById("txt_2").value = "Month";
	document.getElementById("txt_3").value = "Year";
	document.getElementById("txt_4").value = "Day";
	document.getElementById("txt_5").value = "Month";
	document.getElementById("txt_6").value = "Year";
	// Create a function that will receive data sent from the server
	var ajaxRequest = ajaxFunction();
	ajaxRequest.open("GET", "cookies/delete_cookie.php", true);
	ajaxRequest.send(null); 
}


/* OTRAS */

var currTabla = 0;
function ante()
{
	var tablas = document.getElementById("tablas").value;
	document.getElementById("tbl_" + currTabla).style.display = "none";
	document.getElementById("aa_" + currTabla).className = "tablas_off";
	currTabla--;
	if (currTabla == 0)
	{
		document.getElementById("btn_ante").style.display = "none";
	}
	document.getElementById("btn_sig").style.display = "";
	document.getElementById("tbl_" + currTabla).style.display = "";
	document.getElementById("aa_" + currTabla).className = "tablas_on";
	 parent.scrollTo(0,0);
	
}

function sig()
{
	var tablas = document.getElementById("tablas").value;
	document.getElementById("tbl_" + currTabla).style.display = "none";
	document.getElementById("aa_" + currTabla).className = "tablas_off";
	currTabla ++;
	if (currTabla == (tablas-1))
	{
		document.getElementById("btn_sig").style.display = "none";
	}
	document.getElementById("btn_ante").style.display = "";
	document.getElementById("tbl_" + currTabla).style.display = "";
	document.getElementById("aa_" + currTabla).className = "tablas_on";
	 parent.scrollTo(0,0);
}
function tabla(cual)
{
	var tablas = document.getElementById("tablas").value;
	document.getElementById("tbl_" + currTabla).style.display = "none";
	document.getElementById("aa_" + currTabla).className = "tablas_off";
	currTabla = cual;
	document.getElementById("btn_sig").style.display = "";
	document.getElementById("btn_ante").style.display = "";
	if (currTabla == (tablas-1))
	{
		document.getElementById("btn_sig").style.display = "none";
	}
	if (currTabla == 0)
	{
		document.getElementById("btn_ante").style.display = "none";
	}
	document.getElementById("tbl_" + currTabla).style.display = "";
	document.getElementById("aa_" + currTabla).className = "tablas_on";
	 parent.scrollTo(0,0);
}
function set_currM1(cual)
{
	if (cual != "-1")
	{
	document.getElementById("a_" + cual).className = "txt_menu1_on";
	document.getElementById("r_" + cual).className = "txt_menu1_on";
	}
}
function forgot()
{
	window.open("forgot.php","_blank",
				"menubar=no,resizable=no,scrollbars=no,status=no,height=200,width=300,left=200,right=200");
}

function detalle(id)
{
	window.location = "detalle.php?id=" + id;
}

function ajustar()
{
	try
        {
            var i =0;
			var cantidad = parseInt(document.getElementById("cantidad").value);
			var display = '';
			while (document.getElementById("img_" + i))
			{
				var w = document.getElementById("img_" + i).width;
				var h = document.getElementById("img_" + i).height;
				var tempw = 359;
				var temph = 359;
				if (w > h)
				{
				   var div = tempw/w;
				   temph = h * div;
				}else
				{
					var div  = temph/h;
					tempw = w * div;
				}
				document.getElementById("img_" + i).width= tempw;
				document.getElementById("img_" + i).height = temph;
				document.getElementById("img_" + i).style.display = display;
				display = 'none'
				i++;
			}
        }
        catch(x)
        {}
		if (cantidad > 1)
		{
			document.getElementById('ma').style.visibility = 'visible';
		}
}

var currFoto = 0;
function mas()
{
	var cantidad = document.getElementById("cantidad").value;
	document.getElementById("img_" + currFoto).style.display = "none";
	currFoto++;
	if ((currFoto+1) == cantidad)
	{
		document.getElementById('ma').style.visibility = 'hidden';
	}
	document.getElementById('me').style.visibility = 'visible';
	document.getElementById("img_" + currFoto).style.display = "";
}

function menos()
{
	var cantidad = document.getElementById("cantidad").value;
	document.getElementById("img_" + currFoto).style.display = "none";
	currFoto--;
	if (currFoto == 0)
	{
		document.getElementById('me').style.visibility = 'hidden';
	}
	document.getElementById('ma').style.visibility = 'visible';
	document.getElementById("img_" + currFoto).style.display = "";
}

function reservar(cual)
{
	parent.location = "reservacion.php?propiedad=" + cual;
}

function opciones(cual)
{
	parent.location = "contacto2.php?propiedad=" + cual;
}

function seleccionar_campo(id)
{
	// Create a function that will receive data sent from the server
	var ajaxRequest = ajaxFunction();
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
		}
	}
	var queryString = "?id=" + id;
	ajaxRequest.open("GET", "ajax/sel_campo.php" + queryString, true);
	ajaxRequest.send(null); 
}

function loginProp()
{
	// Create a function that will receive data sent from the server
	var ajaxRequest = ajaxFunction();
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
				document.form1.nombre.value = "";
				document.form1.apellido.value = "";
				document.form1.nacionalidad.value = "";
				document.form1.email.value = "";
				document.form1.telefono.value = "";
				document.form1.cliente.value = "";
				document.form1.btn_1.style.display = "none";
				document.form1.btn_2.style.display = "";
		}
	}
	ajaxRequest.open("GET", "cookies/logOut2.php", true);
	ajaxRequest.send(null); 
}


function calcular(id)
{
	var ajaxRequest = ajaxFunction();
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			if (ajaxRequest.responseText.length > 0)
			{
				var array = ajaxRequest.responseText.split("@");
			   var tarifa = parseFloat(array[1]);
			   var days = array[2];
			   document.form1.tarifa.value = tarifa;
			   if (document.form1.descuento.value == "")
			   	document.form1.descuento.value = 0;
			   var descuento = parseFloat(document.form1.descuento.value);
			   var subtotal = tarifa * days;
			   var desc = subtotal* (descuento/100);
			   var total = subtotal - desc;
			   if (isNaN(subtotal))
			   		subtotal = 0;
					if (isNaN(desc))
			   		desc = 0;
					if (isNaN(total))
			   		total = 0;
				document.getElementById("subtotal").innerHTML = "$" +subtotal.toFixed(2);
				document.getElementById("desc").innerHTML = "$" + desc.toFixed(2);
				document.getElementById("total").innerHTML = "$" + total.toFixed(2);
			}
		}
	}
	if (document.form1.fecha1.value != "" && document.form1.fecha2.value != "")
	{
		var str1 = document.form1.fecha1.value;
		var str2 = document.form1.fecha2.value;
	   var dt1   = parseInt(str1.substring(0,2),10);
	   var mon1  = parseInt(str1.substring(3,5),10);
	   var yr1   = parseInt(str1.substring(6,10),10);
	   var dt2   = parseInt(str2.substring(0,2),10);
	   var mon2  = parseInt(str2.substring(3,5),10);
	   var yr2   = parseInt(str2.substring(6,10),10);
	   var inicial = yr1 + "-" + mon1 + "-" + dt1;
		var final = yr2 + "-" + mon2 + "-" + dt2;
		var ruta ="ajax/calcularPrecio.php?id=" + id + "&fechaInicial=" + inicial + "&fechaFinal=" + final;
		ajaxRequest.open("GET", ruta, true);
		ajaxRequest.send(null); 
	}
	
  
}

function imprimir(id)
{
	window.open("imprimir.php?id=" + id,"_blank",
				"menubar=no,resizable=no,scrollbars=no,status=no,height=500,width=500,left=200,right=200");		
}
function pago(obj)
{
	var p1 = document.getElementById("rd_0").checked;
	var tbl1 = document.getElementById("tbl1");
	var tbl2 = document.getElementById("tbl2");
		var btn= document.getElementById("btn_sig");
	if (p1)
	{
		tbl1.style.display="";
		tbl2.style.display="none";
		btn.style.display="none";
	}
	else
	{
		tbl1.style.display="none";
		tbl2.style.display="";
		btn.style.display="";
	}
}
function trim (myString)
{
	return myString.replace(/^\s+/g,'').replace(/\s+$/g,'')
}
 function quickSelect(valor, drop) {
	 for (var i = 0; i < drop.length; i++)
      {
		  if (drop.options[i].value == valor)
		  	drop.options[i].selected = true;
		}
  }


function llenarPropietario(id)
{
	var ajaxRequest = ajaxFunction();
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			if (ajaxRequest.responseText.length > 0)
			{
				var datos = ajaxRequest.responseText.split("$");
				document.form1.nombre.value = trim(datos[0]);
				document.form1.apellido.value = datos[1];
				document.form1.nacionalidad.value = datos[2];
				document.form1.email.value = datos[3];
				document.form1.telefono.value = datos[4];
				document.form1.btn_1.style.display = "";
				document.form1.btn_2.style.display = "none";
			}
			else 
				document.form1.submit();
		}
	}
	var ruta ="ajax/datosPropietario.php?id=" + id;
	document.form1.cliente.value = id;
	ajaxRequest.open("GET", ruta, true);
	ajaxRequest.send(null); 
}


var currPag = 1;
function pagina(cual, set_pag)
{
	
	if (set_pag)
	{
		var i = 1;
		while(document.getElementById("a_" + i))
		{
			document.getElementById("a_" + i).className = "link";
			document.getElementById("p_" + i).style.display = "none";
			i++;
		}
		i--;
		if (document.getElementById("ante"))
			document.getElementById("ante").style.visibility = "visible";
		if (document.getElementById("sig"))
			document.getElementById("sig").style.visibility = "visible";
		if (cual == i)
		{
			if (document.getElementById("sig"))
				document.getElementById("sig").style.visibility = "hidden";
		}
		if (cual == "1")
		{
			if (document.getElementById("ante"))
				document.getElementById("ante").style.visibility = "hidden";
		}
		if (document.getElementById("a_" + cual))
			document.getElementById("a_" + cual).className = "link_bold";
		if (document.getElementById("p_" + cual))
			document.getElementById("p_" + cual).style.display = "";
		currPag = cual;
	}
	else
	{
		currPag = cual;
		var x = document.location.toString();
		if (x.indexOf("pag") > 0)
		{
			x = x.substring(0,x.indexOf("&pag"));
		}
		if (x.indexOf("?") > 0)
			document.location = x + "&pag=" + currPag;
		else 
		document.location = x + "?pag=" + currPag;
	}
}
function siguiente()
{
	currPag++;
	pagina(currPag);
}
function anterior()
{
	currPag--;
	pagina(currPag);
}
function validarContacto(idioma)
{
	var textos = arregloContacto(idioma);
	if (document.getElementById("txt_2").value == "")
	{
		document.getElementById("txt_2").focus();
		alert(textos[0]);
		return false;
	}
		if (document.getElementById("txt_3").value == "")
	{
		document.getElementById("txt_3").focus();
		alert(textos[1]);
		return false;
	}
		if (document.getElementById("txt_5").value == "")
	{
		document.getElementById("txt_5").focus();
		alert(textos[2]);
		return false;
	}
	document.form1.submit();
}


function validarDetalle(cual, idioma)
{
	var textos = arregloDetalle(idioma);
	if (document.form1.fecha1.value == "")
	{
		document.form1.fecha1.focus();
		alerta1(textos[0]);
		return false;
	}
	if (document.form1.fecha2.value == "")
	{
		document.form1.fecha2.focus();
		alerta1(textos[1]);
		return false;
	}
	var ruta = "cookies/set_cookie.php?solofechas=solofechas&fecha1=" + document.form1.fecha1.value + "&fecha2=" + document.form1.fecha2.value + "&id=" + cual;
	window.location = ruta;
}

var currGal = 0;
function fotoSiguiente()
{
	document.getElementById("img_"+currGal).style.display = "none";
	currGal++;
	var cant = document.getElementById("cantidad").value;
	if ((currGal+1) == cant)
		document.getElementById("sig").style.visibility="hidden";
	document.getElementById("ant").style.visibility="visible";
	document.getElementById("img_"+ currGal).style.display = "";
}
function fotoAnterior()
{
	document.getElementById("img_"+currGal).style.display = "none";
	currGal--;
	var cant = document.getElementById("cantidad").value;
	if (currGal == 0)
		document.getElementById("ant").style.visibility="hidden";
	document.getElementById("sig").style.visibility="visible";
	document.getElementById("img_"+ currGal).style.display = "";
}

function cerrarGaleria()
{
	top.Shadowbox.close();
}

function abrirCalendario(objeto)
{
	var obj	= document.getElementById(objeto);
	pop_frame(obj,obj);
}



// PASO 1 - RESERVACIÓN
function passwordChanged(objeto) {
var strength = document.getElementById('strength');
var strongRegex = new RegExp("^(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\W).*$", "g");
var mediumRegex = new RegExp("^(?=.{7,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$", "g");
var enoughRegex = new RegExp("(?=.{6,}).*", "g");
var pwd = document.getElementById(objeto);
if (pwd.value.length==0) {
strength.innerHTML = 'Escriba su contrase&ntilde;a';
} else if (false == enoughRegex.test(pwd.value)) {
strength.innerHTML = 'M&aacute;s caracteres';
} else if (strongRegex.test(pwd.value)) {
strength.innerHTML = '<span style="color:green">Fuerte!</span>';
} else if (mediumRegex.test(pwd.value)) {
strength.innerHTML = '<span style="color:orange">Mediano!</span>';
} else {
strength.innerHTML = '<span style="color:red">D&eacute;bil!</span>';
}
}
function validarPaso1(idioma)
{
	var textos = arregloReservar1(idioma);
	var al = 0;
	if(!validarVacio("fecha1", textos[al]))
		return false;
	al++;
	if(!validarVacio("fecha2", textos[al]))
		return false;
	al++;
	if(!validarVacio("txt_d1", textos[al]))
		return false;
	al++;
	if(!validarVacio("txt_d1b", textos[al]))
		return false;
	al++;
	if(!validarIgual("txt_d1","txt_d1b", textos[al]))
		return false;
	al++;
	if(!validarVacio("txt_d2", textos[al]))
		return false;
	al++;
	if(!validarVacio("txt_d2b", textos[al]))
		return false;
	al++;
	if(!validarIgual("txt_d2","txt_d2b", textos[al]))
		return false;
	al++;
	if(!validarVacio("txt_d3", textos[al]))
		return false;
	al++;
	if(!validarVacio("txt_d4", textos[al]))
		return false;
	al++;
	if(!validarVacio("txt_d5", textos[al]))
		return false;
	al++;
	if(!validarVacio("txt_d6", textos[al]))
		return false;
	al++;
	if(!validarVacio("txt_d7", textos[al]))
		return false;
	al++;
	if(!validarVacio("txt_d8", textos[al]))
		return false;
	al++;
	if(!validarVacio("txt_d9", textos[al]))
		return false;
	al++;
	if(!validarSeleccion("drp_1", textos[al]))
		return false;
	al++;
	if(!validarSeleccion("drp_2", textos[al]))
		return false;
	al++;
	document.form1.btn_sig.value = "Validando..";
	validar_fechas(document.form1.fecha1.value,document.form1.fecha2.value,document.form1.txt_d1.value,document.form1.propiedad.value,document.form1.cliente.value);
}

function loginCli(idioma)
{
	var textos = arregloLogin(idioma);
	var al = 0;
	if(!validarVacio("u_email", textos[al]))
		return false;
	al++;
	if(!validarVacio("u_contrasena", textos[al]))
		return false;
	al++;	
	var ajaxRequest = ajaxFunction();
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			
			var respuesta = ajaxRequest.responseText;
			var res = respuesta.split("$");
			res[0] = trim(res[0]);
			var textos = arregloLogin(res[1]);
			if (res[0] == "-1")
			{
				alerta1(textos[2]);
			}
			else
			{
				alerta1(textos[3]);
				llenarCliente(res[0]);
			}
		}
	}
	var queryString = "?usuario=" + document.getElementById("u_email").value + 
	"&contrasena=" + document.getElementById("u_contrasena").value + "&idioma=" + idioma;
	ajaxRequest.open("GET", "ajax/loginCliente.php" + queryString, true);
	ajaxRequest.send(null);
}
function llenarCliente(id)
{
	var ajaxRequest = ajaxFunction();
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			if (ajaxRequest.responseText.length > 0)
			{
				var datos = ajaxRequest.responseText.split("$");
				document.form1.txt_d1.value = trim(datos[0]);
				document.form1.txt_d1b.value = trim(datos[0]);
				document.form1.txt_d2.value = trim(datos[1]);
				document.form1.txt_d2b.value = trim(datos[1]);
				document.form1.txt_d3.value = datos[2];
				document.form1.txt_d4.value = datos[4];
				document.form1.txt_d5.value = datos[3];
				document.form1.txt_d6.value = datos[6];
				document.form1.txt_d7.value = datos[7];
				document.form1.txt_d8.value = datos[10];
				document.form1.txt_d9.value = datos[8];
				quickSelect(datos[9],document.form1.drp_1);
				quickSelect(datos[5],document.form1.drp_2);
				document.form1.btn_1.style.display = "none";
				document.form1.btn_2.style.display = "";
			}
			else 
				document.form1.submit();
		}
	}
	var ruta ="ajax/datosCliente.php?id=" + id;
	document.form1.cliente.value = id;
	ajaxRequest.open("GET", ruta, true);
	ajaxRequest.send(null); 
}
function loginCli2()
{
	// Create a function that will receive data sent from the server
	var ajaxRequest = ajaxFunction();
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
				document.form1.txt_d1.value = "";
				document.form1.txt_d1b.value = "";
				document.form1.txt_d2.value = "";
				document.form1.txt_d2b.value = "";
				document.form1.txt_d3.value = "";
				document.form1.txt_d4.value = "";
				document.form1.txt_d5.value = "";
				document.form1.txt_d6.value = "";
				document.form1.txt_d7.value = "";
				document.form1.txt_d8.value = "";
				document.form1.txt_d9.value = "";
				document.form1.drp_1.options[0].selected = true;
				document.form1.drp_2.options[0].selected = true;
				document.form1.cliente.value = "";
				document.form1.btn_1.style.display = "";
				document.form1.btn_2.style.display = "none";
		}
	}
	ajaxRequest.open("GET", "cookies/logOut.php", true);
	ajaxRequest.send(null); 
}

function validar_fechas(inicio,fin,usuario,propiedad,idusuario)
{
	var ajaxRequest = ajaxFunction();
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var x = trim(ajaxRequest.responseText);
			if (x.length > 0)
			{
				alerta1(ajaxRequest.responseText);
				document.form1.btn_sig.value = "Siguiente";
			}
			else 
			{
				document.form1.submit();
			}
		}
	}
	var ruta ="ajax/validar.php?inicio="+inicio+"&fin="+fin+"&usuario="+usuario+"&propiedad="+propiedad+"&idusuario="+idusuario;
	ajaxRequest.open("GET", ruta, true);
	ajaxRequest.send(null); 
}

function validarPago(idioma)
{
	if(document.getElementById("rd_1a").checked == false && document.getElementById("rd_1b").checked == false && document.getElementById("rd_1c").checked == false)
	{
		if (idioma == "es")
			alerta1("Favor de seleccionar su forma de pago");
		else
			alerta1("Please select your payment");
		return;
	}
	else
	{
		if (document.getElementById("rd_1c").checked == true)
		{
			document.form2.submit();
		}
		else
		{
			document.form1.submit();
		}
	}
}
function validarEditar(idioma)
{
	var textos = arregloReservar1(idioma);
	var al = 2;
	if(!validarVacio("txt_d1", textos[al]))
		return false;
	al++;
	if(!validarVacio("txt_d1b", textos[al]))
		return false;
	al++;
	if(!validarIgual("txt_d1","txt_d1b", textos[al]))
		return false;
	al++;
	if(!validarVacio("txt_d2", textos[al]))
		return false;
	al++;
	if(!validarVacio("txt_d2b", textos[al]))
		return false;
	al++;
	if(!validarIgual("txt_d2","txt_d2b", textos[al]))
		return false;
	al++;
	if(!validarVacio("txt_d3", textos[al]))
		return false;
	al++;
	if(!validarVacio("txt_d4", textos[al]))
		return false;
	al++;
	if(!validarVacio("txt_d5", textos[al]))
		return false;
	al++;
	if(!validarVacio("txt_d6", textos[al]))
		return false;
	al++;
	if(!validarVacio("txt_d7", textos[al]))
		return false;
	al++;
	if(!validarVacio("txt_d8", textos[al]))
		return false;
	al++;
	if(!validarVacio("txt_d9", textos[al]))
		return false;
	al++;
	if(!validarSeleccion("drp_1", textos[al]))
		return false;
	al++;
	if(!validarSeleccion("drp_2", textos[al]))
		return false;
	al++;
	document.form1.submit();
}

/* Registro de propietario */
function loginProp(idioma)
{
	var textos = arregloPropietario(idioma);
	var al = 0;
	if(!validarVacio("u_email", textos[al]))
		return false;
	al++;
	if(!validarVacio("u_contrasena", textos[al]))
		return false;
	al++;	
	var ajaxRequest = ajaxFunction();
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			
			var respuesta = ajaxRequest.responseText;
			var res = respuesta.split("$");
			res[0] = trim(res[0]);
			var textos = arregloPropietario(res[1]);
			if (res[0] == "-1")
			{
				alerta1(textos[2]);
			}
			else
			{
				//alerta1(textos[3]);
				//llenarPropietario(res[0]);
				window.location='registro-de-propiedad.php';
			}
		}
	}
	var queryString = "?usuario=" + document.getElementById("u_email").value + 
	"&contrasena=" + document.getElementById("u_contrasena").value + "&idioma=" + idioma;
	ajaxRequest.open("GET", "ajax/loginPropietario.php" + queryString, true);
	ajaxRequest.send(null);
}
function llenarPropietario(id)
{
	var ajaxRequest = ajaxFunction();
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			if (ajaxRequest.responseText.length > 0)
			{
				var datos = ajaxRequest.responseText.split("$");
				document.form1.txt_d1.value = trim(datos[0]);
				document.form1.txt_d1b.value = trim(datos[0]);
				document.form1.txt_d2.value = trim(datos[1]);
				document.form1.txt_d2b.value = trim(datos[1]);
				document.form1.txt_d3.value = datos[2];
				document.form1.txt_d4.value = datos[3];
				document.form1.txt_d5.value = datos[4];
				quickSelect(datos[5],document.form1.drp_1);
				document.form1.btn_1.style.display = "none";
				document.form1.btn_2.style.display = "";
			}
			else 
				document.form1.submit();
		}
	}
	var ruta ="ajax/datosPropietario.php?id=" + id;
	document.form1.cliente.value = id;
	ajaxRequest.open("GET", ruta, true);
	ajaxRequest.send(null); 
}
function logOutPropietario()
{
	// Create a function that will receive data sent from the server
	var ajaxRequest = ajaxFunction();
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
				document.form1.txt_d1.value = "";
				document.form1.txt_d1b.value = "";
				document.form1.txt_d2.value = "";
				document.form1.txt_d2b.value = "";
				document.form1.txt_d3.value = "";
				document.form1.txt_d4.value = "";
				document.form1.txt_d5.value = "";
				document.form1.drp_1.options[0].selected = true;
				document.form1.cliente.value = "";
				document.form1.btn_1.style.display = "";
				document.form1.btn_2.style.display = "none";
		}
	}
	ajaxRequest.open("GET", "cookies/logOut2.php", true);
	ajaxRequest.send(null); 
}

function validarPropietario(idioma)
{
	var textos = arregloPropietario2(idioma);
	var al = 0;
	if(!validarVacio("txt_d1", textos[al]))
		return false;
	al++;
	if(!validarVacio("txt_d1b", textos[al]))
		return false;
	al++;
	if(!validarIgual("txt_d1","txt_d1b", textos[al]))
		return false;
	al++;
	if(!validarVacio("txt_d2", textos[al]))
		return false;
	al++;
	if(!validarVacio("txt_d2b", textos[al]))
		return false;
	al++;
	if(!validarIgual("txt_d2","txt_d2b", textos[al]))
		return false;
	al++;
	if(!validarVacio("txt_d3", textos[al]))
		return false;
	al++;
	if(!validarVacio("txt_d4", textos[al]))
		return false;
	al++;
	if(!validarVacio("txt_d5", textos[al]))
		return false;
	al++;
	if(!validarSeleccion("drp_1", textos[al]))
		return false;
	document.form1.submit();
}




function cambiarRenta()
{
	document.getElementById("tarifas").style.display = "none";
	document.getElementById("tarifas2").style.display = "none";
	document.getElementById("tarifas3").style.display = "none";
	document.getElementById("tarifas4").style.display = "none";
	document.getElementById("tarifas5").style.display = "none";
	document.getElementById("precio_venta").style.display = "";
}
function cambiarVenta()
{
	document.getElementById("tarifas").style.display = "";
	document.getElementById("tarifas2").style.display = "";
	document.getElementById("tarifas3").style.display = "";
	document.getElementById("tarifas4").style.display = "";
	document.getElementById("tarifas5").style.display = "";
	document.getElementById("precio_venta").style.display = "none";
}

