
$(function() {
});

/** Rotator **/

var rotationSpeed = 4000;
var rotationFade  = 2000;
var imgLogo = new Array(5);
imgLogo[0]=baseUrl+'/public/img/headers/paintball-1.jpg';
imgLogo[1]=baseUrl+'/public/img/headers/paintball-2.jpg';
imgLogo[2]=baseUrl+'/public/img/headers/paintball-3.jpg';
imgLogo[3]=baseUrl+'/public/img/headers/paintball-4.jpg';
imgLogo[4]=baseUrl+'/public/img/headers/paintball-5.jpg';

var rotatorTimeOut;
var rotatorPhase;

$(function() {
	rotatorPhase = Math.round( Math.random() * 4);
	$('<img/>').appendTo('#header-rotator').attr('src',imgLogo[rotatorPhase]);
	rotatorTimeOut = setTimeout('imgRotator();',rotationSpeed);
});

function imgRotator() {
	rotatorPhase++;
	if(rotatorPhase>4) { rotatorPhase=0; }
	
	var $imgOld = $('#header-rotator img').css('zIndex',2);
	var $imgNew = $('<img/>').css('zIndex',1).appendTo('#header-rotator');
	
	
	$imgNew.load(function() {
		$imgOld.fadeOut( rotationFade , function() {
			$(this).remove();
		});
	});
	$imgNew.attr('src',imgLogo[rotatorPhase]);
	
	rotatorTimeOut = setTimeout('imgRotator('+rotatorPhase+');', rotationSpeed );
}



