
var cssPath ="../themes/"
var win = null;
var index = 1;
	function openDialog(id) {
	  Dialog.alert($(id).innerHTML, {className: "alphacube",  width:850, id: "d" + index})
	  index++;
  }

  function lastDialog(id) {
	  Dialog.confirm($(id).innerHTML, {className: "alphacube",  width:250, okLabel: "Cerrar ventanas", ok: closeAllModalWindows})
  }

  function closeAllModalWindows() {
    Windows.closeAllModalWindows();
    return true;
  }
var foto_repetir=0;
  var FotoWin=null;
  function modalFotos_old(){
      FotoWin = new Window({minimizable: false,maximizable: false, resizable: false, hideEffect:Element.hide, showEffect:Element.show, minWidth: 700,minHeight:400, destroyOnClose: true})
      $('foto_principal').style.width='';
      $('foto_principal').style.height='500px';

      FotoWin.setContent('FotoGrande_int', true, true)
      $('foto_principal').style.width='';
      $('foto_principal').style.height='500px';

      FotoWin.showCenter(true);

  // Set up a windows observer, check ou debug window to get messages
  myObserver = {
    onDestroy: function(eventName, win) {
      if (win == FotoWin) {
        $('FotoGrande_ext').appendChild($('FotoGrande_int'));
        $('foto_principal').style.height='';
        $('foto_principal').style.width='205px';
        FotoWin = null;
        Windows.removeObserver(this);
      }

    }
  }
  Windows.addObserver(myObserver);

  }


function ver_foto(foto){
 var destino= 'ver_imagen.php?imagen=' + foto;

     var hWnd =open(destino, "Foto","resizable=yes, toolbar=no, scrollbars=yes,directories=no,menubar=no,status=no,location=no,width=600, height=300, scrolling=no");
     if (!hWnd.opener)
          hWnd.opener = self;
     if (hWnd.focus != null)
          hWnd.focus();
      return
}

function ver_foto2(foto) {
 var urlfoto=$('foto_principal').src;
 var destino= 'ver_imagen.php?imagen=' + urlfoto;

     var hWnd =open(destino, "Foto","resizable=yes, toolbar=no, scrollbars=yes,directories=no,menubar=no,status=no,location=no,width=600, height=300, scrolling=no");
     if (!hWnd.opener)
          hWnd.opener = self;
     if (hWnd.focus != null)
          hWnd.focus();
      return
}
function ver_foto_previa(foto) {
 $('foto_principal').src=$(foto).src;


}


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}




