// JavaScript Document
function valida_email(valor){
	var objRegExp =/(^[(a-z|0-9)]([(a-z|0_9)_\.]*)@([[a-z|0-9]_\.]*)([.][(a-z|0-9)]{3})$)|(^[(a-z|0-9)]([(a-z|0-9)_\.]*)@([(a-z|0-9)_\.]*)(\.[(a-z|0-9)]{3})(\.[(a-z|0-9)]{2})*$)/i;
	return objRegExp.test(valor); 
	
}

function pregunta(id,form){
	if (!confirm("¿Seguro que deseas continuar?")){
	return;
	}
	else{
		var formulario=document.getElementById(form);
		formulario.action=toString(FAjax('../secciones/usuarios/eliminarusuario.php','campos','listusu='+id+'&envelim='+document.getElementById('envelim').value,'post'));
		
		formulario.submit();
	}
}

function pregunta_prov(id,form){
	if (!confirm("¿Seguro que deseas continuar?")){
	return;
	}
	else{
		var formulario=document.getElementById(form);
		formulario.action=toString(FAjax('../secciones/provincias/eliminarprovincia.php','campos2','listusu='+id+'&envelim='+document.getElementById('envelim').value,'post'));
		
		formulario.submit();
	}
}

function pregunta_inmueble(id,form){
	if (!confirm("¿Seguro que deseas continuar?")){
	return;
	}
	else{
		var formulario=document.getElementById(form);
		formulario.action=toString(FAjax('../secciones/inmuebles/eliminarinmueble.php','divInmueble','listusu='+id+'&envelim='+document.getElementById('envelim').value,'post'));
		
		formulario.submit();
	}
}

function pregunta_tCons(id,form){
	if (!confirm("¿Seguro que deseas continuar?")){
	return;
	}
	else{
		var formulario=document.getElementById(form);
		formulario.action=toString(FAjax('../secciones/tipos/tipo_construccion/delT_construccion.php','divTipConstruc','listusu='+id+'&envelim='+document.getElementById('envelim').value,'post'));		
		formulario.submit();
	}
}

function pregunta_tInmu(id,form){
	if (!confirm("¿Seguro que deseas continuar?")){
	return;
	}
	else{
		var formulario=document.getElementById(form);
		formulario.action=toString(FAjax('../secciones/tipos/tipo_inmueble/delT_Inmueble.php','divTipInmueble','listusu='+id+'&envelim='+document.getElementById('envelim').value,'post'));
		
		formulario.submit();
	}
}

function pregunta_pob(id,form){
	if (!confirm("¿Seguro que deseas continuar?")){
	return;
	}
	else{
		var formulario=document.getElementById(form);
		formulario.action=toString(FAjax('../secciones/provincias/poblaciones/eliminarpoblacion.php','campos2','listusu='+id+'&envelim='+document.getElementById('envelim').value,'post'));		
		formulario.submit();
	}
}

function pregunta_zona(id,form){
	if (!confirm("¿Seguro que deseas continuar?")){
	return;
	}
	else{
		var formulario=document.getElementById(form);
		formulario.action=toString(FAjax('../secciones/provincias/poblaciones/Zonas/eliminarzona.php','campos2','listusu='+id+'&envelim='+document.getElementById('envelim').value,'post'));		
		formulario.submit();
	}
}

function pregunta_investigador(id,form){
	if (!confirm("¿Seguro que deseas continuar?")){
	return;
	}
	else{
		var formulario=document.getElementById(form);
		formulario.action=toString(FAjax('./secciones/investigacion/investigadores/eliminar_investigador.php','cont_investigadores','listinv='+id+'&envelim='+document.getElementById('envelim').value,'post'));		
		formulario.submit();
	}
}

function habilitar(nombre){
	//habilita caja de texto
	document.getElementById(nombre).disabled=false;
}

function habiliatLstTInmueble()
{
	habilitar('lstTInmueble');
}

function habiliatLstTConstruc()
{
	habilitar('lstTConstruc');
}

function habiliatLstProvincia()
{
	habilitar('lstProvincia');
}

