jQuery(document).ready(function(jQuery) {
  
	var thel;

	var thumbint;

	jQuery("#logo, h1 a").click( function() {
				thel = $(this);
			jQuery.post(root + "pages/" + jQuery(this).attr("href") + ".php", "ajax=yes&intro=nointro", function(data) {
				showContent(data);
		}); return false;
	});

	bindNavigation();
	
	function showContent(content)
	{
		jQuery("#changeable").fadeOut(500,function () {
			jQuery("#changeable").html(content);
			jQuery("#changeable").fadeIn(500);
			hilightNav();
		});
	}
	
	function bindNavigation()
	{
		jQuery(".ajaxload").click(function() {
				thel = $(this);
			jQuery.post(root + "pages/" + jQuery(this).attr("href") + ".php", "ajax=yes", function(data) {
				showContent(data);
			});		return false;
		});
		jQuery("#commercialmore a").click(function() {
				thel = $(this);
			jQuery.post(root + "pages/commercial.php", "ajax=yes&category=commercial&subcategory="+$(this).attr("_subcat"), function(data) {
				showContent(data);
			});		return false;
		});
	}
	function hilightNav()
	{
		page = thel.attr("href");
		$("#navigation ul li .current").removeClass("current");

		if(page.search("commercial") != -1)
		{
			subpage = thel.attr("_subcat");
			jQuery("#commercialmore:not(:visible)").show();
			$("#navigation ul li a[href=commercial]").addClass("current");
			jQuery("#commercialmore a[_subcat=" + subpage + "]").addClass("current");
		}
		else
			jQuery("#commercialmore:visible").hide();
		
		$("#navigation ul li a[href=" + page + "]").addClass("current");
	}

});

