function Split(string, delimiter) {
var elements = new Array();
var numElements = 0;
var token;
var index = 0;
var nextIndex = -1;
index = string.indexOf(delimiter);
while (string != "") {
if (string.charAt(0) == delimiter) {
elements[numElements++] = "";
string = string.substring(1);
} else {
nextIndex = string.indexOf(delimiter);
if (nextIndex == -1) {
elements[numElements++] = string;
string = "";
} else {
elements[numElements++] = string.substring(0, nextIndex)
string = string.substring(nextIndex + 1)
}
}
}
return elements;
}
function GetCookie(key) {
var i;
var cookies = Split(document.cookie, ";");
for (i = 0; i < cookies.length; i++) {
if (cookies[i].substring(0, 1) == " ") cookies[i] = cookies[i].substring(1, cookies[i].length);
// Make the cookies case insensitive, like ASP
if (unescape(cookies[i].substring(0, key.length + 1).toUpperCase()) == key.toUpperCase() + "=") {
return unescape(cookies[i].substring(cookies[i].indexOf("=") + 1, cookies[i].length));
}
}
if (key == "BASEUSERSURL") {
return "/"; 
}
return null;
}
function SetCookie(key, value) {
document.cookie = key.toString().toUpperCase() + '=' + escape(value.toString()) + '; path=/';
}
function ClearCookie(key) {
document.cookie = key.toString().toUpperCase() + '=0; expires=Fri, 02-Jan-1970 00:00:00 GMT; path=/';
}
// Sets the cookie with the given expiration date (in days).
// If the bOverRide flag is true, override the existing cookie (if the cookie already exists).
// If it is false, and the cookie already exists, don't ovverride the existing cookie.
// If the cookie doesn't exist in either case, set a new one.
//
function SetExpiresCookie(key, value, daysTillExpiration, bOverRide) 
{
//if don't override and the cookie exists - don't do anything
if(!bOverRide && GetCookie(key)) {	
return;
} else {
//if the cookies doesn't exist - want to set regardless of bOverRide	
//	The cookie was not found
//	make sure daysTillExpiration is valid and a number
if (! daysTillExpiration ) {
daysTillExpiration = 0;
} else {
//	Get the current date
var currentDate = new Date();
//	Add the number of days
var expireTime = currentDate.getTime() + ( 1000 * 60 * 60 * 24 * daysTillExpiration);
var expireDate = new Date(expireTime);
}
// Set the cookie
var setCookieStr = key.toString().toUpperCase() + '=' + escape(value.toString()) + '; path=/;';
if (daysTillExpiration > 0) {
setCookieStr = setCookieStr + 'expires=' + expireDate.toGMTString() + ';';
}
document.cookie = setCookieStr;
}
}
//	Get and Set Cookie
//	This function tests to see if the cookie is there, and if it is not, it sets it
//	has an expiration date (in days)
function GetAndSetCookie(key, value, daysTillExpiration)
{
SetExpiresCookie(key, value, daysTillExpiration, false);
}

var bShowInterceptor = true;
window.onunload = showInterceptor;
function initializeClicks()
{
if (document.all)
{
xAssignLinks(document.all);
}
else if (document.getElementsByTagName)
{
xAssignLinks(document.getElementsByTagName('a'));
xAssignLinks(document.getElementsByTagName('td'))
xAssignLinks(document.getElementsByTagName('div'));
}
if (document.forms)
{
xAssignSubmits(document.forms);
}
else if (document.getElementsByTagName)
{
xAssignSubmits(document.getElementsByTagName('form'));
}
}
function xAssignLinks(itemsToAssign)
{
if (!itemsToAssign)
return;
var undefined;
for (var i = 0; i < itemsToAssign.length; i++)
{
if ((itemsToAssign[i].onclick != null) || (itemsToAssign[i].href != undefined))
{
itemsToAssign[i].oldClick = (itemsToAssign[i].onclick) ? itemsToAssign[i].onclick: function() {};
itemsToAssign[i].onclick = function() { cancelInterceptor(); return this.oldClick(); };
}
}
}
function xAssignSubmits(itemsToAssign)
{
if (!itemsToAssign)
return;
for (var i = 0; i < itemsToAssign.length; i++)
{
itemsToAssign[i].oldOnSubmit = (itemsToAssign[i].onsubmit) ? itemsToAssign[i].onsubmit: function() {};
itemsToAssign[i].onsubmit = function() { cancelInterceptor(); return this.oldOnSubmit(); };
}
}
function cancelInterceptor()
{
bShowInterceptor = false;
if (this != this.parent)
{
this.parent.bShowInterceptor = false;
}
}
function enableInterceptor()
{
bShowInterceptor = true;
}
function showInterceptor()
{
}

