﻿// JScript File
// AJAX
function MetodoAjax()
{ 
    var xmlhttp=false; 
    try 
    { 
        xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
    }
    catch(e)
    { 
        try
        { 
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
        } 
        catch(E) { xmlhttp=false; }
    }
        if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp=new XMLHttpRequest(); } 
        return xmlhttp; 
}
/* MASTER PAGE*/
    if (document.layers) 
    {
        document.captureEvents(Event.MOUSEDOWN);   
    }
    document.onmousedown=click;
  
    function fechaCompleta()
    {
        var mydate=new Date()
        var year=mydate.getYear()
        if (year < 1000)
            year+=1900
        var day=mydate.getDay()
        var month=mydate.getMonth()
        var daym=mydate.getDate()
        if (daym<10)
            daym="0"+daym
        var dayarray=new Array("Domingo","Lunes","Martes","Mi&eacute;rcoles","Jueves","Viernes","S&aacute;bado")

        var montharray=new Array("Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre")
        document.write("<font class='textos_pequenos'>"+dayarray[day]+" "+daym+" de "+montharray[month]+" de "+year+"</font>")
    }

    function click()  
    {
        var message="Gracias por visitar elinmobiliario.cl"; 

        if (document.all) 
        {
            if (event.button == 2) 
            {
                alert(message);
                return false;
            }
            
        }
        if (document.layers) 
        {
            if (e.which == 3) 
            {
                alert(message);
                return false;
            }
        }
    }


    function PopUp(){
        window.open('Usuario/Crear_POPUP.aspx','','height=560,width=840,menubar=0,resizable=0');
    }
    function _AbrirOnLine(){
        window.open('http://messenger.providesupport.com/messenger/elinmobiliario.html','','height=460,width=500,menubar=0,resizable=0');
    }
    function agregarfavoritos(){ 
       if ((navigator.appName=="Microsoft Internet Explorer") && (parseInt(navigator.appVersion)>=4)) { 
          var url="http://www.elinmobiliario.cl/"; 
          var titulo="elinmobiliario.cl - Guia Inmobiliaria. Propiedades, Casas y Departamentos Nuevos."; 
          window.external.AddFavorite(url,titulo); 
       } 
       else { 
          if(navigator.appName == "Netscape") 
             alert ("Presione Crtl+D para agregar este sitio en sus Bookmarks"); 
       } 
    }
    function CargaPopupGuia()
    {
         window.open('Catalogo/Default.aspx','','height=600,width=600,menubar=0,resizable=1');
    
    }

    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_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_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];}
    }