function habiliatLstPoblacion()
{
	habilitar('lstPoblacion');
}

function habiliatLstZona()
{
	habilitar('lstZona');
}

function habilitarCallejero(nombre){
	//habilita caja de texto
	document.getElementById(nombre).disabled=false;
}

function habilitarRadio(){
	//habilita caja de texto
	document.getElementById('radio1').disabled=false;
	document.getElementById('radio2').disabled=false;
}

function linkk(id,nombre,email,pass){
	// cambia el texto de un link
	var validacion=valida_email(email);
	
	if ((nombre!="") && (email!="") && (pass!="") && (validacion==true)){
		var vinculo=document.getElementById(id);
		var image=document.getElementById("icono_"+id);
		image.src="../images/bullet_tick.gif";
		vinculo.innerHTML=nombre + " - " + email;
		vinculo.title=nombre + " , " + email;
	}
	else{
		var image=document.getElementById("icono_"+id);
		image.src="../images/record_red.gif";
	}	  
}

/*
function linkk_inmueble(id,tInmueble,tConstruc,Poblacion,Precio,Metros,Habitaciones,Calle,Descripcion,Fecha,tipInmueble,referencia)
{
	if ((tInmueble!="") && (tConstruc!="") && (Poblacion!="") && (Precio!="") && (Metros!="") && (Habitaciones!="") && 
		(Calle!="") && (Descripcion!="") && (Fecha!="") && (referencia!=""))
	{
		var vinculo=document.getElementById(id);
		var image=document.getElementById("icono_"+id);
		image.src="../images/bullet_tick.gif";
		
		FechaPart = Fecha.split(" ");
		
		arrInmuebles = tipInmueble.split("_");		
		for(i=0; i<=arrInmuebles.length; i++)
		{
			if(tInmueble==arrInmuebles[i])
				break;
		}		
		vinculo.innerHTML = "&nbsp;<b>REF:</b> " + referencia + "  <b>TIPO:</b> " + arrInmuebles[i+1] + "  <b>DIR:</b> " + Calle;
		vinculo.title = FechaPart[0] + " " + Descripcion.substr(0,16) + "...";			
	}
	else{
		var image=document.getElementById("icono_"+id);
		image.src="../images/record_red.gif";
	}
}
*/

function linkk_prov(id,nombre){
	// cambia el texto de un link
	if (nombre!=""){
		var vinculo=document.getElementById(id);
		var image=document.getElementById("icono_"+id);
		image.src="../images/bullet_tick.gif";
		vinculo.innerHTML=nombre;
		vinculo.title=nombre;
	}
	else{
		var image=document.getElementById("icono_"+id);
		image.src="../images/record_red.gif";
	}	  
}

function linkk_zona(id,nombre,Poblacion,Provincia){
	// cambia el texto de un link
	if (nombre!=""){
		var vinculo=document.getElementById(id);
		var image=document.getElementById("icono_"+id);
		image.src="../images/bullet_tick.gif";
		vinculo.innerHTML=nombre+Poblacion+Provincia;
		vinculo.title=nombre;
	}
	else{
		var image=document.getElementById("icono_"+id);
		image.src="../images/record_red.gif";
	}	  
}

function linkk_TipoCons(id,Descripcion){
	// cambia el texto de un link
	if (Descripcion!=""){
		var vinculo=document.getElementById(id);
		var image=document.getElementById("icono_"+id);
		image.src="../images/bullet_tick.gif";
		vinculo.innerHTML=Descripcion;
		vinculo.title=Descripcion;
	}
	else{
		var image=document.getElementById("icono_"+id);
		image.src="../images/record_red.gif";
	}	  
}

function linkk_investigador(id,nombre,apellidos,centro,ciudad){
	// cambia el texto de un link
	if ((nombre!="") && (apellidos!="") && (centro!="") && (ciudad!="")){
		var vinculo=document.getElementById(id);
		var image=document.getElementById("icono_"+id);
		image.src="../images/bullet_tick.gif";
		vinculo.innerHTML=nombre + " , " + apellidos;
		vinculo.title=nombre + " , " + apellidos;
	}
	else{
		var image=document.getElementById("icono_"+id);
		image.src="../images/record_red.gif";
	}		  
}

