/* Change the active-status in the navigation */
var menueactive = function(){

		$$('#tlnav a').each(function(el){
			el.onmouseover = function() {
				playbox(0);
			}
			el.onmouseout = function() {
				stopbox(0);
			}
	});	
}

/* Remove the current active-status from the navigation */
var rmactiveclass = function(){
	$$('#tlnav a').each(function(el){
		el.removeClass("active");	
	});
}

/* Change the soundbox in the navigation (focus)  */
var playbox = function(stat){
				if(stat == 0){
					$$('#boxleft img')[0].src = "tl_files/css/screen/images/box-act.png";
					$$('#boxright img')[0].src = "tl_files/css/screen/images/box-act.png";
					stopbox.delay(100);
				}
}

/* Change the soundbox in the navigation */
var stopbox = function(stat){
					$$('#boxleft img')[0].src = "tl_files/css/screen/images/box.png";
					$$('#boxright img')[0].src = "tl_files/css/screen/images/box.png";
				if(stat == 1){
					playbox.delay(1000);
				}
}


/* Random Function */
function GetRandom( min, max ) {
     if( min > max ) {
	  return( -1 );
      }
      if( min == max ) {
         return( min );
      }
return( min + parseInt( Math.random() * ( max-min+1 ) ) );
}

/* Create a random Hexcolor */
function GetColor(hexa){
var color = hexa;
	switch(hexa){
		case 10: color = "A"; break;
		case 11: color = "B"; break;
		case 12: color = "C"; break;
		case 13: color = "D"; break;
		case 14: color = "E"; break;
		case 15: color = "F"; break;
	}
	
	return color;
}

var i=0;
function MyColors(){
	var colors = new Array(	
		"9e0e0e",
		"cf5c07",
		"043c00",
		"0c5357",
		"28517e",
		"1d2572",
		"462977",
		"a6369d",
		"af0112"
	);
	
	if(i <= colors.length){
		i++;
	}else{
		i=0;
	}	
	return colors[i];
}

/* Change the background-color */
var bgcolor = function(){
	
	var el = $('overlay');
	var original = el.getStyle('background-color');
	
	//var color = GetColor(GetRandom(0,15))+GetColor(GetRandom(0,15))+GetColor(GetRandom(0,15))+GetColor(GetRandom(0,15))+GetColor(GetRandom(0,15))+GetColor(GetRandom(0,15));
	var color = MyColors();
	
	el.set('tween', { duration: 3000 }).tween('background-color', original, "#"+color);
	
	bgcolor.delay(20000);
}



window.addEvent('domready', function(e) {
	menueactive();	
	bgcolor.delay(20000);
});




