// Spectrum Colors animation effect
function spectrum()
{
	// Objects animated
	var allAnimated = "";
	var colorAnimated = "#username";
	var backgroundAnimated = "body";
	
	// Animation Params
	var duration = 4; // in seconds
	var timeout = 1; // in seconds
	var queue = true;
	
	// Select in an array of colors
	var colors = [
		'rgb(233,117,134)', 
		'rgb(248,190,135)', 
		'rgb(255,228,159)', 
		'rgb(242,171,200)', 
		'rgb(177,151,182)', 
		'rgb(222,179,207)'
	];
	// var color = randomIn(colors);
	
	// Or select a random range color
	var r = randomIn(200, 256);
	var g = randomIn(200, 256);
	var b = randomIn(200, 256);
	var color = "rgb("+r+","+g+","+b+")";
	// Animate objects
	if ($.browser.msie && $.browser.version.substr(0,1)<7)
		return false;
	else
	{
		if (allAnimated != '')
			$(allAnimated).animate({ color: color }, { queue:queue, duration:duration*1000 });
		if (colorAnimated != '')
			$(colorAnimated).animate({ color: color }, { queue:queue, duration:duration*1000 });  
		if (backgroundAnimated != '')
			$(backgroundAnimated).animate({ backgroundColor: color }, { queue:queue, duration:duration*1000, complete:function(){ setTimeout("spectrum()", timeout*1000); } });  
	}
}

// Get a random number in a range or array
function randomIn(val1, val2)
{
	if (typeof val1== 'object')
		return val1[val1.length - 1];
		
	else if (typeof val1 == 'number' && typeof val2 == 'number')
		return Math.floor(val1 + ( Math.random() * ( val2 - val1 ) ));
		
	else
		return false;
}
