/*$(function() {

    var $sidebar   = $("#sidebar"),
        $window    = $(window),
        offset     = $sidebar.offset(),
        topPadding = 15;

    $window.scroll(function() {
        if ($window.scrollTop() > offset.top) {
            $sidebar.stop().animate({
                marginTop: $window.scrollTop() - offset.top + topPadding
            });
        } else {
            $sidebar.stop().animate({
                marginTop: 0
            });
        }
    });

});      
$(function() {

    var $sidebar   = $("#sidebar"),
        $window    = $(window),
        offset     = $sidebar.offset(),
        topPadding = parseInt($("#banner").height());

    $window.scroll(function() {          
        if ($window.scrollTop() > offset.top) { 
        if(parseInt($("#banner").height())<50)
            {
            $sidebar.animate({'top': $window.scrollTop() - offset.top + topPadding  });
            }
            else
            {
             $sidebar.animate({'top': $window.scrollTop() - offset.top });
            }
        } else {
            $sidebar.css({ 'top': 0 });
        }
    });

});    
$(function() {

    var $sidebar   = $("#sidebar"),
        $window    = $(window),
        offset     = $sidebar.offset(),
        topPadding = 15;
    $window.scroll(function() {
        if ($window.scrollTop() > offset.top - 450 + $("#banner").height() ) {
        // alert(offset.top);
        if( $("#banner").height() == 10)
        {
            
            $sidebar.stop().animate({ 
                marginTop: $window.scrollTop() - offset.top + 450
            });
            }
            else{
              $sidebar.stop().animate({ 
              
                marginTop: $window.scrollTop() - offset.top + topPadding //parseInt($("#banner").height())
            });
            }
        } else {
            $sidebar.stop().animate({
                marginTop: 0
            });
        }
    });     
     

});   */
$(document).ready(function() {     
	targetBlank();
	
	$('.basta ul').hide();
  $('.napoje ul').hide();       
	
	$("#menu li").mousemove(function() {
   	$('#basta_item').hide(); 
    $('#napoj_item').hide();   
    $('#jlistok_item').hide();  
		$('.basta_link').css({"backgroundPosition":"0px -47px"});
		$('.basta_link_en').css({"backgroundPosition":"0px 0px"});
		$('.basta_link_hu').css({"backgroundPosition":"0px 0px"});      
		$('.napoje_link').css({"backgroundPosition":"0px -47px"}); 
		$('.jlistok_link').css({"backgroundPosition":"0px -47px"});
  });
	
		$('.napoje').mousemove(function() {  
		$('.napoje ul').show();          
		$('.napoje_link').css({"backgroundPosition":"0px 0px"});
		$('.napoje_link_en').css({"backgroundPosition":"0px -47px"});
		$('.napoje_link_hu').css({"backgroundPosition":"0px -47px"});
	});	  
	
		$('.jlistok').mousemove(function() {  
		$('.jlistok ul').show();          
		$('.jlistok_link').css({"backgroundPosition":"0px 0px"});
		$('.jlistok_link_en').css({"backgroundPosition":"0px -47px"});
		$('.jlistok_link_hu').css({"backgroundPosition":"0px -47px"});
	});	
	
	$('.basta').mousemove(function() {  
		$('.basta ul').show();          
		$('.basta_link').css({"backgroundPosition":"0px 0px"});
    $('.basta_link_en').css({"backgroundPosition":"0px -47px"});
    $('.basta_link_hu').css({"backgroundPosition":"0px -47px"});
	});	   

  $('#napoj_item').mouseout(function() { 
		$('#napoj_item').hide();          
		$('.napoje_link').css({"backgroundPosition":"0px -47px"});
		$('.napoje_link_en').css({"backgroundPosition":"0px 0px"});
		$('.napoje_link_hu').css({"backgroundPosition":"0px 0px"});
  });	 
      
  $('#jlistok_item').mouseout(function() { 
		$('#jlistok_item').hide();          
		$('.jlistok_link').css({"backgroundPosition":"0px -47px"});
		$('.jlistok_link_en').css({"backgroundPosition":"0px 0px"});
		$('.jlistok_link_hu').css({"backgroundPosition":"0px 0px"});
  });
  	
	$('#basta_item').mouseout(function() { 
		$('#basta_item').hide();           
		$('.basta_link').css({"backgroundPosition":"0px -47px"});
		$('.basta_link').css({"backgroundPosition":"0px 0px"});

  });		
	              
	$('#jlistok_item').mousemove(function() {    
		$('.jlistok_link').css({"backgroundPosition":"0px 0px"});
		$('.jlistok_link_en').css({"backgroundPosition":"0px -47px"});
		$('.jlistok_link_hu').css({"backgroundPosition":"0px -47px"});
  });	      
   
	$('#napoj_item').mousemove(function() {    
		$('.napoje_link').css({"backgroundPosition":"0px 0px"});
		$('.napoje_link_en').css({"backgroundPosition":"0px -47px"});
		$('.napoje_link_hu').css({"backgroundPosition":"0px -47px"});
  });	
  
	$('#basta_item').mousemove(function() {     
		$('.basta_link').css({"backgroundPosition":"0px 0px"});
    $('.basta_link').css({"backgroundPosition":"0px -47px"});

  });
  
});
  

