function setPage(newPage) {
	$(".page.open-page").removeClass("open-page");
	$("#" + newPage).addClass("open-page");
	if ($(".upsell[data-feature=" + newPage + "]").length == 0) {
		$("#" + newPage).trigger("tabOpened");
	}
	window.location.hash = newPage;
}

window.page = {
	loadTimeout: 0
};
window.page.getBasePath = function() {
	return $("#basePath").text();
};

window.page.showLoading = function() {
	window.page.loadTimeout = setTimeout(function() {
		$(".loadOverlay").show();
	}, 200);
};

window.page.hideLoading = function() {
	$(".loadOverlay").hide();
	if (window.page.loadTimeout != 0) {
		clearTimeout(window.page.loadTimeout);
	}
	window.page.loadTimeout = 0;
};

window.page.getFeatures = function(callback) {
	window.api.get("features/get/", function(data) {
		callback(data.features);
	});
};

window.page.addFeature = function(feature, callback) {
	window.api.post("features/add/", { feature: feature }, function(data) {
		callback();
	});
};

window.page.getOpenPage = function() {
	return $(".page.open-page").attr("id");
};

window.page.sendFeedback = function(type, msg, name, username, webpage, callback) {
	// if the user does not want to send the webpage, the variable will be set to undefined, so don't do any checks here.
	window.api.post("feedback/post/", {
		type: type,
		msg: msg, 
		name: name,
		username: username,
		webpage: webpage
	}, function(data) {
		callback();
	});
};

window.page.openFeedbackModal = function(type) {
	var desc = "Liked a feature? Found something helpful? Tell us what you like! We'd love to hear it, and your feedback helps us make even better things in the future!";
	if (type == "frown") {
		desc = "Annoyed by something? Found a glitch? Hate how something works? Tell us! We'd love to help you and improve PlanHub.";
	} else if (type == "idea") {
		desc = "Have an idea for a new feature? Something that helps you? A tweak to make your life easier? Tell us! We'd love to include it and make PlanHub even better!";
	}

	$("#feedback-modal-title-first").text("Send a ");
	if (type == "idea") {
		$("#feedback-modal-title-first").text("Send an ");
	}
	$(".feedback-type").text(type);
	$(".feedback-desc").text(desc);

	$("#feedback-modal").modal();
};

$(document).ready(function() {
	window.page.showLoading();

	$('[data-toggle="tooltip"]').tooltip({
		container: 'body'
	});

	$(".tabs li").click(function() {
		setPage($(this).attr("data-page"));
	});

	$(".go-dropdown li a").click(function() {
		setPage($(this).attr("data-page"));
	});

	$(".admin-link").click(function() {
		setPage($(this).attr("data-page"));
	});

	$("#page-pref-btn").click(function() {
		window.prefs.openModal(window.page.getOpenPage());
	});

	$(".upsell-btn").click(function() {
		var feature = $(this).attr("data-feature");

		window.page.showLoading();

		window.page.addFeature(feature, function() {
			window.location.hash = feature;
			window.location.reload();
		});

		//$(".upsell[data-feature=" + feature + "]").remove();
	});

	$(".ideaBtn").click(function() {
		window.page.openFeedbackModal("idea");
	});

	$(".smileBtn").click(function() {
		window.page.openFeedbackModal("smile");
	});

	$(".frownBtn").click(function() {
		window.page.openFeedbackModal("frown");
	});

	$("#feedback-submit").click(function() {
		var webpage = undefined;
		if ($("#feedback-snapshot").prop("checked")) {
			// if checkbox is checked, send copy of the webpage
			webpage = window.utils.b64EncodeUnicode($("html").html().toString());
		}
		$(".feedback-footer-normal").addClass("hidden");
		$(".feedback-footer-load").removeClass("hidden");
		window.page.sendFeedback($(".feedback-type:first").text(), $("#feedback-msg").val(), $(".user-name:first").text(), $("#username").text(), webpage, function() {
			$(".feedback-footer-load").addClass("hidden");
			$(".feedback-footer-normal").removeClass("hidden");
			$("#feedback-msg").val("");
			$("#feedback-modal").modal("hide");
			alert("Your feedback has been sent successfully! We'll try to respond to you as soon as possible.");
		});
	});

	window.page.getFeatures(function(features) {
		for (var i = features.length - 1; i >= 0; i--) {
			$(".upsell[data-feature=" + features[i] + "]").remove();
		}

		window.page.hideLoading();

		if (window.location.hash != "") {
			setPage(window.location.hash.substr(1));
		} else {
			setPage("overview");
		}
	});
});
@@ -286,14 +286,36 @@
 out:
+ 0,%0A%09loadWarnTimeout:
  0%0A
-
 %7D;%0A
+%0A
 wind
@@ -502,16 +502,131 @@
 show();%0A
+%09%09window.page.loadWarnTimeout = setTimeout(function() %7B%0A%09%09%09console.warn(%22Loading is taking time...%22);%0A%09%09%7D, 10000);%0A
 %09%7D, 200)
@@ -775,24 +775,28 @@
 meout);%0A%09%7D%0A%09
+if (
 window.page.
@@ -791,32 +791,151 @@
 window.page.load
+WarnTimeout != 0) %7B%0A%09%09clearTimeout(window.page.loadWarnTimeout);%0A%09%7D%0A%09window.page.loadTimeout = 0;%0A%09window.page.loadWarn
 Timeout = 0;%0A%7D;%0A

Work on #204