$(document).ready(function(){
	var url = document.location.href;
	$("#button a").each(function()
	{
		var href = $(this).attr("href").split("../").join("");		
		var hrefPrefix = href.indexOf("/")!=-1 ? href.substring(0, href.lastIndexOf("/"))+"/" : href;

		href = href.split("../").join("");
		hrefPrefix = hrefPrefix.split("../").join("");

		if (href!="" && url.indexOf(href)!=-1)
		{
			$(this).addClass("current");
		}
		else if (hrefPrefix!="" && url.indexOf(hrefPrefix)!=-1)
		{
			$(this).addClass("active");
		}
	})
	$(".sidemenu a").each(function()
	{
		var href = $(this).attr("href").split("../").join("");		

		if (href!="" && url.indexOf(href)!=-1)
		{
			$(this).addClass("selected");
		}
	})
	/*Table*/
	// replace first td with th
	$("table").each(function()
	{
		$(this).find("tbody tr").each(function(i)
		{
			$(this).find(">td:first").replaceWith("<th>" + $(this).find(">td:first").html() + "</th>");
		})
		$("thead").remove();
	})
})
