if(typeof(setAndAnimate)=="undefined")
  document.write("<scr"+"ipt src=\"http://www.moska.com.br/2008/includes/setandanimate.js\"></scr"+"ipt>");
  
carrossel=function(){

  var id;
  var rodando=0;

  this.elementClone=[];
  this.elementMove=[];

  this.mover=function(){
    if(rodando==0){

      rodando=1;

      if(typeof(arguments[0])=="object" && arguments[0].length>=1)
        arguments=arguments[0];
      
      this.to=arguments[0]['to'];
      id=arguments[0]['id'];
  
      if(this.elementClone.length>0)
        this.deletarClone();
      else
        document.getElementById(id).style.marginLeft=0;
  
      this.qtd=document.getElementById(id).getElementsByTagName('li').length;
  
      document.getElementById(id).style.width=(document.getElementById(id).getElementsByTagName('li')[0].offsetWidth*this.qtd)+"px";
      
      this.marginLeftWidth=0;
      
      for(var i=0;i<((this.to<0)?this.to*-1:this.to);i++){
        this.elementMove[this.elementMove.length]=document.getElementById(id).getElementsByTagName('li')[((this.to>0)?i:this.qtd-i-1)];
        this.marginLeftWidth+=this.elementMove[this.elementMove.length-1].offsetWidth;
        this.elementClone[this.elementClone.length]=this.elementMove[this.elementMove.length-1].cloneNode(true);
      }
  
      if(this.to>0){
        for(var i=0;i<((this.to<0)?this.to*-1:this.to);i++){
          document.getElementById(id).appendChild(this.elementClone[i]);
        }
      }else if(this.to<0){
        for(var i=0;i<((this.to<0)?this.to*-1:this.to);i++){
          document.getElementById(id).insertBefore(this.elementClone[i],document.getElementById(id).getElementsByTagName('li')[0]);
        }
        document.getElementById(id).style.marginLeft=(document.getElementById(id).getElementsByTagName('li')[this.to*-1].offsetLeft*-1)+"px";
      }
      

      setAndAnimate.change({
          objName : id+"Animate",
          propriedade : [document.getElementById(id).style, 'marginLeft', 'px'],
          inicio : document.getElementById(id).style.marginLeft,
          fim : ((this.to>0)?this.marginLeftWidth*-1:0),
          callback : function(){ carrossel.deletarClone(); document.getElementById(id).style.marginLeft=0; rodando=0; },
          velocidade : .85
      });

      
    }
  }
  
  this.deletarClone=function(){

    for(var i=0;i<((this.to<0)?this.to*-1:this.to);i++)
      this.elementMove[i].parentNode.removeChild(this.elementMove[i]);

    this.elementClone=[];
    this.elementMove=[];

  }
  
  this.getRodando=function()  {
    return rodando;
  }

}
carrossel=new carrossel();