/* FIN MASTER PAGE*/
/* DEFAULT */
function GetDataSessionBuscadorFiltroComunas(tipoDato,tipoDato2,paginaRecargar)
{
    var ajax1=MetodoAjax();
  	ajax1.open("GET", paginaRecargar+'Comunas='+tipoDato+'&Nombres='+tipoDato2, true);
  	ajax1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    ajax1.send("datos="+tipoDato+"&datos2="+tipoDato2);    
	ajax1.onreadystatechange=function()	{ }
}
function GetDataSessionBuscadorFiltroUF(tipoDato1, tipoDato2,paginaRecargar)
{
    var ajax1=MetodoAjax();
  	ajax1.open("GET", paginaRecargar+'UFD='+tipoDato1+'&UFH='+tipoDato2, true);
  	ajax1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    ajax1.send("datos="+tipoDato1);
	ajax1.onreadystatechange=function()	{ }
}
function GetDataSessionBuscadorFiltroBanos(tipoDato1, tipoDato2,paginaRecargar)
{
    var ajax1=MetodoAjax();
  	ajax1.open("GET", paginaRecargar+'BANOSD='+tipoDato1+'&BANOSH='+tipoDato2, true);
  	ajax1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    ajax1.send("datos="+tipoDato1);
	ajax1.onreadystatechange=function()	{ }
	
}function GetDataSessionBuscadorFiltroDorm(tipoDato1, tipoDato2,paginaRecargar)
{
    var ajax1=MetodoAjax();
  	ajax1.open("GET", paginaRecargar+'DORMD='+tipoDato1+'&DORMH='+tipoDato2, true);
  	ajax1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    ajax1.send("datos="+tipoDato1);
	ajax1.onreadystatechange=function()	{ }
}
function GetDataSessionBuscadorFiltroTipo(tipoDato,paginaRecargar)
{
    var ajax1=MetodoAjax();
  	ajax1.open("GET", paginaRecargar+'TIPO='+tipoDato, true);
  	ajax1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    ajax1.send("datos="+tipoDato);
	ajax1.onreadystatechange=function()	{ }
}
function GetDataSessionBuscador(paginaRecargar)
{
    var ajax1=MetodoAjax();
  	ajax1.open("GET", paginaRecargar, true);
  	ajax1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    ajax1.send("datos=");
	ajax1.onreadystatechange=function()	{ }
}
function MarcarComunas(mapa){
        var str="";
        var _strComuna="";

		if (document.getElementById("ckhuechuraba").checked)
        {
            str = str + ",327";
            _strComuna += "Huechuraba,";
        }
        if (document.getElementById("cklareina").checked)
        {
            str = str + ",314";
		 _strComuna += "La Reina,";	
        }
        if (document.getElementById("cklascondes").checked)
        {
            str = str + ",313";
            _strComuna += "Las Condes,";
        }
        if (document.getElementById("cklobarnechea").checked)
        {
            str = str + ",311";
            _strComuna += "Lo Barnechea,";
        }
        if (document.getElementById("ckmacul").checked)
        {
            str = str + ",342";
            _strComuna += "Macul,";
        }
        if (document.getElementById("cknunoa").checked)
        {
            str = str + ",340";
            _strComuna += "Nuñoa,";
        }
        if (document.getElementById("ckpenalolen").checked)
        {
            str = str + ",315";
            _strComuna += "Peñalolen,";
        }
        if (document.getElementById("ckprovidencia").checked)
        {
            str = str + ",337";
            _strComuna += "Providencia,";
        }
        if (document.getElementById("ckvitacura").checked)
        {
            str = str + ",312";
            _strComuna += "Vitacura,";
        }
        if (document.getElementById("ckcerrillos").checked)
        {
            str = str + ",321";
            _strComuna += "Cerrillos,";
        }
        if (document.getElementById("ckcerronavia").checked)
        {
            str = str + ",318";
            _strComuna += "Cerro Navia,";
        }
        if (document.getElementById("ckloprado").checked)
        {
            str = str + ",319";
            _strComuna += "Lo Prado,";
        }
        if (document.getElementById("ckmaipu").checked)
        {
            str = str + ",320";
            _strComuna += "Maipu,";
        }
        if (document.getElementById("ckquilicura").checked)
        {
            str = str + ",323";
            _strComuna += "Quilicura,";
        }
        if (document.getElementById("ckrenca").checked)
        {
            str = str + ",322";
            _strComuna += "Renca,";
        }
        if (document.getElementById("ckconchali").checked)
        {
            str = str + ",326";
            _strComuna += "Conchali,";
        }
        if (document.getElementById("ckestacioncentral").checked)
        {
            str = str + ",338";
            _strComuna += "Estación Central,";
        }
        if (document.getElementById("ckindependencia").checked)
        {
            str = str + ",324";
            _strComuna += "Independencia,";
        }
        if (document.getElementById("ckquintanormal").checked)
        {
            str = str + ",336";
            _strComuna += "Quinta Normal,";
        }
        if (document.getElementById("ckrecoleta").checked)
        {
            str = str + ",325";
            _strComuna += "Recoleta,";
        }
        if (document.getElementById("cksantiago").checked)
        {
            str = str + ",339";
            _strComuna += "Santiago,";
        }
        if (document.getElementById("ckelbosque").checked)
        {
            str = str + ",333";
            _strComuna += "El Bosque,";
        }
        if (document.getElementById("cklacisterna").checked)
        {
            str = str + ",330";
            _strComuna += "La Cisterna,";
        }
        if (document.getElementById("cklaflorida").checked)
        {
            str = str + ",316";
            _strComuna += "La Florida,";
        }
        if (document.getElementById("cklagranja").checked)
        {
            str = str + ",332";
            _strComuna += "La Granja,";
        }
        if (document.getElementById("cklapintana").checked)
        {
            str = str + ",334";
            _strComuna += "La Pintana,";
        }
        if (document.getElementById("ckloespejo").checked)
        {
            str = str + ",328";
            _strComuna += "Lo Espejo,";
        }
        if (document.getElementById("ckpacerda").checked)
        {
            str = str + ",329";
            _strComuna += "PA Cerda,";
        }
        if (document.getElementById("ckpuentealto").checked)
        {
            str = str + ",295";
            _strComuna += "Puente Alto,";
        }
        if (document.getElementById("cksanbernardo").checked)
        {
            str = str + ",308";
            _strComuna += "San Bernardo,";
        }
        if (document.getElementById("cksanjoaquin").checked)
        {
            str = str + ",341";
            _strComuna += "San Joaquin,";
        }
        if (document.getElementById("cksanmiguel").checked)
        {
            str = str + ",335";
            _strComuna += "San MIguel,";
        }
        if (document.getElementById("cksanramon").checked)
        {
            str = str + ",331";
            _strComuna += "San Ramón,";
        }
        if (document.getElementById("ckcolina").checked)
        {
            str = str + ",292";
            _strComuna += "Colina,";
        }
        if (document.getElementById("ckpudahuel").checked)
        {
            str = str + ",317";
            _strComuna += "Pudahuel,";
        }
        if (document.getElementById("ckpadrehurtado").checked)
        {
            str = str + ",306";
            _strComuna += "Padre Hurtado,";
        }
        if (document.getElementById("ckalhue").checked)
        {
            str = str + ",301";
            _strComuna += "Alhue,";
        }
        if (document.getElementById("ckbuin").checked)
        {
            str = str + ",309";
            _strComuna += "Buin,";
        }
        if (document.getElementById("ckcaleratango").checked)
        {
            str = str + ",307";
            _strComuna += "Calera de Tango,";
        }
        if (document.getElementById("ckcuracavi").checked)
        {
            str = str + ",297";
            _strComuna += "Curacavi,";
        }
        if (document.getElementById("ckelmonte").checked)
        {
            str = str + ",303";
            _strComuna += "El Monte,";
        }
        if (document.getElementById("cklampa").checked)
        {
            str = str + ",293";
            _strComuna += "Lampa,";
        }
        if (document.getElementById("ckmelipilla").checked)
        {
            str = str + ",299";
            _strComuna += "Melipilla,";
        }
        if (document.getElementById("ckpaine").checked)
        {
            str = str + ",310";
            _strComuna += "Paine,";
        }
        if (document.getElementById("ckpenaflor").checked)
        {
            str = str + ",302";
            _strComuna += "Peñaflor,";
        }
        if (document.getElementById("ckpirque").checked)
        {
            str = str + ",296";
            _strComuna += "Pirque,";
        }
        if (document.getElementById("cksjmaipo").checked)
        {
            str = str + ",294";
            _strComuna += "San José de Maipo,";
        }
        if (document.getElementById("cktiltil").checked)
        {
            str = str + ",291";
            _strComuna += "Til-til,";
        }
		var tomarValor=str;
        var tomarValor2=_strComuna.slice(0,_strComuna.length-1);
        
        // TIPO
        var strTipoPropiedad;
        if (document.getElementById("ctl00_ContentPlaceHolder1_rbCasas1").checked == true)
        {
            strTipoPropiedad = "CASA"
        }
        if (document.getElementById("ctl00_ContentPlaceHolder1_rbDptos1").checked == true)
        {
            strTipoPropiedad = "DEPTO"
        }
        if (document.getElementById("ctl00_ContentPlaceHolder1_rbTodos1").checked == true)
        {
            strTipoPropiedad = "TODOS"
        }        
        
        GetDataSessionBuscadorFiltroTipo(strTipoPropiedad,'ajaxrequest3.aspx?');        
        // FIN TIPO

        if (tomarValor2 != "")
        {
            if (mapa==0)
            {
                document.location.href = "Proyecto/Listar.aspx?idComuna=0" + tomarValor + "&comuna=" + tomarValor2;
            }
            else
            {
                document.location.href = "Proyecto/Listar.aspx?tab=1&idComuna=0" + tomarValor + "&comuna=" + tomarValor2;
            }
        }
}

    var postponedCallbackValue = null;
    function onChangeComboBoxDormD(s,e)
    {   var _parametro = "DormD?" + s.GetSelectedItem().value;
        var item = s.GetSelectedItem();

        cboDormitorioDesde1.SetValue(item.value);
        cboDormitorioDesde2.SetValue(item.value);
        cboDormitorioDesde3.SetValue(item.value);
        cboDormitorioDesde4.SetValue(item.value);
        cboDormitorioDesde5.SetValue(item.value);

        if(DefaultCallBack.InCallback())
            postponedCallbackValue = item.value;
        else
            DefaultCallBack.PerformCallback(_parametro);    
    }
    function onChangeComboBoxDormH(s,e)
    {   var _parametro = "DormH?" + s.GetSelectedItem().value;
        var item = s.GetSelectedItem();

        cboDormitorioHasta1.SetValue(item.value);
        cboDormitorioHasta2.SetValue(item.value);
        cboDormitorioHasta3.SetValue(item.value);
        cboDormitorioHasta4.SetValue(item.value);
        cboDormitorioHasta5.SetValue(item.value);

        if(DefaultCallBack.InCallback())
            postponedCallbackValue = item.value;
        else
            DefaultCallBack.PerformCallback(_parametro);    
    }
    function onChangeComboBoxPrecioD(s,e)
    {   var _parametro = "PrecioD?" + s.GetSelectedItem().value;
        var item = s.GetSelectedItem();
        
        cboPrecioDesde1.SetValue(item.value);
        cboPrecioDesde2.SetValue(item.value);
        cboPrecioDesde3.SetValue(item.value);
        cboPrecioDesde4.SetValue(item.value);
        cboPrecioDesde5.SetValue(item.value);
                
        if(DefaultCallBack.InCallback())
            postponedCallbackValue = item.value;
        else
            DefaultCallBack.PerformCallback(_parametro);    
            

    }
    function onChangeComboBoxPrecioH(s,e)
    {   var _parametro = "PrecioH?" + s.GetSelectedItem().value;
        var item = s.GetSelectedItem();
        
        cboPrecioHasta1.SetValue(s.GetSelectedItem().value);
        cboPrecioHasta2.SetValue(s.GetSelectedItem().value);
        cboPrecioHasta3.SetValue(s.GetSelectedItem().value);
        cboPrecioHasta4.SetValue(s.GetSelectedItem().value);
        cboPrecioHasta5.SetValue(s.GetSelectedItem().value);
        
        if(DefaultCallBack.InCallback())
            postponedCallbackValue = item.value;
        else
            DefaultCallBack.PerformCallback(_parametro);    


    }
    function onChangeComboBoxBanosD(s,e)
    {   var _parametro = "BanosD?" + s.GetSelectedItem().value;
        var item = s.GetSelectedItem();

        cboBanoDesde1.SetValue(item.value);
        cboBanoDesde2.SetValue(item.value);
        cboBanoDesde3.SetValue(item.value);
        cboBanoDesde4.SetValue(item.value);
        cboBanoDesde5.SetValue(item.value);
        
        if(DefaultCallBack.InCallback())
            postponedCallbackValue = item.value;
        else
            DefaultCallBack.PerformCallback(_parametro);    
    }
    function onChangeComboBoxBanosH(s,e)
    {   var _parametro = "BanosH?" + s.GetSelectedItem().value;
        var item = s.GetSelectedItem();

        cboBanoHasta1.SetValue(item.value);
        cboBanoHasta2.SetValue(item.value);
        cboBanoHasta3.SetValue(item.value);
        cboBanoHasta4.SetValue(item.value);
        cboBanoHasta5.SetValue(item.value);

        if(DefaultCallBack.InCallback())
            postponedCallbackValue = item.value;
        else
            DefaultCallBack.PerformCallback(_parametro);    
    }    


