var demo_2_marqueePos = -1;
var demo_2_timeout = null;
var demo_2_is_visible = true;
var demo_2_marqueeText = [
	"<img src='http://jerrata.com/software/images/marquee_bg_1.png'>",
	"<img src='http://jerrata.com/software/images/marquee_bg_2.png'>",
	"<img src='http://jerrata.com/software/images/marquee_bg_3.png'>",
	"<img src='http://jerrata.com/software/images/marquee_bg_4.png'>",
	"<img src='http://jerrata.com/software/images/marquee_bg_5.png'>",
	"<img src='http://jerrata.com/software/images/marquee_bg_6.png'>"
];

function demo_2_changeMarqueeText ()
{
	document.getElementById ( "marquee_demo_2" ).innerHTML = demo_2_marqueeText [ demo_2_marqueePos ];
}

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

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

function demo_2_marqueeDisappear ()
{
	demo_2_affectMarquee ( 100, -5, "demo_2_marqueeDisappearCallback" );
}

function demo_2_marqueeAppear ()
{
	demo_2_affectMarquee ( 0, 5, "demo_2_marqueeAppearCallback" );
}

function demo_2_marqueeDisappearCallback ()
{
	demo_2_is_visible = false;
	demo_2_marqueeForward ();
	demo_2_marqueeAppear ();
}

function demo_2_marqueeAppearCallback ()
{
	demo_2_is_visible = true;
	demo_2_setMarqueeOpacityForAllBrowsers ( 99 );
	demo_2_timeout = setTimeout ( "demo_2_marqueeDisappear ()", 8000 );
}

function demo_2_marqueeForward ()
{
	if ( demo_2_timeout != null )
		clearTimeout ( demo_2_timeout );
		
	demo_2_marqueePos++;
	
	if ( demo_2_marqueePos >= demo_2_marqueeText.length )
		demo_2_marqueePos = 0;
		
	demo_2_changeMarqueeText ();
	
	if ( demo_2_is_visible )
		demo_2_timeout = setTimeout ( "demo_2_marqueeDisappear ()", 8000 );
}

function demo_2_marqueeBackward ()
{
	if ( demo_2_timeout != null )
		clearTimeout ( demo_2_timeout );
		
	demo_2_marqueePos--;
	
	if ( demo_2_marqueePos < 0 )
		demo_2_marqueePos = demo_2_marqueeText.length - 1;
		
	demo_2_changeMarqueeText ();
	
	if ( demo_2_is_visible )
		demo_2_timeout = setTimeout ( "demo_2_marqueeDisappear ()", 8000 );
}

function demo_2_startMarquee ()
{
	demo_2_marqueeDisappear ();
}