/* ------------------------------------------------------------------
global.js - scripts used on every page of the site.
------------------------------------------------------------------ */

var schReadyTimesFullList = new Array();

var WaitPanel = function() {
	var panel;
	 return {
        hide : function(doit){
            if(!panel){
	            panel = new YAHOO.widget.Panel("wait",  
					{ width:"240px", 
					  fixedcenter:true, 
					  close:false, 
					  draggable:false, 
					  modal:true,
					  visible:false
					} 
				);

				panel.setHeader("Loading");
				panel.setBody("<div style='text-align:center'><img src='/static/unishippers/images/wait30trans.gif'/><span style='padding-left:10px'>Loading... Please wait.</span></div>");
				panel.render(document.body);	
			}
			if(doit) {
				panel.hide();
			} else {
				panel.show();
			}
        }
     };
}();
/**
 * determines if the current user is using IE
 */
function isIE() {
	
	if(!(navigator && navigator.userAgent && navigator.userAgent.toLowerCase)) {
		return false;
  	} else {
		var detect = navigator.userAgent.toLowerCase();
		if(detect.indexOf('msie') + 1) {
			// browser is internet explorer
			var rv = -1; // Return value assumes failure
			if (navigator.appName == 'Microsoft Internet Explorer') {
				var ua = navigator.userAgent;
				var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
				if (re.exec(ua) != null) {
					rv = parseFloat( RegExp.$1 );
				}
			}
	
			var valid = true;
			// if the version can be found and the version is less than our version number it is invalid
			//if ((ver > -1) && (ver < versionNumber)) {
			//	valid = false;
			//}
			
			//alert(rv );
			return valid;
		} else {
			return false;
		}
  	}
} 

/* parseUri JS v0.1, by Steven Levithan (http://badassery.blogspot.com)
Splits any well-formed URI into the following parts (all are optional):
----------------------
 source (since the exec() method returns backreference 0 [i.e., the entire match] as key 0, 

we might as well use it)
 protocol (scheme)
 authority (includes both the domain and port)
     domain (part of the authority; can be an IP address)
     port (part of the authority)
 path (includes both the directory path and filename)
     directoryPath (part of the path; supports directories with periods, and without a 

trailing backslash)
     fileName (part of the path)
 query (does not include the leading question mark)
 anchor (fragment)
*/
function parseUri(sourceUri){
    var uriPartNames = ["source","protocol","authority","domain","port","path","directoryPath","fileName","query","anchor"];
    var uriParts = new RegExp("^(?:([^:/?#.]+):)?(?://)?(([^:/?#]*)(?::(\\d*))?)?((/(?:[^?#](?![^?#/]*\\.[^?#/.]+(?:[\\?#]|$)))*/?)?([^?#/]*))?(?:\\?([^#]*))?(?:#(.*))?").exec(sourceUri);
    var uri = {};
    
    for(var i = 0; i < 10; i++){
        uri[uriPartNames[i]] = (uriParts[i] ? uriParts[i] : "");
    }
   
    // Always end directoryPath with a trailing backslash if a path was present in the source URI
    // Note that a trailing backslash is NOT automatically inserted within or appended to the "path" key
    if(uri.directoryPath.length > 0){
        uri.directoryPath = uri.directoryPath.replace(/\/?$/, "/");
    }
    
    return uri;
}

/* String sort case insensitive
------------------------------------------------------------------- */
function stringSortNoCase(a,b,order){
    
    a = a.toLowerCase();
    b = b.toLowerCase();
    
    var items = new Array();
    items[0] = a;
    items[1] = b;
    items.sort();
    
	if(order=="asc") {
	    return ( items[1]==a )?1:-1;
	}
	else {
	    return ( items[0]==a )?1:-1;
	}
}


/*
 * Creates the Unishippers namespace
 */
if (typeof UNI == "undefined") {
    var UNI = {};
}

