var marqueePos = -1;
var timeout = null;
var is_visible = true;
var marqueeText = [
	"<img src=\"http://waywithwordsgroup.com/images/clientquote-Carnegie.png\" alt=\"\"><br><br>'<i>Thank you! Bang on time.</i>'<br><br>Carnegie Endowment (International)",
    "<img src=\"http://waywithwordsgroup.com/images/clientquote1.png\" alt=\"Because Words Matter\">",
	"<img src=\"http://waywithwordsgroup.com/images/clientquote-FT.png\" alt=\"\"><br><br>'<i>Thank you to all the team at Way With Words who have worked so hard on this. Thanks everyone for the extraordinary effort getting this across. Much appreciated.</i>'<br><br>Financial Times (International)",
    "<img src=\"http://waywithwordsgroup.com/images/clientquote2.png\" alt=\"Because Words Matter\">",
	"<img src=\"http://waywithwordsgroup.com/images/clientquote-asahishimbun.png\" alt=\"\"><br><br>'<i>That's more than helpful. Thank you so much! Very pleased to hear that we have our ongoing relationship so I have no doubt that that will very much continue ... as always, we're very grateful for the care and attention you offer.</i>'<br><br>Asahi Shimbun Media (Japan)",
    "<img src=\"http://waywithwordsgroup.com/images/clientquote3.png\" alt=\"Because Words Matter\">",
    "<img src=\"http://waywithwordsgroup.com/images/clientquote-IRETourism.png\" alt=\"\"><br><br>'<i>Delighted with the service Thanks. I wouldn't hesitate to use it again.</i>'<br><br>Ireland Tourism (Ireland)",
   	"<img src=\"http://waywithwordsgroup.com/images/clientquote4.png\" alt=\"Because Words Matter\">",
    "<img src=\"http://waywithwordsgroup.com/images/clientquote-Meetingzone.png\" alt=\"\"><br>'<i>Thanks for turning this around well within time. Really appreciate you smashing the deadlines. You have all done a fantastic job, I have no doubt you will exceed our expectations again.</i>'<br><br>Meetingzone (United Kingdom)",
    "<img src=\"http://waywithwordsgroup.com/images/clientquote5.png\" alt=\"Because Words Matter\">",
	"<img src=\"http://waywithwordsgroup.com/images/clientquote-HomeOffice.png\" alt=\"\"><br><br>'<i>I'd just like to say thank you very much for the rate of knots that these transcripts are appearing.</i>'<br><br>Home Office UK Government (United Kingdom)",
    "<img src=\"http://waywithwordsgroup.com/images/clientquote6.png\" alt=\"Because Words Matter\">",
	"<img src=\"http://waywithwordsgroup.com/images/clientquote-BNYMellon.png\" alt=\"\"><br><br>'<i>Thank you so, so, so much. You are a star and I am so grateful to you.</i>'<br><br>BNY Mellon (United States of America)",
    "<img src=\"http://waywithwordsgroup.com/images/clientquote7.png\" alt=\"Because Words Matter\">",
	"<img src=\"http://waywithwordsgroup.com/images/clientquote-Ornico.png\" alt=\"\"><br><br>'<i>Thank you so very much for the prompt and efficient service. We will be using your services again.</i>'<br><br>Ornico Group (South Africa)",
   	"<img src=\"http://waywithwordsgroup.com/images/clientquote8.png\" alt=\"Because Words Matter\">",
    "<img src=\"http://waywithwordsgroup.com/images/clientquote-Edexcel.png\" alt=\"\"><br><br>'<i>I just wanted to say thank you for transcribing the interviews. The transcripts are very accurate and were all ready by the due date. Excellent work.</i>'<br><br>Edexcel (United Kingdom)",
    "<img src=\"http://waywithwordsgroup.com/images/clientquote9.png\" alt=\"Because Words Matter\">",
	"<img src=\"http://waywithwordsgroup.com/images/clientquote-Werksmans.png\" alt=\"\"><br><br>'<i>Hi, Very good turnaround time. The quality of the transcript is better than what which we usually get from the Labour Court transcribers. We will use your company services again.</i>'<br><br>Werksmans Corporate and Commercial Law (South Africa)",
   	"<img src=\"http://waywithwordsgroup.com/images/clientquote10.png\" alt=\"Because Words Matter\">",
    "<img src=\"http://waywithwordsgroup.com/images/clientquote-HumanCapitalProject.png\" alt=\"\"><br><br>'<i>Thanks for the prompt turn around. The quality is great.  I look forward to receiving the others and working with you in the future.</i>'<br><br>Human Capital Project (International)",
    "<img src=\"http://waywithwordsgroup.com/images/clientquote11.png\" alt=\"Because Words Matter\">",
    "<img src=\"http://waywithwordsgroup.com/images/clientquote-SABook.png\" alt=\"\"><br><br>'<i>Excellent!  Thanks very much for your prompt response. We will definitely make use of your services again.</i>'<br><br>SA Book Council (South Africa)",
	"<img src=\"http://waywithwordsgroup.com/images/clientquote-LBS.png\" alt=\"\"><br><br>'<i>Thank you. That was so fast!!  I am amazed by your turnaround times!</i>'<br><br>London Business School (United Kingdom)",
    "<img src=\"http://waywithwordsgroup.com/images/clientquote-Filmnova.png\" alt=\"\"><br><br>'<i>Thank you again for sending over the transcription. It was great that you got it over to us so early too - a perfect service once again.</i>'<br><br>Filmnova Production (United Kingdom)",
    "<img src=\"http://waywithwordsgroup.com/images/clientquote-BreastCancerCare.png\" alt=\"\"><br><br>'<i>Many thanks for both of the transcriptions, part one and two. Excellent service!</i>'<br><br>Breast Cancer Care (International)" ];

