$(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 IE7------*/
	if($.browser.msie && parseFloat($.browser.version) == 7){
			$(function() {
							var zIndexNumber = 9999;
							$('div').each(function() {
								$(this).css('zIndex', zIndexNumber);
								zIndexNumber -= 1;
							});
							$('.user-links').css('z-index','99999');
							$('.sticky-basket-links').css('z-index','99999');
							$('.sub-menu').css('z-index','99999');
							$('.category-box').css('z-index','99999');
							$('#colorbox').css('z-index','9999');
							$('#breadcrumb').css('z-index','9999');
							$('.selectbox-wrapper').css('z-index','9999');
							$('.reveal-modal').css('z-index','99999');
							$('#simplemodal-overlay').css('z-index','9999');
							$('.simplemodal-container').css('z-index','99999');
							$('.simplemodal-wrap').css('z-index','99999');
							$('.ubezpieczenia').css('z-index','99999');
							$('#porownania-box').css('z-index','9999');
							$('#tiptip_holder').css('z-index','99999');
							$('.simplemodal-overlay').css('z-index','9999');
							$('.ads-nav-container').css('z-index','9999');
							$('.simplemodal-wrap').css('z-index','99999 !important');
							$('.simplemodal-data').css('z-index','999999');
                            
                            $('.map_area').css("zIndex","998");
							$('#map-pl').css("zIndex","997");
							$('#map-widoczna-lista').css("zIndex","997");
						});
			};
        
        //tooltip http://code.drewwilson.com/entry/tiptip-jquery-plugin
	$('.tip').tipTip();
	
	
	/* jQuery Cycle Plugin -  http://jquery.malsup.com/cycle/ */
	
	$('.slideshow').cycle({
		fx: 'scrollRight',
		delay: -1000,
		timeout:       8000,
		pause: 1,
		pager:  '.slider_nav,',
		before:  onBefore, 
		after:   onAfter, 
		pagerAnchorBuilder: function(idx, slide) {
			var desc = $(".slideshow a").eq(idx).attr('rel');
			var desc2 = $(".slideshow a").eq(idx).attr('title');
			return '<a href="#"><span class="titleadme"><strong>' + desc + '<\/strong>' + desc2 + '<\/span><\/a>';
		}
	});
	
	$('.progressBar').css("zIndex","10000");
	
	
	
	
	
	function onBefore() { 
		$(".pb5").hide();
		$(".pb5").progressBar(0, 
			{
				    steps:20,
				    step_duration:20,
				    boxImage	: 'common5/js_neo/jquery.progressbar/images/progressbar.gif',		
				    barImage	: 'common5/js_neo/jquery.progressbar/images/progressbg_green.gif'
			}
		);
	}

	function onAfter() {
		$(".pb5").show();
		$(".pb5").progressBar(100, 
			{
				    steps:30,
				    step_duration:105,
				    boxImage	: 'common5/js_neo/jquery.progressbar/images/progressbar.gif',		
				    barImage	: 'common5/js_neo/jquery.progressbar/images/progressbg_green.gif'
			}
		);
	}

	
	/* jQuery-SelectBox - http://plugins.jquery.com/project/jquery-sb*/
	
	$(".tm_right select").sb({
		animDuration: 300
	});
	
	$(".salons_content select").sb({
		animDuration: 300
	});
	
	
	
	//NBP tabs - product list
	
	$('.headline p.tab a').click(function() {
          $('.feat-cont').hide();
                var linkem = $(this).attr('rel');    
                $(linkem).show();       
                $('.headline p.tab').removeClass('active-tab');
                $(this).parent().addClass('active-tab');


        });
	
	/* -----  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($(".bottom-panel"));
		equalHeight($(".menu_bottom"));
		equalHeight($(".equal"));
	//}
	
	
	/* -----  Last-child fix for IE----- */
	if($.browser.msie && parseFloat($.browser.version) < 9) {
		$(".slider_nav a:last-child").css('width', '198px'); //slider_nav
	}
	
	
	/* ------------- Product fotos ------------ */
	$("#prd_show").slideViewerPro({
		galBorderWidth: 0,  // the border width around the main images
		thumbsTopMargin: 5, // 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: 15, // the width of the prev/next buttons that commands the thumbnails
		galBorderColor: "#d8d8d8", // the border color around the main images
		thumbsBorderColor: "#ffffff", // the border color of the thumbnails but not the current one
		thumbsActiveBorderColor: "#c7df88", // the border color of the current thumbnail
		buttonsTextColor: "#000000", //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='common5/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='common5/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 ------------ */
	
        
        
        //rozwijanie koszyka
        $(".show-fly-basket").click(function(){
                $('.basket-box-fly').slideDown();
        });	
        
        $(".basket-box-fly").mouseleave(function(){
                $(this).fadeOut();
        });
		
        
        /* ----- Colorbox ----- */
	$(".cbox_small").colorbox({
		inline:	true,
		width:	"400px",
		height:	"300px",
		close:	"Zamknij"
	});
        
        $(".cbox").colorbox({
                width:	"960px",
                maxHeight: "95%",
		inline:	true,
		close:	"Zamknij"
	});
        
        $(".color_b").colorbox();
	$(".iframe").colorbox({iframe:true, innerWidth:700, innerHeight:700});
	$("a[rel='gallery-me']").colorbox();
        
        $(".cbox_no_wh").colorbox({
		inline:	true,
                maxHeight: "95%",
		close:	"Zamknij"
	});
        
        $(".cbox_out").colorbox({
                innerWidth:  "800px",
                innerHeight: "600px",
		inline:	false,
		close:	"Zamknij"
	});
        /* ----- end Colorbox ----- */
        
        
	//Products tabs
	$('.prd-tabs a').click(function() {
          $('.tab-cont-prd').hide();
                var linkem = $(this).attr('rel');    
                $(linkem).show();       
                $('.prd-tabs li').removeClass('active');
                $(this).parent().addClass('active');


        });
	
	//Photo Slider Home Page  http://jquery.malsup.com/cycle/
	$('.ad-box').cycle({
			      fx:     'fade',
			      timeout: 9000,
			      delay: 10000,
			      pager:   '#ads-nav'
		
			});
			for(var slnr=0;slnr<5;slnr+=1)
			$("#ads-nav a").eq(slnr).html($('<img src="' + $('.ad-box a').eq(slnr).attr('id') + '" alt="' + $('.ad-box a').eq(slnr).attr('rel') + '" class="thumb" /><span class="slide-title">' + $('.ad-box a').eq(slnr).attr('rel') + '</span><span class="slide-title2">' + $('.ad-box a').eq(slnr).attr('title') + '</span>'));
		
        
	//uniform  http://uniformjs.com/#intro
	$(".comp").uniform();
	$(".per-page-area select").uniform();
	$(".sort-area select").uniform();
	$(".manuf-logo select").uniform();
	$("input:file").uniform({fileDefaultText:'', fileBtnText: 'Wybierz plik'});
	
	//Featured products tabs
	$('.feat-tabs a').click(function() {
          $('.feat-cont').hide();
                var linkem = $(this).attr('rel');    
                $(linkem).show();       
                $('.feat-tabs li').removeClass('active');
                $(this).parent().addClass('active');
        });
        
        
	//Category sub-mnu
	/*$('.category-box li').mouseover(function() {
			var ilemam = $(this).children('.sub-menu').height();
			var ileup = ilemam / 3;
			var upme = -ileup;
			var maxme = 150;
			var x = 150;
			if (ilemam > maxme) {
			$(this).children('.sub-menu').css('top',upme)
			}
         
         });*/
        
	/* ------- Left menu ------------- */
        $('#menu li').mouseenter(function() {
            //if ($(this).children().hasClass("sub-menu")) {
                var menuchild = Math.round($('#menu').children().length / 2);
                
                if( $(this).index() < menuchild ) {
                    $(this).children('.sub-menu').css("top","0");
                }
                else {
                    var sub_h = $(this).children('.sub-menu').height()/(-2)+25;
                    $(this).children(".sub-menu").css("top",sub_h+"px");
                }
            //}
        });
        /* ------- end Left menu ------------- */
        
	$("#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");
			
					
                });
				
	/* ------------- newsletter box validation ------------ */
	
	function wyslijNewsletter()
							{
			alert('aaaaaaaaas');
}  
    

});


