$(document).ready(function() {
	var base_url = "http://vodarivne.com/";
	$.post(base_url + 'pub/Count/', {}, print_count);
	
	function print_count(data)
	{
		var mas = data.split("\n");
		$("#count_all").text(mas['0']);
		$("#count_month").text(mas['1']);
		$("#count_day").text(mas['2']);
	}
	
	$("span.span_link").hover(function() {
		$(this).css("cursor", "pointer");
		$(this).css("color", "#ffffff");
	}, function() {
		$(this).css("cursor", "default");
		$(this).css("color", "#0000ff");
	});
	
	if($.browser.msie)
	{
		$("div.div-art_in").click(function() {
			window.location.href = "http://div-art.com";
		});
	}
	
	if($.browser.opera)
	{
		i = 0;
		$("div.menu_item_box").each(function() {
			$(this).css("margin-left", i*121);
			i++;
		});
		
	}
	$("div.sub_menu_container").each(function() {
		if($("#"+$(this).attr("id")+" > div.sub_menu > span").attr("class") == "active_sub_menu_item")
		{
			var id = $(this).attr("id").split("_");
			if(!$.browser.msie)
			{
				$("#"+id[1]).css("background", "url('/images/active.png') bottom no-repeat");
			}
			else
			{
				$("#"+id[1]).css("filter", "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true', sizingMethod='scale', src='/images/activeIE.png')");
			}
			$("#"+id[1]+" > span").css("color", "#000000");
		}	
	});
	
	$("div.menu").hover(function() {
		if($("#sub_"+$(this).attr("id")).css("display") != "block")
		{
			if(!$.browser.opera)
			{
				$(this).animate({height: 50}, "fast");
			}
			else
			{
				$(this).animate({height: 40}, "fast");
			}
			if(!$.browser.msie)
			{
				$(this).css("background", "url('/images/active.png') bottom no-repeat");
			}
			else
			{
				$(this).css("filter", "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true', sizingMethod='scale', src='/images/active.png')");
			}
			
			if(!$.browser.opera)
			{
				$("#"+$(this).attr("id")+" > span").animate({paddingTop: 25}, "fast");
				$("#"+$(this).attr("id")+" > a").animate({paddingTop: 25}, "fast");
			}
			else
			{
				$("#"+$(this).attr("id")+" > span").animate({paddingTop: 20}, "fast");
				$("#"+$(this).attr("id")+" > a").animate({paddingTop: 20}, "fast");
			}
			
			$("#"+$(this).attr("id")+" > span").css("color", "#000000");
			$("#"+$(this).attr("id")+" > a").css("color", "#000000");
			
			$("#"+$(this).attr("id")).css("cursor", "pointer");
		}
	}, function() {
		if($("#sub_"+$(this).attr("id")).css("display") != "block")
		{
			if(!$.browser.opera)
			{
				$(this).animate({height: 30}, "fast");
			}
			else
			{
				$(this).animate({height: 25}, "fast");
			}
			if(!$.browser.msie)
			{
				$(this).css("background", "url('/images/button.png') bottom no-repeat");
			}
			else
			{
				$(this).css("filter", "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true', sizingMethod='scale', src='/images/buttonIE.png')");
			}
			
			$("#"+$(this).attr("id")+" > span").animate({paddingTop: 5}, "fast");
			$("#"+$(this).attr("id")+" > span").css("color", "#ffffff");
			
			$("#"+$(this).attr("id")+" > a").animate({paddingTop: 5}, "fast");
			$("#"+$(this).attr("id")+" > a").css("color", "#ffffff");
			
			$("#"+$(this).attr("id")).css("cursor", "default");
			
			$("div.sub_menu_container").each(function() {
				if($("#"+$(this).attr("id")+" > div.sub_menu > span").attr("class") == "active_sub_menu_item")
				{
					var id = $(this).attr("id").split("_");
					if(!$.browser.msie)
					{
						$("#"+id[1]).css("background", "url('/images/active.png') bottom no-repeat");
					}
					else
					{
						$("#"+id[1]).css("filter", "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true', sizingMethod='scale', src='/images/activeIE.png')");
					}
					$("#"+id[1]+" > span").css("color", "#000000");
				}
			});
		}
	});
	
	$("div.menu").click(function() {
		var id = $(this).attr("id");
		if($("#sub_"+$(this).attr("id")).css("display") == "block")
		{
			$("#sub_"+$(this).attr("id")).animate({height: 'toggle'}, "normal");
			$(this).animate({height: 30}, "fast");
			$("#"+$(this).attr("id")+" > span").animate({paddingTop: 5}, "fast");
			$("#"+$(this).attr("id")+" > span").css("color", "#ffffff");
			if(!$.browser.msie)
			{
				$(this).css("background", "url('images/button.png') bottom no-repeat");
			}
			else
			{
				$(this).css("filter", "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true', sizingMethod='scale', src='images/buttonIE.png')");
			}
			
			$("div.sub_menu_container").each(function() {
				if($("#"+$(this).attr("id")+" > div.sub_menu > span").attr("class") == "active_sub_menu_item")
				{
					var id = $(this).attr("id").split("_");
					if(!$.browser.msie)
					{
						$("#"+id[1]).css("background", "url('/images/active.png') bottom no-repeat");
					}
					else
					{
						$("#"+id[1]).css("filter", "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true', sizingMethod='scale', src='/images/activeIE.png')");
					}
					$("#"+id[1]+" > span").css("color", "#000000");
				}
			});
		}
		else
		{
			$("div.menu").each(function() {
				if($("#sub_"+$(this).attr("id")).css("display") == "block" && $(this).attr("id") != id[1])
				{
					$("#sub_"+$(this).attr("id")).animate({height: 'toggle'}, "normal");
					$(this).animate({height: 30}, "fast");
					$("#"+$(this).attr("id")+" > span").animate({paddingTop: 5}, "fast");
					$("#"+$(this).attr("id")+" > span").css("color", "#ffffff");
					$("#"+$(this).attr("id")+" > span").css("text-decoration", "none");
				}
			});
			
			$("div.sub_menu_container").each(function() {
				if($("#"+$(this).attr("id")+" > div.sub_menu > span").attr("class") == "active_sub_menu_item")
				{
					var id = $(this).attr("id").split("_");
					if(!$.browser.msie)
					{
						$("#"+id[1]).css("background", "url('/images/active.png') bottom no-repeat");
					}
					else
					{
						$("#"+id[1]).css("filter", "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true', sizingMethod='scale', src='/images/active.png')");
					}
					$("#"+id[1]+" > span").css("color", "#000000");
				}
			});
			
			if($("*").index($("#sub_"+$(this).attr("id"))[0]) != -1)
			{
				$("#sub_"+$(this).attr("id")).animate({height: 'toggle'}, "normal");
			}
		}
		
	});
});