var Scroller = function(frameId,contentId,direction,tempo,w,h)
{
	// default parameters
	var thisObj 		= this;
	this.nXlocation 	= 0;
	this.nYlocation 	= 0;
	this.nFrameHeight 	= h;
	this.nFrameWidth	= w;
	this.nTempo			= tempo ;
	this.strDirection	= direction;
	this.scrollerStat	= true;
	this.objFrame		= document.getElementById(contentId);

	// frame parameter
	f = document.getElementById(frameId);

	this.MoveScroller = function()
	{
		switch(this.strDirection)
		{
			case 'u':	// moving up
				this.nXlocation--;
				this.objFrame.style.top=this.nXlocation+"px";
				break;
			case 'd':	// moving sown
				this.nXlocation++;
				this.objFrame.style.top=this.nXlocation+"px";
				break;
			case 'r':	// moving right
				this.nYlocation++;
				this.objFrame.style.left=this.nYlocation+"px";
				break;
			case 'l':	// moving left
				this.nYlocation--;
				this.objFrame.style.left=this.nYlocation+"px";
				break;
		}
	}

	this.CheckScroller = function()
	{
		switch(this.strDirection)
		{
			case 'u':
			if ((0-this.nXlocation) > this.objFrame.offsetHeight) {
					// Scroller Last line at the top of the scroller frame
					this.nXlocation = this.nFrameHeight;
				}
				if(this.nXlocation + this.objFrame.offsetHeight == this.nFrameHeight) {
					// Scroller Last line at the bottom of the scroller frame
				}

				break;
			case 'd':
				if (this.nXlocation > this.nFrameHeight)
				this.nXlocation = -this.objFrame.offsetHeight;
				break;
			case 'r':
				if (this.nYlocation > this.nFrameWidth)
				this.nYlocation = -this.objFrame.offsetWidth;
				break;
			case 'l':
				if ((0-this.nYlocation) > this.objFrame.offsetWidth)
				this.nYlocation = this.nFrameWidth;
				break;
		}	
	}
	
	this.RunScroll = function() {
		if (this.scrollerStat) {
			this.MoveScroller();
			this.CheckScroller();
		}
	}
	
	this.Start = function() {
		this.scrollerStat=true;
	}
	
	this.Stop = function() {
		this.scrollerStat=false;
	}
	
	this.StartScroll = function() {
			setInterval(function() { thisObj.RunScroll(); },thisObj.nTempo);
	}
	
}