var curBan = 0;

$(document).ready(function(){
	// *** MAIN MENU sign width
	$('div.sign').each(function(i){
	 var myDiv = $('div.item')[i];
	 $(this).css({ width: $(myDiv).width()});
	});
	
	
	// Header navigation
	// *** Next 
	$('.ban_but_n').hover(function(){
		$(this).attr("src", "/local/img/ban_next_over-trans.png");
	}, function() {  
        $(this).attr("src","/local/img/ban_next_out-trans.png");
    });
	$('.ban_but_n').click(function(event){
		openBan(curBan + 1);
	});    
	// *** Prev
	$('.ban_but_p').hover(function(){
		$(this).attr("src", "/local/img/ban_prev_over-trans.png");
	}, function() {  
        $(this).attr("src","/local/img/ban_prev_out-trans.png");
    });
	$('.ban_but_p').click(function(event){
		openBan(curBan - 1);
	});  

	startTimer();
	openBan(0);
	
	
	// Najazd na bottomBoxLeft
	$('div#bottomBoxLeft').mouseover(function(event){
		$(this).css({ backgroundColor: "#343434"});
	}).mouseout(function(event){
		$(this).css({ backgroundColor: "#2B2B2B"});
	});
		
	// Najazd na komentarze
	$('div.commentItem').mouseover(function(event){
		$(this).css({ backgroundColor: "#232323"});
	}).mouseout(function(event){
		$(this).css({ backgroundColor: "#121212"});
	});
		
	
});

// *** Open Banner
function openBan(n){
	curBan = n;
	if (curBan > banIMG.length - 1)
		curBan = 0;
	if (curBan < 0)
		curBan = banIMG.length - 1;
		
	hideBox();
	resetTimer();
}
function nextBan(){
	openBan(curBan + 1);
}

function hideBox(){
 $('div#ban_displ').fadeOut("normal", setupBox);
}

function setupBox(){
	var imgsrc = banIMG[curBan];
	var url = banURL[curBan];
	$('div#ban_displ').html('<a href="' + url +'" target="_self"><img src="' + imgsrc + '" border="0" alt=""/></a>');
	$('div#ban_displ').fadeIn("normal");
}


// *** Banner timer
function startTimer(){ 
	bannerTimer = setTimeout('nextBan()', 7000); 
}
function resetTimer(){ 
	clearTimeout ( bannerTimer ); 
	startTimer(); 
}
                

