jQuery(document).ready(function() {

	jQuery.event.add(window, "load", resizeFrame);
	jQuery.event.add(window, "resize", resizeFrame);
	
	function resizeFrame() 
	{
	    var w = $(window).width();
	    if(w < 1018){
			$(".area-53").css('display', 'none');	
		}else{
			$(".area-53").css('display', 'block');
		}
	   
	}

    /// seo text on homepage
    var seoWidth = $('.seoh-menu').width();

    var seoRealWidth = $('.seoh-menu-li-1').width() + $('.seoh-menu-li-2').width() + $('.seoh-menu-li-3').width();

    var ascWidth = (seoWidth - seoRealWidth) / 3;
    var seo1 = $('.seoh-menu-li-1').width() + ascWidth;
    var seo2 = $('.seoh-menu-li-2').width() + ascWidth;
    var seo3 = $('.seoh-menu-li-3').width() + ascWidth;

    $('.seoh-menu-li-1').width(seo1);
    $('.seoh-menu-li-2').width(seo2);
    $('.seoh-menu-li-3').width(seo3);

    $('.seoh-menu-li-1').addClass('active');
    $('.seo-menu-li-1').addClass('active');

    $('.seoh-menu-li-1').click(function(e) {
        $('.seoh-text-runner').animate({right: '0px', top: '0px'}, 500);
        $('.seoh-menu-li-1').addClass('active');
        $('.seoh-menu-li-2').removeClass('active');
        $('.seoh-menu-li-3').removeClass('active');
	});

    $('.seoh-menu-li-2').click(function(e) {
        $('.seoh-text-runner').animate({right: '278px', top: '0px'}, 500);
        $('.seoh-menu-li-2').addClass('active');
        $('.seoh-menu-li-1').removeClass('active');
        $('.seoh-menu-li-3').removeClass('active');
	});

    $('.seoh-menu-li-3').click(function(e) {
        $('.seoh-text-runner').animate({right: '556px', top: '0px'}, 500);
        $('.seoh-menu-li-3').addClass('active');
        $('.seoh-menu-li-1').removeClass('active');
        $('.seoh-menu-li-2').removeClass('active');
	});
    /// end seo text on homepage

    $('.seo-menu-li-1').click(function(e) {
        $('.seo-text-runner').animate({right: '0px', top: '0px'}, 500);
        $('.seo-menu-li-1').addClass('active');
        $('.seo-menu-li-2').removeClass('active');
        $('.seo-menu-li-3').removeClass('active');
	});

    $('.seo-menu-li-2').click(function(e) {
        $('.seo-text-runner').animate({right: '492px', top: '0px'}, 500);
        $('.seo-menu-li-2').addClass('active');
        $('.seo-menu-li-1').removeClass('active');
        $('.seo-menu-li-3').removeClass('active');
	});

    $('.seo-menu-li-3').click(function(e) {
        $('.seo-text-runner').animate({right: '984px', top: '0px'}, 500);
        $('.seo-menu-li-3').addClass('active');
        $('.seo-menu-li-1').removeClass('active');
        $('.seo-menu-li-2').removeClass('active');
	});

    $('.category-more').click(function(e) {
       $('.category-detail').addClass('category-detail2');
       $('.category-more').css('display', 'none');
       $('.category-close').css('display', 'block');
       $('.category-text').css('display', 'block');
       $('.category-detail').animate({height: "358px", top: "170px"}, 500);

       $('.arrow-up2').css('display', 'block');
       $('.arrow-down2').css('display', 'block');
    });
    $('.category-close').click(function(e) {

       $('.category-close').css('display', 'none');
       $('.category-more').css('display', 'block');

       $('.arrow-up2').css('display', 'none');
       $('.arrow-down2').css('display', 'none');

       $('.category-detail').animate({height: "93px", top: "436px"}, 500, function(){
          $('.category-detail').removeClass('category-detail2');
          $('.category-text').css('display', 'none');
       });

    });

    jQuery('#carousel').jcarousel();

	/* zjisteni a nastaveni velikosti okna */
	var footerLinksHeight = $('#footer-links').height();
	$('#footer-links .footer-links-left, #footer-links .footer-links-last').css('height', footerLinksHeight);
	$('.inner-body').css('height', footerLinksHeight);

	/*
    $('.arrow-up').click(function(e) {
       if($('#categories ul').css('top') != '0px'){
            $('.#categories ul').animate({top: "+=42px"}, 50);
       }
    });
    $('.arrow-down').click(function(e) {
		var topMenu = $('#categories ul').css('top');
		topMenu = topMenu.replace("px", "");
		if(topMenu > -340) $('#categories ul').animate({top: "-=42px"}, 50);
    });
    */
    $('.arrow-up').click(function(e) {
       if($('.category-menu ul').css('top') != '0px'){
            $('.category-menu ul').animate({top: "+=42px"}, 50);
       }
    });
    $('.arrow-down').click(function(e) {
		var topMenu = $('.category-menu ul').css('top');
		topMenu = topMenu.replace("px", "");
		if(topMenu > -200) $('.category-menu ul').animate({top: "-=42px"}, 50);
    });

    $('.arrow-up2').click(function(e) {
       if($('.category-text-slider').css('top') != '0px'){
         $('.category-text-slider').animate({top: "+=42px"}, 50);
       }

    });
    $('.arrow-down2').click(function(e) {

       $('.category-text-slider').animate({top: "-=42px"}, 50);

    });
    $('.arrow-up3').click(function(e) {
	   if($('.seoh-text-runner').css('top') != '0px'){
         $('.seoh-text-runner').animate({top: "+=42px"}, 50);
       }

    }); 
    $('.arrow-down3').click(function(e) {
       $('.seoh-text-runner').animate({top: "-=42px"}, 50);

    });
    $('.arrow-up4').click(function(e) {
       if($('.table-slider').css('top') != '0px'){
         $('.table-slider').animate({top: "+=84px"}, 200);
       }

    });
    $('.arrow-down4').click(function(e) {

       $('.table-slider').animate({top: "-=84px"}, 200);

    });

    var heightSeo = $(".seo-text").height();

    $('.product-detail-mid').animate({height: "+="+(heightSeo-100)}, 1);
    //$('.product-detail-mid').animate({height: "+="+heightSeo}, 1);
    //$('.product-detail-mid').animate({height: "-=238px"}, 1);
    $('.detail .seo').animate({height: heightSeo}, 1);
    $('.detail .seo').animate({height: "+=58px"}, 1);
});


