function ImageScroll(container_id,name){
  var instance = this;  
  var max_width=0;
  var max_height=0;
  var total_width=0;
  var container_width=0;
  
  this.objectName=name;
  this._container_height=0;
  this._container=document.getElementById(container_id);
  this._no_scroll=0;
  this._shift_x=0;
  this._shift_y=0;
  this._margin=0;  

  container_width=parseInt(this._container.style.width);
  
  var x=this._container.childNodes;
  for(var i=0; i<x.length; i++){   
    if(x[i].tagName=='IMG'||x[i].tagName=='DIV'){      
      if(parseInt(x[i].style.height)>max_height)max_height=parseInt(x[i].style.height);
      if(parseInt(x[i].style.width)>max_width)max_width=parseInt(x[i].style.width);
      if(total_width!=0) total_width+=this._margin;
      total_width+=parseInt(x[i].style.width);
    }
  }  
//  this._container.style.height=max_height+"px";
//  this._container.offsetParent.style.height=max_height+"px";
  this._container_height=max_height;
  
  var iTop=0; var iLeft=0;
  if(total_width<=container_width){
//   this._container.style.width=total_width+"px";
//   this._container.offsetParent.style.width=total_width+"px";
//   this._no_scroll=1;
  }else if(total_width-max_width<=container_width){
//   this._container.style.width=(total_width-max_width)+"px";
//   this._container.offsetParent.style.width=(total_width-max_width)+"px";    
  }
  
 /*  
  pos=this._container;
  while (pos!=null){
   this._shift_x+=pos.offsetLeft;
   this._shift_y+=pos.offsetTop;
   pos=pos.offsetParent;
  }
  */
  
  
  for(var i=0; i<x.length; i++){   
    if(x[i].tagName=='IMG'||x[i].tagName=='DIV'){      
      x[i].style.position='absolute';
      x[i].style.top=(this._shift_y+iTop+(this._container_height-parseInt(x[i].style.height))/2)+"px"; x[i].style.left=(this._shift_x+iLeft)+"px";

      iLeft+=parseInt(x[i].style.width)+this._margin;
     
    }
  }  
  this._container.style.overflow="hidden";    
  this._container.style.position="relative";  
  this.sliding=false;
  //this.TimeOutID=window.setInterval(this.objectName+'.scroll();',2000);
}

ImageScroll.prototype.scroll=function(left){
  this.left=false;
  if(!this.sliding){
    this.sliding=true;
    if(left==true){
      var first_i=999;
      var last_i;
      var x=this._container.childNodes;      
      for(var i=0; i<x.length; i++){   
        if(x[i].tagName=='IMG'||x[i].tagName=='DIV'){      
           if(first_i==999)first_i=i;last_i=i;
        }
      }      
      this.left=true;
      this._shift_x-=x[last_i].offsetWidth+this._margin;
      x[last_i].style.left=this._shift_x;
      this._container.insertBefore(x[last_i],x[first_i]);      
    }
    this.slide=window.setInterval(this.objectName+'.swipe()',10);
  }
}

ImageScroll.prototype.swipe=function(){
  var speed=50;
  if(this.left==true)this._shift_x+=speed;
  else this._shift_x-=speed;  
  var iLeft=0;      
  var x=this._container.childNodes;
  var first_i=999;
  for(var i=0; i<x.length; i++){   
    if(x[i].tagName=='IMG'||x[i].tagName=='DIV'){      
      if(first_i==999)first_i=i;
      x[i].style.left=iLeft+this._shift_x;
      iLeft+=x[i].offsetWidth+this._margin;
    }
  }  
  if(this.left==true){
    if(this._shift_x>=0){
      window.clearInterval(this.slide);
      this.sliding=false;
    }
  }else{
    if(x[first_i].offsetWidth+this._shift_x<=0){
      window.clearInterval(this.slide);
      this.sliding=false;
      this._shift_x+=x[first_i].offsetWidth+this._margin;
      x[first_i].style.left=iLeft+this._shift_x;
      this._container.appendChild(x[first_i]);
    }
  }
}