function PageScrollerObj(ComponentName,
		ComponentWidth, ComponentHeight, Alignment,
		LeftMargin, TopMargin, RightMargin, BottomMargin,
		ScrollSpeed, LoadMsg, LoadMsgColor, LoadMsgSize,
		BkImage, BkAudio, BkColor, BorderSize, BorderColor,
		StatusBarMsg, Mode, arrangement, PageScrollData, StartMute, MouseOverPause)
{
	this.browser = 0;
	if ( document.all ) this.browser = 1; // IE
	else if ( document.layers ) this.browser = 2; // NS4
	else if ( document.getElementById && !document.all ) this.browser = 3; // NS6
	if ( navigator.userAgent.indexOf("Opera") != -1 ) this.browser = 4; // Opera

	this.name = ComponentName;
	this.ComponentWidth	= ComponentWidth;
	this.ComponentHeight = ComponentHeight;
	this.Alignment = Alignment;
	this.LeftMargin = LeftMargin;
	this.TopMargin = TopMargin;
	this.RightMargin = RightMargin;
	this.BottomMargin = BottomMargin;
	this.swidth = ComponentWidth - LeftMargin - RightMargin;
	if ( this.browser != 3 ) this.swidth -= ( BorderSize + BorderSize );
	this.sheight = ComponentHeight - TopMargin - BottomMargin;
	if ( this.browser != 3 ) this.sheight -= ( BorderSize + BorderSize );
	this.sspeed = ScrollSpeed;
	this.ScrollSpeed = ScrollSpeed;
	this.loadMsg = "<table width="+ComponentWidth+" height="+ComponentHeight+" border=0><TR><TD valign=center align=center><FONT size="+LoadMsgSize+" "+(LoadMsgColor!=""?"color="+LoadMsgColor:"")+"><B>"+LoadMsg+"</B></font></td></tr></table>"
	this.BkImage = BkImage;
	this.BkColor = BkColor;
	this.BorderSize = BorderSize;
	this.BorderColor = BorderColor;
	this.StatusBarMsg = StatusBarMsg;
	this.Mode = Mode;
	this.nGap = (arrangement == 0) ? 0 : this.sheight;
	this.nLoading = 0;
	this.nIntervalId = 0;
	this.IntervalId = 0;
	this.iTotDiv = 0;
	this.strDiv = "";
	this.bPauseFlag = 0;
	this.nTimeOut = 0;
	this.Layers = "";	
	this.BkAudioInterval = 0;
	this.arrPages = new Array ();
	this.BkAudioPlayOnce = false;
	this.MouseOverPause = MouseOverPause;
	this.Started = 0;
	
	//Member functions
	this.LoadContents = PageScroller_LoadContents;	
	this.GenerateHtml = PageScroller_GenerateHtml;
	this.CreateLayers = PageScroller_CreateLayers;
	this.CreateLayerTag = PageScroller_CreateLayerTag;
	this.start = PageScroller_start;
	this.CalculateTotTag = PageScroller_CalculateTotTag;
	this.CreateTag = PageScroller_CreateTag;
	this.Marquee = PageScroller_Marquee;
	this.MouseOver = PageScroller_MouseOver;
	this.MouseOut = PageScroller_MouseOut;
	this.GetTop = PageScroller_GetTop;
	this.SetTop = PageScroller_SetTop;	
	this.AdjustTop = PageScroller_AdjustTop;	
	this.GetHeight = PageScroller_GetHeight;	
	this.SetDivInnerHTML = PageScroller_SetDivInnerHTML;
	this.GetIFrameInnerHTML = PageScroller_GetIFrameInnerHTML;
	this.StartBkAudio = PageScroller_StartBkAudio;
	this.GetIFrame = PageScroller_GetIFrame;
	
	this.Back = PageScroller_Back;
	this.Next = PageScroller_Next;
	this.Pause = PageScroller_Pause;
	this.Play = PageScroller_Play;
	this.Begin = PageScroller_First;
	this.End = PageScroller_Last;
	this.ToggleSound = PageScroller_ToggleSound;
	this.GotoPage = PageScroller_GotoPage;

	this.EnableAudio = navigator.javaEnabled();
	this.PlayAudio = 1 - StartMute;

	if ( this.browser != 4 )
	{	
		var arrPageScroll = PageScrollData.split ( "##RS##" );
		if ( arrPageScroll.length > 0 )
		{
			for ( var i = 0 ; i < arrPageScroll.length-1 ; i++ )
			{
				var arrPageScrollData = arrPageScroll[i].split ( "##FS##" );
				if ( arrPageScrollData.length == 3 )
				{
					if ( ! this.EnableAudio ) arrPageScrollData[1] = "";
					this.arrPages[this.arrPages.length] = new PageScroller_ScrollerPageObj ( arrPageScrollData[0], arrPageScrollData[1], arrPageScrollData[2]);
				}
			}
		}
	
		if ( this.EnableAudio && BkAudio != "" )
		{
			this.BkAudioPlayOnce = ( BkAudio.charAt(BkAudio.length-1) == "1" );
			if (this.PlayAudio) this.BkAudioInterval = setInterval ( this.name+".StartBkAudio()", 1000 );
		}
	}
	return this;
}