/* Email checker
------------------------------------------------------------------ */
function isValidEmail( email ) {

	if ( email != null ) {
	
		var re = /^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.(([0-9]{1,3})|([a-zA-Z]{2,3})|(aero|coop|info|museum|name))$/;
		var result = re.test(email);
		return result;
	}
	
	return false;
}

               
/* Primary Navigation Drop-down menu
------------------------------------------------------------------ */
var marketingbar;
UNI.onMenuBarReady = function() {
	
	var menu = $("menu");

	if ( menu != null && menu.empty() ) {

		var menuUrl = null;
		
		if ( typeof alternateMenuUrl != "undefined" ) {
			menuUrl = alternateMenuUrl;
		}
		else {
			menuUrl = "/content/menu.html"
		}
		
		// Instantiate and render the menu bar
		if ( menuUrl != null ) {
			
			new Ajax.Request(menuUrl, { // don't use unishippers ajax here. No need to trigger the session here.
				method: "get",
				onSuccess: function(o) {
					
					$("menu").innerHTML = o.responseText;
					
					UNI.renderMarketingMenu();
					
				}
			});
		}
	}
	else {
		UNI.renderMarketingMenu();
	}	
	
};
UNI.renderMarketingMenu = function() {
	marketingbar = new YAHOO.widget.MenuBar("menu", { autosubmenudisplay:true, hidedelay:750, lazyload:false, zindex:10000 });
	marketingbar.render();
}


/* Add login link, tools menu, & admin 
------------------------------------------------------------------ */
var toolbar;

/**
 * Load dynamic page content from backend
 */
UNI.pageLoader = function() {
	
	var d = new Date();
	var url = "/eship/HomeContentLoader.action?d=" + d.getTime();
	
	new Ajax.Request(url, {
		method: "get",
		onSuccess: function(o) {
			$("onloadCache").innerHTML = o.responseText;
		},
		onComplete: UNI.pageLoader.doAfter
		
	});
}

/**
 * Do this after dynamic content is loaded
 */
UNI.pageLoader.doAfter = function() {
	
	if ( !$("onloadCache").empty() ) {
		
		// set copyright year in footer
		$("copyrightYear").innerHTML = new Date().getFullYear();
		
		// copy html to proper locations from cache
		$("user-info").innerHTML = $("loginLinkContent").innerHTML;
		$("user-info").show();
		$("loginLinkContent").remove(); // cleanup
		
		$("tools").innerHTML = $("toolsMenuContent").innerHTML;
		$("toolsMenuContent").remove(); // cleanup
		
		var adminContent = $("adminContent");
		if ( adminContent && !adminContent.empty() && $("admin").empty() ) {
			$("admin").innerHTML = $("adminContent").innerHTML;
			$("admin").show();
			$("adminContent").remove() // cleanup
		}
		
		// setup yahoo menu
		toolbar = new YAHOO.widget.MenuBar("tools", { autosubmenudisplay:true, hidedelay:750, lazyload:false, constraintoviewport:true });
		toolbar.render();
		
		// manually start timer
		UNI.session.timer.start();
		
		// render dialogs
		UNI.login.init();
		messageDialogInit();
		confirmDialogInit();
		
	}
}


/** Message Dialog 
-----------------------------------------------------------------------------------*/

UNI.message = {}

function messageDialogInit() {
	
	var handleCancel = function() {
		this.cancel();
	};

	// Instantiate the Dialog
	UNI.message.dialog = new YAHOO.widget.Dialog("message-dialog",  { 
		width : "310px",
		fixedcenter : true,
		visible : false, 
		constraintoviewport : true,
		modal : true,
		buttons : [ { text:"OK", handler:handleCancel, isDefault:true } ]
	 });

	UNI.message.dialog.clear = function() {
		$("message-dialog-title").innerHTML = "";
		$("message-dialog-text").innerHTML = "";
	}
	
	UNI.message.dialog.set = function( title, text ) {
		$("message-dialog-title").innerHTML = title;
		$("message-dialog-text").innerHTML = text;
	}
	
	UNI.message.dialog.setError = function( title, text ) {
		$("message-dialog-text").className = "uni-alert-error";
		UNI.message.dialog.set(title, text);
	}
	
	UNI.message.dialog.setSuccess = function( title, text ) {
		$("message-dialog-text").className = "uni-alert-success";
		UNI.message.dialog.set(title, text);
	}
	
	UNI.message.dialog.setWarning = function( title, text ) {
		$("message-dialog-text").className = "uni-alert-warning";
		UNI.message.dialog.set(title, text);
	}
	
	UNI.message.dialog.setInfo = function( title, text ) {
		$("message-dialog-text").className = "uni-alert-info";
		UNI.message.dialog.set(title, text);
	}
	
	// Render the Dialog
	UNI.message.dialog.render();

	if ( $("message-dialog") ) {
		$("message-dialog").style.display = "block";
	}
}


