﻿n=2;//indizador de visualizar imagen

function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return scrOfY ;
}

function posicioy() {y = getScrollXY();   }

function scrollit(id) {
 var obj=document.getElementById(id);
 obj.style.display='none';
 self.scroll(0,y)
}

function reemplazar_cadena(pos,caracter)
{
 var cadena=document.form.opt.value;


var inicio =cadena.slice(0,pos);
 var final=cadena.slice(pos+1);
 var resultado=inicio+caracter+final;
 document.form.ord.value=caracter;
 document.form.opt.value = resultado;

}

  function ordenar(valu) {

   // document.form.plana.value=1;                     cadena=cadena.replace(/ú/g,"u")
    if (valu=='Fecha'){
    if (document.form.opt.value.charAt(0)=='1')  {reemplazar_cadena(0,'0'); }
    else {reemplazar_cadena(0,'1'); }
    }
     if (valu=='numpro'){
      if (document.form.opt.value.charAt(1)=='1')  {reemplazar_cadena(1,'0'); }
    else {reemplazar_cadena(1,'1'); }
    }
      if (valu=='preu'){
     if (document.form.opt.value.charAt(2)=='1')  {reemplazar_cadena(2,'0'); }
    else {reemplazar_cadena(2,'1'); }
    }
     if (valu=='marca'){
      if (document.form.opt.value.charAt(3)=='1')  {reemplazar_cadena(3,'0'); }
    else {reemplazar_cadena(3,'1'); }
    }
     if (valu=='model'){
     if (document.form.opt.value.charAt(4)=='1')  {reemplazar_cadena(4,'0'); }
    else {reemplazar_cadena(4,'1'); }
    }
     if (valu=='va'){
      if (document.form.opt.value.charAt(5)=='1')  {reemplazar_cadena(5,'0'); }
    else {reemplazar_cadena(5,'1'); }
    }
    if (valu=='ascensor'){
      if (document.form.opt.value.charAt(6)=='1')  {reemplazar_cadena(6,'0'); }
    else {reemplazar_cadena(6,'1'); }
    }
    if (valu=='pd'){
     if (document.form.opt.value.charAt(7)=='1')  {reemplazar_cadena(7,'0'); }
    else {reemplazar_cadena(7,'1'); }
    }
    if (valu=='pa'){
      if (document.form.opt.value.charAt(8)=='1')  {reemplazar_cadena(8,'0'); }
    else {reemplazar_cadena(8,'1'); }
    }
     if (valu != '')
     {
        document.form.listar.value=valu;
        document.form.submit();
     }
    }

function agregar_favoritos(){
   if ((navigator.appName=="Microsoft Internet Explorer") && (parseInt(navigator.appVersion)>=4)) {
      var url="http://Todo-Anuncios.com/";
      var titulo=" Anuncios Clasificados";
      window.external.AddFavorite(url,titulo);
   }
   else {
      if(navigator.appName == "Netscape")
         alert ("Presione Crtl+D para agregar este sitio en sus Bookmarks");
   }
}

function ir(enlace)
    {
     var lk=enlace;
    document.location.href=lk;
    }

function visualizar(x,z,a,titulo){
if (a != 0) document.getElementById(z+"_0").src = titulo+'foto'+a+'.jpg'
else {
if (n<=x) n=n+1;
if (n > x) n=1;
 document.getElementById(z+"_0").src = titulo+'foto'+n+'.jpg'
}
}

