$(document).ready(function() {
	
	/* Preload CSS images  - based on http://www.filamentgroup.com/lab/update_automatically_preload_images_from_css_with_jquery/*/
	//$.preloadCssImages();
	
	
	/* PNGFIX for IE6 */
	if($.browser.msie && parseFloat($.browser.version) < 7) {
		DD_belatedPNG.fix('a,img,div,li,input');
        };
        
        /* z-index fixes */
        if($.browser.msie && parseFloat($.browser.version) < 8) {
            $('.slider_nav').css('zIndex','99980');
            $('.left_menu').css('zIndex','99989');
            $('#menu').css('zIndex','99990');
            $('.submenu').css('zIndex','99991');
            $('.selected_border').css('zIndex','99992');
            $('.zoom').css('zIndex','99998');
            $('.top_search_bar').css('zIndex','999996');
            $('.quick_all_cat').css('zIndex','999997');
            $('.basket').css('zIndex','999999');
            $('.quick_basket').css('zIndex','999998');
	};
	
	
	/* jQuery Cycle Plugin -  http://jquery.malsup.com/cycle/ */
        
    if ($.fn.cycle) {
	$('.slideshow').cycle({
		fx: 'fade',
		delay: 1000,
        timeout: 5000,
		pause: 1,
		pager:  '.slider_nav, .slider_info',
		pagerAnchorBuilder: function(idx, slide) {
			var desc = $(".slideshow a").eq(idx).attr('rel');
			var desc2 = $(".slideshow a").eq(idx).attr('title');
			return '<a href="#"><p class="strong">' + desc + '<\/p><p>' + desc2 + '<\/p><\/a>';
		}
		/*updateActivePagerLink: function(pager, currSlideIndex) {
		}*/
	});
    };
    
	/*for(var i=0;i<4;i++) {
		var desc = $(".slideshow").children("a").eq(i).attr('title');
		var desc2 = $(".slideshow").children("a").eq(i).attr('rel');
		$('.slider_info').append('<div class="slider_info_btn"><p><strong>' + desc + '<\/strong><\/p><p>'+ desc2 +'<\/p><\/div>');
	};
	
	$('.slider_info_btn').click(function() {
		var nr = $('.slider_info_btn').index(this);
		$('.slideshow').cycle(nr);
	});*/

	
	/* jQuery-SelectBox - http://plugins.jquery.com/project/jquery-sb*/
    if ($.fn.sb) {
	$("#my-dropdown, #manufactures").sb({
		animDuration: 300
	});
    };
	
	/* -----  EqualHeight for 3Products on homepage----- */
	
	function equalHeight(group) {
		var tallest = 0;
		group.each(function() {
			var thisHeight = $(this).height();
			if(thisHeight > tallest) {
				tallest = thisHeight;
			}
		});
		group.height(tallest);
	}
	
	if(!$.browser.msie || ($.browser.msie && parseFloat($.browser.version) > 6)) {
		//equalHeight($(".pan_content"));
		//equalHeight($(".bm_content"));
                //equalHeight($(".equal"));
	}
	
	
	
	/* ------- top bar: basket quick view, all categories quick view ------------- */
        
	$(".q_basket").mouseenter(function() {
	    $(".quick_basket").stop(true,true).fadeIn("fast");
	}).mouseleave(function() {
	    $(".quick_basket").stop(true,true).fadeOut("fast");
	});
        
        $(".quick_basket").mouseenter(function() {
	    $(this).stop(true,true).show();
	}).mouseleave(function() {
	    $(this).stop(true,true).fadeOut("fast");
	});
	

	$(".q_all_cat").mouseenter(function() {
            $(".quick_all_cat").stop(true,true).fadeIn("fast");
        }).mouseleave(function() {
            $(".quick_all_cat").stop(true,true).fadeOut("fast");
        });
        
        $(".quick_all_cat").mouseenter(function() {
            $(this).stop(true,true).show();
        }).mouseleave(function() {
            $(this).stop(true,true).fadeOut("fast");
        });
        
        
        
	
        
        /* ----- Colorbox ----- */
	$(".cbox_small").colorbox({
		inline:	true,
		width:	"400px",
		height:	"300px",
		close:	"Zamknij"
	});
        
        $(".cbox").colorbox({
                width:	"960px",
                maxHeight: "95%",
		inline:	true,
		close:	"Zamknij"
	});
        
        $(".cbox_no_wh").colorbox({
		inline:	true,
                maxWidth: "75%",
                maxHeight: "95%",
		close:	"Zamknij"
	});
        
        $(".cbox_out").colorbox({
                innerWidth:  "800px",
                innerHeight: "600px",
		inline:	false,
		close:	"Zamknij"
	});
        /* ----- end Colorbox ----- */

	
	
	/* -----  Product bottom tabs switcher ----- */
	$('ul.tabs li a').click(function() {
		if(!$(this).parent().hasClass("active")) {
			$('.tab-cont-prd').hide();
			var linktab = $(this).attr('rel');    
			$(linktab).show();
			$('ul.tabs li').removeClass('active');
			$(this).parent().addClass('active');
		}
        });
        
        /* -----  NPB tabs switcher ----- */
        $('.npb_switch li a').click(function() {
		if(!$(this).hasClass("active")) {
			$('.feat-cont').hide();
			var linktab = $(this).attr('rel');    
			$(linktab).show();
			$('.npb_switch li a').removeClass('active');
			$(this).addClass('active');
		}
        });
        
	

	/* ------------- Product fotos ------------ */
    if ($.fn.slideViewerPro) {
	$("div#prd_show").slideViewerPro({
		galBorderWidth: 0,  // the border width around the main images
		thumbsTopMargin: 15, // the distance that separates the thumbnails and the buttons from the main images
		thumbsRightMargin: 5, // the distance of each thumnail respect to the next one
		thumbsBorderWidth: 1, // the border width of each thumbnail. Note that the border in reality is above, not around
		buttonsWidth: 20, // the width of the prev/next buttons that commands the thumbnails
		galBorderColor: "#d8d8d8", // the border color around the main images
		thumbsBorderColor: "#333333", // the border color of the thumbnails but not the current one
		thumbsActiveBorderColor: "#ff0000", // the border color of the current thumbnail
		buttonsTextColor: "#ff0000", //the color of the optional text in leftButtonInner/rightButtonInner
		thumbsBorderOpacity: 0.6, // could be 0, 0.1 up to 1.0
		thumbsActiveBorderOpacity: 0.6, // could be 0, 0.1 up to 1.0
		easeTime: 300, // the time it takes a slide to move to its position
		asTimer: 3000, // if autoslide is true, this is the interval between each slide
		thumbs: 3, // the number of visible thumbnails
		thumbsPercentReduction: 25, // the percentual reduction of the thumbnails in relation to the original
		thumbsVis: true, // with this option set to false, the whole UI (thumbs and buttons) are not visible
		leftButtonInner: "<img src='common3/images/ico_prev.png' alt='Poprzednie zdjęcia' />", //could be an image "<img src='images/larw.gif' />" or an escaped char as "&larr";
		rightButtonInner: "<img src='common3/images/ico_next.png' alt='Następne zdjęcia' />", //could be an image or an escaped char as "&rarr";
		autoslide: true, // by default the slider do not slides automatically. When set to true REQUIRES the jquery.timers plugin
		typo: false, // the typographic info of each slide. When set to true, the ALT tag content is displayed
		typoFullOpacity: 0.9, // the opacity for typographic info. 1 means fully visible.
		shuffle: false // the LI items can be shuffled (randomly mixed) when shuffle is true
	});
    };
	
	$("a[rel='g1']").colorbox();
	
	$(".big,").mouseenter(function() {
	    $(".zoom").show();
	}).mouseleave(function() {
	    $(".zoom").hide();
	});
	/* ------------- end Product fotos ------------ */
	
	
	/* ------- TipTip start (http://code.drewwilson.com/entry/tiptip-jquery-plugin) ------------- */
	$(".tip").tipTip({
            defaultPosition:"top",
            delay:100,
            edgeOffset:5
        });
	
        
        /* Uniform */
        $("input:checkbox, input:file").uniform();
	
        
	/* ------- Left menu ------------- */
        $('#menu li').mouseenter(function() {
            if ($(this).children().hasClass("submenu")) {
                var menuchild = Math.round($('#menu').children().length / 2);

                if( $(this).index() < menuchild ) {
                    $(this).children(".submenu").css("top","0");
                }
                else {
                    var sub_h = $(this).children(".submenu").height()/(-2)+17;
                    $(this).children(".submenu").css("top",sub_h+"px");
                }


                $(this).addClass("active");
                $(this).find("a:first").addClass("selected_border");
                $(this).children(".submenu").show();
            }
        }).mouseleave(function() {
            if ($(this).children().hasClass("submenu")) {
                $(this).removeClass("active");
                $(this).find("a:first").removeClass("selected_border");
                $(this).children(".submenu").hide();
            }
        });
        
        $('#menu li').last().addClass("lastElement");
        $('.submenu li').last().removeClass("lastElement");
        /* ------- end Left menu ------------- */


	//facebook icon
        /*function fb_slide() {
            $("#fb_toggler").hover(
                function() {
                   $(this).stop().animate({ paddingRight: 260 }, 800);
                },
                function() {
                   $(this).stop().animate({ paddingRight: 0 }, 500);
            });
        };
        fb_slide();*/
		
			 $("#BDK-Anim3D-Container").parent('div').css("z-Index","9991000");

		

		

                $('#product-data-enlarge-photo2').click(function() {

                    $("#BDK-Anim3D-Container").parent().css("z-Index","9991000");
					$(".basket").css("z-Index","999");
					$(".left_menu ").css("z-Index","999");
					
                });
});


