<!-- // Hide script from old browsers

//---------------------------------------------------------------------------------
//  AUTHOR: Scott Piegdon
//  DATE: 6/19/2000
//  PURPOSE:
//    This javascript provides generic regular expression pattern validation codes
//    that can be used to quickly and easily do form validation on the client.
//---------------------------------------------------------------------------------


function alphafirst(str)
{
	var re = new RegExp("([A-Za-z].*)");
	return (re.exec(str)!=null && RegExp.$1==str);
}
function digitfirst(str)
{
	var re = new RegExp("([0-9].*)");
	return (re.exec(str)!=null && RegExp.$1==str);
}
function onlydigitsandcharshandle(str)
{
	var re = new RegExp("([A-Za-z0-9 ]+)");
	return (re.exec(str)!=null && RegExp.$1==str);
}
function onlydigitsandchars(str)
{
	var re = new RegExp("([A-Za-z0-9]+)");
	return (re.exec(str)!=null && RegExp.$1==str);
}
function onlyemailchars(str)
{
	var re = new RegExp("([\.A-Za-z0-9_\-]+@[\.A-Za-z0-9_\-]+\.[A-Za-z0-9_\-]$)");
	return (re.exec(str)!=null && RegExp.$1==str);
}
function onlydigits(str)
{
	var re = new RegExp("([0-9 ]+)");
	return (re.exec(str)!=null && RegExp.$1==str);
}
function checkpassword(fld1,fld2)
{
	var val = fld1.value;
	msg = "";
	
	if (!onlydigitsandchars(val))
	{
		msg += "Passwords must contain only letters and digits.\n";
	}
	if (fld1.value != fld2.value)
	{
		msg += "Passwords don't match.\n";
	}
	if (val.length < 6)
	{
		msg += "Passwords must be at least 6 characters long.\n";
	}
	reA = new RegExp("[A-Za-z]");
	if (val.search(reA)==-1)
	{
		msg += "Passwords must contain at least one letter (A-Z).\n";
	}
	reD = new RegExp("[0-9]");
	if (val.search(reD)==-1)
	{
		msg += "Passwords must contain at least one digit (0-9).\n";
	}
	
	if (msg.length > 0) {
		alert(msg);
		return false;
	} else {
		return true;
	}
}    
function checkemailchange(fld1,fld2)
{
	var val = fld1.value;
	msg = "";
	
	if (fld1.value != fld2.value)
	{
		msg += "Emails don't match.\n";
	}
	
	if (msg.length > 0) {
		alert(msg);
		return false;
	} else {
		return true;
	}
}          
function checkemail(fld1)
{
	var val = fld1.value;
	if (val.length==0)
	{
		alert("Email address cannot be blank");
		return false;
	}
	if (!onlyemailchars(val))
	{
		alert("Enter a valid email address.");
		return false;
	}
	return true;
}       
function checkusername(fld1)
{
	var val = fld1.value;
	if (!onlydigitsandcharshandle(val))
	{
		alert("Handles must contain only letters, digits and spaces.");
		return false;
	}
	if (val.length < 4)
	{
		alert("Handles must be at least 4 characters long.");
		return false;
	}
	if (val.length > 15)
	{
		alert("Handles cannot be longer than 15 characters.");
		return false;
	}
	if (!alphafirst(val))
	{
		alert("Handles must begin with a letter.");
		return false;
	}
	return true;
}     
function checkccnumber(fld1,fld2)
{
	var val = fld1.value;
	var re = / /gi;
	val = val.replace(re,'');
	re = /-/gi;
	val = val.replace(re,'');
	if (val.length<15 || val.length>16)
	{
		alert("Credit card numbers must contain 15 or 16 digits.");
		return false;
	}
	if (!onlydigits(val))
	{
		alert("Credit card numbers must contain only digits.");
		return false;
	}
	fld2.value = val;
	return true;
}       
function isempty(fld1)
{
	var val = fld1.value;
	re = / /gi;
	val = val.replace(re,'');
	return (val.length == 0)
}
function checknotempty(fld1,nam)
{
	if (isempty(fld1))
	{
		alert(nam + " must be entered");
		return false;
	}
	return true;
}
function checkreferralnumber(fld1,nam)
{
	var val = fld1.value;
	if (!onlydigitsandspaces(val))
	{
		alert(nam + " must contain only digits.");
		return false;
	}
	return true;
}
function checkisnumber(fld1,nam)
{
	var val = fld1.value;
	if (!onlydigits(val))
	{
		alert(nam + " must contain only digits.");
		return false;
	}
	return true;
}
function checkisICQ(fld1,nam)
{
	var val = fld1.value;
	if (!onlydigits(val))
	{
		alert(nam + " must contain only digits.");
		return false;
	}
	return true;
}
function dollars_string(amount)
{
	var temp = amount;
	DigitStrings = new Array('zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine');
	TeenStrings = new Array('ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eightteen', 'nineteen');
	DecadeStrings = new Array('zero', 'ten', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety');
	result = '';
	if (temp >= 1000)
	{
		result = result + dollars_string(Math.floor(temp/1000)) + 'thousand ';
		temp = temp % 1000;
	}
	if (temp >= 100)
	{
		result = result + DigitStrings[Math.floor(temp/100)] + ' hundred ';
		temp = temp % 100;
	}
	if (temp >= 20)
	{
		result = result + DecadeStrings[Math.floor(temp/10)] + ' ';
		temp = temp % 10;
	}
	if (temp >= 10)
	{
		result = result + TeenStrings[Math.floor(temp-10)] + ' ';
		temp = temp - Math.floor(temp);
	}
	else if ((amount == 0) || (temp > 0))
	{
		result = result + DigitStrings[Math.floor(temp)] + ' ';
		temp = temp - Math.floor(temp);
	}
	return result;
}	
function amount_string(amount)
{
	var cents = Math.floor((amount-Math.floor(amount))*100+0.5);
	var centstring = (cents < 10) ? "0"+cents.toString() : cents.toString();
	var dollarstring = dollars_string(Math.floor(amount));
	return dollarstring.charAt(0).toUpperCase() + dollarstring.substr(1) + 'and ' + centstring + '/100';
}
function format_currency(a)
{
	if (isNaN(parseFloat(a)))
		return "";
	var s=(a<0);
	if (s) a=-a;
	var d=Math.floor(a);
	var c=Math.floor((a-d)*100+0.5);
	if (c==100) {d++;c=0;}
	var cs=(c < 10)?"0"+c.toString():c.toString();
	return (s?"-":"")+d.toString()+"."+cs;
}
function validate_field(field, type, autoplace)
{
	if (field.value.length == 0)
	{
		window.isvalid = true;
		return true;
	}
	if (type == "currency")
	{
		var val = field.value.replace(/\$/g,"");
		val = val.replace(/,/g,"");
		if (val.charAt(0) == '=')
		{
/*			try {val = eval(val.substr(1)); }
			catch (e) {val = "error";} */
			val = eval(val.substr(1));
			autoplace = false;
		}
		else if (val.substr(1).search(/[\+\-\*\/]/g) != -1)
		{
/*			try {val = eval(val); }
			catch (e) {val = "error";} */
			val = eval(val);
			autoplace = false;
		}
		numval = parseFloat(val);
		if (isNaN(numval) || Math.abs(numval)>1.0e+10)
		{
			alert("Invalid currency value. Values must be numbers up to 9,999,999,999.99");
			window.isvalid = false;
		}
		else
		{
			if (autoplace && val.indexOf(".") == -1) numval/=100;
			field.value=format_currency(numval.toString());
			window.isvalid = true;
		}
	}
	else if (type == "date")
	{
		var month;
		var day;
		var year;
		
		if (field.value.indexOf("/") == -1)
		{
			var l = field.value.length;
			month = parseInt(field.value.substr(0,2-l%2),10);
			day = parseInt(field.value.substr(2-l%2,2),10);
			year = parseInt(field.value.substr(4-l%2),10);
		}
		else
		{	
			var comps = field.value.split("/");
			month = parseInt(comps[0],10);
			day = parseInt(comps[1],10);
			year = parseInt(comps[2],10);
		}
		if (month >= 1 && month <= 12 && day >= 1 && day <=31 && ((year >= 0 && year < 100) || (year > 1900 && year <2100)))
		{
			if (year < 50)
				year += 2000;
			else if (year < 100)
				year += 1900;
			field.value = getdatestring(new Date(year, month-1, day));
			window.isvalid = true;
		}
		else
		{
			alert("Invalid date value (must be MM/DD/YY, MM/DD/YYYY, MMDDYY or MMDDYYYY)");
			window.isvalid = false;
		}
	}	
	else if (type == "numberorpct")
	{
		var numval;
		var minclip=-10000000;
		var maxclip=10000000;
		
		var val = field.value;
		val = val.replace(/,/g,"");
		var pctidx = val.lastIndexOf("%");
		if (pctidx!=-1)
			val = val.substr(0,pctidx);
		
		numval = parseFloat(val);
		if (isNaN(numval) || numval >= maxclip || numval <= minclip)
		{
			alert("Invalid number or percentage");
			window.isvalid = false;
		}
		else
		{
			if (pctidx!=-1)
				numval += "%";
			field.value = numval;
			window.isvalid = true;
		}
	}
	else if (type == "integer" || type == "posinteger" || type == "float" || type == "posfloat")
	{
		var numval;
		var minclip=-10000000;
		var maxclip=10000000;
		var val = field.value;
		val = val.replace(/,/g,"");
		if (type == "integer")
			numval = parseInt(val,10);
		else if (type == "posinteger")
		{
			numval = parseInt(val,10);
			minclip=0;
		}
		else if (type == "posfloat")
		{
			numval = parseFloat(val);
			minclip=0;
		}
		else
			numval = parseFloat(val);
		if (isNaN(numval) || numval >= maxclip || numval <= minclip)
		{
			if (type=="posinteger" || type=="posfloat")
				alert("Invalid number (must be positive and less than 10,000,000)");
			else
				alert("Invalid number (must be less than 10,000,000)");
			window.isvalid = false;
		}
		else
		{
			field.value = numval;
			window.isvalid = true;
		}
	}
	else if (type == "address")
	{
		var err = '';
		if (field.value.length>999)
		{
			err = "Address too long (truncated at 1000 characters)";
			newval = field.value.substr(0,999);
		}
		if (err != '')
		{
			alert(err);
			field.value = newval;
		}
	}
	else if (type == "time")
	{
		var hours;
		var minutes;
		var year;
		
		var re = /([0-9][0-9]?)?(:[0-5][0-9])?/
		var result = re.exec(field.value)
		if (result==null || result.index > 0 || result[0].length != field.value.length)
		{
			timeval = parseFloat(field.value);
			if (isNaN(timeval))			
				hours = -1;
			else
			{
				hours = Math.floor(timeval);
				minutes = Math.floor((timeval-hours)*60+0.5);
			}
		}
		else
		{
			if (RegExp.$1.length > 0)
				hours = parseInt(RegExp.$1,10);
			else
				hours = 0;
			if (typeof(RegExp.$2) != "undefined" && RegExp.$2.length > 0)
				minutes = parseInt(RegExp.$2.substr(1),10);
			else
				minutes = 0;
		}
		if (hours >= 0 && minutes >= 0 && minutes < 60)
		{
			field.value = hours + ":" + (minutes < 10 ? "0" : "") + minutes;
			window.isvalid = true;
		}
		else
		{
			alert("Invalid time value (must be HH:MI)");
			window.isvalid = false;
		}
	}
	else if (type == "visiblepassword") 
	{
		if (checkpassword(field, field))
			window.isvalid = true;
		else
			window.isvalid = false;
	}
	else if (type == "email") 
	{
		if (checkemail(field, true, true))
			window.isvalid = true;
		else
			window.isvalid = false;
	}
	if (!window.isvalid)
	{
		field.focus();
		field.select();
	}
	return window.isvalid;
}

function nlGetFullYear(d)
{
	if (navigator.appName == "Netscape")
	{
		if (d.getFullYear=="undefined")
			return d.getYear();
	}
	return d.getFullYear();
}
function nlSetFullYear(d,val)
{
	if (navigator.appName == "Netscape")
	{
		if (d.setFullYear=="undefined")
			d.setYear(val);
	}
	d.setFullYear(val);
}
// Scripts currently used by bsfooter.jsp and pandlfooter.jsp to
//  do some specific date calculations
function getdatestring(d)
{
	return (d.getMonth()+1)+"/"+d.getDate()+"/"+nlGetFullYear(d);
}
function stringtodate(s)
{
	var comps = s.split("/");
	var month = parseInt(comps[0],10)-1;
	var day = parseInt(comps[1],10);
	var year = parseInt(comps[2],10);
	var d = new Date(year, month,day);
	if (year < 50)
		nlSetFullYear(d, year+2000);
	else if (year < 100)
		nlSetFullYear(d, year+1900);
	return d;	
}
function adddays(d, daystoadd)
{
	//var newtime = new Date(oldtime.getTime() + 86400 * daystoadd * 1000);
	d.setTime(d.getTime() + 86400 * daystoadd * 1000);
	return d;
}
function addmonths(d, mtoadd)
{
	var curmonth = d.getMonth()+mtoadd;
	while (curmonth < 0)
	{
		curmonth += 12;
		nlSetFullYear(d, nlGetFullYear(d)-1);
	}
	while (curmonth > 11)
	{
		curmonth -= 12;
		nlSetFullYear(d,nlGetFullYear(d)+1);
	}
	d.setMonth(curmonth);
	return d;
}
function modifydate(d, val)
{
	timenow = d;

	// Parse value field into four strings. Each string corresponds
	//  to a different date element:
	//  0th num  - day
	//  1st num  - month
	//  2nd num  - year
	//  3rd char - quarter (0,1,2 (for start month mod 3) or N)
	//  4th char - subtract 1 day (Y or N)
	//  5th char - proceed to end of week (E) beginning of week (W) or do nothing (-)
	// Then take the current date and act on it according to the following rule:
	//  "-"      : use the current date element (ie leave it alone)
	//  "+<num>" : add to the current date element 
	//  "-<num>" : subtract from the current date element
	//  "<num>"  : set the current date element
	// The idea behind the 5th param (#4) is that it is easy to calculate 
	//  the day after some time values very easily (like next fiscal quarter).
	//  So this flag tells you whether you need to subtract one day after 
	//  doing the calculation using the first 4 fields.
	var v = val.split(",");
	var num = 0;
	for (var i=0; i<3; i++)
	{
		if (v[i] == "-")
		{
			continue;
		}
		else if (v[i].charAt(0) == "-" || v[i].charAt(0) == "+")
		{
			num = parseInt(v[i],10);
			if (i==0) // days
				adddays(timenow, num);
			else if (i==1)
				addmonths(timenow, num);
			else if (i==2)
				nlSetFullYear(timenow,nlGetFullYear(timenow)+num);
		}
		else
		{
			num = parseInt(v[i],10);
			if (i==0)
				timenow.setDate(num);
			else if (i==1)
				timenow.setMonth(num);
			else if (i==2)
				nlSetFullYear(timenow,num);
		}
	}
	if (v[3] == "0"||v[3] == "1"||v[3] == "2")
	{
		var qstart = parseInt(v[3],10);
		num = timenow.getMonth();
		addmonths(timenow, 0-((num-qstart+3)%3));
	}
	if (v[4] == "Y")
	{
		adddays(timenow,-1);
	}
	if (v[5] == "E")
	{
		// Proceed to end of week. So add anywhere from 0 to
		//  6 days to get there. 
		num = timenow.getDay(); // 0 -sun, 1-mon, etc
		adddays(timenow, (6-num));
	}
	else if (v[5] == "B")
	{
		// Proceed to begining of week. So subtract anywhere from 0 to
		//  6 days to get there. 
		num = timenow.getDay(); // 0 -sun, 1-mon, etc
		adddays(timenow, (0-num));
	}
	return (getdatestring(timenow));
}
// nlutil_getmodifieddate
//   type  : how to modify the date ("TW (this week), LWTD (last week to date),etc)
//   which : 1 = start of period, 2 = end of period.
function nlutil_getmodifieddate(type,which,fm)
{
	var curdate = new Date();
	if (type=="ALL")
		return "";

	timenow = new Date();
	if (type=="TODAY")
		modifier =  (which==1 ? "-,-,-,N,N,-" : "-,-,-,N,N,-");
	else if (type=="TMTD")
		modifier =  (which==1 ? "1,-,-,N,N,-" : "-,-,-,N,N,-");
	else if (type=="OY")
		modifier =  (which==1 ? "+1,-,-1,N,N,-" : "-,-,-,N,N,-");
	else if (type=="YESTERDAY")
		modifier =  (which==1 ? "-1,-,-,N,N,-" : "-1,-,-,N,N,-");
	else if (type=="OW")
		modifier =  (which==1 ? "-6,-,-,N,N,-" : "-,-,-,N,N,-");
	else if (type=="TW")
		modifier =  (which==1 ? "-,-,-,N,N,B" : "-,-,-,N,N,E");
	else if (type=="LW")
		modifier =  (which==1 ? "-7,-,-,N,N,B" : "-7,-,-,N,N,E");
	else if (type=="LWTD")
		modifier =  (which==1 ? "-7,-,-,N,N,B" : "-7,-,-,N,N,-");
	else if (type=="TWTD")
		modifier =  (which==1 ? "-,-,-,N,N,B" : "-,-,-,N,N,-");
	else if (type=="TM")
		modifier =  (which==1 ? "1,-,-,N,N,-" : "1,+1,-,N,Y,-");
	else if (type=="OM")
		modifier =  (which==1 ? "+1,-1,-,N,N,-" : "-,-,-,N,N,-");
	else if (type=="LM")
		modifier =  (which==1 ? "1,-1,-,N,N,-" : "1,-,-,N,Y,-");
	else if (type=="LMTD")
		modifier =  (which==1 ? "1,-1,-,N,N,-" : "-,-1,-,N,N,-");
	else if (type=="NW")
		modifier =  (which==1 ? "+7,-,-,N,N,B" : "+7,-,-,N,N,E");
	else if (type=="N4W")
		modifier =  (which==1 ? "-,-,-,N,N,B" : "+22,-,-,N,N,E");
	else if (type=="NM")
		modifier =  (which==1 ? "1,+1,-,N,N,-" : "1,+2,-,N,Y,-");
	else if (type=="CUSTOM")
		modifier =  (which==1 ? "-,-,-,-,N,-" : "-,-,-,-,N,-");
	else if (type=="")
		modifier =  (which==1 ? "" : "");
	else if (type.search("FY")!=-1)
	{
		var curmonth = curdate.getMonth();
		var yearmod = (curmonth<fm) ? -1 : 0;
		var endmodifier;
		if (which==1)
		{
			modifier = "1,"+fm+",";
			endmodifier = "N,N,-";
			if (type=="LFYTD" || type=="LFY")
				yearmod +=  -1;
			else if (type=="TFYTD" || type=="TFY")
				yearmod += 0;
			else if (type=="NFY")
				yearmod +=  1;
		}
		else
		{
			if (type=="LFYTD" || type=="TFYTD")
			{
				modifier = "-,-,";
				endmodifier = "N,N,-";
			}
			else
			{
				modifier = "1,"+fm+",";
				endmodifier = "N,Y,-";
			}
			if (type=="TFYTD")
				yearmod =  0; // !! This is always 0 not +=0 !!
			else if (type=="LFY")
				yearmod +=  0; 
			else if (type=="LFYTD")
				yearmod += -1;
			else if (type=="TFY")
				yearmod += 1;
			else if (type=="NFY")
				yearmod +=  2;
		}	

		if (yearmod < 0)
			modifier += yearmod+",";
		else if (yearmod == 0)
			modifier += "-,";
		else if (yearmod > 0)
			modifier += "+"+yearmod+",";

		modifier += endmodifier;
	}
	else if (type.search("FQ")!=-1)
	{
		var curmonth = curdate.getMonth();
		var monthmod=0;
		var endmodifier;
		if (which==1)
		{
			modifier = "1,";
			endmodifier = "-,"+(fm%3)+",N,-";
			if (type=="LFQTD" || type=="LFQ")
				monthmod +=  -3;
			else if (type=="TFQTD")
				monthmod += 0;
			else if (type=="TFQ")
				monthmod += 0;
			else if (type=="NFQ")
				monthmod += 3;
		}
		else
		{
			if (type=="LFQTD" || type=="TFQTD")
			{
				modifier = "-,";
				endmodifier = "-,N,N,-";
			}
			else
			{
				modifier = "1,";
				endmodifier = "-,"+(fm%3)+",Y,-";
			}
			if (type=="TFQTD" || type=="LFQ")
				monthmod =  0; // !! This is always 0 not +=0 !!
			else if (type=="LFQTD")
				monthmod += -3;
			else if (type=="TFQ")
				monthmod += 3;
			else if (type=="NFQ")
				monthmod +=  6;
		}	

		if (monthmod < 0)
			modifier += monthmod+",";
		else if (monthmod == 0)
			modifier += "-,";
		else if (monthmod > 0)
			modifier += "+"+monthmod+",";

		modifier += endmodifier;
	}
	else 
		return "";
	return modifydate(curdate, modifier);
}

function nlPopupHelp(db,s,g,p,usertype) {

	var dest;
	if (usertype == "Employee") {
		dest = "/pages/support/help/text/employee.html";
	} else if (usertype == "CustJob") {
		dest = "/pages/support/help/text/visitor.html";
	} else {
		var str = 'section='+s+'&group='+g;
		if (p!=null)
			str += '&perm='+p;
		str += '&db='+db+'&usertype='+usertype;
		dest = '/pages/support/help/helpframe.jsp?'+str;
	}
	window.open(dest,'popuphelp','scrollbars=yes,width=400,height=400');
}
function DoFieldFocus(form)
{
	var i;
	for (i=0;i<form.elements.length;i++)
	{
		var el = form.elements[i];
		if (el.type == "text" || el.type == "select-one" || el.type == "checkbox")
		{
			el.focus();
			return;
		}
	}
}
function synclist(list,val,makedefault)
{
	var i;
	for (i=0; i < list.length; i++)
		if (list.options[i].value == val)
		{
			list.selectedIndex=i
			if (makedefault == true)
				list.options[i].defaultSelected = true;			
			break;
		}
}
function getlisttext(list, val)
{
	var i;
	for (i=0; i < list.length; i++)
		if (list.options[i].value == val)
			return list.options[i].text
	return "";
}
function getSelectValue(sel)
{
	return sel.options[sel.selectedIndex].value;
}
function resetlist(list)
{
	var i;
	for (i=0; i < list.length; i++)
		if (list.options[i].defaultSelected)
		{
			list.selectedIndex=i
			break;
		}
}
function getEncodedValue(machine_name, linenum, fieldname)
{
	var linearray = document.forms[0].elements[machine_name+'data'].value.split(String.fromCharCode(2));
	var linedata = linearray[linenum-1].split(String.fromCharCode(1));
	var fieldnames = document.forms[0].elements[machine_name+'fields'].value.split(String.fromCharCode(1));
	for (var i=0; i < fieldnames.length; i++)
		if (fieldnames[i] == fieldname)
			return linedata[i];
	return '';
}
function setEncodedValue(machine_name, linenum, fieldname, value)
{
	var linearray = document.forms[0].elements[machine_name+'data'].value.split(String.fromCharCode(2));
	var linedata = linearray[linenum-1].split(String.fromCharCode(1));
	var fieldnames = document.forms[0].elements[machine_name+'fields'].value.split(String.fromCharCode(1));
	for (var i=0; i < fieldnames.length; i++)
		if (fieldnames[i] == fieldname)
			linedata[i] = value;
	linearray[linenum-1] = linedata.join(String.fromCharCode(1));
	document.forms[0].elements[machine_name+'data'].value = linearray.join(String.fromCharCode(2));
}
function setEncodedValues(machine_name, linenum, form)
{
	var linearray = document.forms[0].elements[machine_name+'data'].value.split(String.fromCharCode(2));
	var fieldnames = document.forms[0].elements[machine_name+'fields'].value.split(String.fromCharCode(1));
	var linedata = new Array(fieldnames.length);
	for (var i=0; i < fieldnames.length; i++)
	{
		var fld = form.elements[fieldnames[i]+linenum.toString()];
		if (fld.type == "checkbox")
			linedata[i] = fld.checked ? 'T' : 'F';
		else
			linedata[i] = fld.value;
	}
	linearray[linenum-1] = linedata.join(String.fromCharCode(1));
	document.forms[0].elements[machine_name+'data'].value = linearray.join(String.fromCharCode(2));
}

// End hiding script from old browsers -->