function MarcarFiltroTIPO(strSelect){
    if(strSelect=="CASA")
    {
       document.getElementById("ctl00_ContentPlaceHolder1_rbCasas1").checked = true;
       document.getElementById("ctl00_ContentPlaceHolder1_rbCasas2").checked = true;
       document.getElementById("ctl00_ContentPlaceHolder1_rbCasas3").checked = true;
       document.getElementById("ctl00_ContentPlaceHolder1_rbCasas4").checked = true;
       document.getElementById("ctl00_ContentPlaceHolder1_rbCasas5").checked = true;
    }
    if(strSelect=="DEPTO")
    {
       document.getElementById("ctl00_ContentPlaceHolder1_rbDptos1").checked = true;
       document.getElementById("ctl00_ContentPlaceHolder1_rbDptos2").checked = true;
       document.getElementById("ctl00_ContentPlaceHolder1_rbDptos3").checked = true;
       document.getElementById("ctl00_ContentPlaceHolder1_rbDptos4").checked = true;
       document.getElementById("ctl00_ContentPlaceHolder1_rbDptos5").checked = true;
    }
    if(strSelect=="TODOS")
    {
       document.getElementById("ctl00_ContentPlaceHolder1_rbTodos1").checked = true;
       document.getElementById("ctl00_ContentPlaceHolder1_rbTodos2").checked = true;
       document.getElementById("ctl00_ContentPlaceHolder1_rbTodos3").checked = true;
       document.getElementById("ctl00_ContentPlaceHolder1_rbTodos4").checked = true;
       document.getElementById("ctl00_ContentPlaceHolder1_rbTodos5").checked = true;
    }
    GetDataSessionBuscadorFiltroTipo(strSelect,'ajaxrequest3.aspx?');            
}
function SeleccionaVivirEn(obj)
{
    document.location.href = "viviren/mapa.aspx?idBarrio=" + obj.value;
}
/* FIN DEFAULT */
/* RESULATADO BUSQUEDA*/
function GetDataSessionListar(tipoDato,paginaRecargar)
{
    var ajax1=MetodoAjax();
  	ajax1.open("GET", paginaRecargar+'valores='+tipoDato, true);
  	ajax1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    ajax1.send("datos="+tipoDato);
	ajax1.onreadystatechange=function()	{ }
}

