var ad=new Object(), activeAd=1, adc=0, pos=0, adHeight=335, timeoutBase=0, timeoutFactor=.5, stepFactor=12, stepBase=1, scrollTimeout=6000;
function adInit() 
 {
   ad=document.getElementById('animationcontainer');
   ad.style.top='0px';
   for (i=0;i<ad.childNodes.length;i++)
    {
      if (ad.childNodes[i].nodeName.toLowerCase()=='a') adc++;
    }
   ad.motion=window.setTimeout("slide()", scrollTimeout);
   
 }
 
function slide(num)
 {   
   var timout,span,step;
   window.clearTimeout(ad.motion);
   if (!num)
    {
      document.getElementById('imgnavi'+activeAd).className='';
      num=activeAd+1;
      if (num>adc) num=1;
    }
   pos=ad.style.top;
   pos=pos.substring(0,pos.indexOf('px'));
   pos=parseInt(pos);
   var target=((num-1)*adHeight)*-1;
   span=Math.abs(target-pos);
   step=Math.floor(stepBase+stepFactor*(span/adHeight));

   if (target>pos) 
    {
      pos+=step;
      if (pos>target) pos=target;
    }
   else
    {
      pos-=step;
      if (pos<target) pos=target;
    }
   ad.style.top=pos+'px';
   
   //timeout=timeoutBase+timeoutFactor*(edDiff-span);
   if (pos!=target) ad.motion=window.setTimeout("slide("+num+")", 1);
   else
    { 
      document.getElementById('imgnavi'+activeAd).className='';
      activeAd=num;
      document.getElementById('imgnavi'+activeAd).className='active';
      ad.motion=window.setTimeout("slide()", scrollTimeout);
    }
 }