/* Confirm Dialog
------------------------------------------------------------------ */
UNI.confirm = {}
UNI.confirm.handleOk = function(){};
function confirmDialogInit() {
    
    var handleCancel = function() {
        this.cancel();
    };

    // Instantiate the Dialog
    UNI.confirm.dialog = new YAHOO.widget.Dialog("uni-confirm-dialog",  { 
        width : "260px",
        fixedcenter : true,
        visible : false, 
        constraintoviewport : true,
        modal : true,
        buttons : [ { text:"OK", handler:UNI.confirm.handleOk, isDefault:true }, { text:"Cancel", handler:handleCancel, isDefault:true } ]
     });

    UNI.confirm.dialog.clear = function() {
        $("uni-confirm-title").innerHTML = "";
        $("cuni-confirm-message").innerHTML = "";
    }
    
    UNI.confirm.dialog.set = function( title, text ) {
        $("uni-confirm-title").innerHTML = title;
        $("uni-confirm-message").innerHTML = text;
    }
    
    // Render the Dialog
    UNI.confirm.dialog.render();

    if ( $("uni-confirm-dialog") ) {
        $("uni-confirm-dialog").style.display = "block";
    }
}


/* Login Dialog
------------------------------------------------------------------ */
UNI.login = {}

UNI.login.isLoggedIn = function() {
	if ( $("logged-in") ) {
		return true;
	}
	return false;
};
		
