var x=1;
var degres=0.13;
var globinterv;
var hauteur;

function bouncerX(id,x1,x2,interv)
{
    
  var velocity=0.1;
  var obj=document.getElementById(id);
  obj.style.position="absolute";
  obj.style.top=x1;
  
    hauteur=obj.style.top.replace("px","")*1;
  
    moovetox(id,x2,velocity,interv);    
}


function moovetox(id,x2,velocity,interv)
{
  var obj=document.getElementById(id);
  
  hauteur=obj.style.top.replace("px","")*1;
  
  
  obj.style.top=hauteur+velocity*1;
  velocity=velocity*1+0.2;
  
  if(hauteur<=x2)
  {
    window.setTimeout("moovetox('"+id+"','"+x2+"','"+velocity+"','"+interv+"')",20);
   
  }
  else
  {
   monbouncer=window.setInterval("bounce('"+id+"','"+interv+"')",20);
       
  } 
 }
 function bounce(id,interv)
 {  
  if(!globinterv)
    globinterv=interv;
  
  var obj=document.getElementById(id);
  hauteur=obj.style.top.replace("px","")*1;
  x=x*1+degres;
  globinterv=globinterv-0.08;
  if(globinterv<=0.1)
    clearInterval(monbouncer); 
    obj.style.top=Math.round(hauteur+Math.cos(x)*globinterv*1)+"px";
    
  
 
 }