$(document).ready(function() {

   // ukrycie wszystkich elementow submenu na początku otwarcia strony
    // powód - SEO
	$(".menuMain ul li .subMenu").each( function() {
			$(this).hide();
	});
		
    // ukrycie wszsytkich elementow
    $(".menuMain ul li").each(function() {
            if($(this).hasClass("current"))	    
            {
	            $('#'+ $(this).attr("menunumber")).show();	  
            }
		    else
		    {
		        $('#'+ $(this).attr("menunumber")).hide();
            }
        }
    );

    // pokazywanie menu przy klikniecu
	$(".menuMain ul li h3").click(function() {
		if(!$(this).parent().hasClass("current"))
		{
		    $(".menuMain ul li").each(
		        function() {
		            if($(this).hasClass("current"))
		            {
		                $('#'+ $(this).attr("menunumber")).fadeOut("fast");
		            }
			        $(this).removeClass("current");
		        });
		    var a = $(this).parent().attr("menunumber");
		    var b = 1
			$('#'+a).fadeIn("fast");	
		    $(this).parent().addClass("current");
        }
	});
	
	
	// od szymona 2009-11-05 ,
	// przewijanie menu w lewo i prawo
	$("#available").click(function() {
		$(this).toggleClass("checked");
	});
	/*
	$("#subcategoriesClickPrev").click(function(){
		var temp = $('div.menuExtendedLeftTop > div.active');
		temp.fadeOut();
		temp.prev().fadeIn().addClass('active');
		temp.removeClass('active');
	});
	$("#subcategoriesClickNext").click(function(){
		var temp = $('div.menuExtendedLeftTop div.active');
		temp.fadeOut();
		temp.next().fadeIn().addClass('active');
		temp.removeClass('active');
	});
	$("#producentClickPrev").click(function(){
		var temp = $(this).parent().parent().prev().prev().children().eq(0);
		temp.fadeOut().removeClass('active');
		temp.prev().fadeIn().addClass('active');
	});
	$(".producentClickNext").click(function(){
	    // nadrzedny box z menu producenta, wszystkie operacje w ramach tego boxa
	    var root = $(this).parent().parent().parent();
	    // szukam aktywnego boxu
	    var temp = root.find('div.active');
	    if(temp.length==0)
	    {
	        // jezeli nie ma aktywnego boxu to znaczy ze trzeba pokazac 1 box
	        temp = root.find('div.menuExtendedRightTop div:first');
	        temp.fadeIn().addClass('active');
	    }else
	    {
	        // jezeli jest aktywny box to ukrywamy go i ustawiamy nastepny aktywny
		    temp.fadeOut().removeClass('active');
		    temp.next().fadeIn().addClass('active');
	        // szukamy aktywnego
		    var temp2 = root.find('div.menuExtendedRightTop div.active');
		    if(!temp2.length)
		    {   
		        // jezeli nie ma aktywnego to oznacza ze poprzednie operacje ukryly ostatni box, wiec nalezy pokazac z powrotem 1 box
                temp = root.find('div.menuExtendedRightTop div:first');
	            temp.fadeIn().addClass('active');
		    }
    	}    	
	});*/
	
	//szymon 2009-11-10
	$("div.click a.menuPrev").click(function(){
		var temp = $(this).parent().parent().prev().prev().children().siblings(".active");
		if ($(temp).prev().eq(0).length == 1) {
			$(temp).fadeOut().removeClass("active");
			$(temp).prev().eq(0).fadeIn("slow").addClass("active");
		}
	});
	$(".click a.menuNext").click(function(){
		var temp = $(this).parent().parent().prev().prev().children().siblings(".active");
		if ($(temp).next().eq(0).length == 1) {
			$(temp).fadeOut().removeClass("active");
			$(temp).next().eq(0).fadeIn("slow").addClass("active");
		}
	});		
	
	


});