window.onload= function () {
  
  var $= function (p) { return document.getElementById(p); };


  
// ****** MALDITO IE6 START

  (function () {

    var isIE= false /*@cc_on || true @*/;
    var isIE6= isIE /*@cc_on && !!(!window.XMLHttpRequest && document.compatMode) @*/;

    function fixPNG (img) {
      img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=" + img.src + ", sizingMethod='scale')";
      var src= img.src;
      img.src= src.substring(0, src.indexOf('.png'))+ ".gif";
    }

    if (isIE6) {
      //alert("IE6");
      var pngs= document.getElementsByTagName('IMG');
      var e, n= pngs.length;
      while (n--) {
        ((e= pngs[n]).src.indexOf('.png') >= 0) && fixPNG(e);
      }
    }

    var bs= document.body.style;
  
    (function zoom () {
      var s= parseInt(bs.fontSize, 10) || 100;
      if (isIE) {
        if (s > 100) {
          bs.fontSize= (s-= 2)+"%";
          setTimeout(zoom, 33);
        }
      } else {
        if (s < 116) {
          bs.fontSize= (s+= 2)+"%";
          setTimeout(zoom, 33);
        }
      }
    })();
    
  })();
  
// ****** MALDITO IE6 END






//************** FOTOS START

  var fotos= $('fotos').getElementsByTagName('img');
  var n= fotos.length;
  var efectoEnMarcha= false;
  var fotoEntra;
  var fotoActual= fotos[Math.floor(fotos.length * Math.random())];
  
  function efecto (i, o) {
    efectoEnMarcha= true;
    var porCiento= 0;
    var queEfecto= Math.floor(4*Math.random());
    
    switch (queEfecto) {
      case 0:
        i.style.left= "-100%";
        i.style.display= "";
    
        (function f0 () {
          porCiento+= 1;
          porCiento*= 1.5;
          if (porCiento < 100) {
            o.style.left= porCiento+ "%";
            i.style.left= "-"+ (100- porCiento)+ "%";
            setTimeout(f0, 33);
          } else {
            o.style.display= "none";
            i.style.left= o.style.left= "0";
            fotoActual= i;
            efectoEnMarcha= false;
          }
        })();
        break;
      
      case 1:
        i.style.left= "100%";
        i.style.display= "";
    
        (function f1 () {
          porCiento+= 1;
          porCiento*= 1.5;
          if (porCiento < 100) {
            o.style.left= "-"+ porCiento+ "%";
            i.style.left= (100- porCiento)+ "%";
            setTimeout(f1, 33);
          } else {
            o.style.display= "none";
            i.style.left= o.style.left= "0";
            fotoActual= i;
            efectoEnMarcha= false;
          }
        })();
        break;
        
      case 2:
        i.style.top= "100%";
        i.style.display= "";
    
        (function f2 () {
          porCiento+= 1;
          porCiento*= 1.5;
          if (porCiento < 100) {
            o.style.top= "-"+ porCiento+ "%";
            i.style.top= (100- porCiento)+ "%";
            setTimeout(f2, 33);
          } else {
            o.style.display= "none";
            i.style.top= o.style.top= "0";
            fotoActual= i;
            efectoEnMarcha= false;
          }
        })();
        break;
      
      case 3:
        i.style.top= "-100%";
        i.style.display= "";
    
        (function f3 () {
          porCiento+= 1;
          porCiento*= 1.5;
          if (porCiento < 100) {
            o.style.top= porCiento+ "%";
            i.style.top= "-"+ (100- porCiento)+ "%";
            setTimeout(f3, 33);
          } else {
            o.style.display= "none";
            i.style.top= o.style.top= "0";
            fotoActual= i;
            efectoEnMarcha= false;
          }
        })();
        break;
    }

  }
  
  while (n--) {
    var e= fotos[n];
    
    e.onclick= function () {
      if (efectoEnMarcha) { return; }
      var another;
      do {
        another= fotos[Math.floor(Math.random()*fotos.length)];
      } while (this === another)
      efecto(another, fotoActual);
    };
    
    e.style.position= "absolute";
    e.style.top= e.style.left= "0";
    e.style.display= "none";
  }
  
  fotoActual.style.display= "";

  setTimeout(function f9 () {
    setTimeout(f9, Math.floor(7500+7500*Math.random()));
    if (efectoEnMarcha) { return; }
    
    fotoEntra= fotos[Math.floor(fotos.length * Math.random())];
    if (fotoEntra !== fotoActual) {
      efecto(fotoEntra, fotoActual);
    }
  }, 0);
  

//************** FOTOS END





//************ FAQ START
  
  function click () {
    var pos= this.href.indexOf("#q");
    var id= this.href.substring(1+pos);
    var e= document.getElementById(id).style;
    if ( e.display ) {
      e.display= "";
    } else {
      e.display= "none";
    }
    return false;
  }
  
  var pos, id, grupo= document.getElementsByTagName('a'), n= grupo.length;
  while (n--) {
    if (grupo[n].href && ((pos= grupo[n].href.indexOf("#q")) > 0)) {
      grupo[n].onclick= click;
      id= grupo[n].href.substring(1+pos);
      document.getElementById(id).style.display= "none";
    }
  }

//************ FAQ END



};