/***********************************************
* Cross browser Marquee II- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

var delayb4scroll=1000 //Specify initial delay before marquee starts to scroll on page (2000=2 seconds)
var marqueespeed=1 //Specify marquee scroll speed (larger is faster 1-10)
var pauseit=1 //Pause marquee onMousever (0=no. 1=yes)?

////NO NEED TO EDIT BELOW THIS LINE////////////

var copyspeed=marqueespeed
var pausespeed=(pauseit==0)? copyspeed: 0
var actualheight=''

function scrollmarquee(){
if (parseInt(cross_marquee.style.top)>(actualheight*(-1)+8)) //if scroller hasn't reached the end of its height
cross_marquee.style.top=parseInt(cross_marquee.style.top)-copyspeed+"px" //move scroller upwards
else //else, reset to original position
cross_marquee.style.top=parseInt(marqueeheight)+8+"px"
}

function initializemarquee(){
cross_marquee=document.getElementById("vmarquee")
cross_marquee.style.top=0
marqueeheight=document.getElementById("marqueecontainer").offsetHeight
actualheight=cross_marquee.offsetHeight //height of marquee content (much of which is hidden from view)
if (window.opera || navigator.userAgent.indexOf("Netscape/7")!=-1){ //if Opera or Netscape 7x, add scrollbars to scroll and exit
cross_marquee.style.height=marqueeheight+"px"
cross_marquee.style.overflow="scroll"
return
}
setTimeout('lefttime=setInterval("scrollmarquee()",30)', delayb4scroll)
}

Event.observe(window, 'load', function() {
  MM_preloadImages('imagesv/mm_home_on.gif','imagesv/mm_nuestraempresa_on.gif','imagesv/mm_alquileres_on.gif','imagesv/mm_ventas_on.gif','imagesv/mm_dondeestamos_on.gif','imagesv/mm_contactenos_on.gif');
});



var jTipos=new Array();
var t=new Array();
var jUbic=new Array();
var tt=new Array();



    function oper_cambio(){
        var oo=$('oper');
        var oi=oo.selectedIndex;
        var ov=oo.options[oi].value;
        //alert(ov);
        var ot=$('tipo');
        ot.options.length=0;
        cargar_op('tipo',jTipos[ov],0);
    }



  function oper_cambio_PE(){
        var oo=$('oper');
        var oi=oo.selectedIndex;
        var ov=oo.options[oi].value;
        //alert(ov);

        if(ov==4){
            $('div_periodo_select').style.display='';
            $('div_periodo_texto').style.display='none';
            $('periodo_texto').disabled=true;
            $('periodo_select').disabled=false;
        }else{
            $('div_periodo_select').style.display='none';
            $('div_periodo_texto').style.display='';
            $('periodo_texto').disabled=true;
            $('periodo_select').disabled=false;
        }




        var ot=$('tipo');
        ot.options.length=0;

        var ou=$('ubicacion');
        ou.options.length=0;

        //cargar_op('tipo',jTipos[ov],0);
        selectid=ot;
        //$(selectid).innerHTML="<option value=0></option>";
        insertar_op('tipo',0,"");
        var sTipos=jOTLZ[ov];
        //alert(ov);
        for(keyvar in sTipos){
            if(''+keyvar!=='extend' && !isNaN(keyvar)){
                var texto=jTipos[keyvar];
                insertar_op('tipo',keyvar,texto);
            }
        }
    }

function tipo_cambio_PE(){
        var oo=$('oper');
        var oi=oo.selectedIndex;
        var ov=oo.options[oi].value;
        //alert(ov);

        var ot=$('tipo');
        var oti=ot.selectedIndex;
        var otv=ot.options[oti].value;

        var ou=$('ubicacion');
        ou.options.length=0;

        //cargar_op('tipo',jTipos[ov],0);
        selectid='ubicacion';
        //$(selectid).innerHTML="<option value=0></option>";
        insertar_op(selectid,0,"");
        var sUbic=jOTLZ[ov][otv];
        //alert(ov);
        for(keyvar in sUbic){
            if(''+keyvar!=='extend' && !isNaN(keyvar)){
                var texto=jUbicaciones[keyvar];
                insertar_op(selectid,keyvar,texto);
            }
        }
    }

    function ubic_cambio_PE(){
        //alert('ucpe');
        var oo=$('oper');
        var oi=oo.selectedIndex;
        var ov=oo.options[oi].value;
        //alert(ov);
        if(ov==0){
            return; //si no hay seleccionado operacion no abro barrio
        }
        var ot=$('tipo');
        var oti=ot.selectedIndex;
        var otv=ot.options[oti].value;

        var ou=$('ubicacion');
        var oui=ou.selectedIndex;
        var ouv=ou.options[oui].value;

        var oz=$('zona');
        oz.options.length=0;

        selectid='zona';
        $(selectid).innerHTML="<option value=0></option>";
        var sUbic=jOTLZ[ov][otv][ouv];
        //alert(ov);
        for(keyvar in sUbic){
            if(''+keyvar!=='extend' && !isNaN(keyvar)){
                var vector=sUbic[keyvar];
                insertar_op(selectid,vector[0],vector[1]);
            }
        }
    }
function tipo_cambio(){
        var oo=$('oper');
        var ooi=oo.selectedIndex;
        var oov=oo.options[ooi].value;
        //alert(ov);
        var ot=$('tipo');
        var oti=ot.selectedIndex;
        var otv=ot.options[oti].value;
        //alert(ov);
        var ou=$('ubicacion');
        ou.options.length=0;
        cargar_op('ubicacion',jUbic[oov][otv],0);
    }

var jZona=new Array();

function ubic_cambio(){
        var oo=$('oper');
        var ooi=oo.selectedIndex;
        var oov=oo.options[ooi].value;
        //alert(ov);
        var ot=$('tipo');
        var oti=ot.selectedIndex;
        var otv=ot.options[oti].value;
        var ou=$('ubicacion');
        var oui=ou.selectedIndex;
        var ouv=ou.options[oui].value;


        var url="ajZotu.php?oper=" + oov + "&tipo=" + otv + "&ubic=" +ouv;
        var options={method:'post'};
        var aj=new Ajax.Updater('zona',url,options);

}

function zona_cambio_PE(){
        var oo=$('oper');
        var ooi=oo.selectedIndex;
        var oov=oo.options[ooi].value;

        var ot=$('tipo');
        var oti=ot.selectedIndex;
        var otv=ot.options[oti].value;

        var ou=$('ubicacion');
        var oui=ou.selectedIndex;
        var ouv=ou.options[oui].value;

        var oz=$('zona');
        var ozi=oz.selectedIndex;
        var ozv=oz.options[ozi].value;


        var url="ajD_PE.php?oper=" + oov + "&tipo=" + otv + "&CUZ=" +ozv;
        var options={method:'post'};
        var aj=new Ajax.Updater('dormitorios',url,options);

}




// desplegables
function cargar_op(selectid,vector){
	// carga los datos de un vector en un desplegable
	var opcion_cero=1;
	if(arguments.length>2)
		opcion_cero=arguments[2]; // espera 0 o 1

	var opcion_posicion=0; // por defecto si el valor del array es un vector toma la primera posicion
	if(arguments.length>3)
		opcion_posicion=arguments[3]; // espera que posicion tomar si es vector

	quitartodos_op(selectid);

	if(opcion_cero==1)
		$(selectid).innerHTML="<option value=0></option>";

	for(keyvar in vector){
		if(''+keyvar!=='extend' && !isNaN(keyvar)){
			var vtexto=vector[keyvar];
			var texto='';
			if (typeof vtexto == 'string')
				texto=vtexto;
			else
				texto=vtexto[opcion_posicion];

			//new Insertion.Bottom(selectid, "<option value="+keyvar+">"+keyvar+":"+texto+"</option>");
			insertar_op(selectid,keyvar,texto);
		}
	}

}

function quitartodos_op(selectid){
	  var elSel = document.getElementById(selectid);

	  try {
	    elSel.innerHTML=""; // standards compliant; doesn't work in IE
	  }
	  catch(ex) {
		  for(opts in elSel.childNodes){
			  elSel.remove(opts);
		  }
	  }

}

function insertar_op(selectid,valor,texto){
	  var elOptNew = document.createElement('option');
	  elOptNew.text = texto;
	  elOptNew.value = valor;
	  var elSel = document.getElementById(selectid);

	  try {
	    elSel.add(elOptNew, null); // standards compliant; doesn't work in IE
	  }
	  catch(ex) {
	    elSel.add(elOptNew); // IE only
	  }

}

var aOfertas=new Array();
var aOfertas_indice=-1;

var stopOfertas=0;
function rotarOfertas(){
     if(stopOfertas==1){
         stopOfertas=0;
         return;
     }

     try{
         if(aOfertas_indice>=0){
         $(aOfertas[aOfertas_indice]).style.display='none';
         aOfertas_indice++;
         if(aOfertas_indice>=aOfertas.length)
            aOfertas_indice=0;

         $(aOfertas[aOfertas_indice]).style.display='';
         }else{
         aOfertas_indice++;
         $(aOfertas[aOfertas_indice]).style.display='';
         }


         var t=setTimeout('rotarOfertas()',9000);
     }catch(e){
        // no hay ...
        console.log(aOfertas);
     }

}

function pararOfertas(){
    stopOfertas=1;
}

var str_org="";
var str_cargando="\
            <div id=lista_top><img height='15' width='585' src='imagesv/sup_textos.gif'/></div>\
            <div id='lista_cuerpo' > Cargando . . . <img src='imagesv/wait.gif'> </div>\
            <div id='lista_pie'>\
            <img height=15 width=585 src='imagesv/inf_textos.gif'/>\
            </div>\
            ";

function mostrar_ficha(ficha){
   if(Prototype.Browser.IE){
    document.location.href='index.php?mostrar=ficha&ficha='+ficha;
   }else{
    pararOfertas();
    str_org=$('contenidos').innerHTML;
    $('contenidos').innerHTML=str_cargando;
    new Ajax.Updater('contenidos','ficha.php?ficha='+ficha,{evalScripts:true,asynchronous:false});
    window.scroll(0, 0);
    //getDisp(ficha);
   }
}

function mostrar_resultados(){

    var ubicacion_txt=$('ubicacion').options[$('ubicacion').selectedIndex].text;
    try{
        var zona_txt=$('zona').options[$('zona').selectedIndex].text;
    }catch(e){
        var zona_txt="";
    }
    var param=$('form_buscador').serialize(true);
        param=$H(param);
        param.set("ut",ubicacion_txt);
        param.set("zt",zona_txt);
    if(Prototype.Browser.IE){
        param=param.toQueryString();

        document.location.href='index.php?mostrar=lista&av=0&pag=0&'+param;
        return false;
    }else{

    str_org=$('contenidos').innerHTML;
    $('contenidos').innerHTML=str_cargando;
    window.scroll(0, 0);
    new Ajax.Updater('contenidos','lista.php?av=0&pag=0',{method:'get',parameters:param,evalScripts:true});
    $('frm_codigo').value="";
    }
}

function mostrar_operacion(oper){
    str_org=$('contenidos').innerHTML;
    $('contenidos').innerHTML=str_cargando;
    var desde=$F('buscador_desde');
    new Ajax.Updater('contenidos','lista.php?av=0&pag=0',{method:'get',parameters:{"oper":oper,"desde":desde},evalScripts:true});


}

function mostrar_empresa(){
    str_org=$('contenidos').innerHTML;
    $('contenidos').innerHTML=str_cargando;
    new Ajax.Updater('contenidos','ajax_empresa.php',{method:'get',evalScripts:true});
}


function mostrar_donde(){
    str_org=$('contenidos').innerHTML;
    $('contenidos').innerHTML=str_cargando;
    new Ajax.Updater('contenidos','ajax_donde.php',{method:'get',evalScripts:true});
}


function mostrar_contacto(){
    str_org=$('contenidos').innerHTML;
    $('contenidos').innerHTML=str_cargando;
    new Ajax.Updater('contenidos','ajax_contacto.php',{method:'get',evalScripts:true});
}


function mostrar_lista(av,pag){
    str_org=$('contenidos').innerHTML;
    $('contenidos').innerHTML=str_cargando;
    new Ajax.Updater('contenidos','lista.php?av='+av+'&pag='+pag,{evalScripts:true});
    window.scroll(0,0);
}

function mostrar_volver(){
    if(str_org!==""){
        $('contenidos').innerHTML=str_org;
        str_org="";
    }else{
        window.history.go(-1);
    }
    window.scroll(0,0);
}

function mostrar_gracias(){
    window.scroll(0,0);
     Dialog.alert("Gracias por contactarnos",{className:"alphacube", width:400, height:null,okLabel:'Cerrar'})

     if(arguments.length>0){return;}
    if(str_org!==""){
        $('contenidos').innerHTML=str_org;
        str_org="";
    }else{
        document.location.href='index.php';
    }

}


function mostrar_registro_ok(){
    window.scroll(0,0);
     Dialog.alert("Registramos su búsqueda<br>le enviaremos las novedades<br>que correspondan.",{className:"alphacube", width:400, height:null,okLabel:'Cerrar'})

     if(arguments.length>0){return;}
    if(str_org!==""){
        $('contenidos').innerHTML=str_org;
        str_org="";
    }else{
        document.location.href='index.php';
    }

}

document.vImage0 = new Image;
document.vic = new Image;
document.vic.src="/images/cargando.gif";
var adonde='';
var vSlide;


function mostrar_foto(nespacio,nfoto,tfoto) {
 //	eval("document." + nespacio + ".src = document.vic.src");
 eval("document.vImage0.src = '" + nfoto + "'");
 document.vImage0.onload=mostrar_foto_ahora;
 adonde=nespacio;
 try {
 eval("document.getElementById('TIMAG_" + nespacio + "').innerHTML='" + tfoto +"'");
 } catch(e) {/*nada*/}

}