UNI.login.init = function() {
	
	if ( $("login-dialog") ) {
	
		// Define various event handlers for Dialog
		var handleSubmit = function() {
			
			// if user checked save login do it now.
			UNI.login.saveLogin($("saveLoginCheckbox").checked);
			
			UNI.navigation.redirectUrl = $("redirectUrl").value = UNI.url.https($F("redirectUrl"));
			
			if ( UNI.login.loginDialog.validate() ) {
				UNI.login.loginDialog.setLoginButtonDisabled();
				UNI.login.loginDialog.showWait();
				this.submit();
			}
		};
		var handleCancel = function() {
			UNI.login.loginDialog.setLoginButtonEnabled();
			//UNI.login.loginDialog.clearDialog();
			this.cancel();
		};
		var handleSuccess = function(o) {
			var command = o.responseText;
			
			if ( command == "success" ) {
				UNI.login.afterLogin();
			}
			else if ( command == "isFirstTime" ) {
				UNI.navigation.redirectUrl = "/eship/Disclaimer.action?url=" + UNI.navigation.redirectUrl;
				UNI.login.afterLogin();
			}
			else if ( command == "forceChangePassword" ) {
				UNI.navigation.redirectUrl = "/eship/ChangePassword.action?url=" + UNI.navigation.redirectUrl;
				UNI.login.afterLogin();
			}
			// errors
			else {
			
				UNI.login.loginDialog.hideWait();
				
				if ( command == "login_failed" ) {
					UNI.login.loginDialog.setErrorMessage("Login failed. Please try again.", "");
				}
				else if ( command == "inactive" ) {
					UNI.login.loginDialog.setErrorMessage("This account is not active. Please contact your administrator.", "");
				}
				else {
					UNI.login.loginDialog.setErrorMessage("An unknown error has occured", "");
				}
				
				UNI.login.loginDialog.setLoginButtonEnabled();
			}
		};
		var handleFailure = function(o) {
			UNI.login.loginDialog.hideWait();
			UNI.login.loginDialog.setErrorMessage("Our system is currently not responding. Try again later.", "");
		};
		
		// Instantiate the Dialog
		UNI.login.loginDialog = new YAHOO.widget.Dialog("login-dialog", 
			{ width : "260px",
			  fixedcenter : true,
			  visible : false, 
			  constraintoviewport : true,
			  modal : true,
			  zIndex : 102,
			  postmethod: "form",
			  buttons : [ { text:"Login", handler:handleSubmit, isDefault:true },
						  { text:"Cancel", handler:handleCancel } ]
			} 
		 );
		
		UNI.login.loginDialog.setLoginButtonDisabled = function() {
			var buttons = $$("button[class='default']");
			for ( i=0; i< buttons.length; i++ ) {
				if ( buttons[i].innerHTML == "Login" ) {
					buttons[i].style.display = "none";
				}
			}
		};
		
		
		UNI.login.loginDialog.setLoginButtonEnabled = function() {
			var buttons = $$("button[class='default']");
			for ( i=0; i< buttons.length; i++ ) {
				if ( buttons[i].innerHTML == "Login" ) {
					buttons[i].style.display = "inline";
				}
			}
		};
		
		UNI.login.loginDialog.showWait = function() {
			$("login-content").style.display = "none";
			$("login-wait").style.display = "block";
		}
		
		UNI.login.loginDialog.hideWait = function() {
			$("login-content").style.display = "block";
			$("login-wait").style.display = "none";
		}
		
		// Validate the entries in the form to require that both first and last name are entered
		UNI.login.loginDialog.validate = function() {
			var data = this.getData();
			var errorList = "";
			
			if (data.userName == null || data.userName == "") {
				errorList += "<li>Username is required.</li>";
			} 
			if ( data.password == null || data.password == "" ) {
				errorList += "<li>Password is required.</li>";
			}
			
			if ( errorList != "" ) {
				UNI.login.loginDialog.setErrorMessage("Please check to be sure all fields are filled in.", errorList);
				UNI.login.loginDialog.setLoginButtonEnabled();
				return false;
			}
			
			return true;
		};
	
		UNI.login.loginDialog.setErrorMessage = function(text, list) {
			UNI.login.loginDialog.clearErrorMessage();
			$("login-error-text").innerHTML = text;
			$("login-error-list").innerHTML = list;
			$("login-error-message").style.display = "block";
		};
		
		UNI.login.loginDialog.clearErrorMessage = function() {
			$("login-error-text").innerHTML = "";
			$("login-error-list").innerHTML = "";
			$("login-error-message").style.display = "none";
		};
	
		UNI.login.loginDialog.clearDialog = function() {
			$("userName").value = "";
			$("password").value = "";
			UNI.login.loginDialog.clearErrorMessage();
		};
		
		// Wire up the success and failure handlers
		UNI.login.loginDialog.callback = { success: handleSuccess, failure: handleFailure };
	
		/**
		 * Handles the process of setting up the UI after login
		 */
		UNI.login.afterLogin = function() {
			if ( UNI.navigation.redirectUrl != null ) {
				document.location = UNI.navigation.redirectUrl;
			}
			else {
				document.location.reload();
			}
		}
		
		UNI.login.loginDialog.hideOnSubmit = false;
		
		// Render the Dialog
		UNI.login.loginDialog.render();
	
		// lookup username and password in cookie - must happen after render to work in IE
		var username = Cookie.get("username");
		var password = Cookie.get("password");
		if ( username && $("userName") ) {
			$("saveLoginCheckbox").checked = true;
			$("userName").value = username;
			$("password").value = password;
		}
		
		if ( $("login-dialog") ) {
			$("login-dialog").style.display = "block";
		}
		
		// setup forgot password dialog
		UNI.forgotPassword.init();
		
	}
	
}
/**
 * Logs the user out
 */
UNI.login.logout = function() {
	UNI.ajax.prototypejs.request("/eship/Logout.action", { method:"post", onComplete:UNI.login.logout.after });
}
UNI.login.logout.after = function(o) {
	if( /.*\/index.html/.test(window.location.href) ) {
		window.location.href = "/index.html?refresh=true";
	}
	else {
		window.location.href = "/index.html";
	}
}
UNI.login.saveLogin = function(checked) {
		
	// always remove first
	Cookie.erase("username");
	Cookie.erase("password");
	
	// rest if checked == true
	if ( checked == true ) {
		Cookie.set("username", $F("userName"), 365);
		Cookie.set("password", $F("password"), 365);
	}
	
}

