// JavaScript Document

function llenaCeros(valor){
	longitud = valor.length;
	cadenaCeros =""
	for(i=0;i<8-longitud;i++){
		cadenaCeros =cadenaCeros + "0";
	}
	cadenaCeros =  cadenaCeros + valor;
	return cadenaCeros;
}


function encuentraObjeto(objetoId){
	var ns4 = (document.layers)? true:false;
	var ie4 = (document.all)? true:false ;
	if (ns4){
		objeto = document.layers[objetoId];
	}
	else if (ie4){
		objeto = document.all[objetoId];
	}
	else{
		objeto = document.getElementById(objetoId);
	}
	return objeto;
}

function calseTabla(div, arreglo, numCols,titulo, encabezados, datos, tabla, campos){
	this.div = div;
	this.arreglo = arreglo;
	this.numCols = numCols;
	this.titulo = titulo;
	this.encabezados = encabezados;
	this.datos = datos;
	this.tabla = tabla;
	this.campos = campos;
}

function llenaCombo(nombreDiv,nombreCombo,texto,id, tabla, condicion){
	postString = "nombreDiv=" + nombreDiv;
	postString = postString + "&nombreCombo=" + nombreCombo;
	postString = postString + "&texto=" + texto;
	postString = postString + "&id=" + id;
	postString = postString + "&tabla=" + tabla;
	postString = postString + "&condicion=" + condicion;
	makeRequest("../../procedimientos/comboBox.php", postString, despliegaCombo);
	alert(postString);
}

function llenaLista(div,nombreLista,tabla ,id, texto,  campoComparar, tipo, valor, funcion, evento, condAdicional){  
    postString = "nombreDiv=" + div;
    postString = postString + "&nombreLista=" + nombreLista;
    postString = postString + "&texto=" + texto;
    postString = postString + "&id=" + id;
    postString = postString + "&tabla=" + tabla;
    postString = postString + "&campoComparar=" + campoComparar;
    postString = postString + "&tipo=" + tipo;
    postString = postString + "&valor=" + valor;
    postString = postString + "&funcion=" + funcion; 
    postString = postString + "&evento=" + evento;
    postString = postString + "&condAdicional=" + condAdicional; 
    makeRequest("../../procedimientos/lista.php", postString, despliegaCombo)
}

function rcolonia1(estado,municipio){  
    postString = "estado=" + estado;
    postString = postString + "&municipio=" + municipio;
    makeRequest("../../procedimientos/colonia.php", postString, ajx_llenaColonia)
}

function llenaListaMain(div,nombreLista,tabla ,id, texto,  campoComparar, tipo, valor, funcion, evento, condAdicional){  
    postString = "nombreDiv=" + div;
    postString = postString + "&nombreLista=" + nombreLista;
    postString = postString + "&texto=" + texto;
    postString = postString + "&id=" + id;
    postString = postString + "&tabla=" + tabla;
    postString = postString + "&campoComparar=" + campoComparar;
    postString = postString + "&tipo=" + tipo;
    postString = postString + "&valor=" + valor;
    postString = postString + "&funcion=" + funcion; 
    postString = postString + "&evento=" + evento;
    postString = postString + "&condAdicional=" + condAdicional; 
    makeRequest("../adm/procedimientos/lista.php", postString, despliegaCombo)
}


function validaLogeo(){
	regreso = true;
	if (window.document.logeo.usuario.value==""){
		changeSpan('msgUsr','Campo Requerido');
		regreso = false;
	}
	if (window.document.logeo.contrasena.value==""){
		changeSpan('msgPwd','Campo Requerido')
		regreso = false;
	}
	if(regreso){
		postString = "usr=" + window.document.logeo.usuario.value;
		postString = postString + "&contrasena=" + window.document.logeo.contrasena.value;
		makeRequest("procedimientos/acceso.php", postString, iniciaSesion)
	}
}

function seguro()
{
	var cerrar = confirm("Esta seguro?")
	if (cerrar) 
	{
		makeRequest("procedimientos/logout.php", "a", finSesion)
	}
}