function PageScroller_StartBkAudio ()
{
	var oApplet = document.applets["BkAudio_"+this.name];
	
	if ( this.EnableAudio == false )
	{ clearInterval ( this.BkAudioInterval ); return; }
	if ( oApplet && oApplet.AppletLoaded == true )
	{ (this.BkAudioPlayOnce==true) ? oApplet.PlayAudio() : oApplet.LoopAudio(); clearInterval ( this.BkAudioInterval ); }
}

function PageScroller_ScrollerPageObj(PageName,SoundFile,PauseTime)
{ this.url = PageName; this.Sound = SoundFile; this.Pause = PauseTime; this.text = ""; this.height = ""; }

function PageScroller_GenerateHtml()
{
	document.write ( '<table cellpadding=0 cellspacing=0 border=0 align='+this.Alignment+'><tr><td>' );
	if (this.browser==4)
		document.write('<table width='+this.ComponentWidth+' height='+this.ComponentHeight+' border=1><tr><td align=center valign=center>This component is not compatible with Opera browser.</td></tr></table>');
	else if (this.browser == 2)
	{
		var cw = (this.ComponentWidth-this.BorderSize-this.BorderSize), ch = (this.ComponentHeight-this.BorderSize-this.BorderSize);
		document.write('<ILAYER id="nsbase'+this.name+'" clip= "0,0,'+this.ComponentWidth+','+this.ComponentHeight+'" bgcolor="'+this.BorderColor+'">');
		document.write('<layer id="nsbkg'+this.name+'" left="'+this.BorderSize+'" top="'+this.BorderSize+'" height="'+ch+'" width="'+cw+'" background="'+this.BkImage+'" bgcolor="'+this.BkColor+'"></layer>');
		document.write('<layer id="ns4slider'+this.name+'" left="'+this.BorderSize+'" top='+this.BorderSize+'" clip= "0,0,'+cw+','+ch+';">');
		document.write('<layer id="ns4HandleEvent'+this.name+'" left="0" top=0 height="'+ch+'" width="'+cw+'" onmouseover="'+this.name+'.MouseOver();" onmouseout="'+this.name+'.MouseOut();"></layer>');
		document.write('<layer id="ns4loading'+this.name+'" left="'+this.LeftMargin+'" top='+this.TopMargin+' height="'+this.sheight+'" width="'+this.swidth+'" onmouseover="'+this.name+'.MouseOver();" onmouseout="'+this.name+'.MouseOut();">'+this.loadMsg+'</layer>');
		document.write('<layer id="ns4slider1'+this.name+'" left="'+this.LeftMargin+'" top="'+this.TopMargin+'" height="'+this.sheight+'" width="'+this.swidth+'" clip="0,0,'+this.swidth+','+this.sheight+'" onmouseover="'+this.name+'.MouseOver();" onmouseout="'+this.name+'.MouseOut();">');
		for ( var i = 0 ; i <= this.arrPages.length ; i++ )
			document.write ( '<layer width="'+this.swidth+'" visibility="hidden"></layer>' );
		document.write('</layer></layer></Ilayer>');

		this.Layers = document.layers["nsbase"+this.name].document.layers["ns4slider"+this.name].document.layers["ns4slider1"+this.name].document.layers;
		var doc = document.layers["nsbase"+this.name].document.layers["ns4slider"+this.name].document;
		doc.captureEvents ( Event.MOUSEDOWN);
		doc.onMouseDown = function(event){if(event.target=="") return false;}; 
	}
	else
	{
		document.write('<div id="base'+this.name+'" style="background-image:url('+this.BkImage+');background-color:'+this.BkColor+';position:relative;overflow:hidden;width:'+this.ComponentWidth+';height:'+this.ComponentHeight+';border:'+this.BorderSize+'px solid '+this.BorderColor+'; left:0; top:0;" onmouseover="'+this.name+'.MouseOver(event)" onmouseout="'+this.name+'.MouseOut()">');
		document.write('<div id="PageScroller'+this.name+'" style="position:'+((this.browser==1)?'absolute':'relative')+';overflow:hidden;width:'+this.swidth+';height:'+this.sheight+';left:'+this.LeftMargin+';top:'+this.TopMargin+';clip:rect(0 '+this.swidth+' '+this.sheight+' 0);" onselectstart="event.returnValue = false;"></div>');
		document.write('<div id="LoadingMsg'+this.name+'" style="position:absolute;left:0;top:0;width:'+this.ComponentWidth+';" onselectstart="event.returnValue = false;">');
		document.write(this.loadMsg);
		document.write('</div></div>');
	}
	document.write ( '</td></tr></table>' );
	if (this.browser==4) return;

	if(this.browser == 3) { var e = document.getElementById("base"+this.name); e.onmousedown = function (){return false;}; }

	if (this.browser != 2)
	{
		this.nLoading = 0;
		for ( i = 0 ; i < this.arrPages.length ; i++ )
			document.writeln('<IFRAME ID="IFrame'+this.name+i+'" style="left:-1000;top:-1000;position:absolute" FRAMEBORDER=1></IFRAME>');
		this.GetIFrame(this.nLoading).src = this.arrPages[this.nLoading].url;
		this.IntervalId = setInterval(this.name+".LoadContents()",800);
	}
	else
	{ this.nLoading = -1; this.iTotDiv = this.arrPages.length + 1; }
}

