// Copyright (c) 2008 Software Verification Limited 
// http://www.softwareverify.com

// this file expects that you have already loaded the appropriate prototype and scriptaculous scripts

function loadAndRun()
{
	// fetch the text to display

	new Ajax.Request('/testimonialBanner.php',
		{
			method:'get',
			onSuccess: function(transport)
			{
				var response = transport.responseText;// || "no response text";
				
				startFadeIn(response)
			},
			
			// we handle failure so that we simple re-display the most recent message

			onFailure: function()
			{
				startFadeIn(null)
			}
		});
}

function startFadeIn(str)
{
	// spend 5 seconds fading in, then call the finish callback

	new Effect.Opacity('testimonialMessage',
		{
			duration: 5.0, 
			from: 0.0, to: 1.0,
			delay: 0.0,
			afterFinish : finishFadeIn
		});

	if (str)
	{
		var	elem;

		elem = document.getElementById('testimonialMessage');
		elem.innerHTML = str;
	}
}

function finishFadeIn()
{
	// let user read the message for 10 seconds then fade out in 5 seconds

	new Effect.Opacity('testimonialMessage',
		{
			duration: 5.0, 
			from: 1.0, to: 0.0,
			delay: 10.0,
			afterFinish : loadAndRun
		});
}