function trim(cadena)
{
	for(z=0; z<cadena.length; )
	{
		if(cadena.charAt(z)==" ")
			cadena=cadena.substring(z+1, cadena.length);
		else
			break;
	}

	for(z=cadena.length-1; z>=0; z=cadena.length-1)
	{
		if(cadena.charAt(z)==" ")
			cadena=cadena.substring(0,z);
		else
			break;
	}
	return(cadena);
}

function cambiaSig(objeto){
	obj = document.getElementById(objeto)
	obj.focus();
}


function ventana(valor){
      //alert(valor);
    if (contador ==0 ) {
       ventanas = new Window('window_id', {className: "alphacube", title:"titulo", top:20, left:20, resizable:false, destroyOnClose: false, recenterAuto:false});// Dialog.alert("Close the window 'Test' before opening it again!",{width:200, height:130}); 
       
    
    }
    switch (parseInt(valor)){
        case 0:
            alert("Debes seleccioanr una opción");
            break;
        case 1:
            ventanas.setTitle("Im&aacute;genes");
            ventanas.setURL("cargaImagen.php?idInmueble=" + encuentraObjeto("idInmueble").value);  
            ventanas.setSize(800, 175);
            break;
       
    }   
    //ventanas.setDestroyOnClose(); 
    if(parseInt(valor)!=0){
		ventanas.setZIndex(8000);
		ventanas.showCenter('overlay_modal');
	}
    contador ++; 
}

function pasadato(datopasado){
alert(datopasado); 
ventanas.close();
//contador=0;
}


function oNumero(numero)
{
	//Propiedades 
	this.valor = numero || 0
	this.dec = -1;
	//Mtodos 
	this.formato = numFormat;
	this.ponValor = ponValor;
	//Definicin de los mtodos 
	function ponValor(cad)
	{
		if (cad =='-' || cad=='+') return
		if (cad.length ==0) return
		if (cad.indexOf('.') >=0)
			this.valor = parseFloat(cad);
		else 
			this.valor = parseInt(cad);
	} 
	function numFormat(dec, miles)
	{
		var num = this.valor, signo=3, expr;
		var cad = ""+this.valor;
		var ceros = "", pos, pdec, i;
		for (i=0; i < dec; i++)
		ceros += '0';
		pos = cad.indexOf('.')
		if (pos < 0)
			cad = cad+"."+ceros;
		else
			{
			pdec = cad.length - pos -1;
			if (pdec <= dec)
				{
				for (i=0; i< (dec-pdec); i++)
					cad += '0';
				}
			else
				{
				num = num*Math.pow(10, dec);
				num = Math.round(num);
				num = num/Math.pow(10, dec);
				cad = new String(num);
				}
			}
		pos = cad.indexOf('.')
		if (pos < 0) pos = cad.lentgh
		if (cad.substr(0,1)=='-' || cad.substr(0,1) == '+') 
			   signo = 4;
		if (miles && pos > signo)
			do{
				expr = /([+-]?\d)(\d{3}[\.\,]\d*)/
				cad.match(expr)
				cad=cad.replace(expr, RegExp.$1+','+RegExp.$2)
				}
		while (cad.indexOf(',') > signo)
			if (dec<0) cad = cad.replace(/\./,'')
				return cad;
	}
}//Fin del objeto oNumero:



/****** fumciones arq  *****/
function buscaMunicipio(valor){
	if(valor!=0){
		llenaLista('div_idMunicipio','idMunicipio','abr_municipio' ,'idMunicipio', 'nombreMunicipio', 'idEstado', '=',valor,'buscaColonia(this.value)','onclick','');
		//alert(valor)
	}
}

function buscaColonia(valor){
	if(valor!=0){
		objTmp = encuentraObjeto('idEstado');
        
		rcolonia1(objTmp.options[objTmp.selectedIndex].value,valor)
		
		
		//alert(valor)
	}
}

function buscaTipoInm(valor){
	if(valor!=0){
		llenaLista('div_idTipoInmueble','idTipoInmueble','abr_tipoinmueble' ,'idTipoInmueble', 'descripcionTipoInmueble', 'idUsoInmueble', '=',valor,'','','');
		//alert(valor)
	}
}


