function loadPage(href, link_text) {
	if (!link_text) {
		link_text = "the requested page";
	}

	$(".open_page")
		.removeClass("open_page")
		.slideUp(function() {
			$("#inner")
				.addClass("open_page")
//				.html("<div id='loading' class='box content'>Loading " + link_text + "...</div>")
				.html("<div id='loading' class='box content'>Loading...</div>")
				.slideDown(function() {
					$.ajax({
						type: "GET",
						url: href,
						dataType: "html",
						success: function(data) {
							$("#inner").html(data);
						},
						error: function() {
							$("#inner").html("<div id='failure' class='box content'>Coming soon!</div>");
						}
					});
				});
		});
}

jQuery.fn.ajaxifyLinks = function(selector) {
	mainURL = document.URL.replace("http://ism3.infinityprosports.com", "");

	$(this).live("click", function(event) {
		var $this = $(this);
		if ( ((event.button == 0) || ($.browser.msie && event.button == 1)) && $this.is(selector) ) {
			event.preventDefault();
			switchPage($this);
		}
	});

	function switchPage($anchor) {
		$("html, body").animate({scrollTop: 0});

		var href = $anchor.attr("href");
		var link_text = $anchor.text();

		if ((href != mainURL) && (href != "/")) {
			loadPage(href, link_text);
		} else {
			goHome();
		}
	}

	function goHome() {
		$("#inner")
			.slideUp(function() {
				$("#home")
					.slideDown()
					.addClass("open_page");
			})
			.removeClass("open_page");
	}
}