Cufon.replace('h1');
Cufon.replace('h2');
Cufon.replace('h3');
Cufon.replace('h4');

$(document).ready(function()
{	
	$('form input.button').val('');

	// login
	$(document).cheatCode({
		code : '76,79,71,73,78',
		unbind : false,
		activated : function(){
			window.location = 'sessie';
		}
	});
	// loguit
	$(document).cheatCode({
		code : '76,79,71,85,73,84',
		unbind : false,
		activated : function(){
			window.location = 'sessie?redirect=index.php&logout='+_sessionKeyMd5_;
		}
	});
	// egg
	$(document).cheatCode({
		code : '77,73,70,70,76,69,83',
		unbind : false,
		activated : function(){
			setInterval('placeMiffles();', 100); 
		}
	});
	$(document).cheatCode({
		code : '68,79,69,73',
		unbind : false,
		activated : function(){
			$('body').css({overflow:'hidden'});
			$('#site-container #site-body').css({'background-image':'none'});
			setInterval('placeDoei();', 100); 
			setTimeout(function(){switchbackGround(false);}, 1000); 
		}
	});
	$(document).cheatCode({
		code : '78,69,67',
		unbind : false,
		activated : function(){
			$('body').css({overflow:'hidden'});
			$('#site-container #site-body').css({'background-image':'none'});
			setInterval('placeNEC();', 100); 
			setTimeout(function(){switchbackGround(true);}, 1000); 
		}
	});
	var oParagraphs = $('#testimonial-message').find('p').css('display','none');
	var iShow = random(0,oParagraphs.length);
	oParagraphs.eq( iShow ).css('display','block');
	

	$('#editable-footer_testimonials .rapidEdit-link').live('mousedown', function(){
    $(this).parent().find('p').removeAttr('style').css({display:'block'});
	});

	
});



function placeMiffles()
{
	if ( $('div.miffles').length <= 400 )
	{
		$('div#site-container').append('<div style="left:'+random(20, $(window).width()-75)+'px;top:'+random(20, $(window).height()-75)+'px;" class="miffles"><img src="/images/miffles.gif" alt="Miffles!" title="" /></div>');
	}
}
function placeNEC()
{
	if ( $('div.nec').length <= 400 )
	{
		$('div#site-container').append('<div style="position:absolute;left:'+random(0, $(window).width()-75)+'px;top:'+random(0, $(window).height()-75)+'px;" class="nec"><img src="/images/nec-nijmegen.png" alt="NEC" title="" width="50%" /></div>');
	}
}
curColor = 0;
function switchbackGround(bNEC)
{	
	if (bNEC==true)
	{
		var aColors = ["#Db3742","#269467","#000201"];
		var color = aColors[curColor];
		(curColor < 2 ? curColor++ : curColor = 0);
	}
	else
	{
		var color = genColor();
	}
	//$('body').css({'backgroundColor':genColor()});
	$('body').animate({'backgroundColor':color},1000,function(){
		setTimeout(function(){switchbackGround(bNEC);}, 3000); 	
	});
	
}
function placeDoei()
{
	var sId = 'doei-'+ random(10000,99999);
	if ( !$('div#'+ sId).length)
	{
		$('<div id="'+sId+'" style="font-size:'+(random(60,120))+'px;color:'+genColor()+'">DOEI!!</div>')
			.css({position:'absolute',top: random(0,100) + '%',left:'-200px'})
			.appendTo($('body'))
			.animate({left:'100%','font-size':'150%'},random(100,2000),function(){
				$(this).remove();
			})
	}
}

function random(min, max)
{
	return Math.floor(Math.random() * (max - min)) + min;
}

function genColor(){
	colors = ["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];
	var color = "#";
	for (i=0;i<6;i++)
	{
		color = color + colors[Math.round(Math.random()*14)];
	}
	return color;
}

(function(d){d.each(["backgroundColor","borderBottomColor","borderLeftColor","borderRightColor","borderTopColor","color","outlineColor"],function(f,e){d.fx.step[e]=function(g){if(!g.colorInit){g.start=c(g.elem,e);g.end=b(g.end);g.colorInit=true}g.elem.style[e]="rgb("+[Math.max(Math.min(parseInt((g.pos*(g.end[0]-g.start[0]))+g.start[0]),255),0),Math.max(Math.min(parseInt((g.pos*(g.end[1]-g.start[1]))+g.start[1]),255),0),Math.max(Math.min(parseInt((g.pos*(g.end[2]-g.start[2]))+g.start[2]),255),0)].join(",")+")"}});function b(f){var e;if(f&&f.constructor==Array&&f.length==3){return f}if(e=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(f)){return[parseInt(e[1]),parseInt(e[2]),parseInt(e[3])]}if(e=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(f)){return[parseFloat(e[1])*2.55,parseFloat(e[2])*2.55,parseFloat(e[3])*2.55]}if(e=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(f)){return[parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16)]}if(e=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(f)){return[parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16)]}if(e=/rgba\(0, 0, 0, 0\)/.exec(f)){return a.transparent}return a[d.trim(f).toLowerCase()]}function c(g,e){var f;do{f=d.curCSS(g,e);if(f!=""&&f!="transparent"||d.nodeName(g,"body")){break}e="backgroundColor"}while(g=g.parentNode);return b(f)}var a={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0],transparent:[255,255,255]}})(jQuery);