function buscaTipoInmMain(valor){
	if(valor!=0){
		llenaListaMain('div_idTipoInmueble','idTipoInmueble','abr_tipoinmueble' ,'idTipoInmueble', 'descripcionTipoInmueble', 'idUsoInmueble', '=',valor,'','','');
		//alert(valor)
	}
}

function busqueda(){
		objTmp = encuentraObjeto('idEstado');
        postString = "pagina=1&idEstado=" + objTmp.options[objTmp.selectedIndex].value; 
		objTmp = encuentraObjeto('idUsoInmueble');
        postString = postString + "&idUsoInmueble=" + objTmp.options[objTmp.selectedIndex].value;
		objTmp = encuentraObjeto('idTipoInmueble');
        postString = postString + "&idTipoInmueble=" + objTmp.options[objTmp.selectedIndex].value;
		objTmp = encuentraObjeto('idTipoVenta');
        postString = postString + "&idTipoVenta=" + objTmp.options[objTmp.selectedIndex].value;
		self.location.href = "busqueda.php?" + postString;
}

function cambiaPagina(html,pagina){
		postString = "pagina=" + pagina + "&idEstado=" + estado; 
        postString = postString + "&idUsoInmueble=" + uso;
        postString = postString + "&idTipoInmueble=" + tipo;
        postString = postString + "&idTipoVenta=" + venta;
		self.location.href = html + "?" + postString;
}

function cambiaPaginaProp(html,pagina){
		postString = "pagina=" + pagina ;
		self.location.href = html + "?" + postString;
}

function detalles(id){
		postString = "idInmueble=" + id;
		self.location.href = "detalles.php?" + postString;
}

function altaInmueble(){
	self.location.href="propiedadesAlta.php"
}