/*limpiar campo tipo file*/
function limpiar(id_campo)	{
	f = document.getElementById(id_campo);
	nuevoFile = document.createElement("input");
	nuevoFile.id = f.id;
	nuevoFile.type = "file";
	nuevoFile.name = "archivo";
	nuevoFile.value = "";
	nuevoFile.onchange = f.onchange;
	nodoPadre = f.parentNode;
	nodoSiguiente = f.nextSibling;
	nodoPadre.removeChild(f);
	(nodoSiguiente == null) ? nodoPadre.appendChild(nuevoFile):
		nodoPadre.insertBefore(nuevoFile, nodoSiguiente);
}

function ocultar_capas(capa1,capa2,campo_borrar){
	
	document.getElementById(capa1).style.visibility='visible';
	document.getElementById(capa2).style.visibility='hidden';
	if (document.getElementById(campo_borrar).type!='file'){
			document.getElementById(campo_borrar).value='';
	}
	else{
		limpiar(campo_borrar);	
	}
	document.getElementById(capa1).style.zIndex =2;
	document.getElementById(capa2).style.zIndex =1;
	
}

function jsUpload(upload_field)
{
    // this is just an example of checking file extensions
    // if you do not need extension checking, remove 
    // everything down to line
    // upload_field.form.submit();
	
    var re_text = /\.png|\.jpg|\.xml|\.zip/i;
    var filename = upload_field.value;

    /* Checking file type */
    if (filename.search(re_text) == -1)
    {
        alert("El archivo no es de tipo (jpg, xml, zip) de extensión");
        upload_field.form.reset();
        return false;
    }

    upload_field.form.submit();
    //document.getElementById('upload_status').value = "Subiendo archivo ...";
    //upload_field.disabled = true;
    return true;
}

function fileSize(pathFile)
{
   var fso, f;
   fso = new ActiveXObject("Scripting.FileSystemObject");
   f = fso.GetFile(pathFile);
   return f.size;
}

function validarnuevapoblacion(formulario) {
  
  	////////////////////////////////////
	////////////////////////////////////
	var checkOK = "0123456789"; 
	var checkStr = formulario.txtPrecio.value; 
	var allValid = true; 
	var decPoints = 0; 
	var allNum = ""; 
	for (i = 0; i < checkStr.length; i++) { 
	ch = checkStr.charAt(i); 
	for (j = 0; j < checkOK.length; j++) 
	  if (ch == checkOK.charAt(j))
		break; 
	if (j == checkOK.length) { 
	  allValid = false; 
	  break; 
	} 
	allNum += ch; 
	} 
	if (!allValid) { 
		alert("Escriba sólo dígitos en el campo \"Precio\".");
		formulario.txtPrecio.focus(); 
		return (false); 
	}  
 	////////////////////////////////////
	////////////////////////////////////
	var checkOK = "0123456789"; 
	var checkStr = formulario.txtMetros.value; 
	var allValid = true; 
	var decPoints = 0; 
	var allNum = ""; 
	for (i = 0; i < checkStr.length; i++) { 
	ch = checkStr.charAt(i); 
	for (j = 0; j < checkOK.length; j++) 
	  if (ch == checkOK.charAt(j))
		break; 
	if (j == checkOK.length) { 
	  allValid = false; 
	  break; 
	} 
	allNum += ch; 
	} 
	if (!allValid) { 
		alert("Escriba sólo dígitos en el campo \"Metros\".");
		formulario.txtMetros.focus(); 
		return (false); 
	}
	////////////////////////////////////
	////////////////////////////////////	
	var checkOK = "0123456789"; 
	var checkStr = formulario.txtHabitaciones.value; 
	var allValid = true; 
	var decPoints = 0; 
	var allNum = ""; 
	for (i = 0; i < checkStr.length; i++) { 
	ch = checkStr.charAt(i); 
	for (j = 0; j < checkOK.length; j++) 
	  if (ch == checkOK.charAt(j))
		break; 
	if (j == checkOK.length) { 
	  allValid = false; 
	  break; 
	} 
	allNum += ch; 
	} 
	if (!allValid) { 
		//alert("Escriba sólo dígitos en el campo \"Habitaciones\".");
		formulario.txtHabitaciones.focus(); 
		return (false); 
	}	
}