function mostrar_foto_ahora() {
 eval('document.' + adonde + ".src = document.vImage0.src");
// alert('mostrar');
}

function verfoto(foto) {
 var destino= 'ver_imagen.asp?imagen=' + foto;

     var hWnd =open(destino, "Foto","resizable=yes, toolbar=no, scrollbars=yes,directories=no,menubar=no,status=no,location=no,width=600, height=300, scrolling=no");
     if (!hWnd.opener)
          hWnd.opener = self;
     if (hWnd.focus != null)
          hWnd.focus();
      return
}

var aDisp=new Array();

function getDisp(prop) {

                        var par={ codigo: prop,method:'get' };
                        var aj=new Ajax.Request('ajax_disponibilidad.php?codigo='+prop,
                            { method:'get',asynchronous:false });

                        if(aDisp.length==0){
                            $('disponibilidad').innerHTML='';
                        }else{
                            $('disponibilidad_calendarios').innerHTML=" ";
                            for(i=0;i<aDisp.length;i++){
                                fecha=aDisp[i];
                                div_nombre='calendario_'+fecha[0]+'_'+fecha[1];
                                contenido='<div id="'+div_nombre+'" style="display:inline"></div><br>';
                                $('disponibilidad_calendarios').insert(contenido);
                                new Ajax.Updater(div_nombre,'calenda.php?codigo='+prop+'&mes='+fecha[0]+'&anio='+fecha[1],{evalScripts:true});
                            }



                        }
   }
 var indiceFotoSlide;
 var crecerFotoSlide=0;
 function resetFotoSlide(){
     vSlide=new Array();
     indiceFotoSlide=0;
 }

 function resetFotoSlide2(){
     vSlide=new Array();
     indiceFotoSlide=0;
     $('andres').innerHTML="cargando fotos";
 }

 function cargarFotoSlide(n){
     vSlide[vSlide.length]=n;
     //<a href="javascript:clickSlide();">Ver todas las fotos</a>
     //$('andres').innerHTML="cargando foto "+n;
 }

 function listoFotoSlide(){
     $('andres').innerHTML='<a href="javascript:clickSlide();">Ver todas las fotos</a>';
 }