function muestraObjetos(tipo){
	switch(parseInt(tipo)){
		
		case 0:
		    encuentraObjeto("btn_grabar").disabled = "disabled";
			encuentraObjeto("rng_idUsoInmueble").style.display="inline";
			encuentraObjeto("rng_idTipoInmueble").style.display="inline";
			encuentraObjeto("rng_idTipoVenta").style.display="inline";
			encuentraObjeto("rng_idColonia").style.display="inline";
			encuentraObjeto("rng_idMunicipio").style.display="inline";
			encuentraObjeto("rng_idEstado").style.display="inline";
			encuentraObjeto("rng_esDesarrolloInmueble").style.display="inline";
			encuentraObjeto("rng_m2TerrenoInmueble").style.display="none";
			encuentraObjeto("rng_m2ConstInmueble").style.display="none";
			encuentraObjeto("rng_recamarasInmueble").style.display="none";
			encuentraObjeto("rng_estudioInmueble").style.display="none";
			encuentraObjeto("rng_salaTvInmueble").style.display="none";
			encuentraObjeto("rng_baniosCompInmueble").style.display="none";
			encuentraObjeto("rng_medioBaniosInmueble").style.display="none";
			encuentraObjeto("rng_cuartosServicioInmueble").style.display="none";
			encuentraObjeto("rng_estacionamientoInmueble").style.display="none";
			encuentraObjeto("rng_patioServicioInmueble").style.display="none";
			encuentraObjeto("rng_m2JardinInmueble").style.display="none";
			encuentraObjeto("rng_albercaInmueble").style.display="none";
			encuentraObjeto("rng_cuartoLavadoInmueble").style.display="none";
			encuentraObjeto("rng_areaLavadoInmueble").style.display='none';
			encuentraObjeto("rng_roofInmueble").style.display="none";
			encuentraObjeto("rng_comunesInmueble").style.display="none";
			encuentraObjeto("rng_calidadAcabadosInmueble").style.display="none";
			encuentraObjeto("rng_calidadProyectoInmueble").style.display="none";
			encuentraObjeto("rng_conservacionInmueble").style.display="none";
			encuentraObjeto("rng_ubicacionInmueble").style.display="none";
			encuentraObjeto("rng_otrasCaracterInmueble").style.display="none";
			encuentraObjeto("rng_edadInmueble").style.display="none";
			encuentraObjeto("rng_oficinasInmueble").style.display="none";
			encuentraObjeto("rng_recepcionInmueble").style.display="none";
			encuentraObjeto("rng_salaJuntasInmueble").style.display="none";
			encuentraObjeto("rng_cocinetaInmueble").style.display="none";
			encuentraObjeto("rng_elevadorInmueble").style.display="none";
			encuentraObjeto("rng_bodegaInmueble").style.display="none";
			encuentraObjeto("rng_lineaTelInmueble").style.display="none";
			encuentraObjeto("rng_nivelInmueble").style.display="none";
			encuentraObjeto("rng_usoSueloInmueble").style.display="none";
			encuentraObjeto("rng_tallerInmueble").style.display="none";
			encuentraObjeto("rng_patioManiobrasInmueble").style.display="none";
			encuentraObjeto("rng_precioInmueble").style.display="none";
			encuentraObjeto("rng_esPrincipalInmueble").style.display="inline";
			encuentraObjeto("rng_naveInmueble").style.display="none";
			break;
		case 1://residencial
		    encuentraObjeto("btn_grabar").disabled = false;
			encuentraObjeto("rng_idUsoInmueble").style.display="inline";
			encuentraObjeto("rng_idTipoInmueble").style.display="inline";
			encuentraObjeto("rng_idTipoVenta").style.display="inline";
			encuentraObjeto("rng_idColonia").style.display="inline";
			encuentraObjeto("rng_idMunicipio").style.display="inline";
			encuentraObjeto("rng_idEstado").style.display="inline";
			encuentraObjeto("rng_esDesarrolloInmueble").style.display="inline";
			encuentraObjeto("rng_m2TerrenoInmueble").style.display="inline";
			encuentraObjeto("rng_m2ConstInmueble").style.display="inline";
			encuentraObjeto("rng_recamarasInmueble").style.display="inline";
			encuentraObjeto("rng_estudioInmueble").style.display="inline";
			encuentraObjeto("rng_salaTvInmueble").style.display="inline";
			encuentraObjeto("rng_baniosCompInmueble").style.display="inline";
			encuentraObjeto("rng_medioBaniosInmueble").style.display="inline";
			encuentraObjeto("rng_cuartosServicioInmueble").style.display="inline";
			encuentraObjeto("rng_estacionamientoInmueble").style.display="inline";
			encuentraObjeto("rng_patioServicioInmueble").style.display="inline";
			encuentraObjeto("rng_m2JardinInmueble").style.display="inline";
			encuentraObjeto("rng_albercaInmueble").style.display="inline";
			encuentraObjeto("rng_cuartoLavadoInmueble").style.display="inline";
			encuentraObjeto("rng_areaLavadoInmueble").style.display="inline";
			encuentraObjeto("rng_roofInmueble").style.display="inline";
			encuentraObjeto("rng_comunesInmueble").style.display="inline";
			encuentraObjeto("rng_calidadAcabadosInmueble").style.display="inline";
			encuentraObjeto("rng_calidadProyectoInmueble").style.display="inline";
			encuentraObjeto("rng_conservacionInmueble").style.display="inline";
			encuentraObjeto("rng_ubicacionInmueble").style.display="inline";
			encuentraObjeto("rng_otrasCaracterInmueble").style.display="inline";
			encuentraObjeto("rng_edadInmueble").style.display="inline";
			encuentraObjeto("rng_oficinasInmueble").style.display="none";
			encuentraObjeto("rng_recepcionInmueble").style.display="none";
			encuentraObjeto("rng_salaJuntasInmueble").style.display="none";
			encuentraObjeto("rng_cocinetaInmueble").style.display="none";
			encuentraObjeto("rng_elevadorInmueble").style.display="none";
			encuentraObjeto("rng_bodegaInmueble").style.display="none";
			encuentraObjeto("rng_lineaTelInmueble").style.display="none";
			encuentraObjeto("rng_nivelInmueble").style.display="none";
			encuentraObjeto("rng_usoSueloInmueble").style.display="none";
			encuentraObjeto("rng_tallerInmueble").style.display="none";
			encuentraObjeto("rng_patioManiobrasInmueble").style.display="none";
			encuentraObjeto("rng_precioInmueble").style.display="inline";
			encuentraObjeto("rng_esPrincipalInmueble").style.display="inline";
			encuentraObjeto("rng_naveInmueble").style.display="none";
			break;
		case 2: //Comercial
		    encuentraObjeto("btn_grabar").disabled = false;
			encuentraObjeto("rng_esDesarrolloInmueble").style.display="inline";
			encuentraObjeto("rng_m2TerrenoInmueble").style.display="inline";
			encuentraObjeto("rng_m2ConstInmueble").style.display="inline";
			encuentraObjeto("rng_recamarasInmueble").style.display="none";
			encuentraObjeto("rng_estudioInmueble").style.display="none";
			encuentraObjeto("rng_salaTvInmueble").style.display="none";
			encuentraObjeto("rng_baniosCompInmueble").style.display="none";
			encuentraObjeto("rng_medioBaniosInmueble").style.display="inline";
			encuentraObjeto("rng_cuartosServicioInmueble").style.display="none";
			encuentraObjeto("rng_estacionamientoInmueble").style.display="inline";
			encuentraObjeto("rng_patioServicioInmueble").style.display="none";
			encuentraObjeto("rng_m2JardinInmueble").style.display="none";
			encuentraObjeto("rng_roofInmueble").style.display="none";
			encuentraObjeto("rng_albercaInmueble").style.display="none";
			encuentraObjeto("rng_cuartoLavadoInmueble").style.display="none";
			encuentraObjeto("rng_areaLavadoInmueble").style.display="none";
			encuentraObjeto("rng_comunesInmueble").style.display="none";
			encuentraObjeto("rng_calidadAcabadosInmueble").style.display="none";
			encuentraObjeto("rng_calidadProyectoInmueble").style.display="none";
			encuentraObjeto("rng_conservacionInmueble").style.display="inline";
			encuentraObjeto("rng_ubicacionInmueble").style.display="inline";
			encuentraObjeto("rng_otrasCaracterInmueble").style.display="inline";
			encuentraObjeto("rng_edadInmueble").style.display="inline";
			encuentraObjeto("rng_oficinasInmueble").style.display="inline";
			encuentraObjeto("rng_recepcionInmueble").style.display="inline";
			encuentraObjeto("rng_salaJuntasInmueble").style.display="inline";
			encuentraObjeto("rng_cocinetaInmueble").style.display="inline";
			encuentraObjeto("rng_elevadorInmueble").style.display="inline";
			encuentraObjeto("rng_bodegaInmueble").style.display="inline";
			encuentraObjeto("rng_lineaTelInmueble").style.display="inline";
			encuentraObjeto("rng_nivelInmueble").style.display="inline";
			encuentraObjeto("rng_usoSueloInmueble").style.display="inline";
			encuentraObjeto("rng_tallerInmueble").style.display="none";
			encuentraObjeto("rng_patioManiobrasInmueble").style.display="none";
			encuentraObjeto("rng_precioInmueble").style.display="inline";
			encuentraObjeto("rng_esPrincipalInmueble").style.display="inline";
			encuentraObjeto("rng_naveInmueble").style.display="none";
			break;
		case 3: //Industrial
		    encuentraObjeto("btn_grabar").disabled = false;
			encuentraObjeto("rng_esDesarrolloInmueble").style.display="inline";
			encuentraObjeto("rng_m2TerrenoInmueble").style.display="inline";
			encuentraObjeto("rng_m2ConstInmueble").style.display="inline";
			encuentraObjeto("rng_recamarasInmueble").style.display="none";
			encuentraObjeto("rng_estudioInmueble").style.display="none";
			encuentraObjeto("rng_salaTvInmueble").style.display="none";
			encuentraObjeto("rng_baniosCompInmueble").style.display="none";
			encuentraObjeto("rng_medioBaniosInmueble").style.display="inline";
			encuentraObjeto("rng_cuartosServicioInmueble").style.display="none";
			encuentraObjeto("rng_estacionamientoInmueble").style.display="inline";
			encuentraObjeto("rng_patioServicioInmueble").style.display="none";
			encuentraObjeto("rng_m2JardinInmueble").style.display="none";
			encuentraObjeto("rng_albercaInmueble").style.display="none";
			encuentraObjeto("rng_cuartoLavadoInmueble").style.display="none";
			encuentraObjeto("rng_areaLavadoInmueble").style.display="none";
			encuentraObjeto("rng_roofInmueble").style.display="none";
			encuentraObjeto("rng_comunesInmueble").style.display="none";
			encuentraObjeto("rng_calidadAcabadosInmueble").style.display="none";
			encuentraObjeto("rng_calidadProyectoInmueble").style.display="none";
			encuentraObjeto("rng_conservacionInmueble").style.display="inline";
			encuentraObjeto("rng_ubicacionInmueble").style.display="inline";
			encuentraObjeto("rng_otrasCaracterInmueble").style.display="inline";
			encuentraObjeto("rng_edadInmueble").style.display="inline";
			encuentraObjeto("rng_oficinasInmueble").style.display="inline";
			encuentraObjeto("rng_recepcionInmueble").style.display="inline";
			encuentraObjeto("rng_salaJuntasInmueble").style.display="inline";
			encuentraObjeto("rng_cocinetaInmueble").style.display="none";
			encuentraObjeto("rng_elevadorInmueble").style.display="none";
			encuentraObjeto("rng_bodegaInmueble").style.display="inline";
			encuentraObjeto("rng_lineaTelInmueble").style.display="none";
			encuentraObjeto("rng_nivelInmueble").style.display="none";
			encuentraObjeto("rng_usoSueloInmueble").style.display="inline";
			encuentraObjeto("rng_tallerInmueble").style.display="inline";
			encuentraObjeto("rng_patioManiobrasInmueble").style.display="inline";
			encuentraObjeto("rng_precioInmueble").style.display="inline";
			encuentraObjeto("rng_esPrincipalInmueble").style.display="inline";
			encuentraObjeto("rng_naveInmueble").style.display="inline";
			break;
	}
}