function lanzaCallejero(txtCoordenadas,txtCalle)
{
	var coordenadas = document.getElementById(txtCoordenadas).value;
	var calle = document.getElementById(txtCalle).value;			
	window.open('http://www.ekiser.es/Inmobiliaria/mapas/index.php?coordenadas=' + coordenadas + '&calle=' + calle,'_blank','dependent=yes,width=635,height=520,scrollbars=NO');
}

function lanzaCallejero1(coordenadas)
{
	window.open('http://www.ekiser.es/Inmobiliaria/mapas/index1.php?coordenadas='+coordenadas,'_blank','dependent=yes,width=635,height=435,scrollbars=NO');
	//window.open('http://localhost/Inmoviliaria/mapas/index1.php?coordenadas='+coordenadas,'_blank','dependent=yes,width=635,height=435,scrollbars=NO');
}

function URLEncode(str)
{
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNÑOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnñopqrstuvwxyz" +
					"ÁÉÍÓÚáéíóúÄËÏÖÜäëïöüÇçÀÈÌÒÙàèìòùÂÊÎÔÛâêîôû" +
					"-_.!¡~*'()¿?ºª|@€&<>:;·#$%=`´^+*[]¨{}/" + 
					'"';					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var plaintext = str;
	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
			    alert( "Unicode Character '" 
                        + ch 
                        + "' cannot be encoded using standard URL encoding.\n" +
				          "(URL encoding only supports 8-bit characters.)\n" +
						  "A space (+) will be substituted." );
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for
	return encoded;
}


function URLDecode( )
{
   // Replace + with ' '
   // Replace %xx with equivalent character
   // Put [ERROR] in output if %xx is invalid.
   var HEXCHARS = "0123456789ABCDEFabcdef"; 
   var encoded = document.URLForm.F2.value;
   var plaintext = "";
   var i = 0;
   while (i < encoded.length) {
       var ch = encoded.charAt(i);
	   if (ch == "+") {
	       plaintext += " ";
		   i++;
	   } else if (ch == "%") {
			if (i < (encoded.length-2) 
					&& HEXCHARS.indexOf(encoded.charAt(i+1)) != -1 
					&& HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 ) {
				plaintext += unescape( encoded.substr(i,3) );
				i += 3;
			} else {
				alert( 'Bad escape combination near ...' + encoded.substr(i) );
				plaintext += "%[ERROR]";
				i++;
			}
		} else {
		   plaintext += ch;
		   i++;
		}
	} // while
   document.URLForm.F1.value = plaintext;
   document.URLForm.F1.select();
   return false;
}