function clickSlide(){
//    if(crecerFotoSlide==0){
//        crecerFotoSlide=1;doSlide();
//    }else{
//        crecerFotoSlide=0;
//    }
//
     if(crecerFotoSlide==0){
        crecerFotoSlide=1;
        $('foto_principal').style.width='205px';
        $('foto_principal').style.height='';
        $('FotoGrande_ext').appendChild($('FotoGrande_int'));
        try{
        FotoWin.close();
        }catch(e){/**/}
    }else{
        var i=0;
        if(arguments.length>0){
            indiceFotoSlide=arguments[0];
            foto_repetir=1;
            doSlide();
        }
        crecerFotoSlide=0;
        modalFotos();
    }
}

var foto_principal_alto=200;

var perpetua=null;

 function doSlide(){
     //if(crecerFotoSlide==0)return;
     if(foto_repetir==1){
         clearTimeout(perpetua);
         foto_repetir=0;
         $('foto_principal').src=$("foto"+vSlide[indiceFotoSlide]).src;
         setTimeout("doSlide()",4000);
         return;
     }
     indiceFotoSlide++;

     if(vSlide.length>0){
     if(indiceFotoSlide>=vSlide.length) indiceFotoSlide=0;
     $('foto_principal').src=$('foto'+vSlide[indiceFotoSlide]).src;
     if(crecerFotoSlide==1){
         t=$('foto_principal').getHeight();
         if(t>foto_principal_alto){
             $('FotoGrande_int').style.height=t+'px';
             foto_principal_alto=t;
         }
     }
     perpetua=setTimeout("doSlide()",2000);
     }
 }

 var dalert=null;

 function contactarPorAviso(sec){
     modalContacto(sec);
 }

 function modalContacto(sec){
    var tipo=0;
    if(arguments.length>1){tipo=arguments[1];}
    var params='sec='+sec+'&tipo='+tipo;
    Dialog.alert({url: "ajax_contacto.php?pop=1", options: {method: 'get',parameters:params}},{className:"alphacube", width:800, height:null,okLabel:'Cerrar Ventana'})

  }

   function modalMap(coord){

    var params='coord='+coord;
    Dialog.alert({url: "gmap.php", options: {method: 'get',parameters:params}},{className:"alphacube", width:800, height:null,okLabel:'Cerrar Ventana'})

  }


