gQuoteFaders = new Object;
var bFirstQuote = true;

var kHiddenColor = [ 0xFF, 0xFF, 0xFF ];
var kDisplayedColor = [ 0x22, 0x66, 0xBB ];

function d2h(dec)
{
       return dec.toString(16);
}
function h2d(hex)
{
       return parseInt(hex,16);
}

function CssColorToRgb(color)
{
     if(color.indexOf('rgb')<=-1)
	 {
	     return [h2d(color.substring(1,3)),h2d(color.substring(3,5)),h2d(color.substring(5,7))];
     }
     return color.substring(4,color.length-1).split(',');
}

function RgbToCssColor(color)
{
     return "rgb("+color[0]+","+color[1]+","+color[2]+")";;
}

function lerp(color0, color1, t)
{
	return [Math.round(color0[0] * (1-t) + color1[0] * t), Math.round(color0[1] * (1-t) + color1[1] * t), Math.round(color0[2] * (1-t) + color1[2] * t)];
}

function QuoteFaderBegin( containerId, quoteTextId, quoteSourceId, newQuoteText, newQuoteSource, duration, interval )
{
	key = containerId;
	var fadeObject = new Object;
	gQuoteFaders[key] = fadeObject;
	
	fadeObject.fadeDuration = duration;
	fadeObject.fadeInterval = interval;
	fadeObject.opacityDelta = -interval/duration;
	fadeObject.newQuoteText = newQuoteText;
	fadeObject.newQuoteSource = newQuoteSource;
	fadeObject.container = document.getElementById(containerId);
	fadeObject.quoteText = document.getElementById(quoteTextId);
	fadeObject.quoteSource = document.getElementById(quoteSourceId);
	fadeObject.opacity = 1.0;
	
	if ( bFirstQuote )
	{
//		kDisplayedColor = CssColorToRgb(fadeObject.container.style.color);
		fadeObject.container.style.color = RgbToCssColor(kHiddenColor);
		fadeObject.opacity = 0.0;
		bFirstQuote = false;
	}
	
	setTimeout('QuoteFaderStep("' + key + '")', fadeObject.fadeInterval);
}

function QuoteFaderStep( key )
{
	var fadeObject = gQuoteFaders[key];
	
	fadeObject.opacity += fadeObject.opacityDelta;
	var done = false;
	var pauseTime = 0;
	
	if ( fadeObject.opacity <= 0.0 && fadeObject.opacityDelta < 0.0 )
	{
		// done fading out, swap the text
		fadeObject.quoteText.innerHTML = fadeObject.newQuoteText;
		fadeObject.quoteSource.innerHTML = fadeObject.newQuoteSource;
		fadeObject.opacityDelta = -fadeObject.opacityDelta;
		fadeObject.opacity = 0.0;
		pauseTime = 800;
	}
	else if ( fadeObject.opacity >= 1.0 && fadeObject.opacityDelta > 0.0 )
	{
		// done fading in
		done = true;
		fadeObject.opacity = 1.0;
	}
	
	fadeObject.container.style.color = RgbToCssColor(lerp(kHiddenColor, kDisplayedColor, fadeObject.opacity));
	
	if ( !done )
		setTimeout('QuoteFaderStep("' + key + '")', fadeObject.fadeInterval + pauseTime);
	else
		gQuoteFaders[key] = null;
}

