/* Javascript to display quotes */
var timer;
var paused = false;

var fontOpacity = 0;
var opacityChange = 4;
var fadeRate = 20;
var waitDuration = 7000;
var waitMore = 1000;
var pause = 100;

var quoteValue = 0;
var orderValue = -1;
var quoteCount = 22;
var quoteOrder = new Array(quoteCount);
var quotes = [ ["WION continues to love the ENCO product, and wouldn't trade it for the world!",
				"Jim Carlyle, WION, Ionia, MI"],
				
			   ["Technical Support is important to us...we have not been disappointed.",
			    "Drew Bodker, WBEZ, Chicago"],
			    
			   ["ENCO has been a core piece of software in the running of Sabras Radio...advanced yet straightforward usability.",
			    "Raj Baddhan, Sabras Radio, Midlands, UK"],
			    
			   ["After much research into radio automation systems, we found ENCO's DAD to be the most intuitive system for our student radio staff, and ENCO's customer service is like no other! Thank you ENCO!!!",
			    "Heidi Campbell, Bob Jones University, Greenville, SC"],
			    
			   ["DAD is the most capable and versatile system out there.",
			    "Tom McNally, WFPG/WPUR/WENJ, Atlantic City, NJ"],
			    
			   ["Having worked elsewhere supporting many other competitive systems, from personal experience I can say ENCO is the best in the business.",
			    "Bob Burnham, Specs Howard School of Broadcast Arts, Southfield, MI"],
			    
			   ["We evaluated a lot of automation system prior to our ENCO purchase. We found the features and support to be superior to anything else. Reliable and the best support in the business.",
			    "Mike Pappas, KUVO, Denver, CO"],
			   
			   ["If it's time to upgrade your digital system, DAD needs your consideration.",
			    "Tom Ray, WOR, New York"],
			    
			   ["We do big time radio in a very small market.  Our success is due in no small part to the reliability and power of DAD.",
			    "Steve Rooney, KSEL, Portales, NM"],
			   
			   ["ENCO's DAD platform is incredibly powerful, easy to operate and adaptable to any need.",
			    "Chris Arnaut, WDIV-TV, Detroit, MI"],
			    
			   ["We went with ENCO and DAD back in 1999. At that time it was better than anything else and we have not looked back.",
			    "Allan Fowler, WKMS, Murray, KY"],
			   
			   ["That's why I like Enco -- there always seems to be multiple ways to handle a problem!",
			    "Tom Barclay, Georgia Public Broadcasting, Atlanta, GA"],
			    
			   ["Kudos to all at Enco. We just finished our upgrade and are fast becoming acclimated to all the new features...looks and works great so far.",
			    "Bill Winans, WMHT, Albany, NY"],
			   
			   ["Dave and the gang at ENCO are some of the smartest techies I know.",
			    "Chris Hays, KABC/KLOS, Los Angeles, CA"],
			   
			   ["We've enjoyed good support from ENCO & intend to renew our subscription.",
			    "Gary Hilliard, Entercom Portland, Portland, OR"],
			   
			   ["It has been a pleasure to work with people who are as passionate about their company and what they do as we are of ours.",
			    "Mark Verney, ESPN, Bristol, CT"],
			   
			   ["We like the automation system and plan to use ENCO for a long time to come. Thank you for your great product and the fine support we have had in the past.",
			    "Jerry Jeske, Rio Grande Bible Institute, Edinburg, TX"],
			   
			   ["...everybody here is quite pleased with DAD.  All is well, and thanks again!",
			    "Robb Daly, KQRS/KXXR/WGVX/WGVY/WGVZ, Minneapolis, MN"],
			   
			   ["For me ENCO has always been the Excalibur of automation systems. If you can imagine it, DAD can do it.",
			    "Paul Roy, WJR/WDVD/WDRQ, Detroit, MI"],
			   
			   ["A nice marriage of superb technical features coupled with a user interface that makes sense for the end user.",
			    "Ken Mendez, Salem Communications, Dallas, TX"],
			   
			   ["ENCO's DAD is the most versatile and reliable automation system I have used. It can perform any type of programming we need and the tech support is just as impressive.",
			    "Sal Ortiz, KQTM \"The TEAM\", Albuquerque, NM"],
			    
			   ["I've been using DAD since the DOS days and DAD has met and exceeded all of our needs. The support is responsive and new product innovation is spectacular. ENCO is simply the best.",
			    "Chuck Leavens, WDUQ Pittsburgh Public Radio, Pittsburgh, PA"] ];


	

function displayQuote()
{
	document.getElementById("movie2").innerHTML = 
		"<table width='300' height='300'>" +
			"<tr>" +
				"<td width='5'></td>" +
				"<td valign=\"middle\" style=\"font-family: 'Trebuchet MS', Helvetica, sans-serif; background: white; opacity:" + fontOpacity / 100 + "; filter: alpha(opacity=" + fontOpacity + ");\">" + 
					"<font size='4' color='#000000' onmouseover='pauseQuote()' onmouseout='unpauseQuote()'>\"" + quotes[quoteValue][0] + "\"</font><br><br>" +
					"<font size='2' color='#000000' onmouseover='pauseQuote()' onmouseout='unpauseQuote()'><b>" + quotes[quoteValue][1] + "</b></font>" +
				"</td>" +
			"</tr>" +
		"</table>";

}


function pauseQuote()
{
	paused = true;
}


function unpauseQuote()
{
	paused = false;
}


function pickQuote()
{
	orderValue++;
	if (orderValue >= quoteCount)
	{
		orderValue = 0;
	}
	
	quoteValue = quoteOrder[orderValue];
	fontOpacity = 0;
	timer = window.setInterval("fadeIn()", fadeRate);
}


function fadeIn()
{
	displayQuote();
	fontOpacity += opacityChange;
	
	if (fontOpacity > 100)
	{
		fontOpacity = 100;
		window.clearInterval(timer);
		window.setTimeout("waitOver()", waitDuration);
	}	
}


function waitOver()
{
	if (paused == false)
	{
		fontOpacity = 100;
		timer = window.setInterval("fadeOut()", fadeRate);
	}
	else
	{
		window.setTimeout("waitOver()", waitMore);
	}
}


function fadeOut()
{
	displayQuote();
	fontOpacity -= opacityChange;
	
	if (paused == true)
	{
		fontOpacity = 100;
		window.clearInterval(timer);
		timer = window.setInterval("fadeIn()", fadeRate);
	}
	
	if (fontOpacity < 0)
	{
		fontOpacity = 0;
		window.clearInterval(timer);
		window.setTimeout("pickQuote()", pause);
	}
}


function writeQuote()
{
	var i, randVal, tempVal;
	
	// Fills initial array
	for (i = 0; i < quoteCount; i++)
	{
		quoteOrder[i] = i;
	}
	
	// Randomizes array
	for (i = 0; i < quoteCount - 1; i++)
	{
		randVal = Math.floor(Math.random() * (quoteCount - i)) + i;
		tempVal = quoteOrder[i];
		quoteOrder[i] = quoteOrder[randVal];
		quoteOrder[randVal] = tempVal;
	}
	
	// Start displaying quotes
	pickQuote();
}
