
jQuery.fn.fadeToggle = function(speed, easing, callback) { 
	   return this.animate({opacity: 'toggle'}, speed, easing, callback); 
	}; 

		
$(function()
{
	login_stuff();
	
});


function login_stuff()
{
	var loginon = false;
	$("#login_show").click(function()
	{ 
		$("#login_form").toggle();
		loginon = !loginon;
		if(loginon)
			$("#loginusr").focus();
		
	});
	$("#login_local").change(function() 
	{ 
		$("#loginname_label_neptun").toggle();
		$("#loginname_label_local").toggle();
	});
	
	
}


function tdk_tanszek()
{
	$(".tdk_tanszek_temak_show").click(function(){ $(this).next(".tdk_tanszek_temak").toggle(); })
}

function tdk_temak()
{
	
	$(".tdk_temacim").click(function()
	{ 
		var act = $(this).siblings(".tdk_temaleiras");
		$(this).parent().parent("ul").find(".tdk_temaleiras").each(function()
		{
			if(this == act.get(0))
				$(this).slideToggle();
			else
				$(this).slideUp();
		}) 
	})
	
	var t = location.hash;
	if(t) $("#tdk_temak").find(t).show();
}

function gyik()
{
	$(".gyik_link").click(function() 
	{
		var t = $(this).parent().siblings(".gyik_answer");
		
		$(".gyik_answer:visible").each(function() {
			
			if(t.get(0) != this) $(this).slideUp();
		});
		t.slideDown();
		
		return false;
	});

	var all = true;
	var what = ".gyik_entry";
	 $("#searcher").keyup(function()
		{
			var s = $(this).val();
			
			if(s.length > 0)
			{
				$(what).hide();
				if($("#answerstoo").attr("checked"))
					$(what+":contains("+s+")").show();
				else
					$(".gyik_question:contains("+s+")").parent(what).show();
				
				var hits = $(what+":visible").length;
				if($(what+":visible").length <= 2) $(what+":visible > .gyik_answer").slideDown();
				else $(what+":visible > .gyik_answer").hide();
				
				console.log($("#results"));
				$("#results").html("<small>A keresés nagybetű-érzékeny</small><br /><b>"+hits+"</b> találat:");
			}
			else 
			{
				$(what).show();
				$("#results").html("");
			}
		});
	 
	 $("#answerstoo").change(function(){ $("#searcher").keyup(); });
}