function precarga(pais){
image_logo =  new Image(); image_logo.src = 'images/image.gif';   
switch (pais) {
case "es": {
foto1 = new Image();foto1.src = 'prov/01.gif';
foto2 = new Image();foto2.src = 'prov/02.gif';
foto3 = new Image();foto3.src = 'prov/03.gif';
foto4 = new Image();foto4.src = 'prov/04.gif';
foto5 = new Image();foto5.src = 'prov/05.gif';
foto5 = new Image();foto5.src = 'prov/05.gif';
foto7 = new Image();foto7.src = 'prov/07.gif';
foto8 = new Image();foto8.src = 'prov/08.gif';
foto9 = new Image();foto9.src = 'prov/09.gif';
foto11 = new Image();foto11.src = 'prov/011.gif';
foto12 = new Image();foto12.src = 'prov/012.gif';
foto13 = new Image();foto13.src = 'prov/013.gif';
foto14 = new Image();foto14.src = 'prov/014.gif';
foto15 = new Image();foto15.src = 'prov/015.gif';
foto16 = new Image();foto16.src = 'prov/016.gif';
foto17 = new Image();foto17.src = 'prov/017.gif';
foto18 = new Image();foto18.src = 'prov/018.gif';
foto19 = new Image();foto19.src = 'prov/019.gif';
foto20 = new Image();foto20.src = 'prov/020.gif';
foto21 = new Image();foto21.src = 'prov/021.gif';
foto28 = new Image();foto28.src = 'prov/028.gif';
foto29 = new Image();foto29.src = 'prov/029.gif';
foto30 = new Image();foto30.src = 'prov/030.gif';
foto31 = new Image();foto31.src = 'prov/031.gif';
foto32 = new Image();foto32.src = 'prov/032.gif';
foto33 = new Image();foto33.src = 'prov/033.gif';
foto34 = new Image();foto34.src = 'prov/034.gif';
foto36 = new Image();foto36.src = 'prov/036.gif';
foto38 = new Image();foto38.src = 'prov/038.gif';
foto40 = new Image();foto40.src = 'prov/040.gif';
foto41 = new Image();foto41.src = 'prov/041.gif';
foto42 = new Image();foto42.src = 'prov/042.gif';
foto43 = new Image();foto43.src = 'prov/043.gif';
foto44 = new Image();foto44.src = 'prov/044.gif';
foto45 = new Image();foto45.src = 'prov/045.gif';
foto47 = new Image();foto47.src = 'prov/047.gif';
foto49 = new Image();foto49.src = 'prov/049.gif';
foto50 = new Image();foto50.src = 'prov/050.gif';
foto51 = new Image();foto51.src = 'prov/051.gif';
foto52 = new Image();foto52.src = 'prov/052.gif';
foto53 = new Image();foto53.src = 'prov/053.gif';
foto54 = new Image();foto54.src = 'prov/054.gif';
foto55 = new Image();foto55.src = 'prov/055.gif';
foto56 = new Image();foto56.src = 'prov/056.gif';
foto60 = new Image();foto60.src = 'prov/060.gif';
foto61 = new Image();foto61.src = 'prov/061.gif';
foto62 = new Image();foto62.src = 'prov/062.gif';
foto63 = new Image();foto63.src = 'prov/063.gif';
foto64 = new Image();foto64.src = 'prov/064.gif';
foto65 = new Image();foto65.src = 'prov/065.gif';
foto66 = new Image();foto66.src = 'prov/066.gif';
foto68 = new Image();foto68.src = 'prov/068.gif';
foto69 = new Image();foto69.src = 'prov/069.gif';
foto70 = new Image();foto70.src = 'prov/070.gif';
foto73 = new Image();foto73.src = 'prov/073.gif';
foto74 = new Image();foto74.src = 'prov/074.gif';
foto2100 = new Image();foto2100.src = 'prov/02100.gif';
espana5 = new Image();espana5.src = 'images/espana5.gif';
}
break;
}
}

function inserta_entra(){
    document.getElementById("inserta").src=foto_inserta2.src
  }

  function inserta_sale(){
    document.getElementById("inserta").src=foto_inserta.src

  }


 function tanca_prov(){
  document.getElementById("map1").src='images/espana5.gif';
  hideddrivetip()
 }
 function mostra_prov(zone, zonetext, cuantos){
 ddrivetip('Anuncios en '+zonetext,"#E0FFFF",120)
 eval('document.getElementById("map2").src=foto'+zone+'.src');
 if(zonetext){
 zonetext = zonetext;
 }
 }


function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thecolor, thewidth){
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
enabletip=true
return false
}
}

function positiontip(e){
if (enabletip){
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20

var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth)
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
else if (curX<leftedge)
tipobj.style.left="5px"
else
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetxpoint+"px"

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight)
tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
else
tipobj.style.top=curY+offsetypoint+"px"
tipobj.style.visibility="visible"
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}

