var oStart=null;
var oScroll=null;
var oList=null;
var bPossible=true;
var iInitTop=new Number(0);
var iInitLeft=new Number(0);
var iInitHeight=new Number(0);
var iInitWidth=new Number(0);
var iInitRight=new Number(0);
var iTop=new Number(0);
var iLeft=new Number(0);
var iRight=new Number(0);
var iClipTop=new Number(0);
var iClipRight=new Number(0);
var iClipBottom=new Number(0);
var iClipLeft=new Number(0)

function scrollActus() {
 //set new clip ...
if(bPossible)
{
   if(iRight==iInitRight) {
    iRight=iInitLeft;
    iClipLeft=0;
    iClipRight=0;
    //alert("normal haut haut");
    }
 if(iClipLeft == iInitWidth) {
  iLeft=iInitLeft+iInitRight;
  iClipLeft=0;
  iClipRight=0;
  alert("normal haut");
 }
 //set div ...
 iLeft-=3;
 if (iLeft < iInitLeft) iClipLeft=iClipLeft+3;
 iClipRight+=3;
 oList.style.left=iLeft+"px";
  //alert("je passe");
 oList.style.clip="rect("+iClipTop+(iClipTop>0?"px ":" ")+iClipRight+(iClipRight>0?"px ":" ")+iClipBottom+(iClipBottom>0?"px ":" ")+iClipLeft+(iClipLeft>0?"px ":" ")+")";
 //reset scroll... 

 if(iClipLeft % 441==0  && iClipLeft < iInitWidth && iLeft <= iInitLeft) {
  stopScroll();
  //alert("normal middle");
  bPossible=false;
 }
/*if(iClipLeft>=iClipRight+300)
 {
  stopScroll();
  alert("normal bas");
 }*/
}
}

function scrollActusReverse2() {
bPossible=true;
 //set new clip ...
 if(iRight==iInitRight) {
  iLeft=iInitLeft;
  //iClipLeft=0;
//  iClipRight=0;
   //   alert("coucou du reverse haut");
 }
 if(iLeft!=iInitLeft)
 {
 //set div ...
 iLeft+=3;
 if (iLeft < iInitLeft) iClipLeft=iClipLeft-3;
 iClipRight-=3;
 oList.style.left=iLeft+"px";
 oList.style.clip="rect("+iClipTop+(iClipTop>0?"px ":" ")+iClipRight+(iClipRight>0?"px ":" ")+iClipBottom+(iClipBottom>0?"px ":" ")+iClipLeft+(iClipLeft>0?"px ":" ")+")";
 //reset scroll... 
 if(iClipRight % 468 ==0  && iClipRight < iInitWidth && iRight <= iInitRight) {
  alert("coucou du reverse middle");
  stopScroll();
 }
 if(iLeft==iInitLeft)
 {
  stopScroll(); 
     //alert("coucou du reverse bas");
 }
}
}

function startScroll() {
 stopScroll();
  oScroll=window.setInterval(scrollActus,1);
}
function startScrollReverse() {
 stopScroll();
  oScroll=window.setInterval(scrollActusReverse2,1);
} 
function stopScroll() {
 if(oScroll) window.clearInterval(oScroll);
 if(oStart) window.clearTimeout(oStart);
 oScroll=null;
 oStart=null;
}
function initScroll() {
 //init clipping ... set vars ... 
 if (oList==null) {
  oList=document.getElementById("animtotem");
  if(oList.currentStyle) {
   iLeft=parseInt(oList.currentStyle.left?oList.currentStyle.left:oList.currentStyle.getPropertyValue("left"));
   if(oList.currentStyle.getPropertyValue) var aClip=oList.currentStyle.getPropertyValue("clip").split(/[(,)]/);
   iClipTop=parseInt(oList.currentStyle.clipTop?oList.currentStyle.clipTop:aClip[1]);
   iClipRight=parseInt(oList.currentStyle.clipRight?oList.currentStyle.clipRight:aClip[2]);
   iClipBottom=parseInt(oList.currentStyle.clipBottom?oList.currentStyle.clipBottom:aClip[3]);
   iClipLeft=parseInt(oList.currentStyle.clipLeft?oList.currentStyle.clipLeft:aClip[4]);
  } else if(document.defaultView) {
   iLeft=parseInt(document.defaultView.getComputedStyle(oList, '').getPropertyValue("left"));
   var aClip=document.defaultView.getComputedStyle(oList, '').getPropertyValue("clip").split(/[(,)]/);
   iClipTop=parseInt(aClip[1]);
   iClipRight=parseInt(aClip[2]);
   iClipBottom=parseInt(aClip[3]);
   iClipLeft=parseInt(aClip[4]);
  }
  iInitLeft=iLeft;
  iInitRight=iClipBottom;
  iInitWidth=oList.offsetWidth;
  iInitHeight=oList.offsetHeight;
 }
oStart=startScroll();
}

function initScrollReverse() {
 //init clipping ... set vars ... 
 if (oList==null) {
  oList=document.getElementById("animtotem");
  if(oList.currentStyle) {
   iRight=parseInt(oList.currentStyle.right?oList.currentStyle.right:oList.currentStyle.getPropertyValue("right"));
   if(oList.currentStyle.getPropertyValue) var aClip=oList.currentStyle.getPropertyValue("clip").split(/[(,)]/);
   iClipTop=parseInt(oList.currentStyle.clipTop?oList.currentStyle.clipTop:aClip[1]);
   iClipRight=parseInt(oList.currentStyle.clipRight?oList.currentStyle.clipRight:aClip[2]);
   iClipBottom=parseInt(oList.currentStyle.clipBottom?oList.currentStyle.clipBottom:aClip[3]);
   iClipLeft=parseInt(oList.currentStyle.clipLeft?oList.currentStyle.clipLeft:aClip[4]);
  } else if(document.defaultView) {
   iRight=parseInt(document.defaultView.getComputedStyle(oList, '').getPropertyValue("right"));
   var aClip=document.defaultView.getComputedStyle(oList, '').getPropertyValue("clip").split(/[(,)]/);
   iClipTop=parseInt(aClip[1]);
   iClipRight=parseInt(aClip[2]);
   iClipBottom=parseInt(aClip[3]);
   iClipLeft=parseInt(aClip[4]);
  }
  iInitRight=iRight;
  iInitLeft=iClipBottom;
  iInitWidth=oList.offsetWidth;
  iInitWidth
 }
oStart=startScrollReverse();
}

function controlesouris(Element) {
 var Pos = Element.offsetLeft + "/" + Element.offsetTop;
 alert(Pos);
 return true;
}

function scrollEffect(evenement)
{
  //alert(window.event.clientX);

if(navigator.appName == 'Netscape') {
     initScroll();
     stopScroll();
      if(evenement.pageX<=470)
      {
         initScrollReverse();
      }
      if(evenement.pageX<=570 && evenement.pageX >= 471)
      {
          stopScroll();
       }
       if(evenement.pageX >= 571)
       {
          initScroll();
       }
   }
else{
initScroll();
     stopScroll();
  if(window.event.clientX<=450)
  {
     initScrollReverse();
  }
 if(window.event.clientX<=600 && window.event.clientX >= 451)
  {
     stopScroll();
  }
 if(window.event.clientX >= 601)
  {
      initScroll();
  }
}
}
