 var animBlock = false;
 var csirkeAnim = false;

 reinitialiseScrollPane = function() {
	$("#ajax-loader").css("display", "none");
	$(".jScrollPaneTrack").css("visibility", "visible");
	$("#pane1").html($('#tmp').html()).fadeIn("slow").jScrollPane({scrollbarWidth: 17, dragMaxHeight: 30, dragMinHeight: 30});
	$(".jScrollPaneDrag").css("top", "0px");
	$("#pane1").css("top", "0px");
 }

 function sendFW(formID) {
	if (formID == "game_form") {
		form_valid = false;

		if (!$("#game1").attr("checked") && !$("#game2").attr("checked") &&
			$("#game4").attr("checked") && $("#game5").attr("checked")) {
				form_valid = true;
		}
		
		if (!form_valid) {
			alert("A megadott válaszok nem helyesek! Próbálja újra!");
			return false;
		}

		if ($("#game_name").attr("value") == "" || $("#game_email").attr("value") == "") {
			alert("A név és az email megadása kötelező!");
			return false;
		}
	}

	var params = {};
	$("#" + formID).find("input:text, input:checked, input:selected, input:hidden, textarea, select").filter(":enabled").each(function() {
		params[ this.name || this.id || this.parentNode.name || this.parentNode.id ] = this.value;
	});
	$("#ajax-form-loader").show();
	
	$.post("forms.php?call=ajax", params, function(data){
		alert(data);
		$("#ajax-form-loader").hide();
	});

	return false;
 }

 var prev_content = "";
 function getContent(content_id) {
	var target_html = "";
	if (content_id == "bocsi") {
		$.nyroModalManual({
		  url: 'dialog_bocsi.html'
		});
	}
	if (content_id == "boltok") {
		$.nyroModalManual({
		  url: 'dialog_boltok.html'
		});
	}
	if (content_id == "vasarlok") {
		$.nyroModalManual({
		  url: 'dialog_kerdoiv.html'
		});
	}
	if (content_id == "blog") {
		document.location="http://www.boldogcsirke.hu/blog/";
	}
	if (content_id == "termekek") {
		$.nyroModalManual({
		  url: 'dialog_termekek.html'
		});
	}
	
	if (false && target_html != "" && content_id != prev_content) {
		// never runs in new concept...
		prev_content = content_id;
		$("#pane1").css("display", "none");
		$(".jScrollPaneTrack").css("visibility", "hidden");
		$("#ajax-loader").css("display", "block");
		$('#tmp').load(target_html, '', reinitialiseScrollPane);
		var timer = setTimeout("reinitialiseScrollPane()", 500);
	}
 }

 function showSendFW() {
	$.nyroModalManual({
		 url: 'dialog_sendfw.html'
	});
	return false;
 }

 function showGame() {
	$.nyroModalManual({
		 url: 'dialog_jatek.html'
	});
	return false;
 }

 function topHover(id) {
	if (animBlock) {
		return false;
	}

	$("#overlay-anim").css("visibility", "hidden").attr("class", "top-anim-" + id).css("visibility", "visible");
	$("#overlay-tooltip").attr("class", "top-tooltip-" + id).css("visibility", "visible");
	$("#overlay-dots").attr("class", "overlay-dots-" + id);
	
	if (id == "csirke" && !csirkeAnim) {
		animBlock = true;
		csirkeAnim = true;
		var t1 = setTimeout("unsetBlock()", 5000);
		var t2 = setTimeout("unsetBlockVar()", 1000);
	}
 }

 function topOut(id) {
	if (animBlock) {
		return false;
	}

	$("#overlay-anim").css("visibility", "hidden").attr("class", "");
	$("#overlay-tooltip").css("visibility", "hidden").attr("class", "");
	$("#overlay-dots").attr("class", "overlay-dots-alap");
 }

 function unsetBlock() {
	$("#overlay-anim").css("visibility", "hidden").attr("class", "");
	$("#overlay-tooltip").css("visibility", "hidden").attr("class", "");
	$("#overlay-dots").css("visibility", "overlay-dots-alap");
	csirkeAnim = false;
 }

 function unsetBlockVar() {
	animBlock = false;
 }

 $(document).ready(function() {
	$.nyroModalSettings({
		minWidth: 593,
		minHeight: 421,
		width: 593,
		height: 421
	});

    $("#navigation").slider2({
		step: 21,
		animate: true,
		max: 100,
		change: function(event, ui) {
			if (ui.value == 100) {
				ui.value = 84;
				$("#navigation > .ui-slider-handle").css("left", "84%");
			}
		},
		stop: function(event, ui) {
			if (ui.value == 100) {
				ui.value = 84;
				$("#navigation > .ui-slider-handle").css("left", "84%");
			}
			if (ui.value == 0){
				getContent("bocsi");
				$("#navbar").attr("class", "bt-bocsi");
			}
			if (ui.value == 21) {
				getContent("termekek");
				$("#navbar").attr("class", "bt-termek");
			}
			if (ui.value == 42) {
				getContent("boltok");
				$("#navbar").attr("class", "bt-boltok");
			}
			if (ui.value == 63) {
				getContent("vasarlok");
				$("#navbar").attr("class", "bt-vasarlok");
			}
			if (ui.value == 84)	{
				getContent("blog");
				$("#navbar").attr("class", "bt-blog");
			}
			console.log(ui.value);
		}
	});
  });