function CargaPopup()
{
    showPopWin('PopUpMiMaletin_masivo.aspx',595,276,null,null);
}

function MarcaProyecto(strIdProyecto)
{
    var valor = document.getElementById("ctl00_ContentPlaceHolder1_txtHidden").value;
    if (valor.indexOf(','+strIdProyecto)!=-1)
    {
        var dato = document.getElementById("ctl00_ContentPlaceHolder1_txtHidden").value.replace(','+strIdProyecto,'');            
        document.getElementById("ctl00_ContentPlaceHolder1_txtHidden").value = dato;
    }
    else
    {
        document.getElementById("ctl00_ContentPlaceHolder1_txtHidden").value = valor + "," + strIdProyecto;
    }
    var tomarValor=document.getElementById("ctl00_ContentPlaceHolder1_txtHidden").value;
    GetDataSessionListar(tomarValor,'ajaxrequest2.aspx?');
}    
function MarcaAll()
{
    var valor = document.getElementById("ctl00_ContentPlaceHolder1_txtHidden").value;
    
    var myArray = valor.split(",");
    for (i = 0; i < myArray.length ;i++)
    {
        if (document.getElementById("chkMasivo" + myArray[i])!=null)
        {
            document.getElementById("chkMasivo" + myArray[i]).checked = true;                        
        }            
    }
}
function MarcarMiMaletin()
{
    var valor = document.getElementById("ctl00_ContentPlaceHolder1_txtMaletin").value;
    
    var myArray = valor.split(",");
    for (i = 0; i < myArray.length ;i++)
    {
        if (document.getElementById("chkMasivo" + myArray[i])!=null)
        {
            document.getElementById("chkMasivo" + myArray[i]).checked = true;  
            document.getElementById("chkMasivo" + myArray[i]).disabled='disabled';      
            document.getElementById("masivo"+myArray[i]).innerHTML="<img align='center' src='../App_Themes/elinmobiliario/imagenes/proyecto_seleccionado.png' width='20' height='20' alt='Proyecto existe en mi maletin' />";           
        }            
    }
}