function changeMarqueeText ()
{
	document.getElementById ( "marquee" ).innerHTML = marqueeText [ marqueePos ];
}

function setMarqueeOpacityForAllBrowsers ( alpha ) {
	document.getElementById ( "marquee" ).style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=0,opacity:" + alpha + ")";	// MSIE
	document.getElementById ( "marquee" ).style.KHTMLOpacity = alpha / 100;	// Safari < 1.2, Konqueror
	document.getElementById ( "marquee" ).style.MozOpacity = alpha / 100;	// Older Mozilla & Firefox
	document.getElementById ( "marquee" ).style.opacity = alpha / 100;	// Safari 1.2+, newer Mozilla & Firefox, CSS3
}

function affectMarquee ( currentAlpha, increment, cbFuncName ) {

	var alpha = currentAlpha + increment;

	// have we gone beyond either threshold?
	if ( alpha < 0 || alpha > 95 )	// use 95 so code jumps from 95 -> 99; Mozilla flickers the div if 95 -> 100
	{
		// if so, cancel the operation by invoking callback
		if ( cbFuncName != null )
			cbFuncName ();
	} else {
		// else, adjust transparency and setup the next adjustment
		setMarqueeOpacityForAllBrowsers ( alpha );
		setTimeout ( "affectMarquee ( " + alpha + ", " + increment + ", " + cbFuncName + " )", 25 );
	}
}


function marqueeDisappear ()
{
	affectMarquee ( 100, -5, "marqueeDisappearCallback" );
}

function marqueeAppear ()
{
	affectMarquee ( 0, 5, "marqueeAppearCallback" );
}

function marqueeDisappearCallback ()
{
	is_visible = false;
	marqueeForward ();
	marqueeAppear ();
}

function marqueeAppearCallback ()
{
	is_visible = true;
	setMarqueeOpacityForAllBrowsers ( 99 );
	timeout = setTimeout ( "marqueeDisappear ()", 10000 );
}

function marqueeForward ()
{
	if ( timeout != null ) clearTimeout ( timeout ); // cancel the pending fade out
	marqueePos++;
	if ( marqueePos >= marqueeText.length ) marqueePos = 0;
	changeMarqueeText ();

	if ( is_visible )
		timeout = setTimeout ( "marqueeDisappear ()", 10000 ); // reschedule the fade out in another 10 s
}

function marqueeBackward ()
{
	if ( timeout != null ) clearTimeout ( timeout ); // cancel the pending fade out
	marqueePos--;
	if ( marqueePos < 0 ) marqueePos = marqueeText.length - 1;
	changeMarqueeText ();

	if ( is_visible )
		timeout = setTimeout ( "marqueeDisappear ()", 10000 ); // reschedule the fade out in another 10 s
}

function startMarquee ()
{
	marqueeDisappear ();
}