$(document).ready(function() {


	function megaHoverOver(){
		$(this).find(".second-menu").stop().fadeTo('fast', 1).show();


	}

	function megaHoverOut(){
	  $(this).find(".second-menu").stop().fadeTo('fast', 0, function() {
		  $(this).hide();
	  });
	}
    function megaHoverOver2(){
		$(this).find(".userlist-area").stop().fadeTo('fast', 1).show();


	}

	function megaHoverOut2(){
	  $(this).find(".userlist-area").stop().fadeTo('fast', 0, function() {
		  $(this).hide();
	  });
	}


	var config = {
		 sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)
		 interval: 100, // number = milliseconds for onMouseOver polling interval
		 over: megaHoverOver, // function = onMouseOver callback (REQUIRED)
		 timeout: 500, // number = milliseconds delay before onMouseOut
		 out: megaHoverOut // function = onMouseOut callback (REQUIRED)
	};

	$(".second-menu").css({'opacity':'0'});
	$("ul.main-menu li").hoverIntent(config);


    var config2 = {
		 sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)
		 interval: 100, // number = milliseconds for onMouseOver polling interval
		 over: megaHoverOver2, // function = onMouseOver callback (REQUIRED)
		 timeout: 500, // number = milliseconds delay before onMouseOut
		 out: megaHoverOut2 // function = onMouseOut callback (REQUIRED)
	};

	$(".userlist-area").css({'opacity':'0'});
	$(".extra-list").hoverIntent(config2);
});

$(function(){
	$('#slider2').anythingSlider({
		buildArrows	: false,
		autoPlay	: true,
		hashTags 	: false,
		delay		: 4000
	})
	.find('.panel')
	.find('div[class*=caption]')
	.css({ position: 'absolute' })
	.end()
	.hover(function(){
		showCaptions( $(this) )
	},
	function(){
		hideCaptions( $(this) );
	}); 
	
	
  showCaptions = function(el){
    var $this = el;
    if ($this.find('.caption-top').length) {
      $this.find('.caption-top')
        .show()
        .animate({ top: 0, opacity: 1 }, 400);
    }
    if ($this.find('.caption-right').length) {
      $this.find('.caption-right')
        .show()
        .animate({ right: 0, opacity: 1 }, 400);
    }
    if ($this.find('.caption-bottom').length) {
      $this.find('.caption-bottom')
        .show()
        .animate({ bottom: 0, opacity: 1 }, 400);
    }
    if ($this.find('.caption-left').length) {
      $this.find('.caption-left')
        .show()
        .animate({ left: 0, opacity: 1 }, 400);
    }
  };

  hideCaptions = function(el){
    var $this = el;
    if ($this.find('.caption-top').length) {
      $this.find('.caption-top')
        .stop()
        .animate({ top: -50, opacity: 0 }, 350, function(){
          $this.find('.caption-top').hide(); });
    }
    if ($this.find('.caption-right').length) {
      $this.find('.caption-right')
        .stop()
        .animate({ right: -150, opacity: 0 }, 350, function(){
          $this.find('.caption-right').hide(); });
    }
    if ($this.find('.caption-bottom').length) {
      $this.find('.caption-bottom')
        .stop()
        .animate({ bottom: -50, opacity: 0 }, 350, function(){
          $this.find('.caption-bottom').hide(); });
    }
    if ($this.find('.caption-left').length) {
      $this.find('.caption-left')
        .stop()
        .animate({ left: -150, opacity: 0 }, 350, function(){
          $this.find('.caption-left').hide(); });
    }
  };

  // hide all captions initially
  hideCaptions( $('#slider2 .panel') );

  $('#slider2')
  .anythingSlider()
  .anythingSliderFx({
   // '.selector' : [ 'caption', 'distance/size', 'time', 'easing' ]
   // 'distance/size', 'time' and 'easing' are optional parameters
   '.caption-top'    : [ 'caption-Top', '50px' ],
   '.caption-right'  : [ 'caption-Right', '130px', '1000', 'easeOutBounce' ],
   '.caption-bottom' : [ 'caption-Bottom', '50px' ],
   '.caption-left'   : [ 'caption-Left', '130px', '1000', 'easeOutBounce' ]
  })
  // add a close button (x) to the caption   
  .find('div[class*=caption]')
    .css({ position: 'absolute' })
    .prepend('<span class="close">x</span>')
    .find('.close').click(function(){
      var cap = $(this).parent(),
       ani = { bottom : -50 }; // bottom
      if (cap.is('.caption-top')) { ani = { top: -50 }; }
      if (cap.is('.caption-left')) { ani = { left: -150 }; }
      if (cap.is('.caption-right')) { ani = { right: -150 }; }
      cap.animate(ani, 400, function(){ cap.hide(); } );
    });
});

function showNewsletter(){
	$('#searchForm').hide();
	$('#newsletterForm').slideToggle('slow');
}

function showSearch(){
	$('#searchForm').slideToggle('slow');
	$('#newsletterForm').hide();
}

