// JavaScript Document

function parseURL() {
        var urlParts = new Object();
        // extract the domain name
		urlParts['fullURL'] = document.URL;
        urlParts['domain'] = document.URL.substr(0, document.URL.indexOf('/',7));
        // extract the path and file name
        urlParts['pathFile'] = document.URL.substr(document.URL.indexOf('/',7));

        // Handle any '#' or '?' in the pathPlus. They have to be removed for the on-state detection to work.
        if (urlParts['pathFile'].indexOf('#') != -1) { // Strip off any anchor and store it in the object.
                var pathPlusSplit = urlParts['pathFile'].split('#');
                urlParts['pathFile'] = pathPlusSplit[0];
                urlParts['anchor'] = pathPlusSplit[1];
        } else if (urlParts['pathFile'].indexOf('?') != -1) { // Strip off any arguments and discard, argument parsing will be handled by the getArgs function
                var pathPlusSplit = urlParts['pathFile'].split('?');
                urlParts['pathFile'] = pathPlusSplit[0];
        }

        //alert(url);
        // Extract the first directory of the URL
        // This is used to activate the main button on states
        // Extract everthing up to but not including the 2nd '/'
		var pathParts = urlParts['pathFile'].split('/');
		urlParts['mainDir'] = pathParts[1];
		urlParts['pathParts'] = pathParts;
        return urlParts;
}

function printerFriendly() {
	var domain = document.URL.substr(0, document.URL.indexOf('/',7));
	var printURL = domain + "/network/print/index.asp";
	genPopUp = window.open(printURL,"printer","toolbar=no,location=no,scrollbars=yes,directories=no,status=yes,menubar=yes,resizable=yes,width=760,height=600");
	if (genPopUp.opener == null) genPopUp.opener = window;
	genPopUp.opener.name = "opener";
}

function submitenter(myfield,e) {
	var keycode;
	if (window.event) {
		keycode = window.event.keyCode;
	} else if (e) {
		keycode = e.which;
	} else {
		return true;
	}

	if (keycode == 13) {
		myfield.form.submit();
		return false;
	} else {
   		return true;
	}
}


function randomRange(minNum,maxNum) {
	var randomnumber=Math.floor(Math.random() * (maxNum - 1 + minNum)) + minNum;
	return randomnumber;
}
