Professional Documents
Culture Documents
function newAjax() {
try {
return new window.XMLHttpRequest();
} catch ( e ) {}
try {
return new ActiveXObject("Msxml2.XMLHTTP");
} catch ( e ) {}
try {
return new ActiveXObject("Microsoft.XMLHTTP");
} catch ( e ) {}
return false;
}
function prepvari() {
var res = '';
var va = ['desde', 'hasta', 'dias', 'demanda', 'orden', 'dormd', 'dormh',
'banosd', 'banosh', 'm2d', 'm2h', 'playa', 'vendedor', 'm2', 'marca', 'modelo',
'anod', 'anoh', 'ccd', 'cch', 'color', 'kms', 'combustible', 'eslorad', 'eslorah',
'memoria', 'discoduro', 'operador', 'talla', 'cajacambio', 'concv', 'tipog',
'puertas', 'provincia_origen', 'provincia_destino', 'origen_provincia_id',
'origen_provincia', 'origen_localidad_id', 'origen_localidad', 'origen_zona_id',
'origen_zona', 'destino_provincia_id', 'destino_provincia', 'destino_localidad_id',
'destino_localidad', 'destino_zona_id', 'destino_zona', 'regularidad',
'numero_plazas', 'fecha_compartir_coche','potencia', 'geox', 'geoy', 'geodist'];
for (var i = 0; i < va.length; i++) {
if ((document.getElementById(va[i])) &&
(document.getElementById(va[i]).value != '') &&
(document.getElementById(va[i]).value != 'hasta') &&
(document.getElementById(va[i]).value != 'desde') &&
(document.getElementById(va[i]).value != 'modelo')) {
if (res != '')res = res + '&';
res = res + va[i] + '=' +
unescape(encodeURIComponent(document.getElementById(va[i]).value));
}
}
if (res != "")res = '?' + res;
if (document.getElementById('palabras') &&
(document.getElementById('palabras').value != 'modelo')) res =
cabb(document.getElementById('palabras').value) + res;
return res;
}
function findMe(callback) {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(callback, function() {alert("No ha
sido posible localizarte")});
}
}
function cabb(busq){
busq = busq.toLowerCase();
var re =/[^áéíóúñüäëïöü@\._ça-z0-9]/gi;
busq = busq.replace(re, " ");re = / +/g;
busq = busq.replace(re, "-");re = /^-/;
busq = busq.replace(re, "");re = /-$/;
busq = busq.replace(re, "");
if (busq == " ")busq = "";
if (busq != '') busq = busq +'.htm';
return busq;
}
function cabc(dire){
document.getElementById('categoria').value=dire;
if((dire=='inmobiliaria')||(dire.substr(0,9)=='traspasos'))cabu();else
cargagen('/buscadores/camcat3.php?v2&cat='+dire,'busgen');
}
function cargagen(direc, spanid) {
var ajax = newAjax();
ajax.open("GET", direc, true);
ajax.onreadystatechange = function () {
if (ajax.readyState == 4) {
var o = document.getElementById(spanid);
o.innerHTML = ajax.responseText;
var arr = o.getElementsByTagName("script");
for (var n = 0; n < arr.length; n++)
eval(arr[n].innerHTML);
if (document.getElementById('palabrasAdBoxSingle')) {
document.getElementById('palabrasAdBoxSingle').value =
document.getElementById('palabras').value;
document.getElementById('palabrasAdBoxSingle').id = 'palabras';
}
if (document.getElementById('palabras')) {
var freeTextValue = document.getElementById('palabras').value;
document.getElementById('palabras').id = 'palabrasAdBoxSingle';
if (document.getElementById('palabras')) {
document.getElementById('palabras').value = freeTextValue;
}
}
if (document.getElementById('protmp')) {
var province = document.getElementById('protmp').value;
document.getElementById('protmp').id = 'protmpAdBoxSingle';
if (document.getElementById('protmp').value) {
document.getElementById('protmp').value = province;
}
}
document.getElementById("searchAdBoxAdvanced").style.display =
"block";
document.getElementById('searchAdBoxType').innerHTML = 'OCULTAR
FILTROS';
}
}
};
ajax.send(null);
}
function cabf(){
var cate=document.getElementById('categoria').value;
var prov=document.getElementById('provincia').value;
var dir='anuncios';if(cate!='')dir=cate;
if(prov != ''){
if(prov.indexOf('_cerca') == -1)
dir += '-en-' + prov;
else dir += '-en-' + prov.substr(0, prov.length - 6);
}
if(cate!='inmobiliaria'){
var url = '/'+dir+'/'+prepvari();
if(prov.indexOf('_cerca') != -1)
url += ((url.indexOf('?') == -1) ? '?' : '&') + 'cerca=s';
document.location=url;
}else{document.location='/'+dir+'/';}}
function camodel(este){
if(este=='otros'){
document.getElementById('categoria').value=document.getElementById('marca2').value;
document.getElementById('modelin').innerHTML = '<input
onkeydown="if(event.keyCode==13) cabu();" type=text
onfocus="if(this.value==\'modelo\')this.value=\'\';" id="palabras" maxlength="30"
size=11 class="imputs" value="modelo" tabindex="6" style="width:86%">';
}else if(este==''){
document.getElementById('categoria').value=document.getElementById('marca2').value;
cabu();
}else if(este!=''){
document.getElementById('categoria').value=este;
cabu();
}
}
function tienecadenalarga(cad){
var contz = 0;
var eslargo = false;
var longi = cad.length;
for(var k = 0; k < longi; k++){
if (cad.substring(k,k+1)==' ') contz = 0;else contz ++;
if (contz > 21) eslargo = true;
}
return eslargo;
}
function getCookie(sName){
var aCookie = document.cookie.split("; ");
for (var i=0; i < aCookie.length; i++)
{
var aCrumb = aCookie[i].split("=");
if (sName == aCrumb[0])
return unescape(aCrumb[1]);
}
return null;
}
function estaencookie(ide) {
var cook = getCookie('favoritos');
if (cook != null) {
var aCookie = cook.split(" ");
for (var i=0; i < aCookie.length; i++){
if (aCookie[i] == ide) return true;
}
}
return false;
}
function poncookie(ide){
ide = ide + '';
if (getCookie('favoritos') == null) {
//noinspection JSValidateTypes
document.cookie = 'favoritos=' + ide + '; expires=Thu, 2 Aug 2019 20:47:11
UTC; path=/';
}
else {
//noinspection JSValidateTypes
document.cookie = 'favoritos=' + getCookie('favoritos') + ' ' + ide + ';
expires=Thu, 2 Aug 2019 20:47:11 UTC; path=/';
}
}
function quitacookie(ide){
ide = ide + '';
ajax.onreadystatechange=function(){
if(ajax.readyState==4){
switch (ajax.responseText){
case 'ok':
// operación realizada correctamente (guardado en bbdd)... nada
más que hacer
break;
case 'error':
alert('Ha ocurrido un error. Inténtelo de nuevo más tarde.');
break;
default:
// usuario no logueado
if (poner){
poncookie(ide);
}else{
quitacookie(ide);
}
break;
}
if (ajax.response != 'error')
document.getElementById('fav' + ide).className = (poner ?
favBaseClass + ' ' + 'pagAnuFavButtonOn' : favBaseClass + ' ' +
'pagAnuFavButtonOff');
}
};
ajax.send(null);
}
function tmpof(ide){
ide += '';
ajax.onreadystatechange=function(){
if(ajax.readyState==4){
switch (ajax.responseText){
case 'ok':
// operación realizada correctamente (guardado en bbdd)... nada
más que hacer
break;
case 'error':
alert('Ha ocurrido un error. Inténtelo de nuevo más tarde.');
break;
default:
// usuario no logueado
if (poner){
poncookie(ide);
}else{
quitacookie(ide);
}
break;
}
if (ajax.response != 'error') {
if (poner) {
favouriteElement.className =
favouriteElement.className.replace('i1', 'i2');
favouriteElement.className =
favouriteElement.className.replace('icon-favourite', 'icon-favourite-fill');
} else {
favouriteElement.className =
favouriteElement.className.replace('i2', 'i1');
favouriteElement.className =
favouriteElement.className.replace('icon-favourite-fill', 'icon-favourite');
}
}
}
};
ajax.send(null);
}
function openImageDialog(ide,pos,mufo,svr,svrFotos){
document.getElementById('wind').innerHTML = '<div id=popf
onclick="cerrarw()"></div><div id=popw><div
id=imgw></div></div>';renderBigPicture(ide,pos,mufo,svr,svrFotos);pospop(640);
}
function renderBigPicture(ide,pos,multifoto,svr){
pos = sanitizePosition(pos,multifoto);
var sig = pos + 1;
ide = ide + '';multifoto = multifoto + '';
var images = ImageStore.getImagesBy(ide);
var sal = createGalleryHeader(multifoto, ide, pos, svr, images);
var varspan = document.getElementById('imgw');
if(varspan == null) varspan = document.getElementById('imgg');
varspan.innerHTML=sal;
// console.log(multifoto.substring(sig-1,sig));
// console.log(sig-1);
// console.log(sig);
// if(sig<=multifoto.length) setTimeout(function(){var i=new
Image();i.src=images[multifoto.substring(sig-1,sig)]}, 100);
}
function solonumeros(e){
if (navigator.appName=="Microsoft Internet Explorer"){
var codigo=e.keyCode;
return !((codigo > 58) || (codigo < 47));
}}
function qcero(c){
var i = c.length-1;
var s = false;
var h;
do{
var ch = c.substring(i, i + 1 );
if (ch == ".") h = i;
if ((ch != "0")&&(ch != ".")) s = true;
i--;
}while((i>0) && !(s));
h++;
return h;
}
function visu(c) {
var h = qcero(c);
var j=0;
var x = (c=='0.0.0.0') ? 0 : 30;
if(typeof m != "undefined"){
for (var i=0;i<m.length;i++){
if ( (c.substring(0, h ) == m[i].substring(0, h )) && (c != m[i]) ) {
setTimeout("document.getElementById('"+m[i]+"').style.display =
'';",x*j);
j++;
}
}
for (i=0;i<n.length;i++){
var o = n[i];
if (o != c) {
h = qcero(o);
var k=0;
for (l=0;l<m.length;l++){
if ( (o.substring(0, h ) == m[l].substring(0, h )) &&
(o.substring(0, h ) != sel.substring(0, h )) && (o != m[l]) ) {
setTimeout("document.getElementById('"+m[l]+"').style.display =
'none';",x*k);
k++;
}
}
}
}
}
}
function getDocH(){
var db = document.body;var dde = document.documentElement;
return Math.max(db.scrollHeight, dde.scrollHeight, db.offsetHeight,
dde.offsetHeight, db.clientHeight, dde.clientHeight)
}
function getDocW(){
var db = document.body;var dde = document.documentElement;
return Math.max(db.scrollWidth, dde.scrollWidth, db.offsetWidth, dde.offsetWidth,
db.clientWidth, dde.clientWidth)
}
function cerrarw(){document.getElementById('wind').innerHTML='';}
function od(id, usePhoneProxy){ventana("datos-contacto/?usePhoneProxy=" +
usePhoneProxy + "&id=",id);}
function op(id){ventana("email/enviar_a_un_amigo.php?id=",id);}
function ox(id){ventana("denunciar/marcar.php?id=",id);}
function om (ide){window.open('/mapa/?id='+ide, '', 'toolbar=no, scrollbars=no,
width=670, height=470');}
function mueveba(d){var j=0;var x=30;for (var i=0;i<20;i++)
{setTimeout("document.getElementById('dbus').scrollLeft =
document.getElementById('dbus').scrollLeft"+d+";",x*j);j++;}}
function cn (nombre){document.getElementById('pr').value = nombre;}
function abre(dir){document.location = "/"+dir;}
function addToFavorites() {
var parser = document.createElement('a');
parser.href = location.href;
var url = "http://" + parser.hostname;
var name = parser.hostname;
if (window.sidebar && window.sidebar.addPanel) { // Mozilla Firefox < 23
window.sidebar.addPanel(name, url, "");
} else if (window.external && window.external.AddFavorite) { // IE
window.external.AddFavorite(url, name);
} else if (window.opera && window.print) {
window.external.AddFavorite(url, name);
}else alert("Pulsa ctrl+D para añadir " + parser.hostname.replace("www.", "") +
" a tus favoritos");
}
function cpr(q){
var patt = /\d\d\d\d\d\d\d\d.htm/i;
var sel = 'part';
var urlp = top.location.href;
if(q==1) sel = 'prof';
if(! patt.test(urlp)){
if(urlp.indexOf('?') > 20){
urlp = urlp+'&vendedor='+sel;
}else{
urlp = urlp+'?vendedor='+sel;
}
top.location.href = urlp;
}
}
function isValidDate(date) {
var matches = /^(\d{2})[-\/](\d{2})[-\/](\d{4})$/.exec(date);
if (matches == null) return false;
var d = matches[1];
var m = matches[2] - 1;
var y = matches[3];
var composedDate = new Date(y, m, d);
return composedDate.getDate() == d &&
composedDate.getMonth() == m &&
composedDate.getFullYear() == y;
}
function removeChildren(element) {
while (element.hasChildNodes()){
element.removeChild(element.lastChild);
}
}
removeChildren(document.getElementById('lista_ajax_list'));
switch (type) {
default:
case 'zona':
document.getElementById(preffix + "_div_zona").className = '';
break;
case 'localidad':
document.getElementById(preffix + "_div_zona").className = 'oculto';
var zona = document.getElementById(preffix + '_zona')
zona.value = '';
var zona_id = document.getElementById(preffix + '_zona_id')
zona_id.value = '';
ajaxSearchLoc(targetValueHolderId, null, 'zona_id', 'zona', preffix,
canSkip);
break;
}
}
switch (type) {
default:
case 'localidad':
var ajaxUrl = '/autocomplete/buscaLocalidad.php?provincia=' + provincia
+ '&localidad=' + localzona.value;
break;
case 'zona':
var ajaxUrl = '/autocomplete/buscaZonas.php?idloc=' + localzona.value;
break;
}
localTargetValueHolderId = targetValueHolderId;
ajax.open("GET", ajaxUrl, false);
ajax.onreadystatechange=function() {
if (ajax.readyState == 4) {
removeChildren(lista_ajax_list);
if (ajax.responseText.length > 0) {
var rows = ajax.responseText.split('\n');
if(rows.length == 1) {
var loc = rows[0].split(';');
setLocValueFromAjaxList(targetValueHolderId, loc[0], type,
loc[1] , type, preffix, canSkip);
}
else {
document.getElementById(preffix + "_div_zona").className =
'oculto';
var zona = document.getElementById(preffix + '_zona')
zona.value = '';
var zona_id = document.getElementById(preffix + '_zona_id')
zona_id.value = '';
lista_ajax_list.appendChild(title);
lista_ajax_list.appendChild(document.createElement('br'));
lista_ajax_list.appendChild(document.createElement('br'));
function processAjaxCarModels(carModels){
if (document.getElementById('carmodels')) {
document.getElementById('carmodels').innerHTML = carModels;
}
}
function getCarModels(carBrand){
document.getElementById('categoria').value=carBrand;
var urlc = '/buscadores/movil/getCarModels.php?carBrand=' +
encodeURIComponent(carBrand);
var ajax = newAjax();
ajax.open("GET", urlc, true);
ajax.onreadystatechange = function () {
if (ajax.readyState == 4) {
processAjaxCarModels(ajax.responseText);
}
};
ajax.send(null);
}
function setCarModel(carModel){
if(carModel=='otros'){
document.getElementById('categoria').value=document.getElementById('marca2').value;
document.getElementById('modelin').innerHTML = '<input
onkeydown="if(event.keyCode==13) cabu();" type=text
onfocus="if(this.value==\'modelo\')this.value=\'\';" id="palabras"
placeholder="modelo" maxlength=30 class="imputs" value="modelo" tabindex="6"
style="width:94%">';
}else if(carModel==''){
document.getElementById('categoria').value=document.getElementById('marca2').value;
}else if(carModel!=''){
document.getElementById('categoria').value=carModel;
}
}
function toggleExtraDescription(id) {
var splitId = id.split("-");
if (document.getElementById("readMoreTx-" + splitId[1]).className ==
"readMoreHidden") {
document.getElementById("readMoreTx-" + splitId[1]).className =
"readMoreShown";
document.getElementById(id).innerHTML = " Leer menos";
}
else {
document.getElementById("readMoreTx-" + splitId[1]).className =
"readMoreHidden";
document.getElementById(id).innerHTML = " ... Leer más";
}
}