$(document).ready(function() {
	
// potiwerdzenie dodania produktu do koszyka drop z topu
$(".komorka").click(function () { 
							var nazwaKlasy = $(this).attr('className');
							if(nazwaKlasy == "komorka_active")
								if($(".dodano_do_koszyka").is(":hidden"))
									$(".dodano_do_koszyka").slideDown(600).delay(2500).slideUp(600); 
						});
						   
//banner slider
$(".paging").show();
$(".paging a:first").addClass("active");
var imageWidth = $(".window").width();
var imageSum = $(".image_reel img").size();
var imageReelWidth = imageWidth * imageSum;
$(".image_reel").css({'width' : imageReelWidth});
rotate = function(){
    var triggerID = $active.attr("rel") - 1; //Get number of times to slide
    var image_reelPosition = triggerID * imageWidth; //Determines the distance the image reel needs to slide

    $(".paging a").removeClass('active'); //Remove all active class
    $active.addClass('active'); //Add active class (the $active is declared in the rotateSwitch function)

    $(".image_reel").animate({
        left: -image_reelPosition
    }, 500 );

}; 
rotateSwitch = function(){
    play = setInterval(function(){ //Set timer - this will repeat itself every 7 seconds
        $active = $('.paging a.active').next(); //Move to the next paging
        if ( $active.length === 0) { //If paging reaches the end...
            $active = $('.paging a:first'); //go back to first
        }
        rotate(); //Trigger the paging and slider function
    }, 4000); //Timer speed in milliseconds (7 seconds)
};

rotateSwitch(); //Run function on launch
$(".image_reel a").hover(function() {
    clearInterval(play); //Stop the rotation
}, function() {
    rotateSwitch(); //Resume rotation timer
});	
$(".paging a").click(function() {
    $active = $(this); //Activate the clicked paging
    //Reset Timer
    clearInterval(play); //Stop the rotation
    rotate(); //Trigger rotation immediately
    rotateSwitch(); // Resume rotation timer
    return false; //Prevent browser jump to link anchor
});
						   
						   
						   

//fadeThis
	  $('.fadeThis').append('<span class="hover"></span>').each(function () {
	  var $span = $('> span.hover', this).css('opacity', 0);
	  $(this).hover(function () {
	    $span.stop().fadeTo(400, 1);
	  }, function () {
	    $span.stop().fadeTo(400, 0);
	  });
	});

//faq
		$('div#hide:eq(0)> div').hide();
		$('div#hide:eq(0)> h4.faq').click(function() {
		$(this).next().slideToggle('slow');
	});
	  
});



// tooltip script written by Alen Grakalic (http://cssglobe.com)
 


this.tooltip = function(){	
		xOffset = -15;
		yOffset = 10;		
	$("a.tooltip").hover(function(e){											  
		this.t = this.title;
		this.title = "";									  
		$("body").append("<p id='tooltip'>"+ this.t +"</p>");
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.show("fast");
    },
	function(){
		this.title = this.t;		
		$("#tooltip").remove();
    });	
	$("a.tooltip").mousemove(function(e){
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};

// starting the script on page load
$(document).ready(function(){
	tooltip();
});


