$(document).ready(function(){
  //receipt popup
  $(".receiptSearch").click(function(){
    if ($(this).hasClass("active")) {
      $(".receiptPopup").hide();
      $(this).removeClass("active");
    }
    
    else {
      $(".receiptPopup").show();
      $(this).addClass("active");  
    }
    
    
    return false;
  });
  
  
  //LOGIN PASSWORD
  $(".login_box div:eq(1)").click(function(){
    $(this).find("span").hide();
    $(".login_box input[type=password]").focus();
    
    return false;
  });
  $(".login_box input[type=password]").blur(function(){
    if ($(this).val() == "") {$(".login_box span").show();}
  });
  
  
  
  //GYIK PAGE
  $("#gyik_page .question_bottom a").click(function(){
    $(this).parents(".item:eq(0)").find(".question_bottom").hide();
    $(this).parents(".item:eq(0)").find(".answer_container").show();
        
    return false;
  });
  $("#gyik_page .answer_bottom a").click(function(){
    $(this).parents(".item:eq(0)").find(".question_bottom").show();
    $(this).parents(".item:eq(0)").find(".answer_container").hide();
        
    return false;
  }); 
  
  
  //PRINT
  $("a.print").click(function(){
    print();
  });

  
  //TOOLTIP
  $("a.question").tooltip({
    track: true, 
    delay: 0, 
    showURL: false, 
    opacity: 1, 
    fixPNG: true, 
    showBody: " - ", 
    top: -10, 
    left: -90 
  });
  
    
  //FANCYBOX
  $(".gallery a:not(.video)").fancybox({
    'titleShow' : true,
    'transitionIn' : 'elastic',
    'transitionOut' : 'elastic',
    'easingIn' : 'easeOutBack',
    'easingOut' : 'easeInBack',
    'titlePosition' : 'over' 
  }); 
  $(".gallery a.video").click(function() {
		$.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'title'			: this.title,
			'width'			: 640,
			'height'		: 385,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
			'wmode'				: 'transparent',
			'allowfullscreen'	: 'true'
			}
		});

		return false;
	});  
  
    
  //SEARCH FOCUS 
  $("input[type=text]").focus(function(){
    t = $(this);
    
    var eredetiErtek = t[0].defaultValue;        
    
    $(this).parents(".inputFocus:eq(0)").next(".inputFocus").find("span").hide();
    if (t.val() == "Termék kategória" ||
        t.val() == "Gyártó" ||
        t.val() == "Megnevezés" ||
        t.val() == "Adja meg e-mail címét" ||
        t.val() == "Keresés" ||
        t.val() == "Ellenőrző kód" ||
        t.val() == "Felhasználónév"
    ) {t.val("");}
    
  }).blur(function(){
    t = $(this);
    
    var eredetiErtek = t[0].defaultValue;    
  
    if (t.val() == "") {t.val(eredetiErtek);}
    if ($(this).parents(".inputFocus:eq(0)").next(".inputFocus").find("span").css("display") == "none" &&
        $(this).parents(".inputFocus:eq(0)").next(".inputFocus").find("input[type=password]").val() == "" 
    ) {
      $(this).parents(".inputFocus:eq(0)").next(".inputFocus").find("span").show();
    }
  });    
  $(".inputFocus input[type=password]").focus(function(){$(this).next("span").hide();});
  
  $(window).load(function(){
    $(".inputFocus input, .inputFocus textarea").each(function(){ 
      if ($(this).val() != "" ) { $(this).next("span").hide(); }
    });  
    
  })  


  //CUSTOM FORMOK
  $(".language_select select, .form select, #blogListPage select").selectbox();   
  $(".ask_now_box .checkbox input, .form .checkbox input").uniform();
  
  
  //LEFT MENU
  $(".left_menu .top").click(function(){
    $(".left_menu ul:eq(0), .left_menu_bottom").slideToggle();
    if ($(this).hasClass("open_menu")) {$(this).removeClass("open_menu");}
    else {$(this).addClass("open_menu");}
    
    
    return false;
  });
  
  
  $(".left_menu ul h4").click(function(){
    if ($(this).is(":last-child")) {return true;}

    else {
      if ($(this).hasClass(".open")) {
        $(this).next("ul").slideUp();
        $(this).removeClass("open");        
      }

      else {
        $(this).next("ul").slideDown();
        $(this).addClass("open");
      }
      
      return false;      
    }
  }); 
  

  //ACCORDION
  slideMenu.build('sm',660,10,10,1);

  $("#header_menu .handle a").click(function(event){
      $("#header_menu").find(".active").removeClass("active");  
      $(this).parents("li:eq(0)").addClass("active").find(".jquery_menu_tuske").show();
      
      event.preventDefault();
  });

  
});
