$(document).ready(function() {
	if($('#nav_map')) {
		$('#nav_map area').each(function() {
			$(this).mouseover(function(e) {
				var country_id = $(this).attr('id').replace('area_', '');
				$('#'+country_id).fadeIn('fast');
				// $('#'+country_id).show();
			});
			
			$(this).mouseout(function(e) {
				var country_id = $(this).attr('id').replace('area_', '');
				// $('#'+country_id).fadeOut('fast');
				$('#'+country_id).hide();
			});
		});
	}
	
	$("a[rel^='lightbox']").prettyPhoto({
		theme:'facebook',
		onOpen: function(){$('object').css('visibility','hidden');},
		onClosed: function(){$('object').css('visibility','visible');},
		hideflash: true,
		social_tools:'',
		deeplinking: false
	});
	
	if ($("#tt_pr").length) $("#tt_pr").easyTooltip({elmid:"tt_pr", useElement: "tt_pr_box", prodejna_cd: "Pr"});
	if ($("#tt_os").length) $("#tt_os").easyTooltip({elmid:"tt_os", useElement: "tt_os_box", prodejna_cd: "Os"});
	if ($("#tt_vi").length) $("#tt_vi").easyTooltip({elmid:"tt_vi", useElement: "tt_vi_box", prodejna_cd: "Vi"});
	if ($("#tt_ba").length) $("#tt_ba").easyTooltip({elmid:"tt_ba", useElement: "tt_ba_box", prodejna_cd: "Ba"});
	if ($("#tt_ke").length) $("#tt_ke").easyTooltip({elmid:"tt_ke", useElement: "tt_ke_box", prodejna_cd: "Ke"});
	if ($("#tt_tn").length) $("#tt_tn").easyTooltip({elmid:"tt_tn", useElement: "tt_tn_box", prodejna_cd: "Tn"});
	$(".help").easyTooltip();
	
	function initCallback(carousel, state)
	{	if (state == 'init')
		{	$(".jcarousel-next-horizontal").hide();
			$(".jcarousel-prev-horizontal").hide();
		}
		carousel.buttonNext.bind('click', function() {
			carousel.startAuto(0);
		});
		carousel.buttonPrev.bind('click', function() {
			carousel.startAuto(0);
		});
	};
	function FadeInBtn(cl)
	{	$(".jcarousel-next-horizontal").fadeIn("fast");
		$(".jcarousel-prev-horizontal").fadeIn("fast");
	}
	function FadeOutBtn(cl)
	{	$(".jcarousel-next-horizontal").fadeOut("fast");
		$(".jcarousel-prev-horizontal").fadeOut("fast");
	}
	
	function setupCallbackBanner(carousel)
	{	$(".jcarousel-skin-banner").hover(function() {
			carousel.stopAuto(); FadeInBtn()
			}, function() {
				carousel.startAuto(); FadeOutBtn();
			});
	}
	function setupCallbackNp(carousel)
	{	$(".jcarousel-skin-np").hover(FadeInBtn, FadeOutBtn);
	}
	function setupCallbackAcc(carousel)
	{	$(".jcarousel-skin-acc").hover(FadeInBtn, FadeOutBtn);
	}
	
	if ($('#jcarousel-np').length)
		$('#jcarousel-np').jcarousel({scroll:3,initCallback:initCallback, setupCallback:setupCallbackNp});
	if ($('#jcarousel-banner').length && $('#jcarousel-banner li').length>1) 
		$('#jcarousel-banner').jcarousel({auto:5,scroll:1,wrap:'circular',initCallback:initCallback, setupCallback:setupCallbackBanner});
	if ($('#jcarousel-acc').length && $('#jcarousel-acc li').length>4)
		$('#jcarousel-acc').jcarousel({scroll:4,initCallback:initCallback, setupCallback:setupCallbackAcc});

	if ($('#mask').length)
	{	$('#mask').css({'height':$($('a[rel=panel].selected')).height()});
		$('#panels').width(parseInt($('#mask').width() * $('#panels .panel').length));
		$('#panels .panel').width($('#mask').width());
		$('a[rel=panel]').click(function ()
		{	var panelheight = $($(this).attr('href')).height();
			$('a[rel=panel]').removeClass('selected');
			$(this).addClass('selected');
			$('#mask').animate({'height':panelheight},{queue:false, duration:500});
			$('#mask').scrollTo($(this).attr('href'), 300);
			return false;
		});
		$('a[rel=panel].selected').click();
	}
	
	if ($('#need_help').length)
	{	$('#need_help').tabSlideOut({
			tabHandle: '.need_help_handle',
			pathToTabImage: '/images/need_help_'+$('#need_help').attr("rel")+'.png',
			imageHeight: '215px',
			imageWidth: '47px',
			tabLocation: 'right',
			speed: 300,
			action: 'click',
			topPos: '171px',
			leftPos: '20px',
			fixedPosition: false
		});
	}
	
	
	if ($('#news_tabslide').length)
	{	$('#news_tabslide').tabSlideOut({
			tabHandle: '.news_tabslide_handle',
			pathToTabImage: '/images/news_tabslide_'+$('#news_tabslide').attr("rel")+'.png',
			imageHeight: '183px',
			imageWidth: '53px',
			tabLocation: 'right',
			speed: 300,
			action: 'click',
			topPos: '398px',
			leftPos: '20px',
			fixedPosition: false
		});
	}
	

	$("ul.top-menu li").hover(function()
	{	$(this).addClass("hover");
		$('ul:first',this).fadeIn(200);
	}, function()
	{	$(this).removeClass("hover");
		$('ul:first',this).fadeOut(200);
	});
});