/**
 * Session listener
 */
UNI.session = {}
UNI.session.timer = {}
UNI.session.logoutTimer = null;

UNI.session.timer.start = function() {
	setTimeout("UNI.session.timer.kickoff();",10000); // 10 seconds
}
UNI.session.timer.kickoff = function() {
	
	if ( $("logout-link") != null ) {
		if ( UNI.session.logoutTimer != null ) {
			clearTimeout(UNI.session.logoutTimer);
		}
		setTimeout("UNI.session.timer.notify();",58*60*1000); // 58 minutes
	}
}
UNI.session.timer.notify = function() {
	
	UNI.message.dialog.setWarning("Session Timeout Warning","Your session is about to timeout. Would you like to continue or logout?");
	
	var buttons = [ { text:"Continue", handler:UNI.session.refresh, isDefault:true }, { text:"Logout", handler:UNI.login.logout } ]; 
	UNI.message.dialog.cfg.queueProperty("buttons", buttons);
	UNI.message.dialog.render();
	UNI.message.dialog.show();
	
	clearTimeout(UNI.session.logoutTimer);
	UNI.session.logoutTimer = setTimeout("UNI.login.logout()", 60000);

}

UNI.session.refresh = function() {
	
	clearTimeout(UNI.session.logoutTimer);
	
	var time = new Date().getTime();
	new Ajax.Request("/eship/Ping!refresh.action?d="+time, { // don't use unishippers ajax here. No need to trigger the timer here.
		method: "post",
		onSuccess: UNI.session.refresh.onSuccess,
		onFailure: UNI.session.refresh.onFailure
	});
}

UNI.session.refresh.onSuccess = function(o) {
	
	clearTimeout(UNI.session.logoutTimer);
	
	if ( o.responseText == "OK" ) {
		UNI.message.dialog.cancel();
		UNI.session.timer.start();
	}
	else {
		UNI.session.refresh.onFailure(o);
	}
}

UNI.session.refresh.onFailure = function(o) {
	var buttons = [ { text:"Logout", handler:UNI.login.logout } ]; 
	UNI.message.dialog.cfg.queueProperty("buttons", buttons);
	UNI.message.dialog.render();
	UNI.message.dialog.setError("Could Not Refresh","Could not refresh your session. You will need to login again.");
	UNI.message.dialog.show();
}

/** Forgot Password Dialog 
-----------------------------------------------------------------------------------*/

UNI.forgotPassword = {}

UNI.forgotPassword.showDialog = function() {
	UNI.forgotPassword.dialog.show();
	UNI.forgotPassword.dialog.clearErrorMessage();
	UNI.login.loginDialog.clearDialog();
	UNI.login.loginDialog.hide();
};

