//esta funcion se utiliza para la cabecera
	function Abrir_Ventana2(theURL,w,h) { 
		var windowprops = 'top=150,left=400,toolbar=no,location=no,status=no, menubar=no,scrollbars=no, resizable=no,width=' + w + ',height=' + h;
		var winName = 'Popup';
		window.open(theURL,winName,windowprops); 
	}
    function valida(){ 
    //valido el txtZona 
    if (document.getElementById('busqueda').txtZonas.value.length==0){ 
       alert('El campo Zona es obligatorio'); 
       document.getElementById('busqueda').txtZonas.focus(); 
       return false; 
    } 
     if (document.getElementById('busqueda').txtZonas.value.length<3){ 
       alert('El campo Zona debe tener un minimo de 3 caracteres'); 
       document.getElementById('busqueda').txtZonas.focus(); 
       return false; 
    } 
    if (document.getElementById('busqueda').txtZonas.value.indexOf("%")>=0){ 
       alert('El campo Zona no puede contener \'%\'');
       document.getElementById('busqueda').txtZonas.focus(); 
       return false; 
    }
    return true;
    }
    
	//función que cambia el precio del select de precio en función del tipo que se haya escogido en el select de tipo.
	var precio_Venta=new Array('0 - 60.000' ,'60.000 - 90.000','90.000 - 120.000','120.000 - 150.000','150.000 - 180.000','180.000 - 240.000','240.000 - 300.000','300.000 - 360.000','360.000 - 450.000','450.000 - 600.000','600.000 - 800.000','800.000 - 1.200.000','+1.200.000');
	var precio_Alquiler=new Array('0 - 300' ,'300 - 500','500 - 700','700 - 1.000','1.000 - 1.500','1.500 - 2.000','2.000 - 2.500','+3.000');



	function cambia_precio(){
		var tipo
		var txt_ini=document.getElementById('busqueda').rangodeprecio.options[0].text
		var txt_value=document.getElementById('busqueda').rangodeprecio.options[0].value
		tipo = document.getElementById('busqueda').transType[document.getElementById('busqueda').transType.selectedIndex].value
			mis_precio=eval("precio_" + tipo)
			num_precio = mis_precio.length+1
			document.getElementById('busqueda').rangodeprecio.length = num_precio
			document.getElementById('busqueda').rangodeprecio.options[0].text=txt_ini
			document.getElementById('busqueda').rangodeprecio.options[0].value=txt_value
			for(i=1;i<num_precio;i++){
				/*
			    var cadensa=mis_precio[i-1].split("-");
			    for (var i=0;i<cadena.length;i++){
			    	document.getElementById('busqueda').rangodeprecio.options[i].value=cadena;
			   		document.getElementById('busqueda').rangodeprecio.options[i].text=cadena;
			    } 
					*/
			    
			   document.getElementById('busqueda').rangodeprecio.options[i].value=mis_precio[i-1];
			   document.getElementById('busqueda').rangodeprecio.options[i].text=mis_precio[i-1];
			   
			}
	}
	
	function validaLog(){ 
	    if (document.login.password.value.length==0){ 
	       alert("El campo Password es obligatorio"); 
	       document.login.password.focus(); 
	       return false; 
	    }
	    if (document.login.eMail.value.length==0){ 
	       alert("El campo e-mail es obligatorio"); 
	       document.login.eMail.focus(); 
	       return false; 
	    } else{
			var s = document.login.eMail.value;
			var filter= new RegExp(/^[\w\.-]+@[\w\.-]+\.[\w]{2,}$/);
	
			if (filter.test(document.login.eMail.value)){
				return true;
			}else{
			alert("Email no valido");
				return false;
			}
			document.login.eMail.focus();
			return false;
		}
		return true;
	}