function PageScroller_CreateLayerTag(index)
{
	var doc;
	if ( index < this.arrPages.length ) doc = this.Layers[index+1].document;
	else doc = this.Layers[0].document.layers[index-this.arrPages.length].document;
	doc.open ();
	doc.write ( '<layer src="'+this.arrPages[index%this.arrPages.length].url+'" width="'+this.swidth+'" visibility=hidden onload="'+this.name+'.CreateLayers();"></layer>' );
	doc.close ();
}

function PageScroller_CreateLayers()
{
	this.nLoading++;
	if ( this.nLoading == this.arrPages.length )
	{
		for ( var i = 0 ; i < this.arrPages.length ; i++ )
		{
			this.Layers[i+1].clip.width = this.swidth;
			this.arrPages[i].height = this.Layers[i+1].clip.height;
		}
		this.CalculateTotTag();
		with ( this.Layers[0].document )
		{
			open ();
			for ( i = this.arrPages.length ; i < this.iTotDiv ; i++ )
				write ( '<layer width="'+this.swidth+'" visibility="hidden"></layer>' );
			close ();
		}
	}
	else if ( this.nLoading == this.iTotDiv )
	{
		document.layers["nsbase"+this.name].document.layers["ns4slider"+this.name].document.layers["ns4loading"+this.name].visibility = "hide";
		this.start();
		return;
	}
	setTimeout ( this.name+'.CreateLayerTag('+this.nLoading+');', 500 );
}

function PageScroller_LoadContents()
{
	var val = this.GetIFrameInnerHTML ( this.nLoading );
	if ( val != "" )
	{
		this.arrPages[this.nLoading].text = val;
		this.nLoading++;
		if(this.nLoading == this.arrPages.length)
		{
			clearInterval(this.IntervalId);
			var j;
			for(j=0; j< this.arrPages.length; j++)
				this.strDiv += '<div id="tContent'+this.name+j+'" style="visibility:hidden;position:absolute;width:'+this.swidth+';">'+this.arrPages[j].text+'</div>';
			this.SetDivInnerHTML ( "PageScroller"+this.name, this.strDiv );
			for(j=0; j< this.arrPages.length; j++)
				this.arrPages[j].height = this.GetHeight ( "tContent"+this.name+j, 0 );
			this.CalculateTotTag();
			this.CreateTag();
			this.SetDivInnerHTML ( "LoadingMsg"+this.name, "");
			this.SetDivInnerHTML ( "PageScroller"+this.name, this.strDiv );
			this.start();
		}
		else
			this.GetIFrame(this.nLoading).src = this.arrPages[this.nLoading].url;
	}
}

