/*
Copyright (c) 2008 Prasanna Kumar Nagasamudram - http://prasplugin.com

  This is a licenced software and is only intented to the person who purchased this software
  Under this licence it is NOT allowed to modify, distribute, sublicense, and/or sell copies of the Software
  If this above is require one can go for the dev licence.
*/  

function prasTextScroller(divid,options)
{
  this.delay=options.delay;
  //this.delay=5;
  this.increment = this.savedincrement=1;
  this.url=options.url;
  this.divid=$(divid);
  this.title=options.title;
  this.viewPortdiv=$(divid).parentNode;
  $(divid+'_'+'title').innerHTML = "<B>"+this.title+"</B>";
  this.tmpid = $(divid+'_'+'tmp')
  //this.divid.onmouseover=this.pauseScroll.bind(this);
  
  //this.divid.onmouseout=this.resumeScroll.bind(this);
  $(divid+'_'+'up').onmouseover=this.downScroll.bind(this);
  $(divid+'_'+'down').onmouseover=this.upScroll.bind(this);
  $(divid+'_'+'pause').onmouseover=this.pauseScroll.bind(this);

  //this.loadData();
  
// alert(this.url)
  this.divid.innerHTML = this.url;
  this.divHeight=this.divid.offsetHeight;
  //this.divid.style.top = this.viewPortdiv.offsetHeight+"px";

  this.startScroll();

}

prasTextScroller.prototype = {

  startScroll: function()
  {
  //alert(this.divid.style.top);
    //this.tmpid.innerHTML = this.divid.style.top+"   "+this.divHeight+" "+this.viewPortdiv.offsetHeight;
    if(parseInt(this.divid.style.top) < this.divHeight * (-1))
    {
      this.divid.style.top = this.viewPortdiv.offsetHeight+"px";
    }
    else if(parseInt(this.divid.style.top) > this.viewPortdiv.offsetHeight)
    {
      this.divid.style.top = ((this.divHeight * (-1))+10)+'px';
    }
    else
    {
      this.divid.style.top = (parseInt(this.divid.style.top) - this.increment) + "px";
    }
    setTimeout(this.startScroll.bind(this),this.delay*5);
  },
  pauseScroll: function(e)
  {
    this.increment=0;
  },
  resumeScroll: function()
  {
    this.increment=this.savedincrement;
  },
  downScroll: function()
  {
    this.increment=-1;
  },
  upScroll: function()
  {
    this.increment=1;
  }
  
   
  };   
