var _FEATURED = new Array('ifindwordz','iclimb','bughunt');
var _QUOTE_OFFSET = 0;
var _QUOTES = new Array(
		{ 
			product: 'iFindWordz',
			count: 0, 
			quotes: new Array(
				'I am learning about new words I never knew I could make',
				'I found words I never thought were possible',
				'I no longer have to lug around my dictionary when playing scrabble',
				'We allow ourselves 3 word searches per game',
				'A quick and easy way to verify words')
		},
		{
			product: 'iClimb',
			count: 0, 
			quotes: new Array(
				'Now I can easily keep track of all my climbing activities',
				'I can easily monitor my progress and improve my climbing',
				'I can reminisce about past climbs with friends',
				'Now I will never forget when I completed that classic climb')
		},
		{
			product: 'SandScapes',
			count: 0,
			quotes: new Array(
				'Fascinating display of falling sand',
				'I love to tilt it upside down and watch the mountains dissolve',
				'Watching each grain bounce around is a hoot',
				'Its like meditation I tilt it side to side to make cool scenes',
				'Each particle seems to have a life of its own')
		},
		{
			product: 'BugHunt',
			count: 0,
			quotes: new Array(
				'I really like the graphics, sounds and game play.',
				'Fun to play, kept me busy for 50 minutes.')
		},
		{
			product: 'Visumass',
			count: 0,
			quotes: new Array(
				'I like your software.  Simple and nice.',
				'VisuMass really helped me reach my weight loss goal, thank you!')
		}
);
var _PRODUCTS	= new Array('product_ifindwordz','product_iclimb','product_sandscapes','product_bughunt','product_visumass');

function homeConstr() {

	initProducts();

	initFeatured();

	initQuotes();
}
function initProducts() {
	for (var i=0; i<_PRODUCTS.length; i++) {
		$(_PRODUCTS[i]).hide();
	}
	$('quote-loader').hide();
}
function initQuotes() {
	e = setTimeout('swapQuote()', 3000);
	_QUOTE_OFFSET++;
}
function swapQuote() {

	x = new Effect.Pulsate($$('div#quote-container')[0], { pulses: 1, duration: 2.0 });
	y = setTimeout('updateText()', 1000);
	t = setTimeout('swapQuote()', 5000);
}
function updateText() {

	var objProdId = _QUOTE_OFFSET - 1;
	$(_PRODUCTS[objProdId]).hide();
	newQuote = getQuote();
	$$('div.quote')[0].innerHTML = '"'+newQuote+'"';

	objProdId = _QUOTE_OFFSET - 1;
	$(_PRODUCTS[objProdId]).show();
}
function getQuote() {
	if (_QUOTE_OFFSET == _QUOTES.length) {
		_QUOTE_OFFSET = 0;
	}
	var objProd = _QUOTES[_QUOTE_OFFSET];

	// get random quote
	var offset = Math.floor(Math.random()*objProd.quotes.length);


	_QUOTE_OFFSET++;
	return objProd.quotes[offset];
}

_FEATURED		= new Array(
	{
		id: 'button-ifindwordz',
		hoverClass: 'featured-ifindwordz-hover',
		inhoverClass: 'featured-ifindwordz'
	},
	{	
		id: 'button-iclimb',
		hoverClass: 'featured-iclimb-hover',
		inhoverClass: 'featured-iclimb'
	},
	{	
		id: 'button-sandscapes',
		hoverClass: 'featured-sandscapes-hover',
		inhoverClass: 'featured-sandscapes'
	},
	{	
		id: 'button-bughunt',
		hoverClass: 'featured-bughunt-hover',
		inhoverClass: 'featured-bughunt'
	},	
	{	
		id: 'button-visumass',
		hoverClass: 'featured-visumass-hover',
		inhoverClass: 'featured-visumass'
	}
);
_RANDOM_COUNT = 2;
_FEATURED_RANDOM = new Array(_RANDOM_COUNT);
_FEATURED_DEFAULT_CLASS = 'featured';
function initFeatured() {
	
	for (var i=0; i<_RANDOM_COUNT; i++) {
		_FEATURED_RANDOM[i] = popRandom();
	}
	
	for (i=0; i<_FEATURED.length; i++) {
		$(_FEATURED[i].id).hide();
	}
	$('feature-loader').hide();
/*	for (var j=0; j<_RANDOM_COUNT; j++) {
//		alert(_FEATURED_RANDOM[j].id);
		Element.observe($(_FEATURED_RANDOM[j].id), 'mouseover', function(event) {
//			alert(event.element());
//			$(_FEATURED_RANDOM[arguments[0]].id).className = _FEATURED_DEFAULT_CLASS + ' ' + _FEATURED_RANDOM[arguments[0]].hoverClass;
		});
	}*/
}

function popRandom() {
	var rand = Math.floor(Math.random()*_FEATURED.length);

	//swap
	var last = _FEATURED.length - 1;
	var s = _FEATURED[last];
	_FEATURED[last] = _FEATURED[rand];
	_FEATURED[rand] = s;

	return _FEATURED.pop();
}