$(function() {
	$('#tk-menu-1').mouseover(function() {
		$("#tk-menu-1-short").hide();
		$("#tk-menu-1-full").show();
	});
	$('#tk-menu-1').mouseout(function() {
		$("#tk-menu-1-short").show();
		$("#tk-menu-1-full").hide();
	});
	$('#tk-menu-2').mouseover(function() {
		$("#tk-menu-2-short").hide();
		$("#tk-menu-2-full").show();
	});
	$('#tk-menu-2').mouseout(function() {
		$("#tk-menu-2-short").show();
		$("#tk-menu-2-full").hide();
	});
	$('#tk-menu-3').mouseover(function() {
		$("#tk-menu-3-short").hide();
		$("#tk-menu-3-full").show();
	});
	$('#tk-menu-3').mouseout(function() {
		$("#tk-menu-3-short").show();
		$("#tk-menu-3-full").hide();
	});
	$('#tk-menu-4').mouseover(function() {
		$("#tk-menu-4-short").hide();
		$("#tk-menu-4-full").show();
	});
	$('#tk-menu-4').mouseout(function() {
		$("#tk-menu-4-short").show();
		$("#tk-menu-4-full").hide();
	});

	var timer = null;

	$('#offer-link').mouseover(function() {
		$this = $(this);
		var offset = $this.offset();
		$layer = $("#recipe-info-layer");
		if ((offset.top + $layer.height() + 10) > $(window).scrollTop() + $(window).height()) {
			var $top = (offset.top - $layer.height());
			var $paddingBottom = 45;
		} else {
			var $top = (offset.top);
			var $paddingBottom = 0;
		}
		$layer.css("left", offset.left).css("top", $top).css("padding-bottom", $paddingBottom);
		timer = setTimeout(receptMutat, 300);
	}).mouseout(function() {
		clearTimeout(timer);
		$('#offer-link').removeClass("hover");
		$('#recipe-info-layer').hide();
	});
	$('#recipe-info-layer').mouseover(function() {
		$('#offer-link').addClass("hover");
		$this = $(this)
		$this.show();
	}).mouseout(function() {
		clearTimeout(timer);
		$('#offer-link').removeClass("hover");
		$this.hide();
	});
	$('#recipe-info-layer #close').click(function() {
		$('#recipe-info-layer').hide();
		return false;
	});
	
	function receptMutat() {
		$("#recipe-info-layer").fadeIn("slow");
	}

	var $maxSzaki = $("#tk-index-ask a.button").attr("rel");
	var $szakiSzam = Math.round(($maxSzaki-1) * Math.random() + 1);
	$("#tk-index-ask #szakerto_" + $szakiSzam).show();
	$("#tk-index-ask a.button").click(function(){
		if ($szakiSzam == $maxSzaki) {
			$szakiSzam = 0;
		}
		$szakiSzam ++;
		$("#tk-index-ask #szakerto_" + $szakiSzam).fadeIn("slow").siblings("div").hide();
		return false;
	});

});
