function getEnvInfo() {
	var str = '';
	
	if (navigator.appName == "Microsoft Internet Explorer") {
		str += 'userAgent=' + navigator.userAgent+';';
		str += 'appName=' + navigator.appName+';';
		str += 'appVersion=' + navigator.appVersion+';';
		str += 'appMinorVersion=' + navigator.appMinorVersion+';';
		str += 'platform=' + navigator.platform+';';
		str += 'cookieEnabled=' + navigator.cookieEnabled+';';
		str += 'javaEnabled=' + navigator.javaEnabled()+';';
	}
	else if (navigator.userAgent.indexOf("Mozilla/4.0") != -1 ||
		navigator.userAgent.indexOf("Mozilla/4.7") != -1 ) {		
		str += 'userAgent=' + navigator.userAgent+';';
		str += 'appName=' + navigator.appName+';';
		str += 'appVersion=' + navigator.appVersion+';';
		//str += 'envInfo=' + 'appName=' + URLEncode(navigator.appName+'4.0x-4.7x');
		str += 'platform=' + navigator.platform+';'
	}
	else {		
		str += 'userAgent=' + navigator.userAgent+';';
		str += 'appName=' + navigator.appName+';';
		str += 'appVersion=' + navigator.appVersion+';';
		str += 'platform=' + navigator.platform+';';
		str += 'cookieEnabled=' + navigator.cookieEnabled+';';
	}
	

	
	colors = window.screen.colorDepth;
	str += 'color depth:' + Math.pow (2, colors);
	str += 'anti-aliasintg fonts:' + (window.screen.fontSmoothingEnabled == true) + ';';
	
	str += 'screen width: ' + window.screen.width+';';
	str += 'screen height: ' + window.screen.height+';';
	str += 'max screen width: ' + window.screen.availWidth+';';
	str += 'max screen height: ' + window.screen.availHeight+';';		
	return str;
}

function URLEncode(str) {
	str = str+'';
	str = str.replace(/\s/g, '%20');
		
	return str;
}

function URLUnEncode(str) {
	str = str+'';
	str = str.replace(/\+/g, ' ');
	
	return str;
}

