﻿function getQueryVariable(variable) 
{
	var query = window.location.search.substring(1);
	var vars = query.split("&");
	for (var i = 0; i < vars.length; i++) 
	{
		var pair = vars[i].split("=");
		if (pair[0] == variable) 
		{
			return pair[1];
		}
	}
}

function getBaseURL() 
{
	var url = location.href;  // entire url including querystring - also: window.location.href;
	var baseURL = url.substring(0, url.indexOf('/', 14));


	if ((baseURL.indexOf('http://localhost') != -1)
		|| (baseURL.indexOf('http://172.200.3.10') != -1)) 
	{
		// Base Url for localhost
		var url = location.href;  // window.location.href;
		var pathname = location.pathname;  // window.location.pathname;
		var index1 = url.indexOf(pathname);
		var index2 = url.indexOf("/", index1 + 1);
		var baseLocalUrl = url.substr(0, index2);

		return baseLocalUrl + "/";
	}
	else 
	{
		// Root Url for domain name
		return baseURL + "/";
	}
}

function IsLocal() {
	var baseURL = getBaseURL();

	if ((baseURL.indexOf('http://localhost') != -1)
		|| (baseURL.indexOf('http://172.200.3.10') != -1)) {
		//alert("LOCAL");
		return true;
	}
	else {
		//alert("NOT LOCAL");
		return false;
	}

}

// add this onload="reloadscreen();" to the body tag of kick the user to the login page when they expire.
function reloadscreen() {
	var ls = document.getElementById("ctl00_LoginStatus1");
	if (ls.text.toUpperCase() == "LOG OUT") {
		window.setTimeout("window.location.href='" + getBaseURL() + "login.aspx';", 600000);
	}
}