function html_fotos(foto,id,num_fotos) {
 var txt = '<div id="tabla_fotos" style="padding-top:1px">'
if (num_fotos>1) for (i=1;i <= num_fotos;i++){
txt += '<div id="div-imagen-0'+i+'div-imagen" style="z-index:0"><a  rel="nofollow" href="javascript:visualizar('+num_fotos+','+id+','+i+',\''+foto+'\')" ><img id=\''+id+'_'+i+'\'  width=\'70px\' height=\'70px\'  src=\''+foto+'dim_foto'+i+'.jpg\' onmouseover=\'this.style.border="2px solid #0099FF" ;\'  onmouseout=\'this.style.border="1px solid #0099FF" ;\' style=\'background-color:#FFFFDD;border:1px solid #0099FF ;padding:6px\' /></a></div>';
}
txt +='</div>'
if (num_fotos>1)txt +='<div style="padding-top:90px">';
else txt +='<div style="padding:1px 20px 20px 20px">'
txt += '<div class="div-imagen-00div-imagen" ><a  href="javascript:visualizar('+num_fotos+','+id+',0,\''+foto+'\')\"><img  id=\''+id+'_0\'   onmouseover=\'this.style.border="2px solid #0099FF" ;if (this.width  > 520) this.width=520;\'  onmouseout=\'this.style.border="1px solid #0099FF"\'  src="'+foto+'foto1.jpg"  style=\'background-color:#FFFFDD;border:1px solid #0099FF ;padding:6px\'/></a></div></div> ';
return txt;
}

function iner_fotos(foto,id,num_fotos) {
if (document.getElementById(id).style.display == 'block') {
obj = document.getElementById(id+'_');
if (num_fotos > 0) obj.innerHTML = html_fotos(foto,id,num_fotos) ;
}
}
function trobar_mirats(id) {
var idd= String(id)
stri = (getCookie('t_a_mirats'))
pos = stri.indexOf (idd);
if (pos >= 0)  return " VISTO ";  else return ""
}

function visto (id) {
if (document.getElementById(id).style.display != 'none' ) {
document.getElementById('contador').ident.value=id;
document.getElementById('contador').submit();
obj = document.getElementById(id+'__');
obj.innerHTML = 'VISTO' ;
cookie_mirats (id)
}
}

function cookie_mirats (id) {
   var expdate = new Date();
            expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 365));
if (!getCookie('t_a_mirats')) setCookie('t_a_mirats',id,expdate)
else
 {
    var cok = getCookie('t_a_mirats')+'|'+id;
    setCookie('t_a_mirats',cok,expdate)
 }
}


function cookie_1 (id) {
   var expdate = new Date();
// alert(document.getElementById('info_anunci_inf3'+id).className)
 expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 365));
if (!getCookie('t_a_guardats')) setCookie('t_a_guardats',id,expdate)
else
 {
    var cok = getCookie('t_a_guardats')+'|'+id;
    setCookie('t_a_guardats',cok,expdate)
 }
document.getElementById('info_anunci_inf3'+id).className='info_anunci_inf4';

}
function veure_tel(tel,id){
document.getElementById('info_anunci_inf5'+id).className='info_anunci_inf6';
document.getElementById('info_anunci_inf5'+id).innerHTML=tel;
}


// Crea Cookie
function setCookie(cookieName,cookieValue,expires,path,domain,secure) {
document.cookie=
escape(cookieName)+'='+escape(cookieValue)
+(expires?'; EXPIRES='+expires.toGMTString():'')
+(path?'; PATH='+path:'')
+(domain?'; DOMAIN='+domain:'')
+(secure?'; SECURE':'');
}
// Lee datos de Cookie
function getCookie(variable) {
 var pos_ini, pos_fin, pos, mycook = document.cookie;
  if (!mycook) return "";
  pos = mycook.indexOf(variable);
  if ( pos == -1 ) return "";
   pos_ini = mycook.indexOf("=", pos);
    if ( pos_ini != (pos + variable.length) ) return "";
     pos_fin = mycook.indexOf(";", pos_ini) - 1;
      if (pos_fin == -2) pos_fin = mycook.length - 1;
  return unescape( mycook.substr(pos_ini+1,(pos_fin-pos_ini)) );
  }

  function DeleteCookie(cok1) {
  alert (" borrando cookie "+cok1);
  var fecha_cad = new Date();
   var cok = '';
  setCookie(variable,cok,fecha_cad)
   }

 function e_correo(correu,id){
 alert(correu+id)
  }

 function tornar_guardats(variable) {
 return getCookie(variable);
 }


function showfloatie(thetext, e, optbgColor, optWidth, optHeight,id){
var floatobj=document.getElementById("dhtmlfloatie"+id)
floatobj.style.display="block"
floatobj.style.backgroundColor=optbgColor;
floatobj.style.width=optWidth+"px";
floatobj.style.height=optHeight+"px"
floatobj.style.rigth="2px"
floatobj.innerHTML=thetext
}