function encode(v)
{
return escape(v).replace(/\+/ig, '%2B').replace(/\//ig, '%2F');
}



function alta_inmueble1(form,Guardar,pPostBack)
{	
	var url = "../secciones/inmuebles/NuevoInmueble.php";	
	
	//var PostBack=null;
  /*if(pPostBack!=1)
    PostBack = $('PostBack').value;
  else
    PostBack = 1;
	 	
	var pars = 'refInmueble=' + $('refInmueble').value + 
             '&lstTInmueble=' + $('lstTInmueble').value + 
             '&lstTConstruc=' + $('lstTConstruc').value + 
             '&lstProvincia=' + $('lstProvincia').value +
					   '&lstPoblacion=' + $('lstPoblacion').value + 
             '&lstZona=' + $('lstZona').value + 
             '&chkNovedad=' + $('chkNovedad').value + 
             '&chkDestacado=' + $('chkDestacado').value + 
					   '&chkPublicado=' + $('chkPublicado').value + 
             '&txtPrecio=' + $('txtPrecio').value + 
             '&txtMetros=' + $('txtMetros').value + 
             '&txtHabitaciones=' + $('txtHabitaciones').value + 
					   '&txtBanos=' + $('txtBanos').value + 
             '&txtCalle=' + $('txtCalle').value + 
             '&txtCallejero=' + $('txtCallejero').value + 
             '&txtDescripcion=' + $('txtDescripcion').value + 
					   '&oculto=' + $('oculto').value + 
             '&Obra=' + $('Obra').value + 
             '&PostBack=' + PostBack;
  
  if(Guardar!='') pars+='&Guardar=' + Guardar;
					  
	var myAjax = new Ajax.Updater("divInmueble", url, { method: "get", asynchronous: true, onComplete: f2('admin.php?Menu=Ob&Opcion=1&',pars)} );
*/
}
 
function f2(URL,PARAMS)
{
	alert('terminado');
} 



function alta_inmueble()
{	
	
	 var refInmueble = document.getElementById('refInmueble');
	 var lstTInmueble = document.getElementById('lstTInmueble');
	 var lstTConstruc = document.getElementById('lstTConstruc'); 
	 var lstProvincia = document.getElementById('lstProvincias1');
	 var lstPoblacion = null;
	 if(document.getElementById('lstPoblaciones1')) lstPoblacion = document.getElementById('lstPoblaciones1');
	 var lstZona = null;
	 if(document.getElementById('lstZonas1')) lstZona = document.getElementById('lstZonas1');	 
     
	 var chkNovedad = document.getElementById('chkNovedad');
	 var chkDestacado = document.getElementById('chkDestacado');
	 var chkPublicado = document.getElementById('chkPublicado');
	 var txtPrecio = document.getElementById('txtPrecio');	 	 
	 var txtMetros = document.getElementById('txtMetros');
	 var txtHabitaciones = document.getElementById('txtHabitaciones');
	 var txtBanos = document.getElementById('txtBanos');
	 var txtCalle = document.getElementById('txtCalle');
	 var txtCallejero = document.getElementById('txtCallejero');
	 var txtDescripcion = document.getElementById('txtDescripcion');
	 var Obra = document.getElementById('Obra');	 
	 
	 //Obligatorios	
	 var obligatorio = true;
	 obligatorio = lstObligatorio(lstTInmueble, obligatorio);
	 obligatorio = lstObligatorio(lstTConstruc, obligatorio);
	 obligatorio = lstObligatorio(lstProvincia, obligatorio);
	 obligatorio = lstObligatorio(lstPoblacion, obligatorio);
	 //lstObligatorio(lstZona);	 
	 obligatorio = txtObligatorio(refInmueble, obligatorio);
	 obligatorio = txtObligatorio(txtPrecio, obligatorio);
	 obligatorio = txtObligatorio(txtMetros, obligatorio);
	 obligatorio = txtObligatorio(txtCalle, obligatorio);
	 obligatorio = txtObligatorio(txtDescripcion, obligatorio);
	  
	 if(obligatorio)
	 {
		 if(confirm('¿Desea guardar este inmueble?'))
		 {		
		 	 miFechaActual = new Date() 
			 Fecha= miFechaActual.getFullYear() + "-" + (miFechaActual.getMonth() + 1) + "-" +
					miFechaActual.getDate() + " " +  miFechaActual.getHours() + ":" +
					miFechaActual.getMinutes() + ":" + miFechaActual.getSeconds();
					
			 var Parametros = 'refInmueble=' + refInmueble.value + 
							  '&lstTInmueble=' + lstTInmueble.value + 
							  '&lstTConstruc=' + lstTConstruc.value + 
							  '&lstProvincia=' + lstProvincia.value + 
							  '&lstPoblacion=' + lstPoblacion.value;
							  
							  if(lstZona!=null) Parametros += '&lstZona=' + lstZona.value;
							  
				Parametros += '&chkNovedad=' + chkNovedad.checked + 
							  '&chkDestacado=' + chkDestacado.checked + 
							  '&chkPublicado=' + chkPublicado.checked + 
							  '&txtPrecio=' + txtPrecio.value + 
							  '&txtMetros=' + txtMetros.value + 
							  '&txtHabitaciones=' + txtHabitaciones.value + 
							  '&txtBanos=' + txtBanos.value + 
							  '&txtCalle=' + txtCalle.value.replace(/€/g,'-euro-') + 
							  '&txtCallejero=' + txtCallejero.value + 
							  '&txtDescripcion=' + txtDescripcion.value.replace(/€/g,'-euro-') + 
							  '&Obra=' + Obra.checked +
							  '&Fecha=' + Fecha +
							  '&sqlInmueble=guardarInmuebla';

				FAjax('../secciones/inmuebles/sqlInmueble.php','divInmueble',Parametros,'post');	
		 }
	 }
	 else
	 {
		 alert('Debe revisar los campos remarcados en rojo');
	 }
 
}


function mod_inmueble()
{	
	 var idInmueble = document.getElementById('idInmueble');
	 var refInmueble = document.getElementById('refInmueble');
	 var lstTInmueble = document.getElementById('lstTInmueble');
	 var lstTConstruc = document.getElementById('lstTConstruc'); 
	 var lstProvincia = document.getElementById('lstProvincias1');
	 var lstPoblacion = null;
	 if(document.getElementById('lstPoblaciones1')) lstPoblacion = document.getElementById('lstPoblaciones1');
	 var lstZona = null;
	 if(document.getElementById('lstZonas1')) lstZona = document.getElementById('lstZonas1');	 
     
	 var chkNovedad = document.getElementById('chkNovedad');
	 var chkDestacado = document.getElementById('chkDestacado');
	 var chkPublicado = document.getElementById('chkPublicado');
	 var txtPrecio = document.getElementById('txtPrecio');	 	 
	 var txtMetros = document.getElementById('txtMetros');
	 var txtHabitaciones = document.getElementById('txtHabitaciones');
	 var txtBanos = document.getElementById('txtBanos');
	 var txtCalle = document.getElementById('txtCalle');
	 var txtCallejero = document.getElementById('txtCallejero');
	 var txtDescripcion = document.getElementById('txtDescripcion');
	 var Obra = document.getElementById('Obra');	 
	 
	 //Obligatorios	
	 var obligatorio = true;
	 obligatorio = lstObligatorio(lstTInmueble, obligatorio);
	 obligatorio = lstObligatorio(lstTConstruc, obligatorio);
	 obligatorio = lstObligatorio(lstProvincia, obligatorio);
	 obligatorio = lstObligatorio(lstPoblacion, obligatorio);
	 //lstObligatorio(lstZona);	 
	 obligatorio = txtObligatorio(refInmueble, obligatorio);
	 obligatorio = txtObligatorio(txtPrecio, obligatorio);
	 obligatorio = txtObligatorio(txtMetros, obligatorio);
	 obligatorio = txtObligatorio(txtCalle, obligatorio);
	 obligatorio = txtObligatorio(txtDescripcion, obligatorio);
	  
	 if(obligatorio)
	 {
		 if(confirm('¿Desea guardar este inmueble?'))
		 {
			 miFechaActual = new Date() 
			 Fecha= miFechaActual.getFullYear() + "-" + (miFechaActual.getMonth() + 1) + "-" +
					miFechaActual.getDate() + " " +  miFechaActual.getHours() + ":" +
					miFechaActual.getMinutes() + ":" + miFechaActual.getSeconds();
					
			 var Parametros = 'idInmueble=' + idInmueble.value +
			 				  '&refInmueble=' + refInmueble.value + 
							  '&lstTInmueble=' + lstTInmueble.value + 
							  '&lstTConstruc=' + lstTConstruc.value + 
							  '&lstProvincias1=' + lstProvincia.value + 
							  '&lstPoblaciones1=' + lstPoblacion.value;
							  
							  if(lstZona!=null) Parametros += '&lstZonas1=' + lstZona.value;
							  
				Parametros += '&chkNovedad=' + chkNovedad.checked + 
							  '&chkDestacado=' + chkDestacado.checked + 
							  '&chkPublicado=' + chkPublicado.checked + 
							  '&txtPrecio=' + txtPrecio.value + 
							  '&txtMetros=' + txtMetros.value + 
							  '&txtHabitaciones=' + txtHabitaciones.value + 
							  '&txtBanos=' + txtBanos.value + 
							  '&txtCalle=' + txtCalle.value.replace(/€/g,'-euro-') + 
							  '&txtCallejero=' + txtCallejero.value + 
							  '&txtDescripcion=' + txtDescripcion.value.replace(/€/g,'-euro-') + 
							  '&Obra=' + Obra.checked +
							  '&Fecha=' + Fecha +
							  '&sqlInmueble=modificarInmueble';	
							  							  
				for(x=0;x<lstTInmueble.length;x++)			
					if(lstTInmueble.options[x].value==lstTInmueble.value) break;				
				tInmueble = lstTInmueble.options[x].innerHTML;
				//descripcion = txtDescripcion.value.substr(0,16) + "...";
				descripcion = txtDescripcion.value;
				 	
				FAjax('../secciones/inmuebles/sqlInmueble.php','modificarInmueble',Parametros,'post');	
				
				var vinculo=document.getElementById(idInmueble.value);
				var image=document.getElementById("icono_"+idInmueble.value);
				image.src="../images/bullet_tick.gif";
								
				vinculo.innerHTML = "&nbsp;<b>REF:</b> " + refInmueble.value + " <b>TIPO:</b> " + tInmueble + " <b>DIR:</b> " + txtCalle.value;
				vinculo.title = descripcion;																	
		 }
	 }
	 else
	 {
		 alert('Debe revisar los campos remarcados en rojo');
	 }
 
}


function lstObligatorio(lst,obligatorio)
{
	if(lst!=null)
		if(lst.value=='')
		{
			lst.options[0].style.backgroundColor = "#FF0000";
			return false;
		}
		else
		{
			lst.options[0].style.backgroundColor = "";
			return obligatorio;
		}
}

function txtObligatorio(txt,obligatorio)
{
	if(txt!=null)
		if(txt.value=='')
		{ 
			txt.style.borderColor="#FF0000";
			return false;
		}
		else 
		{
			txt.style.borderColor="";
			return obligatorio;
		}
}


function lanza(Control,idCapa,url,CamposById,CamposTXT,Metod)
{	
	 var arrCamposByIdValues = new Array();
	 var arrCamposById = new Array();
	 var arrCamposTXT = new Array();
	 var Parametros = null;	 
	 arrCamposById=CamposById.split(',');
	 arrCamposTXT=CamposTXT.split(',');	 
	 if (CamposById!='')
	 {
		 for(x=0; x < arrCamposById.length; x++)
		 {
			 campoNomValor = arrCamposById[x].split('.');
			 switch(campoNomValor[1])
			 {
				 case 'v': arrCamposByIdValues[x] =  campoNomValor[0] + '=' + document.getElementById(campoNomValor[0]).value; 
				 case 'c': arrCamposByIdValues[x] =  campoNomValor[0] + '=' + document.getElementById(campoNomValor[0]).checked;
			 }	
		 }	 
		 Parametros = arrCamposByIdValues.join('&');
	 }

	 if(CamposTXT != '' && arrCamposTXT.length > 0)	 
		 if (arrCamposTXT.length == 1)
			 if (Parametros==null) Parametros = arrCamposTXT; else Parametros += '&' + arrCamposTXT;		 
		 else		 
			 if (Parametros==null) Parametros = arrCamposTXT.join('&'); else Parametros += '&' + arrCamposTXT.join('&');	
			 	
	 frmcontrol = document.getElementById(Control);
	 returntoString(FAjax(url,idCapa,Parametros,Metod));	
	 frmcontrol.submit();			  
}

function borraQuiero(form)
{
		var formulario=document.getElementById(form);
		formulario.FaltanDatos.value='No';
				
		for(x=0;x<formulario.Operacion.length;x++) formulario.Operacion[x].checked=false;		
		for(x=0;x<formulario.inmueble.length;x++) formulario.inmueble[x].checked=false;			
		for(x=0;x<formulario.habitaciones.length;x++) formulario.habitaciones[x].checked=false;				
		for(x=0;x<formulario.banos.length;x++) formulario.banos[x].checked=false;				
		for(x=0;x<formulario.metros.length;x++) formulario.metros[x].checked=false;						
		for(x=0;x<formulario.precios2.length;x++) formulario.precios2[x].checked=false;			
		for(x=0;x<formulario.precios1.length;x++) formulario.precios1[x].checked=false;				
			
		formulario.descripcion.value='';
		formulario.nombre.value='';
		formulario.direccion.value='';
		formulario.telefono.value='';
		formulario.mail.value='';
		
		formulario.ValAviso.checked=false;
		
		formulario.action="";		
		formulario.submit();
}


function consulta(id,texto,precio)
{
	//window.open('http://www.ekiser.es/Inmobiliaria/consulta.php?id='+id+'&reff='+texto+'&precio='+precio,'_blank','dependent=yes,width=280,height=320,scrollbars=NO');			
	//window.open('http://www.cuatrokreativos.com/Inmobiliaria/consulta.php?id='+id+'&reff='+texto+'&precio='+precio,'_blank','dependent=yes,width=350,height=430,scrollbars=NO');
	window.open('http://www.ekiser.es/Inmobiliaria/consulta.php?id='+id+'&reff='+texto+'&precio='+precio,'_blank','dependent=yes,width=350,height=455,scrollbars=NO');			
}

function cerrarse()
{ 
  window.close();
}

/*
function cerrarse()
{
	var formulario=document.getElementById('enviomapa');
	var coordenada=document.getElementById('coordenadas').value;
	formulario.action=toString(FAjax('../mapas/guardacoorde.php','enviomapa','coordenadas=' + coordenada,'post'));		
	//formulario.submit();
	window.close();
}

function limpiar()
{
	var formulario=document.getElementById('enviomapa');
	var coordenada=" ";
	formulario.action=toString(FAjax('../mapas/guardacoorde.php','enviomapa','coordenadas=' + coordenada,'post'));		
	//formulario.submit();
	window.close();	
}
*/

function limpiaCampo(nombre)
{
	document.getElementById(nombre).value="";	
}

/*
function cargarCoorde()
{
	var formulario=document.getElementById('enviomapa');
	var coordenada=document.getElementById('coordenadas').value;
	formulario.action=toString(FAjax('../mapas/guardacoorde.php','enviomapa','coordenadas=' + coordenada,'post'));		
	//formulario.submit();
	window.close();	
}
*/


function changeProv()
{		
	codProv = document.getElementById('lstProvincias1').value;
	if(document.getElementById('_Zonas'))
	{
		document.getElementById('_Zonas').innerHTML="";
		if(document.getElementById('_btZonas'))
			document.getElementById('_btZonas').innerHTML="";
	}
	
	if(document.getElementById('_btPoblaciones')) 
		document.getElementById('_btPoblaciones').innerHTML="";
	
	if(codProv=="")
		document.getElementById('_Poblaciones').innerHTML="";		
	else
	{	
		Parametros = 'codProv=' + codProv;
		FAjax('../secciones/inmuebles/combos.php','_Poblaciones',Parametros,'post');	
	}
}


function changePob()
{	
	codPob = document.getElementById('lstPoblaciones1').value;
	
	if(document.getElementById('_btZonas'))
		document.getElementById('_btZonas').innerHTML="";
	if(codPob=="")
		document.getElementById('_Zonas').innerHTML="";
	else
	{	
		Parametros = 'codPob=' + codPob;
		FAjax('../secciones/inmuebles/combos.php','_Zonas',Parametros,'post');	
	}
}


function solonumeros(e) {
    tecla = (document.all) ? e.keyCode : e.which;
    if (tecla==8) return true; //Tecla de retroceso (para poder borrar)
    patron = /\d/; //ver nota
    te = String.fromCharCode(tecla);
    return patron.test(te); 
}