$(window).load(function() {
                               
    $(".rotate").show(300);  
    
		$(".anim_buton1").click(function() {  
    $("#banner2").hide();  
    $("#anim_butonVyp").show(1500);    
		$('#banner1').show();
		});
		
		$(".anim_buton2").click(function() { 
    $("#banner2").hide();
    $("#anim_butonVyp").show(1500);     
		$('#banner3').show();
		});
		
		$(".anim_buton3").click(function() { 
    $("#banner2").hide(); 
    $("#anim_butonVyp").show(1500);    
		$('#banner4').show();
		});

});
  

   function slideUpDown(page)
   {
    	//slider hide & show
    	var banner  = $('#banner');   
    	var banner2 = $('#banner2'); 
    	var slider  = $('#slider');
    	
    	if(page != undefined){
        if(page == 0){
        	slider.removeClass("arrow_up").addClass("arrow_down");
        	banner.css({'height':'10px','opacity':'0',"z-index":"1"});
        	banner2.hide();
        }  
        
        if(page == 1){
  				slider.removeClass("arrow_down").addClass("arrow_up");  
        	banner.css({'height':'428px','opacity':'1',"z-index":"1"});    
        	banner2.show();
        }   	
      }

		if (slider.hasClass('arrow_up')) {
		  if(page == undefined)
      {                  
       	banner2.show();
  			banner.animate({ 
  			  height: '428',				
      	  opacity: 1
  			}, 1000, function(){
  				slider.removeClass("arrow_up").addClass("arrow_down");
  			});
			}else{
       	slider.removeClass("arrow_up").addClass("arrow_down");
      }
		} else {     
		  if(page == undefined)
      {             
        banner2.show();
  			banner.animate({ 
  				height: '10',			
      	  opacity: 0
  			}, 1000, function(){
  				slider.removeClass("arrow_down").addClass("arrow_up");
  			});             			
         banner.children().each(function(index) {
           $("#"+$(this).attr('id')).css({"z-index":"0"});
         });

        }else{
       	slider.removeClass("arrow_down").addClass("arrow_up");
      }
		}

  
   }
 
  /**
   *  nahradenie target=_"blank" v tagu a kvoli xhtml validite
   *  example <a href="creoneo.com" rel="external" >text</a>     
   */ 
  function targetBlank()
  {                 
    $('a[rel*=external]').click( function() {  
         window.open(this.href);
         return false;
    });  
  }   
  
  function ViewPhoto(reg)
  {             
   $("#"+reg).parent().show();   
   $(".photo_view").hide();
   $("#"+reg).show("100");   
 	 $.scrollTo('#' + reg, 800);
  }
  
  function check_email(value) {
  if (!value.match(/^(?:[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9\-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9\-]*[a-z0-9])?)$/i)) {
    alert('Zadali ste nesprávnu emailovú adresu!');
    document.getElementById('mailinglist_form').email.focus();
  } else {
    document.getElementById('mailinglist_form').submit();
  }
}
