// JavaScript Document

var postDataGlobal;

function enviaExitoso(){

	//ok form	

	//alert("pasa el form");

}



function regresoExitoso(){

	//alert("Ligggto");

	 var idSector = "";

     var tabla="barrio";

    // getContentPag("datosBarrio","busqra/datos_sector.php","idSector="+idSector+"&tabla="+tabla);

}



function regresoError(){

	alert("Error");

}



function validaCedula(){

	var nripro = document.getElementById("numid").value;

	var tipoid = document.getElementById("tipoid").value;
	//alert(tipoid);

	    if (nripro==""){

			alert("Ingrese el Campo Numero ID.");

			document.DateForm.numid.focus();

			return false;

		}

		if(isNaN(nripro)){

		    alert("El Numero ID no es un Numero, borre los caracteres especiales o letras.");

			document.DateForm.numid.focus();

			return false;

		}

getContentPag("datosPropietario","datosPropietario.php","numid="+nripro+"&tipoid="+tipoid);

}



function validarAddInmueble(){

	

	if(document.getElementById("numid").value==""){

		alert ("Ingrese su Numero de Identidad");

		document.DateForm.numid.focus(); return false;

	}

	if(document.getElementById("nomape").value==""){

		alert ("Ingrese su Nombre Completo");

		document.DateForm.nomape.focus(); return false;

	}

	if((document.getElementById("tele").value=="") && (document.DateForm.cel.value=="")){

		alert ("Ingrese el Numero de Telefono");

		document.DateForm.tele.focus(); return false;

	}

	if(document.getElementById("email").value==""){ 

	    alert ("Ingrese el E-mail");	

		document.DateForm.email.focus(); return false;

	}

	if(document.getElementById("diresi").value==""){

		alert ("Ingrese la Direccion del propietario");

		document.DateForm.diresi.focus(); return false;

	}

	/////////////////////////

	if(document.DateForm.tipomueble.value==""){ 

	   alert ("Seleccione el tipo de inmueble");

	   document.DateForm.tipomueble.focus(); return false;

	}

	if(document.DateForm.paisinm.value==""){ 

	   alert ("Ingrese el Pais");	

	   document.DateForm.paisinm.focus(); return false;

	}

	if(document.DateForm.dptoinm.value==""){ 

	   alert ("Ingrese el Departamento");	

	   document.DateForm.dptoinm.focus(); return false;

	}

	if(document.DateForm.ciudadinm.value==""){

		alert ("Ingrese la Ciudad");	

		document.DateForm.ciudadinm.focus(); return false;

	}

	if(document.DateForm.dirinmueble.value==""){

		alert ("Ingrese la Direccion del inmueble");	

		document.DateForm.dirinmueble.focus(); return false;

	}

	if(document.DateForm.areacons.value==""){ 

	    alert ("Ingrese el Area Construida.");	

		document.DateForm.areacons.focus(); return false;

	}

	if((document.DateForm.arealote.value=="") && (document.DateForm.tipomueble.value!="Apartamento")){ 

		alert ("Ingrese el Area Lote");	

		document.DateForm.arealote.focus(); return false;

	}

	if((document.DateForm.fondo.value=="") && (document.DateForm.tipomueble.value!="Apartamento")){ 

		alert ("Ingrese el Area Fondo");	

		document.DateForm.fondo.focus(); return false;

	}

	if((document.DateForm.frente.value=="") && (document.DateForm.tipomueble.value!="Apartamento")){ 

		alert ("Ingrese el Area Frente");	

		document.DateForm.frente.focus(); return false;

	}

	if(document.DateForm.estracto.value==""){ 

		alert ("Ingrese el estrato de la vivienda");	

		document.DateForm.estracto.focus(); return false;

	}

	if(document.getElementById("ciudades").value=="0"){ 

		alert ("Seleccione la ciudad");	

		document.getElementById("ciudades").focus(); return false;

	}

	if(document.getElementById("sectores").value=="0"){ 

		alert ("Seleccione el sector");	

		document.getElementById("sectores").focus(); return false;

	}

	if(document.getElementById("barrios").value=="0"){ 

		alert ("Seleccione el barrio");	

		document.getElementById("barrios").focus(); return false;

	}

	if((document.DateForm.arriendo.checked) && (document.DateForm.varriendo.value=="" || document.DateForm.varriendo.value == 0)){

		alert ("Por favor ingrese el valor del Arriendo");	

		document.DateForm.varriendo.focus(); return false;

	}

	if((document.DateForm.venta.checked) && (document.DateForm.vventa.value=="" || document.DateForm.vventa.value==0)){

		alert ("Por favor ingrese el valor de la Venta");	

		document.DateForm.vventa.focus(); return false;

	}

	if((document.DateForm.temporada.checked) && (document.DateForm.vtemporada.value=="" || document.DateForm.vtemporada.value == 0)){ 

		alert ("Por favor ingrese el valor del arriendo por Temporada");	

		document.DateForm.vtemporada.focus(); return false; 

	}

	if(document.DateForm.caracte.value==""){ 

		alert ("Ingrese la Caracteristica del Inmueble");	

		document.DateForm.caracte.focus(); return false; 

	}

	if((document.DateForm.alcoba.value=="") && (document.DateForm.tipomueble.value!="Local" || document.DateForm.tipomueble.value!="Bodega" || document.DateForm.tipomueble.value!="Parqueadero")){ 

		alert ("Ingrese la Cantidad de Cuartos");	

		document.DateForm.alcoba.focus(); return false; 

	}

	if(document.getElementById("banos").value==""){ 

		alert ("Ingrese la Cantidad de Banos");	

		document.getElementById("banos").focus(); return false; 

	}

	if(document.DateForm.ubicallave.value==""){ 

		alert ("Ingrese la Ubicación de la llave");	

		document.DateForm.ubicallave.focus(); return false; 

	}else{

		document.DateForm.Pexpeid.value=document.getElementById("expeid").value;

		document.DateForm.Pnomape.value=document.getElementById("nomape").value;

		document.DateForm.Ptele.value=document.getElementById("tele").value;

		document.DateForm.Pcel.value=document.getElementById("cel").value;

		document.DateForm.Pemail.value=document.getElementById("email").value;

		document.DateForm.Ppais.value=document.getElementById("pais").value;

		document.DateForm.Pdpto.value=document.getElementById("dpto").value;

		document.DateForm.Pciudad.value=document.getElementById("ciudad").value;

		document.DateForm.Pdiresi.value=document.getElementById("diresi").value;

		document.DateForm.Pdirofi.value=document.getElementById("dirofi").value;

		document.DateForm.Ptelofi.value=document.getElementById("telofi").value;

		document.DateForm.Pdirenvi.value=document.getElementById("direnvi").value;

		document.DateForm.Bciudades.value=document.getElementById("ciudades").value;

		document.DateForm.Bsectores.value=document.getElementById("sectores").value;

		document.DateForm.Bbarrios.value=document.getElementById("barrios").value;

		document.DateForm.submit();

	}
}



function cargaContenido(){

 var idCiudad = document.getElementById("ciudades").value;
//alert(idCiudad);
 if(idCiudad==""){ 

 idCiudad=document.conavan.ciudades.value;

 }

 var tabla="sector";

 getContentPag("datosSector","busqra/datos_sector.php","idCiudad="+idCiudad+"&tabla="+tabla);

}



function cargaBarrios(){

 var idSector = document.getElementById("sectores").value;

 if(idSector==""){ 

 idSector=document.conavan.sectores.value;

 }

 var tabla="barrio";

 getContentPag("datosBarrio","busqra/datos_sector.php","idSector="+idSector+"&tabla="+tabla);

}




function getContentPag(divHtml,linkCompleto,parametros){

	var actualizaStatus = false;

	totalCampos = 3;

	var postData = parametros;

		new Ajax.Updater(divHtml,linkCompleto,{ method:'post' , parameters: postData , onComplete: regresoExitoso, onFailure: regresoError});

}
