Shadowbox.init({
  language:   "cs",
  players:    ["img","iframe"]	
});

$().ready(function(){

	$("#cf").validate();
	animateMenu();
	slideshowControl();
	$('H1 A').pngfix();
	incubator();	
	offersImageToggle();
	
});

function incubator() {
	$('[rel="remove"],[rel="delete"]').click(function(){
		if(!confirm('Opravdu si přejete smazat tuto položku?')) {
			return false;
		}
	});

}

function offersImageToggle() {
	if(!$.browser.msie) {
		return;
	}
	
	$('#content .floating-list LI A').hover(
		//hover
		function(){
			$(this).css('z-index',1000);
			$(this + ' .hover-image').show();
		},
		//out
		function(){
			$(this + '.hover-image IMG').hide();
			$(this).css('z-index',2);			
		}
	);
}

function animateMenu() {
/*
	$('#nav-primary A').each(function(){
		var pos = getBgPosX(this);
	});
*/	

	$('#nav-primary A[class!="active"]')
		.mouseover(function(){
			var pos = getBgPosX(this);

			$(this).css('backgroundPosition',pos+' -66px')

			$(this).stop().animate(
				{backgroundPosition:"("+pos+" 0)"}, 
				{duration:500}
			);
			
		})
		
		.mouseout(function(){
			var pos = getBgPosX(this);
			$(this).stop().animate(
				{backgroundPosition: "(" + pos + " -66px)"}, 
				{duration:500}
			);			
			
		});	
}

function getBgPosX(self) {
	if($(self).css('backgroundPosition') == null || $(self).css('backgroundPosition') == 'undefined') {
		var pos = $(self).css('background-position-x');
	}
	else {
		var pos = $(self).css('backgroundPosition').split(' ');
		pos = pos[0];
	}
	return pos;	
}

function slideshowControl() {
	$('#slideshow-offers LI').hide().slice(0,3).show();
	$('#slideshow-offers [rel="rw"]').click(function(){
		$('#slideshow-offers LI.active:first').addClass('mark');	// mark the new beginning
		var $next = $('#slideshow-offers LI.mark').prevAll(); 
		if($next.length < 1) {
			$('#slideshow-offers LI').removeClass('mark');
			return false;
		}
		$('#slideshow-offers LI.active').removeClass('active').slideUp().fadeOut();
		$next.slice(0,3).addClass('active').slideDown().fadeIn();
		$('#slideshow-offers LI.mark').removeClass('mark');
		return false;		
	});
	$('#slideshow-offers [rel="ff"]').click(function(){
		$('#slideshow-offers LI.active:last').addClass('mark');	// mark the new beginning
		var $next = $('#slideshow-offers LI.mark').nextAll(); 
		if($next.length < 1) {
			$('#slideshow-offers LI').removeClass('mark');
			return false;
		}
		$('#slideshow-offers LI.active').removeClass('active').slideUp().fadeOut();
		$next.slice(0,3).addClass('active').slideDown().fadeIn();
		$('#slideshow-offers LI.mark').removeClass('mark');
		return false;
	});	
}	


