$(document).ready(function() {

	//Stylish Select Box
	$('#capacity').sSelect();

	//headerImg slideshow
	$(function() {
		$('#slideshow').cycle({
			speed:       1000,
			timeout:     5000,
			pager:      '#pager',
			pagerEvent: 'mouseover',
			pauseOnPagerHover: true
		});
	});
  
	$("#slideshow-banner5").hover(
      function () {
        $('#slideshow-banner').cycle({
			speed:       1000,
			timeout:     2000,
			pager:      '#slideshow-banner',
			pagerEvent: 'mouseover',
			pauseOnPagerHover: true
		});
      }, 
      function () {
		$(this).find("span:last").remove();
      }
    );
    
    $("#nav li:first ul").remove();

  
  
  
	// jTabs plugin
	$(function(){
		// Initialize Tabs /zobrazi tab podla parametra #number v URL/ 
		$('.tabs').tabs({ fx: { opacity: 'show' } }); 
		if(document.location.hash!='') {
			//get the index from URL hash
			tabSelect = document.location.hash.substr(1,document.location.hash.length);
			$('.tabs').tabs('select',tabSelect-1);
		}
	});
  
	//productsSlideshow slideshow
	$('#productsSlideshow').after('<ul id="thumbs">').cycle({
        //fx:     'turnDown',
        speed:  '1000',
        timeout: 0,
        pager:  '#thumbs',
        pagerAnchorBuilder: function(idx, slide) {
            return '<li><a href="#"><img src="' + slide.src + '" width="84" /></a></li>';
        }
	});

	// jCarousel plugin
	$(".similar").jcarousel({
    	scroll: 4,
		wrap: "last",
		animation: "slow"
	});

	//breadcrumbs class add
	$("#breadcrumbs li:first").addClass("first");
   	
	//odsadenia boxov
	$("#products li:nth-child(5n+0)").addClass("nooffset");
	$("#gallery li:nth-child(6n+0)").addClass("nooffset");
	$("#thumbs li:last").addClass("nooffset");

	// funkcia pre vysunutie info o obrazku
	jQuery.fn.masque = function(classe) {	
		$(this).hover(function(){
		$(this).find(classe).stop().animate({height:"22px",opacity: "0.7"},400);
	},function () { 
		$(this).find(classe).stop().animate({height:"22px",opacity: "0"}, 400);
	});
	}
	// aplikacia funkcie masque
	$("#products li").masque(".show");
	
	// scrollTop
	$('.scrollTop').click(function() {
		$('html, body').animate({scrollTop: '0px'}, 1000,'easeOutQuart');
		return false;
	});

	 // Add data property to all images (just an example);
	/*
	$('img').each(function(){
		$(this).data('extension', $(this)[0].src.match(/\.(.{1,4})$/)[1]);
	});
	 */
	// Select all images with PNG or JPG extensions:
	$('img:regex(data:extension, png|gif)').addClass('nooffset');

	// USB klasik 111 replace image http://james.padolsey.com/javascript/regex-selector-for-jquery/
	//$('img:regex(data:extension, jpg|png)').addClass('nooffset');
	/*
	$('img:regex(src,product-3)').attr({ 
        src: "gallery/usb_klasik_11.gif",
        title: "jQuery",
        alt: "jQuery Logo"
    });
     */
    // Select all elements with an ID starting a vowel:
	//$(':regex(id,products)').addClass('nooffset');

	// Select all SCRIPT tags with a SRC containing jQuery:
	//$('script:regex(src,jQuery)').addClass('nooffset');
	//$('img:regex(src,product-3)').addClass('nooffset');
	
});



/*************** slideshow-banner **********************/
var image_count;
var image_interval;
var old_image = 0;
var current_image = 0;
	 
$(document).ready(function(){
	image_count = $("#slideshow-banner img").size();
	$("#slideshow-banner img").css({opacity: 0.0});
	$("#slideshow-banner img:eq("+current_image+")").css({opacity: 1.0});
	 
	//image_interval = setInterval(image_rotate,1000); //time in milliseconds
	$('#slideshow-banner').hover(function() {
		$("#slideshow-banner img:first").css('z-index', '0');
		image_interval = setInterval(image_rotate,1000); //time in milliseconds
		image_rotate();
	   }, function() {
		clearInterval(image_interval);
		$("#slideshow-banner img:eq("+current_image+")").css({opacity: 0.0});
		$("#slideshow-banner img:first").css({opacity: 1.0});
		$("#slideshow-banner img:first").css('z-index', '100');
	   });
	});
	 
	function image_rotate() {
		current_image = (old_image + 1) % image_count; 
		$("#slideshow-banner img:eq(" + old_image + ")").animate({opacity: 0.0},"slow", function() {
		$(this).css({opacity: 0.0});
		});
		$("#slideshow-banner img:eq(" + current_image + ")").show().animate({opacity: 1.0},"slow");  
		old_image = current_image;
	}
	
	// suckerfish
	$(document).ready(function(){
    $("#nav li").hover(
        function(){ $("ul", this).fadeIn("fast"); }, 
        function() { } 
    );
    if (document.all) {
        $("#nav li").hoverClass ("sfHover");
    }
});

$.fn.hoverClass = function(c) {
    return this.each(function(){
        $(this).hover( 
            function() { $(this).addClass(c);  },
            function() { $(this).removeClass(c); }
        );
    });
};  