function MarcaDesmarcar(strIdSubCategoria, strIdComunas, strLogo, strLogoDesactivado)
{
    var valor = document.getElementById("ctl00_ContentPlaceHolder1_txtHidden2").value;
    if (valor.indexOf(','+strIdSubCategoria+"&")!=-1)
    {
        var dato = document.getElementById("ctl00_ContentPlaceHolder1_txtHidden2").value.replace(','+strIdSubCategoria+"&",'');            
        document.getElementById("ctl00_ContentPlaceHolder1_txtHidden2").value = dato;
        parent.frames['FrameMapas'].SacarPuntos("../XmlDinamic/XmlMapaVivirEn.aspx?idComunas=" + strIdComunas + "&idSubCategoria="+ strIdSubCategoria + "&");
        document.getElementById("btn" + strIdSubCategoria).style.backgroundImage = "url(../Upload/VivirEn/SubCategoria/" + strLogoDesactivado + ")";
    }
    else
    {
        document.getElementById("ctl00_ContentPlaceHolder1_txtHidden2").value = valor + "," + strIdSubCategoria + "&";
        parent.frames['FrameMapas'].CargarPuntos("../XmlDinamic/XmlMapaVivirEn.aspx?idComunas=" + strIdComunas + "&idSubCategoria="+ strIdSubCategoria +"&");
        document.getElementById("btn" + strIdSubCategoria).style.backgroundImage = "url(../Upload/VivirEn/SubCategoria/" + strLogo + ")";
    }
}   

