/* CSS Document 
   Empresa: Ubicar Bienes Raices
   Design by Luis Carlos Aponte
   Built 27-12-2009 */
   
//CREACION DEL OBJETO AJAX
function nuevoAjax() {
var XMLHttpRequestObject = false;
	if (window.XMLHttpRequest) {
		XMLHttpRequestObject = new XMLHttpRequest();
	} else {
		if (window.ActiveXObject) {
			XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP"); 
		}
	}
	return XMLHttpRequestObject;
}
function mostrarMapa() {
	if(document.getElementById('mostrar-mapa').innerHTML=="Ver Mapa") {
	document.getElementById('mostrar-mapa').innerHTML='Ocultar Mapa';
	document.getElementById('mapa').style.display='block';
	document.getElementById('mapa').style.visibility='visible';
	} else {
	if(document.getElementById('mostrar-mapa').innerHTML=="Ocultar Mapa") {
	document.getElementById('mostrar-mapa').innerHTML='Ver Mapa';
	document.getElementById('mapa').style.display='none';
	document.getElementById('mapa').style.visibility='hidden';
	}
	}
}
//FUNCIONES DE VALIDACION DE FORMULARIOS
function is_text(e) {
	var cadena = "ABCDEFGHIJKLMNÑOPQRSTUVWXYXabcdefghijklmnñopqrstuvwxyzáéíóú";
}
function is_number(e) {
    var num = "0123456789";            // caracteres numericos
    for (i=0; i<e.length; i++) {
        if (num.indexOf(e.charAt(i),0) == -1) {
        return false;
    	} else {
    	return true;
    	}
    }
}
function is_email(e) {
 //expresion regular
 	var b=/^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/
 	
 	//comentar la siguiente linea si no desea que apaeresca el alert()
 	// alert("Email " + (b.test(txt)?"":"no ") + "válido.");
 	
 	//devuelve verdadero si validacion OK, falso en caso contrario
 	return b.test(e);
}
function is_error(Ctrl,e,eMsg,eClass) {
	Ctrl.className=eClass;
	document.getElementById('div'+e).style.visibility = 'visible';
	document.getElementById('div'+e).style.display = 'block';
	document.getElementById('div'+e).innerHTML=eMsg;
}
function is_validate(Ctrl,e,nClass) {
	Ctrl.className=nClass;
	document.getElementById('div'+e).style.visibility = 'hidden';
	document.getElementById('div'+e).style.display = 'none';
}
function ValidarFormContactos() {
	var frm = document.cntact;
	var error = false;
	//VALIDAR CAMPOS
		if(frm.nombre.value=="") {
		is_error(frm.nombre,'nombre','Campo Requerido','input4');
		error = true;
		} else {
		if(frm.nombre.value.length<=9) {
		is_error(frm.nombre,'nombre','Ingrese su Nombre Completo','input4');
		error = true;
		}
		}
		if(frm.email.value=="") {
		is_error(frm.email,'email','Campo Requerido','input4');
		error = true;
		} else {
		if(!is_email(frm.email.value)) {
		is_error(frm.email,'email','Ingrese un E-mail válido','input4');
		error = true;
		}
		}
		if(frm.phone.value=="") {
		is_error(frm.phone,'phone','Campo Requerido','input4');
		error = true;
		} else {
		if(frm.phone.value.length<=6) {
		is_error(frm.phone,'phone','Ingrese un Numero de Teléfono válido','input4');
		error = true;
		} else {
		if(!is_number(frm.phone.value)) {
		is_error(frm.phone,'phone','No se admiten letras en el Número de Teléfono','input4');
		error = true;
		}
		}
		}
		if(frm.subject.options[frm.subject.selectedIndex].value=="0") {
		is_error(frm.subject,'subject','Seleccione el Motivo de su Consulta','input2');
		frm.subject.style.background = '#ffebe8';
		error = true;
		}
	//DEVOLVER RESULTADO DE LA VALIDACION
	return error;	
}
function EnviarContacto() {
	if(!ValidarFormContactos()) {
	var frm_nombre = document.cntact.nombre.value;
	var frm_email = document.cntact.email.value;
	var frm_phone = document.cntact.phone.value;
	var frm_subject = document.cntact.subject.options[document.cntact.subject.selectedIndex].value;
	var frm_message = document.cntact.message.value;
	//ENVIAR EL MENSAJE
		//Guardar el HTML DEL DIV Y DECLARARLO
		var actcod = document.getElementById('contenido-in').innerHTML;
		var capa = document.getElementById('contenido-in');
		//Crear el Objeto Ajax
		var ajax=nuevoAjax();
		//Mostrar el Mensaje de Envio
		var sendingmsg = "\n";
		sendingmsg = sendingmsg + "						<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\n";
		sendingmsg = sendingmsg + "							<tr>\n";
		sendingmsg = sendingmsg + "								<td align=\"center\">\n";
		sendingmsg = sendingmsg + "									<table border=\"0\" width=\"500px\">\n";
		sendingmsg = sendingmsg + "										<tr>\n";
		sendingmsg = sendingmsg + "											<td class=\"location\"><a href=\"index.php\">Inicio</a> > Enviando Mensaje</td>\n";
		sendingmsg = sendingmsg + "										</tr>\n";
		sendingmsg = sendingmsg + "										<tr>\n";
		sendingmsg = sendingmsg + "											<td style=\"height:60px;\">&nbsp;</td>\n";
		sendingmsg = sendingmsg + "										</tr>\n";
		sendingmsg = sendingmsg + "										<tr>\n";
		sendingmsg = sendingmsg + "											<td align=\"center\"><br><br><div style=\"color:#666666;font-size:12px;\">Espere un Momento<br>Su Mensaje esta siendo enviado...</div></td>\n";
		sendingmsg = sendingmsg + "										</tr>\n";
		sendingmsg = sendingmsg + "										<tr>\n";
		sendingmsg = sendingmsg + "											<td style=\"height:60px;\">&nbsp;</td>\n";
		sendingmsg = sendingmsg + "										</tr>\n";
		sendingmsg = sendingmsg + "										<tr>\n";
		sendingmsg = sendingmsg + "											<td><br><br><br><br></td>\n";
		sendingmsg = sendingmsg + "										</tr>\n";
		sendingmsg = sendingmsg + "									</table>\n";
		sendingmsg = sendingmsg + "								</td>\n";
		sendingmsg = sendingmsg + "							</tr>\n";
		sendingmsg = sendingmsg + "						</table>\n";
		capa.innerHTML=sendingmsg;
		//Declarar HTML de un Mensaje de Confirmacion
		var msgsendok = "\n";
		msgsendok = msgsendok + "						<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\n";
		msgsendok = msgsendok + "							<tr>\n";
		msgsendok = msgsendok + "								<td align=\"center\">\n";
		msgsendok = msgsendok + "									<table border=\"0\" width=\"500px\">\n";
		msgsendok = msgsendok + "										<tr>\n";
		msgsendok = msgsendok + "											<td class=\"location\"><a href=\"index.php\">Inicio</a> > <a href=\"contactos.php\">Contáctenos</a> > Mensaje Enviado</td>\n";
		msgsendok = msgsendok + "										</tr>\n";
		msgsendok = msgsendok + "										<tr>\n";
		msgsendok = msgsendok + "											<td style=\"height:60px;\">&nbsp;</td>\n";
		msgsendok = msgsendok + "										</tr>\n";
		msgsendok = msgsendok + "										<tr>\n";
		msgsendok = msgsendok + "											<td align=\"center\"><br><br><div style=\"color:#00254a;font-family:Tahoma;font-size:12px;\">Su Mensaje <b>ha sido enviado</b> correctamente!!<br>Personal de Ubicar Bienes Raíces le responderá en el menor tiempo posible...<br>\n";
		msgsendok = msgsendok + "												<br><br><br><a href=\"http://www.ubicarbienesraices.com\" style=\"color:#00254a;font-family:Tahoma;font-size:12px;text-decoration:underline;\">www.ubicarbienesraices.com</a><br><br><br>\n";
		msgsendok = msgsendok + "											</td>\n";
		msgsendok = msgsendok + "										</tr>\n";
		msgsendok = msgsendok + "										<tr>\n";
		msgsendok = msgsendok + "											<td style=\"height:60px;\">&nbsp;</td>\n";
		msgsendok = msgsendok + "										</tr>\n";
		msgsendok = msgsendok + "										<tr>\n";
		msgsendok = msgsendok + "											<td><br><br><br><br></td>\n";
		msgsendok = msgsendok + "										</tr>\n";
		msgsendok = msgsendok + "									</table>\n";
		msgsendok = msgsendok + "								</td>\n";
		msgsendok = msgsendok + "							</tr>\n";
		msgsendok = msgsendok + "						</table>\n";
		//Abir Conexion y Enviar el Mensaje con AJAX
		ajax.open("GET", "contactos_.php?name="+frm_nombre+"&email="+frm_email+"&phone="+frm_phone+"&subject="+frm_subject+"&message="+frm_message, true);
		ajax.onreadystatechange = function() {
			if(ajax.readyState==4 && ajax.status==200) {
			//Mostrar el Mensaje de Enviado Correctamente
			capa.innerHTML=msgsendok;
			document.title=document.title+" > Mensaje Enviado";
			}
		}
		ajax.send(null);
	}
}
function formBuscarIndex(Ctrl) {
	if(Ctrl.options[Ctrl.selectedIndex].value=="0") {
	document.getElementById('td1-1').style.display = 'none';
	document.getElementById('td1-2').style.display = 'none';
	} else {
	if(Ctrl.options[Ctrl.selectedIndex].value=="1") {
	document.getElementById('td1-1').style.display = 'block';
	document.getElementById('td1-2').style.display = 'block';
	} else {
	if(Ctrl.options[Ctrl.selectedIndex].value=="2") { 
	document.getElementById('td1-1').style.display = 'block';
	document.getElementById('td1-2').style.display= 'block';
	} else {
	document.getElementById('td1-1').style.display = 'none';
	document.getElementById('td1-2').style.display = 'none';
	}
	}
	}
}
function PrecioHasta(valorinicial) {
	var selectHasta = document.getElementById('cat_d');
	var option_a;
	var option_b;
	var option_c;
	var option_d;
	var option_e;
	var option_f;
	var option_g;
	var option_h;
	var option_i;
	var option_j;
	selectHasta.disabled=false;
		//Si el Valor Inicial es US$ 0.00
		if(valorinicial==0) {
		selectHasta.innerHTML='';
		//Poner todos los Valores en el Campo Hasta
		option_a = document.createElement("option"); option_a.value="sel"; option_a.innerHTML="Seleccione";
		option_b = document.createElement("option"); option_b.value="1000"; option_b.innerHTML = "US$ 1,000.00";
		option_c = document.createElement("option"); option_c.value="10000"; option_c.innerHTML = "US$ 10,000.00";
		option_d = document.createElement("option"); option_d.value="50000"; option_d.innerHTML = "US$ 50,000.00";
		option_e = document.createElement("option"); option_e.value="100000"; option_e.innerHTML = "US$ 100,000.00";
		option_f = document.createElement("option"); option_f.value="150000"; option_f.innerHTML = "US$ 150.000,00";
		option_g = document.createElement("option"); option_g.value="200000"; option_g.innerHTML = "US$ 200,000.00";
		option_h = document.createElement("option"); option_h.value="250000"; option_h.innerHTML = "US$ 250,000.00";
		option_i = document.createElement("option"); option_i.value="500000"; option_i.innerHTML = "US$ 500.000,00";
		option_j = document.createElement("option"); option_j.value="1000000"; option_j.innerHTML = "US$ 1,000,000.00 o más";
		selectHasta.appendChild(option_a);
		selectHasta.appendChild(option_b);
		selectHasta.appendChild(option_c);
		selectHasta.appendChild(option_d);
		selectHasta.appendChild(option_e);
		selectHasta.appendChild(option_f);
		selectHasta.appendChild(option_g);
		selectHasta.appendChild(option_h);
		selectHasta.appendChild(option_i);
		selectHasta.appendChild(option_j);
		} else {
		if(valorinicial==1000) {
		//Borrar los que ya estaban
		selectHasta.innerHTML='';
		//Empezar desde US$ 10,000.00
		option_a = document.createElement("option"); option_a.value="sel"; option_a.innerHTML="Seleccione";
		option_b = document.createElement("option"); option_b.value="10000"; option_b.innerHTML = "US$ 10,000.00";
		option_c = document.createElement("option"); option_c.value="50000"; option_c.innerHTML = "US$ 50,000.00";
		option_d = document.createElement("option"); option_d.value="100000"; option_d.innerHTML = "US$ 100,000.00";
		option_e = document.createElement("option"); option_e.value="150000"; option_e.innerHTML = "US$ 150.000,00";
		option_f = document.createElement("option"); option_f.value="200000"; option_f.innerHTML = "US$ 200,000.00";
		option_g = document.createElement("option"); option_g.value="250000"; option_g.innerHTML = "US$ 250,000.00";
		option_h = document.createElement("option"); option_h.value="500000"; option_h.innerHTML = "US$ 500.000,00";
		option_i = document.createElement("option"); option_i.value="1000000"; option_i.innerHTML = "US$ 1,000,000.00 o más";
		selectHasta.appendChild(option_a);
		selectHasta.appendChild(option_b);
		selectHasta.appendChild(option_c);
		selectHasta.appendChild(option_d);
		selectHasta.appendChild(option_e);
		selectHasta.appendChild(option_f);
		selectHasta.appendChild(option_g);
		selectHasta.appendChild(option_h);
		selectHasta.appendChild(option_i);
		} else {
		if(valorinicial==10000) {
		//Borrar los que ya estaban
		selectHasta.innerHTML='';
		//Empezar desde US$ 50,000.00
		option_a = document.createElement("option"); option_a.value="sel"; option_a.innerHTML="Seleccione";
		option_b = document.createElement("option"); option_b.value="50000"; option_b.innerHTML = "US$ 50,000.00";
		option_c = document.createElement("option"); option_c.value="100000"; option_c.innerHTML = "US$ 100,000.00";
		option_d = document.createElement("option"); option_d.value="150000"; option_d.innerHTML = "US$ 150.000,00";
		option_e = document.createElement("option"); option_e.value="200000"; option_e.innerHTML = "US$ 200,000.00";
		option_f = document.createElement("option"); option_f.value="250000"; option_f.innerHTML = "US$ 250,000.00";
		option_g = document.createElement("option"); option_g.value="500000"; option_g.innerHTML = "US$ 500.000,00";
		option_h = document.createElement("option"); option_h.value="1000000"; option_h.innerHTML = "US$ 1,000,000.00 o más";
		selectHasta.appendChild(option_a);
		selectHasta.appendChild(option_b);
		selectHasta.appendChild(option_c);
		selectHasta.appendChild(option_d);
		selectHasta.appendChild(option_e);
		selectHasta.appendChild(option_f);
		selectHasta.appendChild(option_g);
		selectHasta.appendChild(option_h);
		} else {
		if(valorinicial==50000) {
		//Borrar los que ya estaban
		selectHasta.innerHTML='';
		//Empezar desde US$ 100,000.00
		option_a = document.createElement("option"); option_a.value="sel"; option_a.innerHTML="Seleccione";
		option_b = document.createElement("option"); option_b.value="100000"; option_b.innerHTML = "US$ 100,000.00";
		option_c = document.createElement("option"); option_c.value="150000"; option_c.innerHTML = "US$ 150.000,00";
		option_d = document.createElement("option"); option_d.value="200000"; option_d.innerHTML = "US$ 200,000.00";
		option_e = document.createElement("option"); option_e.value="250000"; option_e.innerHTML = "US$ 250,000.00";
		option_f = document.createElement("option"); option_f.value="500000"; option_f.innerHTML = "US$ 500.000,00";
		option_g = document.createElement("option"); option_g.value="1000000"; option_g.innerHTML = "US$ 1,000,000.00 o más";
		selectHasta.appendChild(option_a);
		selectHasta.appendChild(option_b);
		selectHasta.appendChild(option_c);
		selectHasta.appendChild(option_d);
		selectHasta.appendChild(option_e);
		selectHasta.appendChild(option_f);
		selectHasta.appendChild(option_g);
		} else {
		if(valorinicial==100000) {
		//Borrar los que ya estaban
		selectHasta.innerHTML='';
		//Empezar desde US$ 150,000.00
		option_a = document.createElement("option"); option_a.value="sel"; option_a.innerHTML="Seleccione";
		option_b = document.createElement("option"); option_b.value="150000"; option_b.innerHTML = "US$ 150,000.00";
		option_c = document.createElement("option"); option_c.value="200000"; option_c.innerHTML = "US$ 200,000.00";
		option_d = document.createElement("option"); option_d.value="250000"; option_d.innerHTML = "US$ 250,000.00";
		option_e = document.createElement("option"); option_e.value="500000"; option_e.innerHTML = "US$ 500.000,00";
		option_f = document.createElement("option"); option_f.value="1000000"; option_f.innerHTML = "US$ 1,000,000.00 o más";
		selectHasta.appendChild(option_a);
		selectHasta.appendChild(option_b);
		selectHasta.appendChild(option_c);
		selectHasta.appendChild(option_d);
		selectHasta.appendChild(option_e);
		selectHasta.appendChild(option_f);
		} else {
		if(valorinicial==150000) {
		//Borrar los que ya estaban
		selectHasta.innerHTML='';
		//Empezar desde US$ 200,000.00
		option_a = document.createElement("option"); option_a.value="sel"; option_a.innerHTML="Seleccione";
		option_b = document.createElement("option"); option_b.value="200000"; option_b.innerHTML = "US$ 200,000.00";
		option_c = document.createElement("option"); option_c.value="250000"; option_c.innerHTML = "US$ 250,000.00";
		option_d = document.createElement("option"); option_d.value="500000"; option_d.innerHTML = "US$ 500.000,00";
		option_e = document.createElement("option"); option_e.value="1000000"; option_e.innerHTML = "US$ 1,000,000.00 o más";
		selectHasta.appendChild(option_a);
		selectHasta.appendChild(option_b);
		selectHasta.appendChild(option_c);
		selectHasta.appendChild(option_d);
		selectHasta.appendChild(option_e);
		} else {
		if(valorinicial==200000) {
		//Borrar los que ya estaban
		selectHasta.innerHTML='';
		//Empezar desde US$ 250,000.00
		option_a = document.createElement("option"); option_a.value="sel"; option_a.innerHTML="Seleccione";
		option_b = document.createElement("option"); option_b.value="250000"; option_b.innerHTML = "US$ 250,000.00";
		option_c = document.createElement("option"); option_c.value="500000"; option_c.innerHTML = "US$ 500.000,00";
		option_d = document.createElement("option"); option_d.value="1000000"; option_d.innerHTML = "US$ 1,000,000.00 o más";
		selectHasta.appendChild(option_a);
		selectHasta.appendChild(option_b);
		selectHasta.appendChild(option_c);
		selectHasta.appendChild(option_d);
		} else {
		if(valorinicial==250000) {
		//Borrar los que ya estaban
		selectHasta.innerHTML='';
		//Empezar desde US$ 500,000.00
		option_a = document.createElement("option"); option_a.value="sel"; option_a.innerHTML="Seleccione";
		option_b = document.createElement("option"); option_b.value="500000"; option_b.innerHTML = "US$ 500.000,00";
		option_c = document.createElement("option"); option_c.value="1000000"; option_c.innerHTML = "US$ 1,000,000.00 o más";
		selectHasta.appendChild(option_a);
		selectHasta.appendChild(option_b);
		selectHasta.appendChild(option_c);
		} else {
		if(valorinicial==500000) {
		//Borrar los que ya estaban
		selectHasta.innerHTML='';
		//Empezar desde US$ 1,000,000.00
		option_a = document.createElement("option"); option_a.value="sel"; option_a.innerHTML="Seleccione";
		option_b = document.createElement("option"); option_b.value="1000000"; option_b.innerHTML = "US$ 1,000,000.00 o más";
		selectHasta.appendChild(option_a);
		selectHasta.appendChild(option_b);
		} 
		}
		}
		}
		}
		}
		}
		}
		}
}
function ValidarSearchIndex(frm) {
	var error = false;
	var mensaje;
	var Ctrl;
	if(frm.cat_a.options[frm.cat_a.selectedIndex].value=="0") {
	error = true;
	mensaje = "Seleccione el Tipo de Inmueble";
	Ctrl = frm.cat_a;
	} else {
	if(frm.cat_c.options[frm.cat_c.selectedIndex].value=="sel") {
	error = true;
	mensaje = "Seleccione el monto Desde US$";
	Ctrl = frm.cat_c;
	} else {
	if(frm.cat_d.options[frm.cat_d.selectedIndex].value=="sel") {
	error = true;
	mensaje = "Seleccione el monto Hasta US$";
	Ctrl = frm.cat_d;
	}
	}
	}
	if(error) {
	alert(mensaje);
	Ctrl.focus();
	return false;
	} else {
		var cod = "								<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\n";
	cod = cod + "								<tr>\n";
	cod = cod + "									<td>\n";
	cod = cod + "										<table align=\"center\" border=\"0\" width=\"500px\">\n";
	cod = cod + "											<tr>\n";
	cod = cod + "												<td class=\"location\"><a href=\"index.php\">Inicio</a> > Procesando...</td>\n";
	cod = cod + "											</tr>\n";
	cod = cod + "											<tr>\n";
	cod = cod + "												<td style=\"height:90px;\">&nbsp;</td>\n";
	cod = cod + "											</tr>\n";
	cod = cod + "											<tr>\n";
	cod = cod + "												<td align=\"center\">\n";
	cod = cod + "													<div style=\"position:relative;width:420px;\">\n";
	cod = cod + "														<table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" bgcolor=\"#003366\" width=\"100%\">\n";
	cod = cod + "															<tr>\n";
	cod = cod + "																<td style=\"color:#ffffff;font-family:Segoe UI;font-size:18px;font-weight:700;padding-top:6px;padding-left:4px;padding-bottom: 6px;\">\n";
	cod = cod + "																	Ubicar Bienes Raices.com\n";
	cod = cod + "																</td>\n";
	cod = cod + "															</tr>\n";
	cod = cod + "															<tr bgcolor=\"#ffffff\">\n";
	cod = cod + "																<td align=\"center\" style=\"color:#00468c;font-family:Arial;font-size:12px;font-weight:700;margin:0;\"><br><br><br><br><br>\n";
	cod = cod + "																	<img border=\"0\" src=\"http://www.ubicarbienesraices.com/images/cargando.gif\" alt=\"Procesando...\"><br>Procesando su Búsqueda<br>Aguarde un momento por favor...<br><br><br><br><br>\n";
	cod = cod + "																	<span style=\"float:right;color:#666666;font-family:Arial;font-size:10px;font-weight:normal;margin:0;padding-right:3px;\">\n";
	cod = cod + "																		Powered by LCA\n";
	cod = cod + "																	</span>\n";
	cod = cod + "																</td>\n";
	cod = cod + "															</tr>\n";
	cod = cod + "														</table>\n";
	cod = cod + "													</div>\n";
	cod = cod + "												</td>\n";
	cod = cod + "											</tr>\n";
	cod = cod + "											<tr>\n";
	cod = cod + "												<td>&nbsp;</td>\n";
	cod = cod + "											<tr>\n";
	cod = cod + "											<tr>\n";
	cod = cod + "												<td style=\"height:180px\">&nbsp;</td>\n";
	cod = cod + "											<tr>\n";
	cod = cod + "											<tr>\n";
	cod = cod + "												<td style=\"height:180px\">&nbsp;</td>\n";
	cod = cod + "											<tr>\n";
	cod = cod + "										</table>\n";
	cod = cod + "									</td>\n";
	cod = cod + "								</tr>\n";
	cod = cod + "							</table>\n";
	document.getElementById('contenido-in').innerHTML=cod;
	document.title="Procesando Búsqueda";
	frm.btnSearch.disabled=true;
	return true;
	}
}
//FUNCION PARA ORDENAR RESULTADOS EN INMUEBLES.PHP
function ordenaranuncios(order,t,pag) {
	if(order.options[order.selectedIndex].value=="0") {
	return false;
	} else {
	window.location.href="inmuebles.php?cat="+t+"&action=mostrar&orderby="+order.options[order.selectedIndex].value+"&page="+pag;
	}
}
function verinfo(id) {
	window.open("verinmueble.php?id="+id,'info','');
}