function HTMLEncode(str) {
	str = str+'';
	str = str.replace(/</g, '&lt;');
	str = str.replace(/>/g, '&gt;');
	str = str.replace(/"/g, '&quot;');
	str = str.replace(/\\/g, '&apos;');
	str = str.replace(/&/g, '&amp;');
	str = str.replace(/\s/g, '&nbsp;');
	return str;
}

function HTMLUnEncode(str) {
	str = str+'';
	str = str.replace(/&lt;/g, '<');
	str = str.replace(/&gt;/g, '>');
	str = str.replace(/&quot;/g, '"');
	str = str.replace(/&apos;/g, '\'');
	str = str.replace(/&amp;/g, '&');
	str = str.replace(/&nbsp;/g, ' ');
	
	return str;
}

function FileNameEncode(str) {
	str = str + '';
	str = str.replace(/\s/g, '_');
	str = str.replace(/:/g, '-');
	str = str.replace(/\\/g, '-');
	str = str.replace(/\//g, '-');
	str = str.replace(/<>"\|/g, ' ');
	return str;
}
// force myself to get out of frameset
function backtoTopFrame() {
	if (self != top) {
	    if (document.images)
	        top.location.replace(window.location.href);
	    else
	        top.location.href = window.location.href;
	}
}

function wait(delay) {
	string = "pauseforalert("+delay+");";
	setTimeout(string,delay);
}

function pauseforalert(delay) {	
	//alert("Ok "+delay/1000+" seconds have elapsed");
}

function stringFilter(input) {
	s = input.value;
	filteredValues = "1234567890";     // Characters stripped out
	var i;
	var returnString = "";
	for (i = 0; i < s.length; i++) {  // Search through string and append to unfiltered values to returnString.
	var c = s.charAt(i);
	if (filteredValues.indexOf(c) == -1) returnString += c;
	}
	input.value = returnString;
}

function findTag(eItem) {
	var objATag = new Object();
	objATag = eItem.all.tags("A").item(0)
	return objATag;
}

function isWebTV() {
	if ( (navigator.appName.indexOf ( "WebTV" ) != -1 ) ) {	// WebTV
		return true;
	} else {
		return false;
	}
}

function isMSIE () {
	if ( (navigator.appVersion.indexOf ("MSIE") != -1) ) {
		return true;
	} else {
		return false;
	}
}

function isMacintosh () {
	if ( (navigator.appVersion.indexOf ("Macintosh") != -1) ) {
		return true;
	} else {
		return false;
	}
}

function isBrowserVersion(versionString) {	// versionString = 3.01
	return ( navigator.userAgent.indexOf (versionString) != -1);
}

function getTimeStampString() {
        n = new Date();
        var nhour = n.getHours();
        var str = "";
        var ampm = "AM";
        if ( nhour >= 12 ) {
                ampm = "PM";
                if ( nhour>12) nhour -= 12;
        }

        dnum = n.getMonth()+1;
        if ( dnum < 10 ) { str += "0"; }
        str += dnum.toString() + "/";

        dnum = n.getDate();
        if ( dnum < 10 ) { str += "0"; }
        str += dnum.toString() + "/";

        str += n.getFullYear().toString() + " ";

        if ( nhour < 10 ) { str += "0"; }
        str += nhour.toString() + ":";

        dnum = n.getMinutes();
        if ( dnum < 10 ) { str += "0"; }
        str += dnum.toString() + ":";

        dnum = n.getSeconds();
        if ( dnum < 10 ) { str += "0"; }
        str += dnum.toString();

        str += " " + ampm;
        return (str);
}

var timeoutMsg="As a security measure, you are timed out after 10 minutes of inactivity.\* <BR>The browser has detected 8 minutes of inactivity and you will have 2 minutes to<BR>Click \"OK\" to continue with your current session before you time out.<BR>";
var timeoutMsg2="As a security measure, you are timed out after 10 minutes of inactivity.\nClick on OK to go to the time-out screen from where you may sign back in";
var timeoutMsg99="\*Please note: when you are composing an email or <BR> feedback the browser cannot detect this as activity";

var timerNotResetFlag=true;
var resetTimeoutURL="";
var timeoutURL="";

function setGoToTimeout() {
	xtimerID = window.setTimeout ("goToTimeout()", timeout2Value+timeout3Value );
}

function clearGoToTimeout() {
	clearTimeout(xtimerID);
 	timerID=window.setTimeout ("displayAlert(saveBaseURL)",timeOutMilliseconds);	// let the cycle start over again..
	return true;
}


function getTimeout2Value () {
	return timeout2Value;
}

function goToTimeout() {
	var timeoutString = 'Timeout Notice at ' + getTimeStampString() + '\n\n';
	timeoutString += timeoutMsg2;
	timeoutString += ' \n';
        alert (timeoutString);
	self.status ="Redirect now...";
        self.location = timeoutURL;
	return;
}
function splitIt(myString,delimiter){
	var retArray = new Array();
	var pos = myString.indexOf(delimiter);

	if(pos == -1)
	{
	retArray[0] = myString;

	return retArray;
	}
	else {
	var arrPos = 0;

	var remStr = myString;
	var remStr1 = myString;


	while(true){//(remStr.indexOf(delimiter) > 0){
	retArray[arrPos]= remStr.substring(0,pos);

	remStr = remStr.substring(pos+1);

	pos = remStr.indexOf(delimiter);
	arrPos++;
	if(pos == -1)
	 break;
	}
	retArray[arrPos] = remStr;
	return retArray;
	}
}
function isReturn(c) {
  var test = "" + c;
  if (test == "\n" || test == "\r") { return true; }
  return false;
}

function removeCR(s) {
  var test = "" + s;
  var new_s = "";
  for (var k = 0; k < test.length; k++) {
    var c = test.substring(k, k+1);
    if (isReturn(c) == false) { new_s = new_s + c; } 
    else { new_s = new_s + " "; }
  }
  return new_s;
}
function stripHtmlTags(inputString) {
	var i,j,k;
	var t = new String(inputString);
	k = t.length;
	for (i=0; i<k; i++ ) {	// WebTV won't allow regular expression, so here we go..
		if ( t.charAt(i) == "<" ) {
			var part1 = t.substring(0,i);
			for (j=i; j<k; j++ ) {
		        if (t.charAt(j) == ">") {
					var ptag = t.substring(i,j);
					var part2 = t.substring(j+1,t.length);
					
					if ( ptag.toLowerCase().indexOf("br") != -1) {
						ptag="\n";
		            } else if ( ptag.toLowerCase().indexOf("p") != -1) {
						ptag="\n";
		            } else  ptag="";
		            
		            t = part1 + ptag + part2;
		            k -= ptag.length;
		            i--;
		            break;
		        }
		    }
		}
	}
	return t;
}

function trim(hasSpaceString) {
	while(hasSpaceString.charAt(0) == " ") {
		hasSpaceString = hasSpaceString.substring(1,(hasSpaceString.length));
	}
	while(hasSpaceString.charAt(hasSpaceString.length -1) == " ") {
		hasSpaceString = hasSpaceString.substring(0,(hasSpaceString.length -2));
	}
	return hasSpaceString;
}

function firstDigit(digit, error) {
	var first = digit 
	if(first.charAt(0)!='4' && first.charAt(0)!='5'
		&& first.charAt(0)!='2' && first.charAt(0)!='3') {
		errorMsg = errorMsg + "<li>" + error + "<p>\n\n";
		erMsg2 = erMsg2 + error + "\n";
		errorstatus = 1;
		
		return false;
	}
	return true;
}

function killWin () {
	if (openWin == 1) {
	if ( (new_win!=null) && (new_win.close!=null) )
		new_win.close();
	}
	
	new_win=""; 	//new_win = null;
	openWin = 0;
}

function errorMessage(num,err) {
	this.number = num;
	this.message = err;
}

function getLastDayOfMonth(iMonth, iYear) {
	var result = 0;
	switch(iMonth) {
	case 0: case 2: case 4: case 6: case 7: case 9: case 11:
		result = 31;
		break;
	case 3: case 5: case 8: case 10:
		result = 30;
		break;
	case 1:
		if (iYear%4==0) result = 29;
		else result = 28;
	}
	return result;
}

function getLastDay(objForm, selectIndex) {
	var thisDate = new Date(objForm.startyr.options[objForm.startyr.selectedIndex].text, objForm.startmo.options[objForm.startmo.selectedIndex].value, 1);
	var thisMonth = thisDate.getMonth();
	var thisYear = thisDate.getYear();
	var lastDayOfMonth = getLastDayOfMonth(thisMonth, thisYear);
	// clear up old options
	for (var i=0; i<objForm.startdate.length; i++) {
		objForm.startdate.options[0] = null;
	}
	// repopulate days of this month
	for (var i=0;i<lastDayOfMonth;i++) {
		objForm.startdate.options[i] = new Option(i+1);
		if (i==26) objForm.startdate.options[i].selected = true;
	}
}

/*
 * This function parses comma-separated name=value argument pairs from
 * the query string of the URL. It stores the name=value pairs in 
 * properties of an object and returns that object.
 */
function getArgs() {
    var args = new Object();
    var query = location.search.substring(1);  // Get query string.
    var pairs = query.split(",");              // Break at comma.
    for(var i = 0; i < pairs.length; i++) {
		var pos = pairs[i].indexOf('=');       // Look for "name=value".
		if (pos == -1) continue;               // If not found, skip.
		var argname = pairs[i].substring(0,pos);  // Extract the name.
		var value = pairs[i].substring(pos+1); // Extract the value.
		args[argname] = unescape(value);          // Store as a property.
    }
    
    return args;                               // Return the object.
}

function isEmpty(str)	{
	var b = false;
		
	strTemp = new String(str);	
	if (strTemp == null) {
		b = true;
	}
	else {
		if (strTemp == 'undefined' || strTemp=='null'|| strTemp.length == 0) b = true;
	}	
	
	return b;
}