$(document).ready(function() {
       
       $(".product-photo a").fancybox();
	
       $(".fancy").fancybox();
       $(".fancy-video").fancybox();
       
	$(".thumbs-area").cycle({
        fx:      'fade',
        timeout:  0,
        prev:    '#prev',
        next:    '#next'
        });
        
	
	var iletych = $(".thumbs-area > .thumb-pack").length;
		var iletam = iletych - 1;
		var ileindex = iletych + 1;
	
	if ($(".thumbs-area .thumb-pack").eq(0).css('z-index') == (ileindex))
		{
			$("#prev").hide();
			$("#prev-off").show();
		}
		else {
			$("#prev").show();
			$("#prev-off").hide();
		}
                
       var n = $(".thumbs-area ul > li").length;
       if (n<6) 

		{
			$("#prev").hide();
			$("#prev-off").show();
                        $("#next").hide();
			$("#next-off").show();
		}
		
		
	
       $(".navi-btn").click(function() {
		

		if ($(".thumbs-area .thumb-pack").eq(0).css('z-index') == (ileindex))
		{
			$("#prev").hide();
			$("#prev-off").show();
		}
		else {
			$("#prev").show();
			$("#prev-off").hide();
		}
	
	
		if ($(".thumbs-area .thumb-pack").eq(iletam).css('z-index') == (ileindex))
		{
			$("#next").hide();
			$("#next-off").show();
		}
		else {
			$("#next").show();
			$("#next-off").hide();
		}			
	});


	$(".thumbs-area .thumb-pack ul li a").click(function() {
	
	var ileile = $(".thumbs-area .thumb-pack ul  li > a").index(this);
	$(".thumbs-area .thumb-pack ul li a img").removeClass('active');
	$(this).children('img').addClass('active');
	$(".product-photo a").hide();
	$(".product-photo > a").eq(ileile).show();

	});
	
	
	$(".menu-insie li a.lvl").click(function() {
		$(this).addClass('active');
		var dad = $(this).parent();
		//$(".menu-insie li").hide();
		$(dad).show();
		var uldad = $(dad).children('.submenu')
		$(uldad).children('li').show();
		$(uldad).show();
	});
	
	$(".menu-insie .close-menu").click(function() {
		$(".menu-insie li a.lvl").removeClass('active');
		var dad4 = $(this).parent();
		//$(".menu-insie li").show();
		$(dad4).hide();
	});
	
	/*
	$(".bottom-menu li a.lvl").click(function() {
		$(this).addClass('active');
		var dad = $(this).parent();
		$(".bottom-menu li").hide();
		$(dad).show();
		var uldad = $(dad).children('.submenu')
		$(uldad).children('li').show();
		$(uldad).show();
	});
	
	$(".bottom-menu .close-menu").click(function() {
		$(".bottom-menu li a.lvl").removeClass('active');
		var dad4 = $(this).parent();
		$(".bottom-menu li").show();
		$(dad4).hide();
	});
	*/
	
	$(".menu-level1 .menu-lvl-content .close-menu").click(function() {
		var dad3 = $(this).parent().parent().parent();
		$(dad3).hide();
		$('.menu-level2').hide();
		$('.menu-level3').hide();
		$('.menu-level4').hide();
		$('.main-menu a.lvl-down').removeClass('active');
		$('.menu-lvl-content a.lvl-down').removeClass('active');
	});
	$(".menu-level2 .menu-lvl-content .close-menu").click(function() {
		var dad3 = $(this).parent().parent().parent();
		$(dad3).hide();
		$('.menu-level3').hide();
		$('.menu-level4').hide();
		$('.menu-lvl-content a.lvl-down').removeClass('active');
	});
	$(".menu-level3 .menu-lvl-content .close-menu").click(function() {
		var dad3 = $(this).parent().parent().parent();
		$(dad3).hide();
		$('.menu-level4').hide();
		$('.menu-lvl-content a.lvl-down').removeClass('active');
	});
	$(".menu-level4 .menu-lvl-content .close-menu").click(function() {
		var dad3 = $(this).parent().parent().parent();
		$(dad3).hide();
		$('.menu-lvl-content a.lvl-down').removeClass('active');
	});
	
	$('.main-menu a.lvl-down').click(function() {
		$('.main-menu a.lvl-down').removeClass('active');
		$('.menu-lvl-content a.lvl-down').removeClass('active');
		$(this).addClass('active');
		var dad2 = $(this).attr("rel");
		var mom1 = $(this).attr("title");
		$('.show-menu').hide();
		$(mom1).children(dad2).show();
	});
	
	$('.menu-lvl-content a.lvl-down').click(function() {
		$(this).parent().parent().find('a').removeClass('active');
		$(this).addClass('active');
		var mom3 = $(this).parent().parent().parent().parent().parent();
		var dad2 = $(this).attr("rel");
		$(mom3).find('.show-menu').hide();
		$(this).parent().parent().parent().parent().show();
		$(this).parent().parent().parent().parent().prevAll('.show-menu').show();
		$(mom3).children(dad2).show();
		$(mom3).children(dad2).find('a.lvl-down').removeClass('active');
	});
	
	$('.close-me-x').click(function() {
		$('.pic-desc-box').hide();
	});
	$('.slide-me-x').click(function() {
		$(this).hide();
		$('.slide-me-y').show();
		$('.upper').slideUp();
		$('.content-desc-bottom2').delay(100).fadeIn('fast');
		
	});
	$('.slide-me-y').click(function() {
		$(this).hide();
		$('.slide-me-x').show();
		$('.upper').slideDown();
		$('.content-desc-bottom2').delay(100).fadeOut('fast');
		

	});
	
	
	for(var b=2;b<50;b+=3)
	$('.cat-list .cat-list-item:eq('+b+')').css("margin-right","0px");
	
	for(var c=4;c<50;c+=5)
	$('.cat-list .product-item:eq('+c+')').css("margin-right","0px");
	
	
	
	if($.browser.msie && parseFloat($.browser.version) < 8){	
	$("#header").css('zIndex', 100);
	$(".main-wrapper-bg").css('zIndex', 50);	
	}



	$(".last-watched").click(function(){
	$(this).hide();
	$(".last-watched2").show();
	$(".watched-content").animate({ 
	  right: "0px"
	}, 700 );
	
	});
	
	$(".last-watched2").click(function(){
	$(this).hide();
	$(".last-watched").show();
	$(".watched-content").animate({ 
	  right: "-240px"
	}, 700 );
	
	});
	
	$(".close-x").click(function(){
	$(".last-watched2").hide();
	$(".last-watched").show();
	$(".watched-content").animate({ 
	  right: "-240px"
	}, 700 );
	
	});

	
	$('.product-menu li a').click(function() {
				$('.prd-content').hide();
				$('.prd-content2').hide();
				$('.product-menu li').removeClass('active');
				$(this).parent().addClass('active');
				var tabname = $(this).attr('rel');
				$("#"+tabname+"").show();
			});


	var telme = $(window).height();
	var oneme = 743;
	var twome = 600;
	var hejt = 535;
	
	if (telme<oneme && telme>twome)
	{
		var roz = oneme - telme;
		var roz2 = hejt - roz;
		$("#pic-panel").css('height', roz2);
		$(".pic-content").css('height', roz2);
	}
	$(window).resize(function() {
	var telme = $(window).height();
	var oneme = 743;
	var hejt = 535;
	
	if (telme<oneme && telme>twome)
	{
		var roz = oneme - telme;
		var roz2 = hejt - roz;
		$("#pic-panel").css('height', roz2);
		$(".pic-content").css('height', roz2);
	}
	
	});

	$('#pl li a').click(function(){
		var map1 = $(this).attr("rel");
		$('.partner-box').hide();
		$(map1).show();
	});
		
	var tauzen = 1000;
	var pasekw = $('.pic-menu').width();
	var leftnew = (tauzen - pasekw)/2;
	$(".pic-menu").css('left', leftnew);

	
});
