$(document).ready(function() {
	var url = document.location;
	var mas = url + "";
	var help = mas.split("/");
	var base_url = help[0] + "//" + help[2] + "/";
	
	$("a.menu_link").hover(function() {
		$(this).parent().css("background-position", "5px 7px");
	}, function() {
		$(this).parent().css("background-position", "5px -10px");
	});
	
	var  where = document.referrer;
	if(where == 0)
	{
		$("#back_link").html("");
	}
	else
	{
		$("#back_link").html("<a href="+where+" class='foot_link' title='Повернутися на попередню сторінку' onmouseup='blur();'><<< Повернутися</a>");
	}
	
	$("span.span_link").hover(function() {
		$(this).css("color", "#dbff4d");
		$(this).css("text-decoration", "none");
	}, function() {
		$(this).css("color", "#fff100");
		$(this).css("text-decoration", "underline");
	});
	
	$("span.span_link").click(function() {
		if($(this).parent().attr("class") == "year")
		{
			if($("#" + $(this).parent().attr("id") + "_pupils").css("display") == "none")
			{
				$("div.year_pupils").each(function() {
					if($(this).css("display") == "block")
					{
						$(this).animate({"height": "hide"}, "slow");
					}
				});
				
				$("#" + $(this).parent().attr("id") + "_pupils").animate({"height": "show"}, "slow");
			}
			else
			{
				$("#" + $(this).parent().attr("id") + "_pupils").animate({"height": "hide"}, "slow");
				
				$("div.pupil_box").css("display", "none");
				$("#empty_pupil").animate({"opacity": "show"}, "slow");
			}
		}
		else
		{
			if($(this).parent().attr("class") == "kafedra")
			{
				if($("#" + $(this).attr("id") + "_sub").css("display") == "none")
				{
					$("div.kafedra_sub").each(function() {
						if($(this).css("display") == "block")
						{
							$(this).animate({"height": "hide"}, "slow");
						}
					});
					
					$("#" + $(this).attr("id") + "_sub").animate({"height": "show"}, "slow");
				}
				else
				{
					$("#" + $(this).attr("id") + "_sub").animate({"height": "hide"}, "slow");
				}
			}
			else
			{
				if($("#" + $(this).attr("id") + "_box").css("display") == "none")
				{
					$("div.pupil_box").each(function() {
						if($(this).css("display") != "none")
						{
							$(this).css("display", "none");
						}
					});
					
					$("#" + $(this).attr("id") + "_box").animate({"opacity": "show"}, "slow");
					$("#" + $(this).attr("id") + "_box").css("display", "table");
				}
				else
				{
					$("#" + $(this).attr("id") + "_box").css("display", "none");
					$("#empty_pupil").animate({"opacity": "show"}, "slow");
				}
			}
		}
	});
});