function randCol()
{	
	var rand_col = col[ Math.floor( Math.random() * col.length ) ];	
	return rand_col;
}

function randFade(id,oldCol)
{
	var newCol = randCol();
	while (newCol == oldCol)
	{
		var newCol = randCol();
	}
	colorFade(id,'background',oldCol,newCol,35,35);
	return newCol;
}

function fade(id,alpha,endalpha)
{
	// Step av 100
	var step = 1;
	var timer = 10;
	var tt = document.getElementById(id);
	if (alpha < endalpha)
	{
		var go = 1;
	} 
	else
	{
		var go = -1;
	} 
	tt.timer = setInterval(function(){actualFade(go);},timer);
	
	function actualFade(d)
	{
		var a = alpha;
		if((a != endalpha && d == 1) || (a != 0 && d == -1)){
			var i = step;
			if(endalpha - a < step && d == 1){
				i = endalpha - a;
			}else if(alpha < step && d == -1){
				i = a;
			}
			alpha = a + (i * d);
			tt.style.opacity = alpha * .01;
			tt.style.filter = 'alpha(opacity=' + alpha + ')';
		}else{
			clearInterval(tt.timer);
			if(d == 1){startFades();}
			if(d == -1){window.location='./';}
		}
	}
}