function loadPage(page, contentTarget) {
	if (contentTarget == null) {
		contentTarget = "content";
	}

	if(contentTarget=="content"){
		document.getElementById('content').scrollTop=0;
		
		loadPage("content/sidebar.php?site="+getPathWithoutParams(page),"sidebar");
		loadPage("content/titel.php?site="+getPathWithoutParams(page),"titel");
	}	

	$("#" + contentTarget).hide();

	if (getFileExtension(page) != "php") {
		$.ajax( {
			url :(page),
			cache :false,
			success : function(html) {
				$("#" + contentTarget).html(html);
				$("#" + contentTarget).fadeIn("slow");
				mit_scrollbar();
			}
		});
	} else {
		$.post(getPathWithoutParams(page), getParams(page), function(html) {
			$("#" + contentTarget).html(html);
			$("#" + contentTarget).fadeIn("slow");
			mit_scrollbar();
		});
	}
	if(contentTarget!="titel"&&contentTarget!="sidebar"){
		// setTimeout('mit_scrollbar()',1500);
	}
}



function loadPageCallback(page, contentTarget, func) {
	if (contentTarget == null) {
		contentTarget = "content";
	}
	$("#" + contentTarget).hide();

	if (getFileExtension(page) != "php") {
		$.ajax( {
			url :(page),
			cache :false,
			success : function(html) {
				$("#" + contentTarget).html(html);
				$("#" + contentTarget).fadeIn("slow");
				func();
			}
		});
	} else {
		$.post(getPathWithoutParams(page), getParams(page), function(html) {
			$("#" + contentTarget).html(html);
			$("#" + contentTarget).fadeIn("slow");
			func();
		});
	}
}

$(document).ready( function() {
		
	$("a.pageLink").live("click", function() {
		$(this).blur();
		$("a.pageLink").css("font-weight", "normal");
		$(this).css("font-weight", "bold");

		var id = $(this).attr("href");
		var contentTarget = $(this).attr("contentTarget");
		loadPage(id, contentTarget);

		// Avoid the browser following the href link
			return false;
	});

	$("a.mainMenuButton").mouseover(function() {
		
		
		
		
	});

	$("a.mainMenuButton").live("click", function() {

		$("a.mainMenuButton").each(function() {
			$(this).removeClass($(this).attr("id")+"Hover");
			$(this).addClass($(this).attr("id"));			
		});
		
			
		$(this).removeClass($(this).attr("id"));
		$(this).addClass($(this).attr("id") + "Hover");


		$(".buttonMenu").hide("slow");
		$("#" + $(this).attr("id")+"SubMenu").show("slow");


		$(this).blur();
		$("a.pageLink").css("font-weight", "normal");
		$(this).css("font-weight", "bold");

		var id = $(this).attr("href");
		var contentTarget = $(this).attr("contentTarget");
		loadPage(id, contentTarget);

		// Avoid the browser following the href link
			return false;
	});	
	
	// Load 'Startseite'
		loadPage("content/home.php", "content");


		
		$("#homeButtonSubMenu").show("slow");
		$("#homeButton").addClass($("#homeButton").attr("id") + "Hover");
	});