function PageScroller_CalculateTotTag()
{
	var totContentHeight = 0, iXtraDiv=0, CurrTotDiv=0;
	while(totContentHeight < this.sheight)
	{ totContentHeight += this.arrPages[iXtraDiv%this.arrPages.length].height; iXtraDiv++; }
	CurrTotDiv = this.arrPages.length + iXtraDiv;
	
	this.iTotDiv = CurrTotDiv + (this.arrPages.length-(CurrTotDiv%this.arrPages.length))
}

function PageScroller_CreateTag()								
{
	var iHeight = (this.Mode == 0) ? 1 : this.sheight;
	if (this.browser != 2)
	{
		for(var j=0; j< this.iTotDiv; j++)		
		{
			this.strDiv += '<div id="Content'+this.name+j+'" style="position:absolute;left:0;top:'+iHeight+';width:'+this.swidth+';" onselectstart="event.returnValue = false;">'+this.arrPages[j%this.arrPages.length].text+'</div>';
			iHeight += this.arrPages[j%this.arrPages.length].height + this.nGap;
		}
	}
}

function PageScroller_start()
{
	if ( this.browser == 2 )
	{
		var i, l, iHeight = (this.Mode == 0) ? 1 : this.sheight; 
		l = this.Layers[0];
		for ( i = l.document.layers.length-1 ; i >= 0 ; i-- )
			l.document.layers[i].moveAbove ( l );
		for ( i = 0 ; i < this.iTotDiv ; i++ )
		{
			l = this.Layers[i+1];
			l.top = iHeight; l.width = this.swidth; l.visibility = "show";
			l = l.document.layers[0]; l.width = this.swidth; l.visibility = "show";
			iHeight += this.arrPages[i%this.arrPages.length].height ;
		}
	}
	if (!this.bPauseFlag) this.nIntervalId = setInterval(this.name+".Marquee();", 100 );
	this.Started = 1;
}

function PageScroller_GetIFrame ( index )
{
	if ( this.browser == 1 ) return document.all("IFrame"+this.name+index);
	else if ( this.browser == 2 ) return null;
	else if ( this.browser == 3 ) return document.getElementById("IFrame"+this.name+index);
}

function PageScroller_GetTop ( name, index )
{
	if (this.browser == 1) return document.all(name).style.pixelTop;
	else if ( this.browser == 2 ) return this.Layers[index+1].top;
	else if ( this.browser == 3 ) return parseInt(document.getElementById(name).style.top);
}

function PageScroller_SetTop ( name, index, value )
{
	if (this.browser == 1 ) document.all(name).style.pixelTop = value;
	else if ( this.browser == 2 ) this.Layers[index+1].top = value;
	else if ( this.browser == 3 ) document.getElementById(name).style.top = value;
}

function PageScroller_AdjustTop(offset)
{
	for(var i = 0; i < this.iTotDiv; i++)
		this.SetTop ( "Content"+this.name+i, i, this.GetTop("Content"+this.name+i,i)-offset );
}

function PageScroller_Marquee()
{
	var i, divTop, index2;

	for(i=0; i < this.iTotDiv; i++)
	{
		divTop = this.GetTop ( "Content"+this.name+i, i ) ;
		if ( divTop > 0 && divTop <= this.sspeed )
		{ this.AdjustTop( divTop-this.sspeed ); divTop = 1; }
		if (divTop >= ((this.GetHeight("Content"+this.name+i,i))*-1))
		{
			if ( divTop == 1)
			{
				clearInterval(this.nIntervalId);
				index2 = i % this.arrPages.length;
				if ( this.EnableAudio && this.PlayAudio )
				{
					var oApplet = document.applets["ItemAudio_"+this.name];
					if ( oApplet && oApplet.AppletLoaded == true ) (this.arrPages[index2].Sound!="") ? oApplet.PlayAudio(index2+1) : oApplet.StopAudio();
				}
				this.nTimeOut = setTimeout(this.name+".nIntervalId = setInterval('"+this.name+".Marquee();',100)",this.arrPages[i%this.arrPages.length].Pause);
				divTop=this.sspeed;
			}
			this.SetTop ( "Content"+this.name+i, i, (divTop-this.sspeed));
		}
		else
		{
			index2 = ( i == 0 ) ? this.iTotDiv-1 : i-1;
			this.SetTop( "Content"+this.name+i, i, this.GetTop("Content"+this.name+index2,index2)+this.GetHeight("Content"+this.name+index2,index2)+this.nGap );
		}
	}
}

function PageScroller_GetHeight( name, index )
{
	if (this.browser == 1 ) return document.all(name).clientHeight;
	else if ( this.browser == 2 ) return this.Layers[index+1].clip.height;
	else if ( this.browser == 3 ) return document.getElementById(name).offsetHeight;
}