/*UBICACCIONES*/
function CargaPopupUCAcciones()
{
    showPopWin('PopUpMiMaletin.aspx',595,276,null,null);
}
function CargaPdfUCAcciones()
{
    showPopWin('pdf.aspx',750,400,null,null);
}
/* FIN UCACCIONES*/

/* ADD ICONS*/
addthis_pub             = 'fherman'; 
addthis_logo            = 'http://www.elinmobiliario.cl/App_Themes/elinmobiliario/imagenes/menu_sup/logo_el_inmobiliario.jpg';
addthis_logo_background = 'EFEFFF';
addthis_logo_color      = '666699';
addthis_brand           = 'elinmobiliario.cl';
addthis_options         = 'favorites, facebook, google, live, myspace, twitter, delicious, digg';

/*  FICHA MAULTIMEDIA  */
function PintaOpcionMultimedia(tipo)
{
	var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
	var nameClass;
	if ( isIE )
	{
		nameClass = 'className';
	}
	else
	{
		nameClass = 'class';
	}	
	
	if (tipo == 'Interior360')
	{
		document.getElementById("ctl00_ContentPlaceHolder1_id360").setAttribute(nameClass,'active');
		if (document.getElementById("ctl00_ContentPlaceHolder1_idVideos")!= null)
		{
	        document.getElementById("ctl00_ContentPlaceHolder1_idVideos").setAttribute(nameClass,'');
        }
	}
	if (tipo == 'ComercialTv')
	{
	    if (document.getElementById("ctl00_ContentPlaceHolder1_id360")!= null)
	    {
		    document.getElementById("ctl00_ContentPlaceHolder1_id360").setAttribute(nameClass,'');
	    }
		document.getElementById("ctl00_ContentPlaceHolder1_idVideos").setAttribute(nameClass,'active');
	}
}
function CargarVideos(nombreArchivo,tipoVideo,TipoArchivo,idVideo)
{
    PintaOpcionMultimedia(tipoVideo);
    document.getElementById("FrameMultimedia").src='PreCargaMultimedia.aspx?File='+ nombreArchivo + '&Type='+ tipoVideo + '&Version='+ TipoArchivo + '&idVideo=' + idVideo;
}
/*FIN FICHA MAULTIMEDIA*/
/* PLANTAS */
    //Para abrir popUp de detalle de plantas y propiedades.
function CargaPopupLogueo()
{
   showPopWin('PopUpDetallePropiedad.aspx',595,276,null,null);
}
function muestraimagen()
{
    if (document.getElementById("IdImagen").style.display== "none" || document.getElementById("IdImagen").style.display== "")    
    {
		var theBody = document.getElementsByTagName("BODY")[0];
		var scTop = parseInt(getScrollTop(),10);
		var scLeft = parseInt(theBody.scrollLeft,10);
		var fullHeight = getViewportHeight();
		var fullWidth = getViewportWidth();
		var height = document.getElementById("ctl00_ContentPlaceHolder1_idImagenPlantaReal").height;
		var width = document.getElementById("ctl00_ContentPlaceHolder1_idImagenPlantaReal").width;
        
        document.getElementById("IdImagen").style.display="block";
        document.getElementById("IdCerrar").style.width = width + "px";
        if (fullWidth - 970 < 0)        
        {
            document.getElementById("IdImagen").style.left = "322px";
        }
        else    
        {
            document.getElementById("IdImagen").style.left = (((fullWidth - 970) / 2) + 322) + "px";
        }
    }
    else
    {
        document.getElementById("IdImagen").style.display = "none";
    }
}
/* FIN PLANTAS */