function grabaInmueble(tipo){
	postString="";
	objTmp1 = encuentraObjeto("idUsoInmueble");
	objTmp2 = encuentraObjeto("idTipoInmueble");
	objTmp3 = encuentraObjeto("idTipoVenta");
	objTmp4 = encuentraObjeto("idEstado");
	objTmp5 = encuentraObjeto("idMunicipio");
	if(parseInt(objTmp1[objTmp1.selectedIndex].value) <=0){
		alert("Debe seleccionar una opcion en el campo \"Uso Inmueble\" ");
		objTmp1.focus();
	}
	else if(parseInt(objTmp2[objTmp2.selectedIndex].value) <=0){
		alert("Debe seleccionar una opcion en el campo \"Tipo Inmueble\" ");
		objTmp2.focus();
	} 
	else if(parseInt(objTmp3[objTmp3.selectedIndex].value) <=0){
		alert("Debe seleccionar una opcion en el campo \"Vender o Rentar\" ");
		objTmp3.focus();
	}
	else if(parseInt(objTmp4[objTmp4.selectedIndex].value) <=0){
		alert("Debe seleccionar una opcion en el campo \"Estado\" ");
		objTmp4.focus();
	}
	else if(parseInt(objTmp5[objTmp5.selectedIndex].value) <=0){
		alert("Debe seleccionar una opcion en el campo \"Municipio\" ");
		objTmp5.focus();
	}
	else if(trim(encuentraObjeto("coloniaInmueble").value)==""){
		alert("Debe ingresar un dato en el  campo \"Colonia\" ");
		encuentraObjeto("coloniaInmueble").focus();
	}
	else if(trim(encuentraObjeto("precioInmueble").value)==""){
		alert("Debe  ingresar un valor en el campo \"Precio\" ");
		encuentraObjeto("precioInmueble").focus();
	}
	else{
		postString = postString + "idUsoInmueble=" + objTmp1[objTmp1.selectedIndex].value ;
		postString = postString + "&idTipoInmueble=" + objTmp2[objTmp2.selectedIndex].value ;
		postString = postString + "&idTipoVenta=" + objTmp3[objTmp3.selectedIndex].value ;
		postString = postString + "&idEstado=" + objTmp4[objTmp4.selectedIndex].value ;
		postString = postString + "&idMunicipio=" + objTmp5[objTmp5.selectedIndex].value ;
		postString = postString + "&idColonia=" + encuentraObjeto("idColonia").value ;
		postString = postString + "&precioInmueble=" + encuentraObjeto("precioInmueble").value;
		postString = postString + "&esDesarrolloInmueble=" + (encuentraObjeto("esDesarrolloInmueble").checked?encuentraObjeto("esDesarrolloInmueble").value:"0");
		postString = postString + "&m2TerrenoInmueble=" + encuentraObjeto("m2TerrenoInmueble").value;
		postString = postString + "&m2ConstInmueble=" + encuentraObjeto("m2ConstInmueble").value;
		postString = postString + "&recamarasInmueble=" + encuentraObjeto("recamarasInmueble").value;
		postString = postString + "&estudioInmueble=" + encuentraObjeto("estudioInmueble").value;
		postString = postString + "&salaTvInmueble=" + encuentraObjeto("salaTvInmueble").value;
		postString = postString + "&baniosCompInmueble=" + encuentraObjeto("baniosCompInmueble").value;
		postString = postString + "&medioBaniosInmueble=" + encuentraObjeto("medioBaniosInmueble").value;
		postString = postString + "&cuartosServicioInmueble=" + encuentraObjeto("cuartosServicioInmueble").value;
		postString = postString + "&estacionamientoInmueble=" + encuentraObjeto("estacionamientoInmueble").value;
		postString = postString + "&patioServicioInmueble=" + encuentraObjeto("patioServicioInmueble").value;
		postString = postString + "&m2JardinInmueble=" + encuentraObjeto("m2JardinInmueble").value;
		postString = postString + "&albercaInmueble=" + (encuentraObjeto("albercaInmueble").checked?encuentraObjeto("albercaInmueble").value:"0");
		postString = postString + "&cuartoLavadoInmueble=" + (encuentraObjeto("cuartoLavadoInmueble").checked?encuentraObjeto("cuartoLavadoInmueble").value:"0");
		postString = postString + "&areaLavadoInmueble=" + (encuentraObjeto("areaLavadoInmueble").checked?encuentraObjeto("areaLavadoInmueble").value:"0");
		postString = postString + "&roofInmueble=" + (encuentraObjeto("roofInmueble").checked?encuentraObjeto("roofInmueble").value:"0");
		postString = postString + "&comunesInmueble=" + (encuentraObjeto("comunesInmueble").checked?encuentraObjeto("comunesInmueble").value:"0");
		objTmp = encuentraObjeto("calidadAcabadosInmueble");
		postString = postString + "&calidadAcabadosInmueble=" + objTmp[objTmp.selectedIndex].value;
		objTmp = encuentraObjeto("calidadProyectoInmueble");
		postString = postString + "&calidadProyectoInmueble=" + objTmp[objTmp.selectedIndex].value;
		objTmp = encuentraObjeto("conservacionInmueble");
		postString = postString + "&conservacionInmueble=" + objTmp[objTmp.selectedIndex].value;
		objTmp = encuentraObjeto("ubicacionInmueble");
		postString = postString + "&ubicacionInmueble=" + objTmp[objTmp.selectedIndex].value;
		postString = postString + "&otrasCaracterInmueble=" + encuentraObjeto("otrasCaracterInmueble").value;
		postString = postString + "&edadInmueble=" + encuentraObjeto("edadInmueble").value;
		postString = postString + "&oficinasInmueble=" + encuentraObjeto("oficinasInmueble").value;
		postString = postString + "&recepcionInmueble=" + encuentraObjeto("recepcionInmueble").value;
		postString = postString + "&salaJuntasInmueble=" + encuentraObjeto("salaJuntasInmueble").value;
		postString = postString + "&cocinetaInmueble=" + encuentraObjeto("cocinetaInmueble").value;
		postString = postString + "&elevadorInmueble=" + encuentraObjeto("elevadorInmueble").value;
		postString = postString + "&bodegaInmueble=" + encuentraObjeto("bodegaInmueble").value;
		postString = postString + "&lineaTelInmueble=" + encuentraObjeto("lineaTelInmueble").value;
		postString = postString + "&nivelInmueble=" + encuentraObjeto("nivelInmueble").value;
		objTmp = encuentraObjeto("usoSueloInmueble");
		postString = postString + "&usoSueloInmueble=" + objTmp[objTmp.selectedIndex].value;
		postString = postString + "&tallerInmueble=" + encuentraObjeto("tallerInmueble").value;
		postString = postString + "&patioManiobrasInmueble=" + encuentraObjeto("patioManiobrasInmueble").value;
		postString = postString + "&esPrincipalInmueble=" + (encuentraObjeto("esPrincipalInmueble").checked?encuentraObjeto("esPrincipalInmueble").value:"0");
		postString = postString + "&naveInmueble=" + encuentraObjeto("naveInmueble").value;
		postString = postString + "&coloniaInmueble=" + encuentraObjeto("coloniaInmueble").value;
		//alert(postString);
		
		if(tipo==1){
			makeRequest("../../procedimientos/grabaInmueble.php", postString, ajx_finGrabarInmueble);
		}
		else{
			postString = postString + "&idInmueble=" + encuentraObjeto("idInmueble").value;
			makeRequest("../../procedimientos/grabaInmuebleEdicion.php", postString, ajx_finGrabarInmuebleEdc);
		}

	}
}
function imagenes(id){
	self.location="imagenes.php?idInmueble="+ id ;
}

