var $A = Array.from = function(iterable) {
  if (!iterable)return []; if (iterable.toArray) {
    return iterable.toArray();
  } else {
    var results = []; for (var i = 0, length = iterable.length; i < length; i++)results.push(iterable[i]); return results;
  }
};
Function.prototype.bind = function() {
  var __method = this, args = $A(arguments), object = args.shift(); return function() {
    return __method.apply(object, args);
  }
}
var marquee=function(speedvalue,demo2id,demo1id,demoid,direction){
      this.speed=speedvalue;
      if(arguments.length==5)
          this.direction=direction;
      else
          this.direction=10;
      this.m=document.getElementById(demo2id);
      this.n=document.getElementById(demo1id);
      this.q=document.getElementById(demoid);
      this.m.innerHTML=this.n.innerHTML;
}
marquee.prototype={
   MyMar:null,
   directiontemp:0,
   Marquee:function(){
      switch(this.direction){
		 case 30:
		      if(this.directiontemp==0){this.directiontemp=1;this.q.scrollLeft=0;}
			  
			  if(this.q.scrollLeft>=this.n.offsetWidth)
			     this.q.scrollLeft-=this.n.offsetWidth;
			  else
			     this.q.scrollLeft++;
			  break;
      }
   },
   setbegin:function(){
      this.q.onmouseover=this.setmouseover.bind(this);
      this.q.onmouseout=this.setmouseout.bind(this);
      this.MyMar=setInterval(this.Marquee.bind(this),this.speed);
   },
   setmouseover:function(){
      clearInterval(this.MyMar);
   },
   setmouseout:function(){
      this.MyMar=setInterval(this.Marquee.bind(this),this.speed);
   }
}
var marquee1=new marquee(30,'demo2','demo1','demo',30);
marquee1.setbegin();
