$(document).ready(function() {
    
	$("a.targetblank").click(function(){
		this.target = "_blank";
	});	

    
         /* wysuwana treść koszyka*/
	$('.show-sticky').click(function(){$('.basket-content2').slideToggle('slow') });
        $('.sticky-off').click(function(){$('.basket-content2').hide() });
	
	
	$('.ui-state-active').click(function(){$('.basket-content').slideToggle('slow') });
	
	
	$('.one-1').click(function(){$('.overflay-link').hide(); $('.overlay-4').show()});
	$('.one-2').click(function(){$('.overflay-link').hide(); $('.overlay-5').show()});
	$('.one-3').click(function(){$('.overflay-link').hide(); $('.overlay-6').show()});
	
    /* bajer do szukajki*/
	$('input.search-input').focus(function() {$(this).attr("value", ""); });
	$('input.search-input').blur(function() {
		if($(this).attr("value")=='')
			$(this).attr("value", "Szukaj produktu w naszym sklepie"); 
	});
        
    /* bajer do newslettera */
	$('input.newsletter-input-txt').focus(function() {$(this).attr("value", ""); });
	$('input.newsletter-input-txt').blur(function() {
		if($(this).attr("value")=='')
			$(this).attr("value", "podaj adres e-mail");
	});
        
    /* główny slideshow - obsługa efektów i 'wypełnienie' nawigacji altami i titlami*/
	$('.slideshow-content').cycle({
              fx:     'scrollLeft',
              easing: 'easeInOutExpo', 
              delay:  -2000, 
              pager:   '#nav',
              pagerarrow: '.slideshow-arrow'

	});
        //for(var slnr=0;slnr<6;slnr+=1)
		$('.slideshow-content > a').each(function(slnr) {
			$("#nav a").eq(slnr).html($('<div class="slide-title">' + $('.slideshow-content a').eq(slnr).attr('title') + '</div><div class="slide-title2">' + $('.slideshow-content a').eq(slnr).attr('rel') + '</div><span class="nav-arrow"></span>'));
			
		});
		$("#nav a").eq(0).addClass('first-slide');$("#nav a").eq(4).addClass('last-slide');$("#nav a").eq(1).addClass('slide2');$("#nav a").eq(2).addClass('slide3');$("#nav a").eq(3).addClass('slide4');
        
        /* główny slideshow - dodanie i obsługa czarnej strzałeczki*/
        $.fn.cycle.updateActivePagerLink=function(pager,currSlide)
        {$(pager).find("a").removeClass("activeSlide").filter("a:eq("+currSlide+")").addClass("activeSlide");
        }
      
        /* inicjonwanie boxa z polecanymi 3 produktami - oferta dnia*/
        $(".accordion").accordion();
	
	
	
        
        /* inicjonwanie boxa z polecanymi 3 produktami - oferta dnia*/
        $(".accordion2").accordion();
        
        /* wysuwany button - 'zobacz pelny opis' */
        $('.accordion').children('div').hover(
            function () {
               $(this).children('.see-full').slideDown('fast');
            }, 
            function () {
                 $(this).children('.see-full').slideUp('fast');
            }
         );
        
    
		/* obsługa tabów dla promo produktów - promocje, polecane, nowości */
        $("h2").click(function() {this.blur();});
        $(".tab1").click(function(){
            $('.product-promo-box-navi a').removeClass('selected')
            $('.product-promo-box-navi li').removeClass('selected-to')
            $('.product-promo-box-navi .tabli1').addClass('selected-to')
            $(this).addClass('selected')
            $(".product-promo-list").hide()
            $(".tab-cont1").css('display','inline')
        });
         $(".tab2").click(function(){
            $('.product-promo-box-navi a').removeClass('selected')
              $('.product-promo-box-navi li').removeClass('selected-to')
            $('.product-promo-box-navi .tabli2').addClass('selected-to')
            $(this).addClass('selected')
            $(".product-promo-list").hide()
            $(".tab-cont2").css('display','inline')
        });
         $(".tab3").click(function(){
            $('.product-promo-box-navi a').removeClass('selected')
              $('.product-promo-box-navi li').removeClass('selected-to')
            $('.product-promo-box-navi .tabli3').addClass('selected-to')
            $(this).addClass('selected')
            $(".product-promo-list").hide()
            $(".tab-cont3").css('display','inline')
        });
        
        /* inicjowanie slideshowa dla zawartości pierwszego taba - salony eksperckie */
        $('.infobox-slideshow').cycle({
              fx:     'fade',
              easing: 'easeInOutExpo', 
              delay:  -2000,
              pager:   '#tab-nav' 
	});
         $("#tab-nav a").html('');
         $('.compare-action input:checkbox').checkbox();

        function equalHeight(group)
	   {
		tallest = 0;
		group.each(function() {
		    thisHeight = $(this).height();
		    if(thisHeight > tallest) {
			tallest = thisHeight;
		    }
		});
		group.height(tallest);
	    }
	


});
$(document).ready(function() {
	$(".tab-navigation a").anchorAnimate();
    $("a.see-more-pht").anchorAnimate();
	$('div.full-product-view-box div.rate-txt > a').anchorAnimate();
	
	

	$("a[rel=zdjeciagroup]").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
		    return '<span id="fancybox-title-over">Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + ' ' + title + '</span>';
		}
	});

	
	
    $('.tech-data a[title]').qtip();
});

jQuery.fn.anchorAnimate = function(settings) {

 	settings = jQuery.extend({
		speed : 1100
	}, settings);	
	
	return this.each(function(){
		var caller = this
		$(caller).click(function (event) {	
			event.preventDefault()
			var locationHref = window.location.href
			var elementClick = $(caller).attr("href")
			
			var destination = $(elementClick).offset().top;
			$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, settings.speed, function() {
				window.location.hash = elementClick
			});
		  	return false;
		})
	})
}