function modalFotos(){
      FotoWin = new Window({className:"alphacube",minimizable: false,maximizable: false, resizable: false, hideEffect:Element.hide, showEffect:Element.show, minWidth: 700,minHeight:400, destroyOnClose: true})
      $('foto_principal').style.width='';
      $('foto_principal').style.height='500px';

      FotoWin.setContent('FotoGrande_int', true, true)
      $('foto_principal').style.width='';
      $('foto_principal').style.height='500px';

      FotoWin.showCenter(true);
      FotoWin.maximize();
  // Set up a windows observer, check ou debug window to get messages
  myObserver = {
    onDestroy: function(eventName, win) {
      if (win == FotoWin) {
        $('FotoGrande_ext').appendChild($('FotoGrande_int'));
        $('foto_principal').style.height='';
        $('foto_principal').style.width='205px';
        FotoWin = null;
        Windows.removeObserver(this);
      }

    }
  }
  Windows.addObserver(myObserver);

  }


  function usuarios_registrados(){
      Dialog.alert("En construcción",{className:"alphacube", width:300, height:null,okLabel:'Cerrar'})

  }

function enviar_mail(form){
    $('code_check').style.background="";
    $('frm_contacto_email').style.background="";
    $('frm_contacto_tel').style.background="";

    if(parseInt($F('code_check'))==0 || $F('code_check')==""){
        $('code_check').style.background="#ff8a8a";
    }else if($F('frm_contacto_email')=="" && $F('frm_contacto_tel')==""){
        $('frm_contacto_email').style.background="#ff8a8a";
        $('frm_contacto_tel').style.background="#ff8a8a";


    }else{
      form.action="contactenos_validar.php";
      form.submit();
      Dialog.closeInfo();
      
    }


  }

function recordar_validar(){

    $('frm_recordar_email').style.background="";

    if($F('frm_recordar_email')=="" || $F('frm_recordar_email')=="su email"){
        $('frm_recordar_email').style.background="#ff8a8a";
    }else{
      $('frm_recordar').submit();
    }

}

function limpiar_recordar(){
    if($F('frm_recordar_email')=="su email"){
        $('frm_recordar_email').value="";
    }
}


function avanzada_cambio_ubic(){
        var oo=$('av_operacion');
        var ooi=oo.selectedIndex;
        var oov=oo.options[ooi].value;
        //alert(ov);
        var ot=$('av_tipo');
        var oti=ot.selectedIndex;
        var otv=ot.options[oti].value;
        var ou=$('av_ubicacion');
        var oui=ou.selectedIndex;
        var ouv=ou.options[oui].value;


        var url="ajZotu.php?oper=" + oov + "&tipo=" + otv + "&ubic=" +ouv;
        var options={method:'post'};
        var aj=new Ajax.Updater('av_zona',url,options);

}