function getAbsoluteElementPosition(element) {
  if (typeof element == "string")
    element = document.getElementById(element)
    
  if (!element) return { top:0,left:0 };
  
  var y = 0;
  var x = 0;
  while (element.offsetParent) {
    x += element.offsetLeft;
    y += element.offsetTop;
    element = element.offsetParent;
  }
  return {top:y,left:x};
}

	
function ensenar()
{
	document.getElementById("resumen").style.display = "block";
  	var elemento = document.getElementById("otrosEnlaces");
  	var pos = getAbsoluteElementPosition(elemento);
	pos.top = pos.top - 100;
	pos.left = pos.left + 20;
	document.getElementById("resumen").style.top = pos.top+"px";
	document.getElementById("resumen").style.left = pos.left+"px";
}

function esconder()
{
	document.getElementById("resumen").style.display = "none";
}

function mostrar(id)
{
	if (document.getElementById('td_sub_' + id)!= 'null'){
		if (document.getElementById('td_sub_' + id).style.display != ''){
			document.getElementById('td_sub_' + id).style.display ='';
			document.getElementById('vinculo' + id).className ="link1_over";
		}
		else {
			document.getElementById('td_sub_' + id).style.display='none';
			document.getElementById('vinculo' + id).className ="link1";
		}
	}
}

function mostrarocultar()
{
 	   if (document.getElementById("subterminos").style.display != 'none'){
			document.getElementById("subterminos").style.display ='none';
		}
		else {
			document.getElementById("subterminos").style.display='block';
		}
}


function mostrar_enlaces()
{
 	   if (document.getElementById("relacionados").style.display != 'none'){
			document.getElementById("relacionados").style.display ='none';
			document.getElementById("relacionados_2").style.display='block';
		}
		else {
			document.getElementById("relacionados_2").style.display='none';
			document.getElementById("relacionados").style.display='block';
		}
}



function NumberFormat(num, numDec, decSep, thousandSep){
    var arg;
    var Dec;
    Dec = Math.pow(10, numDec); 
    if (typeof(num) == 'undefined') return; 
    if (typeof(decSep) == 'undefined') decSep = ',';
    if (typeof(thousandSep) == 'undefined') thousandSep = '.';
    if (thousandSep == '.')
     arg=/./g;
    else
     if (thousandSep == ',') arg=/,/g;
    if (typeof(arg) != 'undefined') num = num.toString().replace(arg,'');
    num = num.toString().replace(/,/g, '.'); 
    if (isNaN(num)) num = "0";
    sign = (num == (num = Math.abs(num)));
    num = Math.floor(num * Dec + 0.50000000001);
    cents = num % Dec;
    num = Math.floor(num/Dec).toString(); 
    if (cents < (Dec / 10)) cents = "0" + cents; 
    for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3); i++)
     num = num.substring(0, num.length - (4 * i + 3)) + thousandSep + num.substring(num.length - (4 * i + 3));
    if (Dec == 1)
     return (((sign)? '': '-') + num);
    else
     return (((sign)? '': '-') + num + decSep + cents);
   } 

   function EvaluateText(cadena, obj){
    opc = false; 
    if (cadena == "%d")
     if (event.keyCode > 47 && event.keyCode < 58)
      opc = true;
    if (cadena == "%f"){ 
     if (event.keyCode > 47 && event.keyCode < 58)
      opc = true;
     if (obj.value.search("[.*]") == -1 && obj.value.length != 0)
      if (event.keyCode == 46)
       opc = true;
    }
    if(opc == false)
     event.returnValue = false; 
   } 

function DifDate(f1, f2){
	var resta = f1.getTime() - f2.getTime();
	return (Math.floor(resta / (1000 * 60 * 60 * 24)));
}

function diasDesde(){
	var hoy = new Date();
	otrodia = new Date(2010,6,28) 
	dias = DifDate(hoy, otrodia);
	dias = dias + 22580;
	
	num = dias;
	
	var texto = NumberFormat(num, '0', '.', ',');
	texto = texto.replace(',', '.');
	
	document.write(texto);
}