var qsParm = new Array();
function qs() {
    var query = window.location.search.substring(1);
    var parms = query.split('&');
    for (var i=0; i<parms.length; i++) 
    {
        var pos = parms[i].indexOf('=');
        if (pos > 0) 
        {
            var key = parms[i].substring(0,pos);
            var val = parms[i].substring(pos+1);
            qsParm[key] = val;
        }
    }
}
function replaceEspacios(var1)
{
    var _return = "";
    _return = var1.replace("%20"," ");    
    return _return    
}
function CrearPlayer(idTipoContenido,_rutaServer) {
    var s2 = new SWFObject(_rutaServer + "/contentmanager/Multimedia/player3.swf","playlist","250","312","8");
    s2.addVariable("file",_rutaServer + "/XMLDinamic/XMLMultimedia.aspx?idTipoContenido=" + idTipoContenido);
    s2.addParam('allowscriptaccess','always');
    s2.addParam('allowfullscreen','true');
    s2.addParam('wmode', 'transparence');
    s2.addParam("quality", "high");
    s2.addVariable('height','312');
    s2.addVariable('width','250');
    s2.addVariable('displayheight','170');
    s2.addVariable('displaywidth','250');
    s2.addVariable("repeat","false");
    s2.addVariable('backcolor','0x000000');
    s2.addVariable('frontcolor','0xF7F7F7');
    s2.addVariable('lightcolor','0x999999');
    s2.addVariable('searchbar','false');
    s2.addVariable('autoscroll','false');
    s2.addVariable('overstretch','false');
    s2.addVariable('showstop','true');
    s2.addVariable('showdownload','false');
    //s2.addParam('bufferlength','30');            
    s2.write("div_player");				        

}
function cambioSector1(sector, inicio)
{
    Refcapa='document.getElementById("';
    Refestilo='").style';
    document.getElementById("SecOriente").className = 'pestOff_aux';
    document.getElementById("SecPoniente").className = 'pestOff_aux';
    document.getElementById("SecCentro").className = 'pestOff_aux';
    document.getElementById("SecSur").className = 'pestOff_aux';
    document.getElementById("SecSubUrbano").className = 'pestOff_aux';

    document.getElementById('first_search').style.display = 'none';
    document.getElementById('second_search').style.display = 'none';
    document.getElementById('third_search').style.display = 'none';
    document.getElementById('fourth_search').style.display= 'none';
    document.getElementById('fifth_search').style.display = 'none';

    if(sector == 'tdO')
    {

        document.getElementById('first_search').style.display = 'block';
        document.getElementById("SecOriente").className = 'pestOOn_aux';
        document.getElementById('first_search').className = 'fondoO_aux';
        document.getElementById('tpO').className = 'tipoO_aux';
    }
    if(sector == 'tdP')
    {
        document.getElementById('second_search').style.display = 'block';
        document.getElementById("SecPoniente").className = 'pestPOn_aux';
        document.getElementById('second_search').className = 'fondoP_aux';
        document.getElementById('tpP').className = 'tipoP_aux';
    }    
    if(sector == 'tdC')
    {
        document.getElementById('third_search').style.display = 'block';
        document.getElementById("SecCentro").className = 'pestCOn_aux';
        document.getElementById('third_search').className = 'fondoC_aux';
        document.getElementById('tpC').className = 'tipoC_aux';
    }
    if(sector == 'tdS')
    {
        document.getElementById('fourth_search').style.display= 'block';
        document.getElementById("SecSur").className = 'pestSOn_aux';
        document.getElementById('fourth_search').className = 'fondoS_aux';
        document.getElementById('tpS').className = 'tipoS_aux';
    }
    if(sector == 'tdSU')
    {
        document.getElementById('fifth_search').style.display = 'block';
        document.getElementById("SecSubUrbano").className = 'pestSUOn_aux';
        document.getElementById('fifth_search').className = 'fondoSU_aux';
        document.getElementById('tpSU').className = 'tipoSU_aux';
    }
}


function acceptNum(evt){	
// NOTE: Backspace = 8, Enter = 13, '0' = 48, '9' = 57	
var nav4 = window.Event ? true : false;
var key = nav4 ? evt.which : evt.keyCode;	
return (key <= 13 || (key >= 48 && key <= 57));
}