UNI.forgotPassword.init = function() {
	
	if ( $("forgot-password-dialog") ) {
	
		// Define various event handlers for Dialog
		var handleSubmit = function() {
			this.submit();
		};
		var handleCancel = function() {
			this.cancel();
		};
		var handleSuccess = function(o) {
			if( o.responseText == 'success' ) {
				UNI.forgotPassword.dialog.clearErrorMessage();
				UNI.message.dialog.show();		
				UNI.message.dialog.setSuccess("Forgot Password", "We have sent you an email with a new password. Please follow the instructions in that message to login.");
			}	
			else {
				UNI.forgotPassword.dialog.show();
				UNI.forgotPassword.dialog.setErrorMessage("Forgot Password", "Username and email do not match.  Please enter them again.");
			}
		};
		var handleFailure = function(o) {
			UNI.forgotPassword.dialog.setErrorMessage("Our system is currently not working. Try again later.");
		};
	
		// Instantiate the Dialog
		UNI.forgotPassword.dialog = new YAHOO.widget.Dialog("forgot-password-dialog",  { 
			width : "260px",
			fixedcenter : true,
			visible : false, 
			constraintoviewport : true,
			modal : true,
			buttons : [ { text:"Send", handler:handleSubmit, isDefault:true },
					  { text:"Cancel", handler:handleCancel } ]
		 });
	
		UNI.forgotPassword.dialog.setErrorMessage = function(text, list) {
			UNI.forgotPassword.dialog.clearErrorMessage();
			$("forgot-password-error-text").innerHTML = text;
			$("forgot-password-error-list").innerHTML = list;
			$("forgot-password-error-message").style.display = "block";
		};
		
		UNI.forgotPassword.dialog.clearErrorMessage = function() {
			$("forgot-password-error-text").innerHTML = "";
			$("forgot-password-error-list").innerHTML = "";
			$("forgot-password-error-message").style.display = "none";
		};
		
		// Validate the entries in the form to require that both first and last name are entered
		UNI.forgotPassword.dialog.validate = function() {
			var data = this.getData();
			var errorList = "";
			
			if (data.username == null || data.username == "") {
				errorList += "<li>Username is required.</li>";
			} 
			if ( data.email == null || data.email== "" ) {
				errorList += "<li>Email is required.</li>";
			}
			
			if ( errorList != "" ) {
				UNI.forgotPassword.dialog.setErrorMessage("Please check to be sure all fields are filled in.", errorList);
				return false;
			}
			
			return true;
		};
	
		UNI.forgotPassword.dialog.clearDialog = function() {
			$("forgotPasswordUsername").value = "";
			$("forgotPasswordEmail").value = "";
			$("forgot-password-error-message").innerHTML = "";
		}
	
		// Wire up the success and failure handlers
		UNI.forgotPassword.dialog.callback = { success: handleSuccess, failure: handleFailure };
	
		
		// Render the Dialog
		UNI.forgotPassword.dialog.render();
	
		// unhide the dialog
		$("forgot-password-dialog").style.display = "block";
		
	}
}

/**
 * UNI.navigation namespace. Use this for navigation.
 */
UNI.navigation = {}

/**
 * The url to use after the login dialog succeeds
 */
UNI.navigation.redirectUrl = null;

/**
 * nav checks to see if the user is logged in before navigating
 * @url - string url
 */
UNI.navigation.nav = function( url ) {

	// force close of the tools menubar
	var tools = $("tools");
	if ( toolbar ) {
		tools.hide();
		tools.show();
	}
	
	if ( UNI.login.isLoggedIn() ) {
		document.location = "/eship/"+url;
	}
	else {
		$("redirectUrl").value = url;
		UNI.login.loginDialog.show();
	}
}


/**
 * UNI.url namespace
 */
UNI.url = {}

/**
 * Ensures the specified url contains https
 * @url - String url must be an absolute url starting with http or https
 */
UNI.url.https = function( url ) {
	
	// default to current location if url is not specified
	url = ( url || document.location.href );
	
	return ( url.indexOf("unishippers.com") > -1 && url.indexOf("https") == -1 ) ? url.replace("http:","https:") : url;
	
}


/** Small Function For Popup Help Dialogs 
-----------------------------------------------------------------------------------*/

function openHelp(helpLink) {
	window.open(helpLink, "", "toolbar=1,location=0,menubar=1,scrollbars=1,resizable=1,height=380,width=500");
}


/** Message functions
----------------------------------------------------------------------------------- */
UNI.message.field = "messages";
UNI.message.clear = function() {
	$(UNI.message.field).innerHTML = "";
};
UNI.message.setField = function(field) {
	UNI.message.field = field;
};
UNI.message.setMessage = function( type, message ) {
	UNI.message.clear();
	$(UNI.message.field).innerHTML = message;
	$(UNI.message.field).className = "uni-alert-" + type;
};
/**
 * type: success, error, warning
 * text: { title:"", messages:["","",""] }
 */
UNI.message.setMessages = function( type, text ) {
	UNI.message.clear();
	var field = UNI.message.field;
	field.innerHTML = "<span>"+text.title+"</span><ul>";
	if ( typeof text.messages != "undefined") {
		for ( i=0; i<text.messages.length; i++ ) {
			field.innerHTML = field.innerHTML + "<li>" + text.messages[i] + "</li>";
		}
	}
	field.innerHTML = field.innerHTML + "</ul>";
	$(field).className = "uni-alert-" + type;
};

