﻿var arrEcScroller = new Array();
// ################################  FW_Scroller  Helper functions ###################
function FW_Scroller_Scroll(ccName)
{
	var HTMLControl = document.getElementById(ccName);
	HTMLControl.Object.Event_Scroll();
}


var sLog = null;
var EnableLog = false;
var iii = 0;

// ################################  FW_Scroller  class #############################
function FW_Scroller(ccName,iWidth,iHeight)
{

	if(EnableLog)
	    sLog = document.getElementById("Log")
	
	this.indent = 4;
	this.ccName = ccName;
	this.width = iWidth;
	this.height = iHeight;
	
	this.Interval = null;
	
	this.HTMLControl = document.getElementById(ccName)
	this.HTMLControl.Object = this;
	
	this.cntA = document.getElementById(ccName + '_ContentA')
	this.cntB = document.getElementById(ccName + '_ContentB')
	
	
	this.cntA.style.left =  iWidth + "px";
	this.cntB.style.left = (iWidth + GetOBJWidth(this.cntA)) + "px";
	
	
	
	this.Event_Scroll = function()
	{
		if(this.cntA.offsetLeft == -1*(GetOBJWidth(this.cntA) + this.width + this.indent))
		{
			//sLog.innerHTML = "Return <br>" + sLog.innerHTML
			
			return;
		}
		
		this.cntA.style.left = (parseInt(this.cntA.style.left,10)-1) + "px"; 
		
		
		// Not Enught Items
		if(GetOBJWidth(this.cntA) < this.width)
		{
		    if(this.cntA.offsetLeft  <  -1* (GetOBJWidth(this.cntA)) )
		    {
		        //alert("Now")
		        this.cntA.style.left = ( this.width  ) + "px"; 
		    }
		    return;
		}
		
		
		
		
		this.cntB.style.left = ( parseInt(this.cntA.style.left,10) + GetOBJWidth(this.cntA) + this.cntA.offsetLeft) + "px";
		
//		if(EnableLog)
//		    sLog.innerHTML = "this.cntA.style.left: " + this.cntA.style.left +" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Width: " + GetOBJWidth(this.cntA) + " <br>" + sLog.innerHTML
		
		if(this.cntA.offsetLeft + GetOBJWidth(this.cntA) >  this.width + this.indent)
		{
		    this.cntB.style.display = "none" 
		    this.cntB.style.left = (this.indent + this.width) + "px"; 
		 }
        else
            {
            this.cntB.style.left = 4 + this.cntA.offsetLeft + ( GetOBJWidth(this.cntA)) + "px"; 
            this.cntB.style.display = "block"
            }
		
		if(this.cntA.offsetLeft + GetOBJWidth(this.cntA) < 0)
		{
			window.status = this.cntB.offsetLeft
			if(this.indent + this.width > this.cntA.offsetLeft)
				this.cntA.style.left = (this.indent + this.width + GetOBJWidth(this.cntA)) + "px"; 
			  else
			     this.cntA.style.left = parseInt(this.cntB.style.left,10) + this.cntB.offsetLeft + GetOBJWidth(this.cntB); 
			// Replace between divs
			var tmpDiv = this.cntA;
			this.cntA = this.cntB;
			this.cntB = tmpDiv;
			
			this.cntA.style.display = "block"

		}
	}
	this.Event_StopScroll = function()
			{	
				if(this.Interval!=null) 
					{
					clearInterval(this.Interval);	
					this.Interval = null;
					}
			}
	this.Event_StartScroll = function()
			{	
				this.Interval = setInterval("FW_Scroller_Scroll('"+this.ccName+"')", 20);	
			}
	
	this.HTMLControl.onmouseover = function()
			{	var Object = this.Object; Object.Event_StopScroll();	}
	
	this.HTMLControl.onmouseout = function()
			{	var Object = this.Object; Object.Event_StartScroll();	}	

	this.Event_StartScroll()
}			
