function fadeInPage()
{
	timer2 = setTimeout("fadeInBackground()", 1000);
}



var intBrightness = 46;

function fadeInBackground()
{	
	var aryRGB = getRGB_from_HSV(180, 255, intBrightness);
	setBackgroundColor(aryRGB);	
	
	intBrightness += 2;
		
	if (intBrightness > 100)
	{
		flyInContent();
	}
	else
	{		
		timer1 = setTimeout("fadeInBackground()", 100);	
	}
}
	
function flyInContent()
{	
	document.getElementById('contentArea').style.top = 0;	
	document.getElementById('contentArea').style.left = 0;

	HSVColorCycle();
}


var bolEnableCycle = ''
var intHue = 180;
var RGB = [0,0,0];

function HSVColorCycle()
{
	if  (bolEnableCycle=='true')
	{
		intHue += 1;
		if (intHue > 255) intHue = 0;
		
		RGB = getRGB_from_HSV(intHue, 255, 100);
		setBackgroundColor(RGB);
	}
	
	var timer1 = setTimeout("HSVColorCycle()", 200);
}

function setBackgroundColor(aryRGB)
{	
	window.document.body.style.backgroundColor='rgb(' + aryRGB['0'] + ' ' + aryRGB['1'] + ' ' + aryRGB['2'] + ')';
	document.getElementById('contentArea').style.border = 'rgb(' + aryRGB['0'] + ' ' + aryRGB['1'] + ' ' + aryRGB['2'] + ') 2px dashed';
	document.body.style.scrollbarBaseColor = 'rgb(' + aryRGB['0'] + ' ' + aryRGB['1'] + ' ' + aryRGB['2'] + ')';
	
	document.getElementById('divRed').innerText = aryRGB['0'];
	document.getElementById('divGreen').innerText = aryRGB['1'];
	document.getElementById('divBlue').innerText = aryRGB['2'];
}
	

function getRGB_from_HSV(h,s,v) //input range 0-255, returns array of 3 values
{	
	var RGB = [0,0,0];
	var range = 0;
	var phase = 0;
	var sat = 0;
	var val = 0;	
	
	h *= 6; 
	range = h % 255; 
	phase = Math.floor(h / 255);
	
	sat = s / 255;
	val = v / 255;
		
	var tmp = new Array(3);
	var mid = (7 - phase) % 3;
	tmp[Math.floor((phase + 7) / 2) % 3] = 255;
	tmp[(Math.floor(phase / 2) + 5) % 3] = 0;
	if ((phase % 2) == 1) tmp[mid] = 255 - range;
	else tmp[mid] = range;
	for (i=0; i<3; i++)
	{
		tmp[i] = 255 - ((255 - tmp[i]) * sat);
		tmp[i] *= val;
		RGB[i] = Math.round(tmp[i]);
	}
		
	return RGB 	
}	