﻿function ScrollScript( scrollerName , scrollerContentName , objectName , scrollSpeed)
	{
		this.scroller 			= document.getElementById(scrollerName);
		this.scrollerContent 	= document.getElementById(scrollerContentName);
		this.objectId 			= objectName;
		this.scrollingSpeed     = scrollSpeed;
		
		this.scrollerHeight			= parseInt(this.scroller.offsetHeight);
		this.scrollerContentHeight 	= parseInt(this.scrollerContent.offsetHeight);
		
		this.paused				= false;
		
		if (document.all)
		{
			this.scrollerContent.style.pixelTop = this.scrollerHeight;
		} else {
			this.scrollerContent.style.top = this.scrollerHeight + 'px';
		}
		
		
		this.ExecuteScroll 	= function()
		{
			if (!this.paused)
			{/*
				var offset = document.getElementById("offset");
				var offsetParent = document.getElementById("offsetParent");
			
				if (document.all)
				{
					offset.innerHTML = this.scrollerContent.style.pixelTop;
					offsetParent.innerHTML = this.scrollerContentHeight;
				}
				else
				{
					offset.innerHTML = this.scrollerContent.style.top;
					offsetParent.innerHTML = this.scrollerContentHeight;
				}
			*/
				if (document.all)
				{
					if (this.scrollerContent.style.pixelTop < (this.scrollerContentHeight * -1))
						this.scrollerContent.style.pixelTop = this.scrollerHeight;
					else
						this.scrollerContent.style.pixelTop -= scrollSpeed;
				}
				else
				{
					var pixelTop = this.scrollerContent.style.top.replace('px','');
					
					if( pixelTop < (this.scrollerContentHeight * -1) )
						this.scrollerContent.style.top = this.scrollerHeight + 'px';
					else
						this.scrollerContent.style.top =  (pixelTop - scrollSpeed) + 'px';
				}
			}
			
			setTimeout( this.objectId + ".ExecuteScroll()", 100);
		}
	
		this.StopScrolling = function()
		{
			this.paused = true;
		}
		
		this.ResumeScrolling = function()
		{
			this.paused = false;
		}
	}
	

