$(document).ready(function(){

	$(".mnews").hide();
	$(".mnews:first").show();
	$(".mpages:first").attr({"class":"mpages active"});
	
	$(".mpages").click(function(){
		var nid = '#' + $(this).attr("id") + '-div';
		if ($(nid).css("display") == "none"){
				$(".mnews").fadeOut("fast");
				$(nid).fadeIn("slow");
		}
		$(".mpages").attr({"class":"mpages"});
		$(this).attr({"class":"mpages active"});
	});
	
	
	$(".menu li ul").hide();
	$(".menu li ul.open").show();
	$(".menu li a").click(function(){
		location.href = $(this).attr("href");
	});
	$(".menu li").click(function(){
		if ($("ul li",this).length){
			if ($("ul",this).css("display") == "none"){
				$("ul", this).slideDown("fast");
				$(this).addClass("open");
			}
			else
			{
				$("ul", this).slideUp("fast");
				$(this).removeClass("open");
			}
		}
		else {
			location.href = $("a",this).attr("href");
		}
		return false;
	});

	$(".menu li ul li a").each(function(){
		var hreflink = $(this).attr("href");

		if (hreflink.toLowerCase()==location.href.toLowerCase() || location.href.toLowerCase().search(hreflink.toLowerCase())>=0) {
			$("ul",$(this).parents("li")).css({"display":"block"});
			$(this).attr({"class":"active"});
		}
	});
	
	$("#ul a").each(function(){
		var hreflink = $(this).attr("href");

		if (hreflink.toLowerCase()!="/")
		if (hreflink.toLowerCase()==location.href.toLowerCase() || location.href.toLowerCase().search(hreflink.toLowerCase())>=0) {
			$(this).parents("li").attr({"class":"current"});
		}
	});
});
