// Majax by Matmat - http://www.smart-com.com.mx

sHeight = 0;
Speed = 0;

function Majax(){

TextSpeed = document.getElementById('textspeed');
var a = document.getElementsByTagName('a'), i = 0, iCount = a.length;
for (i; i<iCount; i++) {

// Accordeon et premiere page
if (a[i].id.indexOf("+open") != -1) {

      a[i].onclick = function() {
      ShowId = document.getElementById(this.id.replace("+", ""));
      Size = ShowId.firstChild.offsetHeight;
      f = Size/100;
      g = (f*15);
      d = new Date().getTime();
      if(ShowId.offsetHeight < Size){
      sHeight = ShowId.offsetHeight;
      setTimeout(SmoothShow, 80);
      }else{
      sHeight = ShowId.offsetHeight;
      setTimeout(SmoothHide, 80);
      }
      return false;

      }
    }
  }
}


function SmoothShow(){
  Rectif();
  sHeight += (g+Speed);
  SetStyle(ShowId);
  if(sHeight > Size){
      ShowId.style.height = "100%";
  }else{
  setTimeout(SmoothShow, 80);
  }
}

function SmoothHide(){
  Rectif();
  sHeight -= (g+Speed);
  SetStyle(ShowId);
  if(sHeight <= 0){
      ShowId.style.height = "0px";
  }else{
  setTimeout(SmoothHide, 80);
  }
}

function SetStyle(obj){
  if(sHeight < 0)sHeight=0;
  obj.style.filter = 'alpha(opacity = '+(sHeight/f)+')';
  obj.style.opacity = sHeight/Size;
  obj.style.height = sHeight+'px';
}

function Rectif(){
  d2 = new Date().getTime();
  Speed = 0-((d+=80) - d2);if (Speed<0)Speed=0;
  Speed = Speed/2;
  TextSpeed.firstChild.nodeValue = Speed;
}


