
$().ready(function(){
	
	navAnimationInit();
	incubator();
	//replace_shadowbox();
	news();
	newsletter();
	holiday_selector();

});

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

function replace_shadowbox() {

	$('A[rel="order_catalogue"]').attr('href','#form-order_catalogue').attr('rel','shadowbox;height=300;width=640;');
	
}

function holiday_selector() {
	
	$('#holiday-selector .prev').click(function(){
		$active = $('#holiday-selector .content.active');
		
		if($active.prev('.content').length > 0) {
			$active.removeClass('active').prev('.content:eq(0)').addClass('active');
		}
		return false;
		
	});
	$('#holiday-selector .next').click(function(){
		$active = $('#holiday-selector .content.active');
		
		if($active.next('.content').length > 0) {
			$active.removeClass('active').next('.content:eq(0)').addClass('active');
		}
		return false;
	});

}

function navAnimationInit() {
	$("#nav-primary A:hover").css('background','none');
	$("#nav-primary").lavaLamp({ fx: "backout", speed: 700 });
}

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

function news() {
	$('#news .next').click(function(){
		if( $('#news .content.active').next('.content').hasClass('hidden') ) {
			var curr = $('#news .content.active').removeClass('active').addClass('hidden');
			$(curr).next('.content').addClass('active').removeClass('hidden');
		}
		return false;
	});
	$('#news .prev').click(function(){
		if( $('#news .content.active').prev('.content').hasClass('hidden') ) {
			var curr = $('#news .content.active').removeClass('active').addClass('hidden');
			$(curr).prev('.content').addClass('active').removeClass('hidden');
		}
		return false;
	});	
}

function newsletter() {
	$('#newsletter-block LABEL').show().click(function(){
		$(this).hide();
		$('#newsletter-block INPUT[type="text"]').focus();
	});
	$('#newsletter-block INPUT[type="text"]').val('').focus(function(){
		$('#newsletter-block LABEL').hide();
	});
	$('#newsletter-block INPUT[type="text"]').blur(function(){
		if( !$('#newsletter-block INPUT[type="text"]').val() ) {
			$('#newsletter-block LABEL').show();
		}
		
	});	
	
}


