var notWhitespace = /\S/;
function TickerObj(o)
{
  this.Count=0;
  this.MSX = -1;
  this.MEX = -1;
  this.xmlDoc=null;
  this.IsStop = false;
  this.IsInit = false;
  this.SObj =document.getElementById(o);
  this.TTimeOut =  this.SObj.getAttribute("TTimeOut");
  this.Obj = o + "Object"; eval(this.Obj + "=this");
  this.TimeoutId = null;
  this.SObj.parentNode.onmouseover= new Function(this.Obj+".MouseOver()")
  this.SObj.parentNode.onmouseout= new Function(this.Obj+".MouseOut()");  
  this.SObj.parentNode.onmousemove= new Function(this.Obj+".MouseMove()");  
  if (window.ActiveXObject) this.xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
  else if (document.implementation && document.implementation.createDocument) this.xmlDoc=document.implementation.createDocument("","doc",null);  
  return this;
}
TickerObj.prototype.MouseMove = function()
{
  this.MSX = this.MEX;
  this.MEX = event.clientX;
}
TickerObj.prototype.MouseOver = function()
{
  clearTimeout(this.TimeoutId);
  this.TimeoutId=null;
  this.IsStop = true;
}
TickerObj.prototype.MouseOut = function()
{
  if(this.MSX>-1) 
  {
	if(this.MSX > this.MEX +1) this.TTimeOut =  this.SObj.getAttribute("TTimeOutHigh");
	else if(this.MSX + 1 < this.MEX) this.TTimeOut =  this.SObj.getAttribute("TTimeOutLow");
	else this.TTimeOut =  this.SObj.getAttribute("TTimeOut");
  }
  this.IsStop = false;
  this.TickerRun();
}
TickerObj.prototype.Init = function()
{
  this.LoadXml();
  if (window.ActiveXObject) this.Fetchxml();
  else if (typeof this.xmlDoc!="undefined") this.xmlDoc.onload= new Function(this.Obj+".Init_ticker()");  
}
TickerObj.prototype.LoadXml = function()
{
  var now = new Date();
  urlSuffix = new String();
  urlSuffix = "NoCache=" +  now + this.Count;
  url = this.SObj.getAttribute("TXmlUrl") + "?" + escape(urlSuffix);
  if (typeof this.xmlDoc!="undefined") this.xmlDoc.load(url);
}
TickerObj.prototype.TickerRun = function()
{
  if(this.IsStop==false && this.IsInit)
  {
    this.left--;
    this.SObj.style.left = this.left; 
    if(this.left>this.StopMove )
    { 
      this.TimeoutId=setTimeout(this.Obj+".TickerRun()",this.TTimeOut);
    }
    else
    {
	  this.SObj.innerHTML = "";
      this.IsInit = false;
      this.Init();
    }
  }
}
TickerObj.prototype.Init_ticker = function()
{
 if(this.xmlDoc.getElementsByTagName("xmlticker")==null) return;
 if(this.xmlDoc.getElementsByTagName("xmlticker")[0]==null) return;
 this.tickerobj=this.xmlDoc.getElementsByTagName("xmlticker")[0];
 if(this.tickerobj==null) return;
 if(this.tickerobj.childNodes==null) return;

  for (i=0;i<this.tickerobj.childNodes.length;i++)
  {
    if ((this.tickerobj.childNodes[i].nodeType == 3)&&(!notWhitespace.test(this.tickerobj.childNodes[i].nodeValue))) 
    {
      this.tickerobj.removeChild(this.tickerobj.childNodes[i]);
      i--;
    }
  }
  this.Count++;
  this.left = this.SObj.parentNode.offsetWidth;
  this.SObj.innerHTML = this.tickerobj.childNodes[0].firstChild.nodeValue;
  this.StopMove = this.SObj.offsetWidth * -1;
  this.IsInit = true;
  this.TickerRun();
}
TickerObj.prototype.Fetchxml = function()
{
  if (this.xmlDoc.readyState==4) this.Init_ticker();
  else if(this.IsStop==false) this.TimeoutId=setTimeout(this.Obj+".Fetchxml()",10);
}