quotes = [
	["Having been a speaker at virtually every major industry conference there is; the LOGIN event is at the top of my list. There is no other conference I have attended with as many decision-makers and C-level executives in a venue which better fosters business and networking. Attendance is a definite must!", "Sean F. Kane, Esq. – Kane & Associates LLC"],
	["LOGIN offers great networking opportunities, a beautiful venue, valuable information from the sessions and the best amenities. LOGIN has the best online game design and marketing seminars I have attended all year and easily pays for itself in the knowledge and contacts gained.", "Aaron Jones, MarkeeDragon Inc"],
	["Where else can you find the best and brightest of the MMO space all in one place?", "Anne Toole, Narrative Designer/Writer"],
	["Last year's conference was the perfect venue for bringing together leaders and visionaries within the online gaming industry. It was an honor to serve on an executive panel with my peers, and very fulfilling to attend the wide variety of great sessions offered at the event. In my opinion it was the key event of the year for networking, catching up with industry colleagues, and making new friends. I look forward to the next LOGIN event.", "Bob Ferrari, VP of Business Development, Turbine"],
	["The networking opportunities that I encountered at LOGIN were unlike any other conference I've been a part of. The range of individuals present - from executives to relative newbies - can't be surpassed. A truly phenomenal show.", "Cody Bye, Managing Editor Ten Ton Hammer"],
	["With its laser-sharp content focus, excellent amenities, and brilliant attendees, LOGIN was easily the best conference I've attended in memory.", "Darius Kazemi, President Orbus Gameworks"],
	["The best run conference in the gaming industry.", "Douglas Naimo, President, Triggerfinger Software"],
	["This conference is at the top of my list. This was honestly a perfect conference as far as I'm concerned. The networking was fantastic, the environment was lush (even decadent), the speakers were terrific, and I loved the location.", "Erin Hoffman, Game Designer, Philomath Games"],
	["LOGIN was a great combination of education and networking, laser-focused on the people and issues that matter most to the exploding MMOG industry.", "John Young, General Manager, Slipgate Ironworks"],
	["If you work in the online games space - this is the show to attend.", "Katja Reitemeyer, Director, Media & Entertainment, iEnergizer"],
	["Thanks for all your hard work at LOGIN. It was a great turnout. I enjoyed the speakers, the topics were interesting, and the networking was incredible. I made more new friends than at any show I have attended... and that is a lot of shows!", "Krissie Franco, Exe. V.P. Production, Hydrogen Whiskey"],
	["Evergreen's conferences are everything a game conference should be &mdash; great sessions, speakers, and plenty of networking opportunities. We look forward to participating in 2009!", "Matt Tullis, Sr. Manager Game Segment, Dolby Laboratories"],
	["I think it speaks very well of the organizers that in such a short period of time they've been able to develop a conference that is so content rich, well organized and just right in terms of size. Bravo.", "Mike Doyle, Producer Online, Relic Entertainment"],
	["First time at LOGIN, great experience, learned a lot, particularly thanks to very well moderated panels. The small size like first GDCs was a great opportunity for networking.", "Nicolas Eypert, Creative Director, UBISOFT"],
	["LOGIN was a great conference - a small environment, packed with decision makers from across the games industry. We will definitely be attending in the future.", "Paul Manwell, Director - Business Development, PX Interactive"],
	["I thought that the conference made it easy to connect with almost all that attended. I liked that most people stuck around for the conference thru the end.", "Phil Adam, President, BigWorld"],
	["LOGIN was one the best organized and most valuable conferences that I have attended in a very long time!", "Pierre Joubert, Senior Director Partnerships, BitTorrent, Inc"],
	["LOGIN was positively energizing. I was absolutely thrilled to be surrounded by professionals working in MMOs and virtual worlds.", "Sande Chen, Writer/Designer, The Writers Cabal"],
	["One of the best game conferences that really work. Deals signed and the right people met.", "Seth Crofton, Humanity Online"],
	["Most relevant topics, most synergistic atmosphere, and most productive 4 days I've had in a long time. Simply put, LOGIN provides the best opportunity for executive level professional to network - period.", "Skylar Kreisher, CEO, Olympus Entertainment"],
	["One of the best game conferences I have attended, both in terms of content and execution.", "Thomas Edwards, Principal Consultant, Englobe Inc."],
	["I really found your event more rewarding than any tradeshow I have ever been to. Great talks, great atmosphere you guys built, and great food. Sign me up for next year.", "Tony Roam Gascon, Production Manager, Reinvented, Inc."],
	["Seattle is a beautiful city, a perfect backdrop for a fantastic conference. LOGIN has swiftly become my favorite event of the year.", "Troy Hewitt, Director, Community Relations Flying Lab Software"],
	["Evergreen's past event was an intimate get-together of some of the sharpest minds in the MMO field today.", "Sam Lewis, Lead Designer, Cartoon Network"],
	];

lastUsedIndex = -1;

function RandomInt( range )
{
	return Math.floor(Math.random() * range);
}

function StartQuoteFader()
{
	var nextIndex;
	do
	{
		nextIndex = RandomInt(quotes.length);
	} while ( nextIndex == lastUsedIndex && quotes.length > 1 );
	
	var newQuoteText = quotes[nextIndex][0];
	var newQuoteSource = "- " + quotes[nextIndex][1];
	
	QuoteFaderBegin("quoteContainer", "frontQuoteText", "frontQuoteSource", newQuoteText, newQuoteSource, 1500, 40);
	lastUsedIndex = nextIndex;
	setTimeout('StartQuoteFader()', 10000);
}

