var demo_marqueePos = -1;
var demo_timeout = null;
var demo_is_visible = true;
var demo_marqueeText = [
	"<em>Does your website DoMarquee?</em>",
	"DoMarquee supports embedded <a href='http://jerrata.com/?product=DoMarquee'>Web links</a>.",
	"DoMarquee supports embedded <a href='mailto:johnnie@jerrata.com?subject=DoMarquee'>email links</a>.",
	"DoMarquee shows <strong>any content</strong> you'd like to display",
	"<em>smoothly</em>: with <strong>attractive</strong>, fading animations.",
	"DoMarquee is <strong>fully-customizable</strong> for <u>your</u> website.",
	"<strong>Show banner ads</strong> for 30 seconds each, or 2 minutes.",
	"Showcase <strong>famous quotes</strong> and wise sayings.",
	"Create an online <strong>photo album</strong> for family & friends.",
	"<strong>Forward & backward buttons</strong> support scrolling.",
	"Add an <strong>unlimited</strong> number of slides to your marquee.",
	"Know Javascript? Make changes to DoMarquee at will.",
	"Sample webpage included to make installation <u>easy</u>.",
	"Download DoMarquee <strong>for free</strong>, today!"
];

function demo_changeMarqueeText ()
{
	document.getElementById ( "marquee_demo" ).innerHTML = demo_marqueeText [ demo_marqueePos ];
}

function demo_setMarqueeOpacityForAllBrowsers ( alpha )
{
	document.getElementById ( "marquee_demo" ).style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=0,opacity:" + alpha + ")";
	document.getElementById ( "marquee_demo" ).style.KHTMLOpacity = alpha / 100;
	document.getElementById ( "marquee_demo" ).style.MozOpacity = alpha / 100;
	document.getElementById ( "marquee_demo" ).style.opacity = alpha / 100;
}

function demo_affectMarquee ( currentAlpha, increment, cbFuncName )
{
	var alpha = currentAlpha + increment;
	
	if ( alpha < 0 || alpha > 95 )
	{
		if ( cbFuncName != null )
			cbFuncName ();
	}
	else
	{
		demo_setMarqueeOpacityForAllBrowsers ( alpha );
		setTimeout ( "demo_affectMarquee ( " + alpha + ", " + increment + ", " + cbFuncName + " )", 25 );
	}
}

function demo_marqueeDisappear ()
{
	demo_affectMarquee ( 100, -5, "demo_marqueeDisappearCallback" );
}

function demo_marqueeAppear ()
{
	demo_affectMarquee ( 0, 5, "demo_marqueeAppearCallback" );
}

function demo_marqueeDisappearCallback ()
{
	demo_is_visible = false;
	demo_marqueeForward ();
	demo_marqueeAppear ();
}

function demo_marqueeAppearCallback ()
{
	demo_is_visible = true;
	demo_setMarqueeOpacityForAllBrowsers ( 99 );
	demo_timeout = setTimeout ( "demo_marqueeDisappear ()", 10000 );
}

function demo_marqueeForward ()
{
	if ( demo_timeout != null )
		clearTimeout ( demo_timeout );
		
	demo_marqueePos++;
	
	if ( demo_marqueePos >= demo_marqueeText.length )
		demo_marqueePos = 0;
		
	demo_changeMarqueeText ();
	
	if ( demo_is_visible )
		demo_timeout = setTimeout ( "demo_marqueeDisappear ()", 10000 );
}

function demo_marqueeBackward ()
{
	if ( demo_timeout != null )
		clearTimeout ( demo_timeout );
		
	demo_marqueePos--;
	
	if ( demo_marqueePos < 0 )
		demo_marqueePos = demo_marqueeText.length - 1;
		
	demo_changeMarqueeText ();
	
	if ( demo_is_visible )
		demo_timeout = setTimeout ( "demo_marqueeDisappear ()", 10000 );
}

function demo_startMarquee ()
{
	demo_marqueeDisappear ();
}