function PageScroller_SetDivInnerHTML ( name, val )
{
	var obj;
	
	if ( this.browser == 1 ) obj = document.all(name);
	else if ( this.browser == 3 ) obj = document.getElementById(name);
	obj.innerHTML = val;
}

function PageScroller_GetIFrameInnerHTML ( index )
{
	var obj, val = "";
	if ( this.browser == 1 )
	{
		obj = document.frames["IFrame"+this.name+index].document.all.tags("BODY");
		if ( typeof(obj[0]) != "undefined" ) val = obj[0].innerHTML;
	}
	else if ( this.browser == 3 )
	{
		obj = document.getElementById("IFrame"+this.name+index);
		if ( obj.contentDocument != null  ) val = obj.contentDocument.body.innerHTML
	}

	return val;
}

function PageScroller_MouseOver(event)
{
	if(!this.bPauseFlag) { if ( this.MouseOverPause ) this.sspeed=0; window.status=this.StatusBarMsg; }
}

function PageScroller_MouseOut(event)
{
	if(!this.bPauseFlag) { this.sspeed=this.ScrollSpeed; window.status=""; }
}

function PageScroller_Back() { }
function PageScroller_Next() { }
function PageScroller_First() { }
function PageScroller_Last() { }

function PageScroller_Pause()
{
	if ( this.browser == 4 ) return;
	this.bPauseFlag = 1;
	clearInterval(this.nIntervalId);
	clearTimeout(this.nTimeOut);
	if ( this.EnableAudio && this.PlayAudio )
	{
		var oBkApplet = document.applets["BkAudio_"+this.name];
		var oItemApplet = document.applets["ItemAudio_"+this.name];
		if ( oBkApplet && oBkApplet.AppletLoaded == true ) oBkApplet.StopAudio();
		if ( oItemApplet && oItemApplet.AppletLoaded == true ) oItemApplet.StopAudio();
	}
}

function PageScroller_Play()
{
	if ( this.browser == 4 ) return;
	if(this.bPauseFlag)
	{
		this.bPauseFlag = 0;
		if (!this.Started) return;
		this.nIntervalId = setInterval(this.name+'.Marquee();',100);
		if ( this.EnableAudio && this.PlayAudio )
		{
			var oBkApplet = document.applets["BkAudio_"+this.name];
			if ( oBkApplet && oBkApplet.AppletLoaded == true ) ( (this.BkAudioPlayOnce==true) ? oBkApplet.PlayAudio() : oBkApplet.LoopAudio() );
		}
	}
}

function PageScroller_ToggleSound()
{
	if ( this.browser == 4 ) return;
	if ( this.EnableAudio )
	{
		var oBkApplet, oItemApplet;

		this.PlayAudio = 1 - this.PlayAudio;
		if ( ! this.bPauseFlag || ! this.PlayAudio )
		{
			oBkApplet = document.applets["BkAudio_"+this.name];
			oItemApplet = document.applets["ItemAudio_"+this.name];
			if ( oBkApplet && oBkApplet.AppletLoaded == true ) 
				(this.PlayAudio==0) ? oBkApplet.StopAudio() : ( (this.BkAudioPlayOnce==true) ? oBkApplet.PlayAudio() : oBkApplet.LoopAudio() );
			if ( oItemApplet && oItemApplet.AppletLoaded == true )
				if (this.PlayAudio==0) oItemApplet.StopAudio();
		}
	}
}

function PageScroller_GotoPage ( index )
{
	var i, divTop, index2;

	index = parseInt ( index );
	if ( isNaN(index) || index <= 0 || index > this.arrPages.length ) return 0;
	this.Pause ();

	divTop = 0;
	for(i=index-1; i < this.iTotDiv; i++)
	{
		this.SetTop ( "Content"+this.name+i, i, divTop);
		divTop += this.GetHeight("Content"+this.name+i,i);
	}
	for(i=0; i < index-1; i++)
	{
		this.SetTop ( "Content"+this.name+i, i, divTop);
		divTop += this.GetHeight("Content"+this.name+i,i);
	}
	if ( this.EnableAudio && this.PlayAudio )
	{
		var oApplet = document.applets["ItemAudio_"+this.name];
		if ( oApplet && oApplet.AppletLoaded == true )
			(this.arrPages[index-1].Sound!="") ? oApplet.PlayAudio(index) : oApplet.StopAudio();
	}
}