function checkTimeOut(){ limpiarTimeOuts(); try { panelInfo.hide();}
catch (e) { ;}
try { panelEspere.hide();}
catch (e) { ;}
try { myLoadingControl.hideButton_();}
catch (e) { ;}
alert("Parece que el servidor está tardando demasiado. Pruebe dentro de unos instantes.");}
function beginTimeOut(seconds){ timeOutID = window.setTimeout("checkTimeOut()", seconds * 1000); return timeOutID;}
function endTimeOut(timeOutID){ if (timeOutID != null)
window.clearTimeout(timeOutID);}
function atp_setCurrentYPos(pos){ try { if (document.body && document.body.scrollTop)
document.body.scrollTop = pos; if (document.documentElement && document.documentElement.scrollTop)
document.documentElement.scrollTop = pos; if (window.pageYOffset)
window.pageYOffset = pos;}
catch (e) { ;}
}
function myDivHeight(el){ divHeight = 0; if (el) { if (el.offsetHeight) { divHeight = el.offsetHeight;}
else
if (el.style.pixelHeight) { divHeight = el.style.pixelHeight;}
}
return divHeight;}
function random(min, max){ var valor = 0; escala = max - min; valor = Math.random() * escala; valor = Math.floor(valor); return min + valor;}
function getXY(e){ e = e || window.event; var cursor = { x: 0, y: 0
}; if (e.pageX || e.pageY) { cursor.x = e.pageX; cursor.y = e.pageY;}
else { var de = document.documentElement; var b = document.body; cursor.x = e.clientX + (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0); cursor.y = e.clientY + (de.scrollTop || b.scrollTop) - (de.clientTop || 0);}
return cursor;}
function ATPaTipoOracion(s){ var re = new RegExp("[ \t][ \t]+", "g"); var texto = s.replace(re, " "); var frases = texto.split('. '); for (var i = 0; i < frases.length; i++)
frases[i] = frases[i].slice(0, 1).toUpperCase() + frases[i].slice(1).toLowerCase(); alert(frases.join('. '));}
String.prototype.ATPaTipoOracion = function(){ var re = new RegExp("[ \t][ \t]+", "g"); var texto = this.replace(re, " "); var frases = texto.split('. '); for (var i = 0; i < frases.length; i++)
frases[i] = frases[i].slice(0, 1).toUpperCase() + frases[i].slice(1).toLowerCase(); return frases.join('. ');}
function ATPescape(data){ return escape(data);}
function validar(e){ tecla = (document.all) ? e.keyCode : e.which; if (tecla == 8)
return true; if (tecla == 9)
return true; if (tecla == 0)
return true; pattern = /^[0-9]*$/; te = String.fromCharCode(tecla); return pattern.test(te);}
function submitBusqueda(e){ tecla = (document.all) ? e.keyCode : e.which; if (tecla == 13)
buscarInmuebles();}
function Mod(X, Y){ return X - Math.floor(X / Y) * Y;}
function ATP_alternateClass(classPrefix, numberOfClasses){ this.alternateCount = 1; this.classPrefix = classPrefix; this.numberOfClasses = numberOfClasses;}
ATP_alternateClass.prototype.alternate = function(){ var indice = Mod(++this.alternateCount, this.numberOfClasses) + 1; var alt = this.classPrefix + indice; return alt;}
function getIconInmueble(precio,paralista){ var image = ""; var sufijo = ""; var p1, p2, p3, p4; var tp; if (parent.getTipoOperacionBusqueda)
tp = parent.getTipoOperacionBusqueda(); else
tp = tipoOperacionBusqueda; if (tp == "V"){ p1 = 100000; p2 = 200000; p3 = 300000; p4 = 400000;}else{ p1 = 200; p2 = 400; p3 = 500; p4 = 600;}
if (paralista == true)
sufijo = "d"; if (precio == 0)
image = "/img/icons/sin_precio" + sufijo + ".png"; else
if (precio < p1)
image = "/img/icons/mm_20_purple" + sufijo + ".png"; else
if (precio < p2)
image = "/img/icons/mm_20_green" + sufijo + ".png"; else
if (precio < p3)
image = "/img/icons/mm_20_blue" + sufijo + ".png"; else
if (precio < p4)
image = "/img/icons/mm_20_yellow" + sufijo + ".png"; else
image = "/img/icons/mm_20_red" + sufijo + ".png"; return image;}
function readCookie(name){ var nameEQ = name + "="; var ca = document.cookie.split(';'); for (var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ')
c = c.substring(1, c.length); if (c.indexOf(nameEQ) == 0)
return c.substring(nameEQ.length, c.length);}
return null;}
function createCookie(name, value, days){ if (days) { var date = new Date(); date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); var expires = "; expires=" + date.toGMTString();}
else
var expires = ""; document.cookie = name + "=" + value + expires + "; path=/";}
function cargarIndex(url, id){ createCookie("mostrarPanel", "s"); createCookie("idmostrado", id); document.location.href = url;}
function getPrecio(quePrecio){ if (quePrecio > 0) { var precio_final = formatPrecio(quePrecio); var precio_pts = Math.round(parseInt(quePrecio) * 166.386, 0).toString(); var precio_t = formatPrecio(precio_pts) + " pts";}
else { var precio_final = _t_price_consult; var precio_t = "";}
var p = { precio_final : precio_final, precio_t: precio_t
}
return p;}
function formatPrecio(precio){ var precio_string = precio.toString(); var precio_final = ""; var ind = 0; for (var i = precio_string.length - 1; i >= 0; i--) { ind++; precio_final = precio_string.charAt(i) + precio_final; if ((ind == 3) && (i != 0)) { precio_final = "." + precio_final; ind = 0;}
}
return precio_final;}
function getPagina(){ var paginas = document.getElementById('iraPagina'); paginas.blur(); var valor = 0; for (var i = 0; i < paginas.length; i++) { if (paginas[i].selected) { valor = paginas[i].value; break;}
}
alert(document.getElementById('iraPagina').value); return valor;}
function atp_config(){ this.tipoPagina = 1; this.parametros = "";}
var atpCorreo = ""; var atpNombreCorreo = ""; var atpTelefonoCorreo = ""; function scrollCorreo(){ document.getElementById('scroll_datos').scrollTop = document.getElementById('scroll_datos').scrollHeight;}
function ATPcheckemail(mail){ var str = mail; var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (filter.test(str))
return true; else { var mensaje = _t_i_d; mensaje += _t_a_c.replace("//mail//", mail); if (confirm(mensaje))
return true; else
return false;}
}
function ATPMailWindow(id, referencia, frame){ var texto = ""; var ref_texto = "(" + _t_n_r + ")"; var tid = ""; if (arguments.length == 3)
tid = "_f"; if ((referencia != null) && (referencia.length > 0))
ref_texto = referencia; texto += "<form id='enviar_correo_info'>"; texto += "<div class='caja'>"; texto += "<span class='alt1'>" + _t_mail + " (" + _t_optional + "): </span><input type='text' style='width:300px;' id='ATP_from" + tid + "' value='" + unescape(atpCorreo) + "'><br />"; texto += "<span class='alt1'>" + _t_name + " (" + _t_mandatory + "): </span><input type='text' style='width:200px;' id='ATP_nombre" + tid + "' value='" + unescape(atpNombreCorreo) + "'><br />"; texto += "<span class='alt1'>" + _t_phone + " (" + _t_mandatory + "): </span><input type='text' style='width:200px;' id='ATP_tel" + tid + "' value='" + unescape(atpTelefonoCorreo) + "'><br />"; texto += "<span class='alt1'>" + _t_subject + ":</span> <span class='alt2'>" + _t_m_d + "</span><span class='alt1'>" + ref_texto + "</span></div>"; texto += "<textarea  style='margin: 10px;padding: 10px;' rows=8 id='ATP_body" + tid + "' cols=48>" + _t_m_b + "</textarea>"; texto += "<br /><input type='checkbox' id='ATP_acepto" + tid + "' name='ATP_acepto" + tid + "' value='s'><a href='/aviso_legal.php' target='_blank'>" + _t_acepto + "</a><br />"; if (arguments.length == 3)
texto += "<br /><input type='button' class='btn'  style='margin: 10px;' value='" + _t_m_s + "' id='send_mail" + tid + "' name='send_mail' onclick=\"javascript:ATPSendMail(" + id + ",true);\">"; else
texto += "<br /><input type='button' class='btn'  style='margin: 10px;' value='" + _t_m_s + "' id='send_mail" + tid + "' name='send_mail' onclick=\"javascript:ATPSendMail(" + id + ");\">"; texto += "</form>"; return texto;}
function ATPSendMail(idInmueble, frame){ var tid = ""; if (arguments.length == 2)
tid = "_f"; var correo = document.getElementById("ATP_from" + tid).value; var cuerpo = document.getElementById("ATP_body" + tid).value; var tel = document.getElementById("ATP_tel" + tid).value; var nombre = document.getElementById("ATP_nombre" + tid).value; var acepto = document.getElementById("ATP_acepto" + tid); if (!acepto.checked){ alert(_t_aviso_legal); return;}
if (correo.length > 0) { if (ATPcheckemail(correo) == false)
return;}
if (tel.length == 0) { alert(_t_t_mand); return;}
if (nombre.length == 0) { alert(_t_n_mand); return;}
if (cuerpo.length == 0) { alert(_t_m_mand); return;}
correo = ATPescape(correo); cuerpo = ATPescape(cuerpo); tel = ATPescape(tel); nombre = ATPescape(nombre); atpCorreo = correo; atpNombreCorreo = nombre; atpTelefonoCorreo = tel; panelCorreo.hide(); mostrarPanelEspere(_t_sending); endTimeOut(timeOutEnviarCorreo); timeOutEnviarCorreo = beginTimeOut(tiempoTimeOut); var request = '/inmuebles/' + atp_version + '/json/json_enviar_correo.php?ln=' + _t_l + '&ID=' + idInmueble + "&from=" + correo + "&body=" + cuerpo + "&nombre=" + nombre + "&tel=" + tel + "&timeout=" + timeOutEnviarCorreo; aObj = new JSONscriptRequest(request); aObj.buildScriptTag(); aObj.addScriptTag();}
function proccesRequestEnviarCorreo(jData){ if (timeOutEnviarCorreo) { if (jData != null) { if (jData.timeout != timeOutEnviarCorreo)
return;}
else { endTimeOut(timeOutEnviarCorreo); timeOutEnviarCorreo = null; return;}
endTimeOut(timeOutEnviarCorreo); timeOutEnviarCorreo = null;}
panelEspere.hide(); if (jData.resultado == 0)
alert(_t_success); else
alert(_t_no_success);}
function showMailWindow(ID){ try { panelInfo.hide();}
catch (e) { ;}
panelEspere.hide(); panelCorreo.setHeader(_t_m_t); var texto = ""; texto += "<div style='overflow:auto;' id='atp_mail'>"
texto += "<div style='text-align:left;' id='caja_correo'><div class='caption'>" + _t_m_c + "</div>"; texto += ATPMailWindow(ID, ""); texto += "</div>"; texto += "</div>"; panelEspere.hide(); panelCorreo.setBody(texto); panelCorreo.render(document.body); panelCorreo.show();}
var myScriptCounterHistory = 0; function JSONscriptRequestHistory(fullUrl){ this.fullUrl = fullUrl; this.noCacheIE = '&noCacheIE=' + (new Date()).getTime();}
JSONscriptRequestHistory.scriptCounter = 1; JSONscriptRequestHistory.prototype.buildScriptTag = function(){ var his = document.getElementById('frame_history'); his.src = this.fullUrl + this.noCacheIE + "&scriptid=" + myScriptCounterHistory;}
var myScriptCounter = 0; function JSONscriptRequest(fullUrl){ this.fullUrl = fullUrl; this.noCacheIE = '&noCacheIE=' + (new Date()).getTime(); this.headLoc = document.getElementsByTagName("head").item(0); this.scriptId = 'YJscriptId' + JSONscriptRequest.scriptCounter++;}
JSONscriptRequest.scriptCounter = 1; JSONscriptRequest.prototype.buildScriptTag = function(){ this.scriptObj = document.createElement("script"); this.scriptObj.setAttribute("type", "text/javascript"); this.scriptObj.setAttribute("src", this.fullUrl + this.noCacheIE + "&scriptid=" + myScriptCounter); this.scriptObj.setAttribute("id", this.scriptId);}
JSONscriptRequest.prototype.removeScriptTag = function(){ this.headLoc.removeChild(this.scriptObj);}
JSONscriptRequest.prototype.addScriptTag = function(){ this.headLoc.appendChild(this.scriptObj);}
var panelCorreo = new YAHOO.widget.Panel("ATP_correo", { width: '500px', height: '450px', fixedcenter: true, constraintoviewport: true, underlay: "none", close: true, visible: false, draggable: false, modal: false
}); var panelFotosPeq = new YAHOO.widget.Panel("panelFotosPeq", { close: false, visible: false, draggable: false, modal: false
}); var panelEspere = new YAHOO.widget.Panel("espere", { width: '300px', fixedcenter: true, constraintoviewport: true, underlay: "none", close: false, visible: false, draggable: true, modal: true
}); var panelTooltip = new YAHOO.widget.Panel("panelTooltip", { width: '150px', constraintoviewport: true, underlay: "none", close: false, visible: false, draggable: false, modal: false
}); function cerrarPanelMasInfo(){ panel.hide();}
var panel = new YAHOO.widget.Panel("datos_inmuebleID", { width: "750px", fixedcenter: true, iframe:false, constraintoviewport: true, underlay: "none", close: true, visible: false, draggable: true, modal: true
}); panelClose = function(type, args){ createCookie("mostrarPanel", "n"); var div = document.getElementById('datos_inmuebleID_c'); if (div) { div.style.zIndex = 0; div.style.top = "-10000px"; div.style.left = "-10000px";}
div = document.getElementById('caja_video'); if (div){ div.innerHTML = "";}
div = document.getElementById('caja_mapa'); if (div){ div.innerHTML = "";}
}
panelShow = function(type, args){ createCookie("mostrarPanel", "s"); createCookie("idmostrado", globalInmuebleID);}
panel.hideEvent.subscribe(panelClose); panel.showEvent.subscribe(panelShow); var panelImagen = new YAHOO.widget.Panel("fotos_grandes", { width: "350px", fixedcenter: true, constraintoviewport: true, underlay: "none", close: true, visible: false, draggable: true, modal: false
}); var panelVideo = new YAHOO.widget.Panel("panel_video", { width: "450px", height: "390px", fixedcenter: true, constraintoviewport: true, underlay: "none", close: true, visible: false, draggable: true, modal: true
}); panelVideoClose = function(type, args){ var div; div = document.getElementById('caja_video_panel'); if (div){ div.innerHTML = "";}
}
panelVideo.hideEvent.subscribe(panelVideoClose); function mostrarPanelVideo(id, idPromocion){ var param; if (id)
param = "id="+id; else
param = "id_promocion="+idPromocion; var texto = "<div id ='caja_video_panel'><iframe src='/" + atp_version + "/video.php?" + param + "' frameborder='0' scrolling='no' style='width:450px; height:370px;border:0; margin:0px; margin-bottom:10px; padding:0px;'></iframe></div>"; panelVideo.setHeader("Video"); panelVideo.setBody(texto); panelVideo.render(document.body); panelVideo.show();}
function mostrarPanelEspere(atp_header, texto){ var mensaje = ""; if (arguments.length > 1)
mensaje = texto; mensaje += " " + _t_please_wait; panelEspere.setHeader(atp_header); panelEspere.setBody("<div class='caja' style='margin:0px;'><div style='text-align:center'><img src='/img/indicator.gif'></div><span class='alt1'>" + mensaje + "</span></div>"); panelEspere.render(document.body); panelEspere.show();}