/*FINANCIAMIENTO*/
function calculaMontos(campo)
{
    var valor1 = parseInt(document.getElementById("ctl00_ContentPlaceHolder1_txtValorPropiedad").value);
    var valor2 = parseInt(document.getElementById("ctl00_ContentPlaceHolder1_txtMontoCredito").value);
    var valor3 = parseInt(document.getElementById("ctl00_ContentPlaceHolder1_txtFinanciamiento").value);

    if (campo=="1" && valor1     > 0) //Valor Propiedad
    {
        if (valor2 > 0) //Calcula Financiamiento
        {
            valor3 = Math.round(valor2*100/valor1);
        }
        else
        {
            if (valor3 > 0) //Calcula Monto Crédito
            {
                valor2 = Math.round(valor1*valor3/100);
            }
        }
        
    }
    if (campo=="2" && valor2 > 0) //Monto Crédito
    {
        if (valor1 > 0) //Calcula Financiamiento
        {
            valor3 = Math.round(valor2*100/valor1);
        }
        else
        {
            if (valor3   > 0) //Valor Propiedad
            {
                valor1 = Math.round(valor2*100/valor3);
            }    
        }
    }
    if (campo=="3" && valor3 > 0) // Financiamiento
    {
        if (valor1 > 0) //Calcula Monto Credito
        {
            valor2 = Math.round(valor1*valor3/100);
        }
        else
        {
            if (valor2 > 0) //Valor Propiedad
            {
                valor1 = Math.round(valor2*100/valor3);
            }    
        }
    }
    
    document.getElementById("ctl00_ContentPlaceHolder1_txtValorPropiedad").value = valor1>0?valor1:"";
    document.getElementById("ctl00_ContentPlaceHolder1_txtMontoCredito").value = valor2>0?valor2:""; 
    document.getElementById("ctl00_ContentPlaceHolder1_txtFinanciamiento").value = valor3>0?valor3:"";
}

function ValidaRentas()
{
    var _return = true;
    
    if (cboRentas.GetSelectedItem().value == '0')
    {
        alert("Debe seleccionar Renta");
        _return = false;
    }        
    
    return _return   
    
}

function vRut(s, e)
{
    if (e.value!=null)
    {
        e.value = formato_rut(e.value, true);
	    var tmpstr = "";
	    var intlargo = e.value;
	    if (intlargo.length> 0)
	    {
		    crut = e.value
		    largo = crut.length;
		    if ( largo <2 )
		    {
			    return false;
		    }
		    for ( i=0; i <crut.length ; i++ )
		    if ( crut.charAt(i) != ' ' && crut.charAt(i) != '.' && crut.charAt(i) != '-' )
		    {
			    tmpstr = tmpstr + crut.charAt(i);
		    }
		    rut = tmpstr;
		    crut=tmpstr;
		    largo = crut.length;
    	
		    if ( largo> 2 )
			    rut = crut.substring(0, largo - 1);
		    else
			    rut = crut.charAt(0);
    	
		    dv = crut.charAt(largo-1);
    	
		    if ( rut == null || dv == null )
		    return false;
    	
		    var dvr = '0';
		    suma = 0;
		    mul  = 2;
    	
		    for (i= rut.length-1 ; i>= 0; i--)
		    {
			    suma = suma + rut.charAt(i) * mul;
			    if (mul == 7)
				    mul = 2;
			    else
				    mul++;
		    }
    	
		    res = suma % 11;
		    if (res==1)
			    dvr = 'k';
		    else if (res==0)
			    dvr = '0';
		    else
		    {
			    dvi = 11-res;
			    dvr = dvi + "";
		    }
    	
		    if ( dvr != dv.toLowerCase() )
		    {
			    return false;
		    }
		    
		    return true;
	    }
	}
}

function formato_rut(texto, activo) 
{ 
    var invertido = ""; 
    var dtexto = ""; 
    var cnt = 0; 
    var i=0; 
    var j=0; 
    var largo = "";     
    if (activo && texto!=null) { 
          texto = formato_rut(texto, false) 
          largo = texto.length; 
          for ( i=(largo-1),j=0; i>=0; i--,j++ ) 
            invertido = invertido + texto.charAt(i);           
          dtexto = dtexto + invertido.charAt(0); 
          dtexto = dtexto + '-';           
          for ( i=1,j=2; i<largo; i++,j++ ) 
          { 
            if ( cnt == 3 ) 
            { 
              dtexto = dtexto + '.'; 
              j++; 
              dtexto = dtexto + invertido.charAt(i); 
              cnt = 1; 
            } 
            else 
            {  
              dtexto = dtexto + invertido.charAt(i); 
              cnt++; 
            } 
          } 
          invertido = ""; 
          for ( i=(dtexto.length-1),j=0; i>=0; i--,j++ ) 
            invertido = invertido + dtexto.charAt(i); 
          if (invertido == '-') invertido = "" 
          texto = invertido; 
    } else { 
        var tmpstr = ""; 
        if(texto!=null)
        {
            for ( i=0; i < texto.length ; i++ ) 
            if ( texto.charAt(i) != ' ' && texto.charAt(i) != '.' && texto.charAt(i) != '-' ) 
                tmpstr = tmpstr + texto.charAt(i); 
            texto = tmpstr; 
        }
    } 
    return texto; 
} 