/** Ajax Wrappers
----------------------------------------------------------------------------------- */
UNI.ajax = {}
UNI.ajax.prototypejs = {}
UNI.ajax.prototypejs.request = function( url, options ) {
	UNI.session.timer.start();
	return new Ajax.Request( url, options );
}
UNI.ajax.prototypejs.updater = function( elemId, url, options ) {
	UNI.session.timer.start();
	return new Ajax.Updater( elemId, url, options );
}
UNI.ajax.yui = {}
UNI.ajax.yui.connect = function(method, url, callback, parameters ) {
	UNI.session.timer.start();
	return YAHOO.util.Connect.asyncRequest(method, url, callback, parameters);
}

/** Customer Admin
----------------------------------------------------------------------------------- */
UNI.customerAdmin = {};
UNI.customerAdmin.restoreAdmin = function() {
	
	var after = function(o) {
		window.location.href = "/";
	} 
	
	UNI.ajax.prototypejs.request("/eship/RestoreUser.action", { method:"post", onComplete:after } )
	
}


/** Functional view
----------------------------------------------------------------------------------- */
UNI.page = {}
UNI.page.contentPane = {}
UNI.page.contentPane.show = function() {
	if ( $("contentPane") != null ) {
		$("loadingPane").hide();
		$("contentPane").show();
	}
}
UNI.page.contentPane.hide = function() {
	if ( $("contentPane") != null ) {
		$("contentPane").hide();
		$("loadingPane").show();
	}
}

/** Cookie
------------------------------------------------------------------------------------ */
var Cookie = {

    set: function(name, value, daysToExpire) {

        var expire = "";
        var path = "; path=/";

        if (daysToExpire != undefined) {

            var d = new Date();
            d.setTime(d.getTime() + (86400000 * parseFloat(daysToExpire)));
            expire = "; expires=" + d.toGMTString();
        }

        return (document.cookie = escape(name) + "=" + escape(value || "") + expire + path);
    },

    get: function(name) {
        var cookie = document.cookie.match(new RegExp("(^|;)\\s*" + escape(name) + "=([^;\\s]*)"));
        return (cookie ? unescape(cookie[2]) : null);
    },

    erase: function(name) {
        var cookie = Cookie.get(name) || true;
        Cookie.set(name, "", -1);
        return cookie;
    },

    accept: function() {

        if ( typeof navigator.cookieEnabled == "boolean") {
        	return navigator.cookieEnabled;
        }

        Cookie.set("_test", "1");
        return (Cookie.erase("_test") == "1");
    }

};



/** load content
--------------------------------------------------------------------------------- */
YAHOO.util.Event.onContentReady("menu", UNI.onMenuBarReady);
YAHOO.util.Event.onContentReady("tools", UNI.pageLoader);

UNI.Data = {
	upsservicelevels: [
		{id:"1", code:"ND",desc:"UPS Next Day Air\u00AE"},
		{id:"2", code:"ND4",desc:"UPS Next Day Air Saver\u00AE"},
        {id:"3", code:"ND5",desc:"UPS Next Day Air\u00AE Early A.M.\u00AE"},
        {id:"4", code:"SC",desc:"UPS 2nd Day Air\u00AE"},
		{id:"5", code:"SC25",desc:"UPS 2nd Day Air A.M.\u00AE"},
		{id:"6", code:"SC3",desc:"UPS 3 Day Select\u00AE"},
		{id:"7", code:"SG",desc:"UPS Ground"},
		{id:"8", code:"SND",desc:"Saturday - UPS Next Day Air\u00AE"},
		{id:"9", code:"SND5",desc:"Saturday - UPS Next Day Air\u00AE Early A.M.\u00AE"},
        {id:"10", code:"SSC",desc:"Saturday - UPS 2nd Day Air\u00AE"},
		{id:"11", code:"ZZ1",desc:"UPS Worldwide Express\u00AE"},
        {id:"13", code:"ZZ90",desc:"UPS Worldwide Saver\u00AE"},
		{id:"12", code:"ZZ2",desc:"UPS Worldwide Expedited\u00AE"},
		{id:"14", code:"ZZ11",desc:"UPS Standard"}
	]
};