function eliminaImg(id,inmueble){
	if(confirm("La imagen se eliminara por completo de la base de datos")){
		postString = "";
		postString = postString + "idFotos=" + id;
		postString = postString + "&idInmueble=" + inmueble;
		makeRequest("../../procedimientos/eliminaFoto.php", postString, ajx_finEliminaFoto);
	}
}

function edita(id){
	self.location="propiedadesEdicion.php?idInmueble="+ id ;
}

function eliminaInmueble(id){
	if(confirm("El inmueble se eliminara por completo de la base de datos")){
		postString = "";
		postString = postString + "idInmueble=" + id;
		makeRequest("../../procedimientos/eliminaInmueble.php", postString, ajx_finEliminaInmueble);
	}
}

function asigna(estado, valor,inmueble){
	postString = "";
	postString = postString + "idFotos=" + valor;
	postString = postString + "&idInmueble=" + inmueble;
	makeRequest("../../procedimientos/asignaPrincipal.php", postString, ajx_asignaPrincipal);
}

function muestraDetalleTipo(tipo){
	switch(tipo){
		case 1:
			encuentraObjeto("basRes").style.display="inline";
			encuentraObjeto("basCom").style.display="none";
			encuentraObjeto("basInd").style.display="none";
			encuentraObjeto("otrosRes").style.display="inline";
			encuentraObjeto("otrosCom").style.display="none";
			encuentraObjeto("otrosInd").style.display="none";
			break;
		case 2:
			encuentraObjeto("basRes").style.display="none";
			encuentraObjeto("basCom").style.display="inline";
			encuentraObjeto("basInd").style.display="none";
			encuentraObjeto("otrosRes").style.display="none";
			encuentraObjeto("otrosCom").style.display="inline";
			encuentraObjeto("otrosInd").style.display="none";
			break;
		case 3:
			encuentraObjeto("basRes").style.display="none";
			encuentraObjeto("basCom").style.display="none";
			encuentraObjeto("basInd").style.display="inline";
			encuentraObjeto("otrosRes").style.display="none";
			encuentraObjeto("otrosCom").style.display="none";
			encuentraObjeto("otrosInd").style.display="inline";
			break;
	}
}


function abreFoto(url){
	ventana = window.open(url, "vista","top=0,left =0; width=800, height = 600");
	ventana.focus();
}
