if(navigator.appName.indexOf("Microsoft") > -1){
	var toggle = 'block';
} else {
	var toggle = 'inline';
}


/*************************************************************************\
Form button mouseover events. Looks at the scrElement in the event to 
determine if it is type button or submit and changes the class type.
\*************************************************************************/

/*
extends isValidCharacters to validate for alpha/numerics.
*/
function isValidAlphaNumeric(obj,displayAlert)
{
	isValidCharacters("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 ",obj,displayAlert);
}

/*************************************************************************\
isValidCharacters(Characters, Form object,true)
Parameter 1 - Only characters allowed
Parameter 2 - Form object
Parameter 3 - True or False to show the alert message for this function
Returns if the form element characters given are valid and specifies the
character that is incorrect in the form field.
\*************************************************************************/
function isValidCharacters(chars,obj,displayAlert) 
{
	var field = obj.value;
	field = Trim(field);
	obj.value = field;
	if(!field == "")
	{
		var charset = chars
		var valid = "yes";
		var temp;
		for (var i=0; i<field.length; i++) 
		{
			temp = "" + field.substring(i, i+1);
			if (charset.indexOf(temp) == "-1") 
			{
				if(displayAlert == true)
				{
					alert("Invalid character(s)" + " ' "+field.substring(i, i+1)+" ' " + "provided for this field. Please try again.");
					obj.select();
					obj.focus();
				}
				return false;
			}
		}
	}
	return true;
}


function isQty(obj)
{
	if(obj.value.length > 0)
	{
		if(isNaN(Number(obj.value)))
		{
			obj.value = "";
			return false;
		}
		else
			return true;
	}
	else
		return false;
}

/*************************************************************************\
RemoveCharacters(Form object, Character To Replace, Replace With Character)
Removes the requested character from the object text specified. 
Will remove any character specified.
\*************************************************************************/
function RemoveCharacters(obj,char1,repl)
{
	var field = obj.value;
	if(!field == "")
	{	
		field = field.toString().replace(char1,repl);
		//field = field.toString().replace(/\+char+|\,/g,repl);
		obj.value = field;
	}
}
/*************************************************************************\
Trim(Character String)
Removes the trailing spaces in a string.
\*************************************************************************/
function Trim(str)
{
	return str.replace(/^\s*|\s*$/g,"");
}
/*************************************************************************\
isValidZip(Form object,true)
Parameter 1 - Form object
Parameter 2 - True or False to show the alert message for this function
Returns if the zip code given is valid and formats correctly. Zip can be 
either five digits or five digits a - and four digits
\*************************************************************************/
function isValidZip(obj,displayAlert) 
{
	var field = obj.value;
	field = Trim(field);
	obj.value = field;
	var valid = "0123456789-";
	var hyphencount = 0;
	if(!field == "")
	{
		if (field.length!=5 && field.length!=10) 
		{
			if(displayAlert == true)
			{
				alert("Please enter your 5 digit or 5 digit+4 zip code. A properly formatted zip code should be like '12345' or '12345-6789'. Please try again.");
				obj.select();
				obj.focus();
			}	
			return false;
		}
		for (var i=0; i < field.length; i++) 
		{
			temp = "" + field.substring(i, i+1);
			if (temp == "-") hyphencount++;
			if (valid.indexOf(temp) == "-1") 
			{
				if(displayAlert == true)
				{
					alert("Invalid characters in your zip code.  Please try again.");
					obj.select();
					obj.focus();
				}
				return false;
			}
			if ((hyphencount > 1) || ((field.length==10) && ""+field.charAt(5)!="-")) 
			{
				if(displayAlert == true)
				{
					alert("The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'.   Please try again.");
					obj.select();
					obj.focus();
				}
				return false;
			}
		}
		return true;
	}
	return true;
}
/*************************************************************************\
isValidEmail(Form object,true)
Parameter 1 - Form object
Parameter 2 - True or False to show the alert message for this function
Returns if the date given is valid. Compares forat to email pattern to
determine string format. Email must have @ . can also include -
\*************************************************************************/
function isValidEmail(obj,displayAlert) 
{
	var field = obj.value;
	field = Trim(field);
	obj.value = field;
	if(field != "")
	{
		if(field.indexOf("@") == -1)
		{
			if(displayAlert == true)
			{
				alert("The email address given must have a @ and . characters.");
			}
			obj.select();
			obj.focus();
			return false;
		}
	
		if(field.indexOf(".") == -1)
		{
			if(displayAlert == true)
			{
				alert("The email address given must have a @ and . characters.");
			}
			obj.select();
			obj.focus();
			return false;
		}	
		var emailPat=/^(.+)@(.+)$/
		var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
		var validChars="\[^\\s" + specialChars + "\]"
		var quotedUser="(\"[^\"]*\")"
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
		var atom=validChars + '+'
		var word="(" + atom + "|" + quotedUser + ")"
		var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
		var matchArray=field.match(emailPat)
		if (matchArray==null) 
		{
			//alert("The email address given is not formatted correctly");
			//obj.select();
			//obj.focus();
			return false;
		}
		var user=matchArray[1]
		var domain=matchArray[2]
		if (user.match(userPat)==null) 
		{
			if(displayAlert == true)
			{
				alert("The username doesn't seem to be valid.");
			}
			obj.select();
			obj.focus();
			return false;
		}
		var IPArray=domain.match(ipDomainPat)
		if (IPArray!=null) 
		{
			for (var i=1;i<=4;i++) 
			{
				if (IPArray[i]>255) 
				{
					if(displayAlert == true)
					{
						alert("Destination IP address is invalid!");
					}
					obj.select();
					obj.focus();
					return false;
				}
			}
			return true;
		}
		
		var domainArray=domain.match(domainPat)
		if (domainArray==null) 
		{
			if(displayAlert == true)
			{
				alert("The domain name doesn't seem to be valid.");
				obj.select();
				obj.focus();
			}
			return false;
		}
		var atomPat=new RegExp(atom,"g")
		var domArr=domain.match(atomPat)
		var len=domArr.length
		if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3) 
		{
			if(displayAlert == true)
			{
				alert("The address must end in a three-letter domain, or two letter country.");
				obj.select();
				obj.focus();
			}
			return false;
		}
		if (len<2) 
		{
			if(displayAlert == true)
			{
				alert("This address is missing a hostname!");
				obj.select();
				obj.focus();
			}
			return false;
		}
		return true;
	}
	return true;
}
/*************************************************************************\
isValidMoney(Form object,true)
Parameter 1 - Form object
Parameter 2 - True or False to show the alert message for this function
Returns if the dollar amount given is valid and formats, removes $ and ,
from the field. If dollar amount is given with 3 decimal places script
will round up to two decimal places
\*************************************************************************/
function isValidMoney(obj,displayAlert) 
{
	var field = obj.value;
	field = Trim(field);
	obj.value = field;
	if(!field == "")
	{	
		if(isValidCharacters("-0123456789.$,",obj,displayAlert) != false)
		{
			var matchRegEx = field.match(/^[+-]?((\$\d*)|(\$\d*\.\d{2})|(\d*)|(\d*\.\d{2}))$/);
			if(matchRegEx == null)
			{
				if(displayAlert == true)
				{
					alert('Invalid currency format. Please try again.');
					obj.select();
					obj.focus();
				}
				return false;
			}
			field = field.toString().replace(/\$|\,/g,'');

			sign = (field== (field = Math.abs(field)));
			field = Math.floor(field*100+0.50000000001);
			cents = field%100;
			field = Math.floor(field/100).toString();
			if(field.length > 10)
			{
				if(displayAlert == true)
				{
					alert('Invalid currency format. Value given has exceeded the limit for this field. Please try again.');
					obj.select();
					obj.focus();
				}
				return false;				
			}
			if(cents<10)
			{
				cents = "0" + cents;
			}
			for (var i = 0; i < Math.floor((field.length-(1+i))/3); i++)
			{
				field = field.substring(0,field.length-(4*i+3)) + field.substring(field.length-(4*i+3));
			}
			//number = new Number(field);
			//field = number.toFixed(2);
			obj.value = (((sign)?'':'-') + field + '.' + cents);
		}
	}
	return true;
}
/*************************************************************************\
isNumeric(Form object, true)
Parameter 1 - Form object
Parameter 2 - True or False to show the alert message for this function
Returns if the form element characters given are valid
\*************************************************************************/
function isNumeric(obj,displayAlert)
{
	var field = obj.value;
	field = Trim(field);
	obj.value = field;
	if(!field == "")
	{
		var charset = '0123456789';
		var valid = "yes";
		var temp;
		fieldsize = Math.floor(field).toString();
		if(fieldsize.length > 10)
		{
			if(displayAlert == true)
			{
				alert('Invalid number format. Value given has exceeded the limit for this field. Please try again.');
				obj.select();
				obj.focus();
			}
			return false;			
		}
		else
		{
			for (var i=0; i<field.length; i++) 
			{
				temp = "" + field.substring(i, i+1);
				if (charset.indexOf(temp) == "-1") 
				{
					if(displayAlert == true)
					{
						alert("Invalid character(s)" + " ' "+field.substring(i, i+1)+" ' " + "provided for this field. Please try again.");
						obj.select();
						obj.focus();
					}
					return false;
				}
			}
		}
	}
	return true;
}
/*************************************************************************\
isValidPercentage(Form object)
Returns if the form element characters given are valid
\*************************************************************************/
function isValidPercentage(obj,displayAlert)
{
	var field = obj.value;
	field = Trim(field);
	obj.value = field;
	if(!field == "")
	{
		field = field.toString().replace(/\%|\,/g,'');
		obj.value = field;
		var charset = '-.0123456789';
		var valid = "yes";
		var temp;
		fieldsize = Math.floor(field).toString();
		if(fieldsize.length > 10)
		{
			if(displayAlert == true)
			{
				alert('Invalid percentage format. Value given has exceeded the limit for this field. Please try again.');
				obj.select();
				obj.focus();
			}
			return false;			
		}
		else
		{
			for (var i=0; i<field.length; i++) 
			{
				temp = "" + field.substring(i, i+1);
				if (charset.indexOf(temp) == "-1") 
				{
					alert("Invalid character(s)" + " ' "+field.substring(i, i+1)+" ' " + "provided for this field. Please try again.");
					obj.select();
					obj.focus();
					return false;
				}
			}
		}
	}
	return true;
}
/*************************************************************************\
isValidDecimal(Form object)
Returns if the form element characters given are valid
\*************************************************************************/
function isValidDecimal(obj,displayAlert)
{
	var field = obj.value;
	field = Trim(field);
	obj.value = field;
	if(!field == "")
	{
		field = field.toString().replace(/\%|\,/g,'');
		obj.value = field;
		var charset = '-.0123456789';
		var valid = "yes";
		var temp;
		fieldsize = Math.floor(field).toString();
		if(fieldsize.length > 10)
		{
			if(displayAlert == true)
			{
				alert('Invalid decimal format. Value given has exceeded the limit for this field. Please try again.');
			}
			obj.select();
			obj.focus();
			return false;			
		}
		else
		{
			for (var i=0; i<field.length; i++) 
			{
				temp = "" + field.substring(i, i+1);
				if (charset.indexOf(temp) == "-1") 
				{
					alert("Invalid character(s)" + " ' "+field.substring(i, i+1)+" ' " + "provided for this field. Please try again.");
					obj.select();
					obj.focus();
					return false;
				}
			sign = (field== (field = Math.abs(field)));
			field = Math.floor(field*100+0.50000000001);
			cents = field%100;
			field = Math.floor(field/100).toString();
			if(cents<10)
			{
				cents = "0" + cents;
			}
			obj.value = (((sign)?'':'-') + field + '.' + cents);
			}
		}
	}
	return true;
}
/*************************************************************************\
isValidPositiveDecimal(Form object)
Returns if the form element characters given are valid
\*************************************************************************/
function isValidPositiveDecimal(obj,displayAlert)
{
	var field = obj.value;
	field = Trim(field);
	obj.value = field;
	if(!field == "")
	{
		if(isValidCharacters("0123456789.,",obj,displayAlert) != false)
		{
			field = field.toString().replace(/\%|\,/g,'');
			obj.value = field;
			var charset = '.0123456789';
			var valid = "yes";

			fieldsize = Math.floor(field).toString();
			if(fieldsize.length > 10)
			{
				if(displayAlert == true)
				{
					alert('Invalid decimal format. Value given has exceeded the limit for this field. Please try again.');
				}
				obj.select();
				obj.focus();
				return false;			
			}
			else
			{
				for (var i=0; i<field.length; i++) 
				{
					sign = (field== (field = Math.abs(field)));
					field = Math.floor(field*100+0.50000000001);
					cents = field%100;
					field = Math.floor(field/100).toString();
					if(cents<10)
					{
						cents = "0" + cents;
					}
					obj.value = (field + '.' + cents);
				}
			}
		}
		else
		{
			return false;
		}
	}
	return true;
}
/*************************************************************************\
isValidPhoneNumber(Form object,true)
Parameter 1 - Form object
Parameter 2 - True or False to show the alert message for this function
Returns if the dollar amount given is valid and formats, removes $ and ,
from the field. If dollar amount is given with 3 decimal places script
will round up to two decimal places
\*************************************************************************/
function isValidPhoneNumber(obj,displayAlert) 
{
	var field = obj.value;
	field = Trim(field);
	obj.value = field;
	if(!field == "")
	{	
		field = field.toString().replace(/\(|\,/g,'');
		field = field.toString().replace(/\)|\,/g,'');
		field = field.toString().replace(/\.|\,/g,'');
		field = field.toString().replace(/\-|\,/g,'');
		obj.value = field;		

		var areacode = field.substring(0,3);
		var num1 = field.substring(3,6);
		var num2 = field.substring(6,10);
		
		if(isValidCharacters("0123456789,",obj,displayAlert) != false)
		{
			var matchRegEx = field.match(/^(\d{3})-?\d{3}-?\d{4}$/);
			if(matchRegEx == null)
			{
				if(displayAlert == true)
				{
					alert('Invalid phone number. Must be 10 digits or in the form 123-450-6789. Please try again.');
					obj.select();
					obj.focus();
				}
				return false;
			}
		}
		obj.value = (areacode+'-'+num1+'-'+num2);
	}
	return true;
}
/*************************************************************************\
isValidSSN(Form object,true)
Parameter 1 - Form object
Parameter 2 - True or False to show the alert message for this function
Returns if the social security number is valid. Checks the matchArr pattern
against the value given. SSN format should be ###-##-####. isValidSSN does
not require - between numbers.
\*************************************************************************/
function isValidSSN(obj,displayAlert)
{
	var field = obj.value;
	field = Trim(field);
	obj.value = field;
	if(!field == "")
	{
		field = field.toString().replace(/\-|\,/g,'');
		obj.value = field;
		
		var num1 = field.substring(0,3);
		var num2 = field.substring(3,5);
		var num3 = field.substring(5,9);		
					
		if(isValidCharacters("0123456789,",obj,displayAlert) != false)
		{
			var matchRegEx = field.match(/^(\d{3})-?\d{2}-?\d{4}$/);
			var numDashes = field.split('-').length - 1;
			if(matchRegEx == null || numDashes == 1)
			{
				if(displayAlert == true)
				{
					alert('Invalid social security number. Must be 9 digits or in the form 123-45-6789. Please try again.');
				}
				obj.select();
				obj.focus();
				return false;
			}
			else
			{
				if(parseInt(matchRegEx[1],10)==0)
				{
					if(displayAlert == true)
					{
						alert("Invalid social security number. Social security numbers can't start with 000.");
					}
					obj.select();
					obj.focus();
					return false;
				}
			}
		}
		obj.value = (num1+'-'+num2+'-'+num3);
	}
	return true;
}
/*************************************************************************\
isValidDate(Form object,true)
Parameter 1 - Form object
Parameter 2 - True or False to show the alert message for this function
Function call when user calls script onblur on a date field

\*************************************************************************/
function isValidDate(obj,displayAlert) 
{
	var field = obj.value;
	field = Trim(field);
	obj.value = field;
	if(!field == "")
	{
		if(isValidCharacters("0123456789/-.",obj,displayAlert) != false)
		{
			if (chkdate(obj) == false) 
			{	
				if(displayAlert == true)
				{
					alert("Invalid date given. Dates must be in the format of MM/DD/YYYY.  Please try again.");
					obj.select();
					obj.focus();
				}
				return false;
			}
			else 
			{
				return true;
			}
		}
	}
	return true;
}






/*************************************************************************\
isPastDate(Form object,true,User Date,true)
Parameter 1 - Form object
Parameter 2 - Allow date to be same as current date, true or false
Parameter 3 - User date if different than the current user machine
Parameter 4 - True or False to show the alert message for this function
Function to check if passed in date is less than the current date.
Uses the isValidDate function to confirm valid date format.
\*************************************************************************/
function isPastDate(obj,allowToday,userDate,displayAlert) 
{
	if(!obj.value == "")
	{
		if(isValidDate(obj,displayAlert))
		{
			if(userDate != null || userDate != false)
			{
				var objToday = userDate;
			}
			else
			{
				var objToday = new Date();
			}
			var objDateConvert = new Date(obj.value);
			var objDate = new Date(objDateConvert.getFullYear(), objDateConvert.getMonth(), objDateConvert.getDate());

			var objUserDateConvert = new Date(objToday);
			var objUserDate = new Date(objUserDateConvert.getFullYear(), objUserDateConvert.getMonth(), objUserDateConvert.getDate());		

			if(allowToday)
			{
				if(objDate <= objUserDate)
				{
					return true;
				}
				else
				{
					if(displayAlert == true)
					{
						alert("Invalid date given. Date must be less than or equal to the current date. Please try again.");
					}
					obj.select();
					obj.focus();		
					return false;
				}
			}
			else
			{
				if(objDate < objUserDate)
				{
					return true;
				}
				else
				{
					if(displayAlert == true)
					{
						alert("Invalid date given. Date must be less than the current date. Please try again.");
					}
					obj.select();
					obj.focus();		
					return false;
				}	
			}
		}
	}
	return true;
}
/*************************************************************************\
isFutureDate(Form object,true,User Date,true)
Parameter 1 - Form object
Parameter 2 - Allow date to be same as current date, true or false
Parameter 3 - User date if different than the current user machine
Parameter 4 - True or False to show the alert message for this function
Function to check if passed in date is greter than the current date.
Uses the isValidDate function to confirm valid date format.
\*************************************************************************/
function isFutureDate(obj,allowToday,userDate,displayAlert) 
{
	if(!obj.value == "")
	{
		if(isValidDate(obj,displayAlert))
		{
			if(userDate != null && userDate != false)
			{
				var objToday = userDate;
			}
			else
			{
				var objToday = new Date();
			}
			var objDateConvert = new Date(obj.value);
			var objDate = new Date(objDateConvert.getFullYear(), objDateConvert.getMonth(), objDateConvert.getDate());

			var objUserDateConvert = new Date(objToday);
			var objUserDate = new Date(objUserDateConvert.getFullYear(), objUserDateConvert.getMonth(), objUserDateConvert.getDate());		

			if(allowToday)
			{
				if(objDate >= objUserDate)
				{
					return true;
				}
				else
				{
					if(displayAlert == true)
					{
						alert("Invalid date given. Date must be greater than or equal to the current date. Please try again.");
					}
					obj.select();
					obj.focus();		
					return false;
				}
			}
			else
			{
				if(objDate > objUserDate)
				{
					return true;
				}
				else
				{
					if(displayAlert == true)
					{
						alert("Invalid date given. Date must be greater than the current date. Please try again.");
					}
					obj.select();
					obj.focus();		
					return false;
				}	
			}
		}
	}
}
/*************************************************************************\
chkdate(Form object)
Function called from isValidDate function
Returns if the date given is valid and formats correctly 01/01/2003. Dates
can be given with different seperators . / - Function will reformat with /
and will set all month day and year values according to the format 01/01
even if the user does not enter month and day with 2 digit values
\*************************************************************************/
function GetFullYear(year) {
    return (year + parseInt(val.century)) - ((year <=
(parseInt(val.cutoffyear) % 100)) ? 0 : 100);
}

function chkdate(obj) 
{
	var strDatestyle = "US";
	var strDate;
	var strDateArray;
	var strDay;
	var strMonth;
	var strYear;
	var intday;
	var strday;
	var intMonth;
	var intYear;
	var booFound = false;
	var field = obj;
	var seperator = "/"
	var strSeparatorArray = new Array("-"," ","/",".");
	var intElementNr;
	var err = 0;
	var strMonthArray = new Array(12);
	strMonthArray[0] = "01";
	strMonthArray[1] = "02";
	strMonthArray[2] = "03";
	strMonthArray[3] = "04";
	strMonthArray[4] = "05";
	strMonthArray[5] = "06";
	strMonthArray[6] = "07";
	strMonthArray[7] = "08";
	strMonthArray[8] = "09";
	strMonthArray[9] = "10";
	strMonthArray[10] = "11";
	strMonthArray[11] = "12";
	strDate = field.value;
	if (strDate.length < 1) 
	{
		return true;
	}
	for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++) 
	{
		if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1) 
		{
			strDateArray = strDate.split(strSeparatorArray[intElementNr]);
			if (strDateArray.length != 3) 
			{
				err = 1;
				return false;
			}
			else 
			{
				strDay = strDateArray[0];
				strMonth = strDateArray[1];
				strYear = strDateArray[2];
			}
		booFound = true;
   		}
	}
	if (booFound == false) 
	{
		if (strDate.length > 5) 
		{
			strDay = strDate.substr(0, 2);
			strMonth = strDate.substr(2, 2);
			strYear = strDate.substr(4);
   		}
		else
		{
			err = 1;
			return false;
		}
	}
	if (strYear.length == 2) 
	{
		if (strYear >= 50)
		{
			strYear = '19' + strYear;
		}
		else
		{
			strYear = '20' + strYear;
		}
	}
	if (strYear.length == 3 || strYear.length == 1)
	{
		return false;	
	}
	// US style
	if (strDatestyle == "US") 
	{
		strTemp = strDay;
		strDay = strMonth;
		strMonth = strTemp;
	}
	intday = parseInt(strDay, 10);
	if (isNaN(intday)) 
	{
		err = 2;
		return false;
	}
	strday = intday.toString();
	if (strday.length == 1)
	{
		strday = '0' + intday;
	}
	else
	{
		strday = intday;
	}
	intMonth = parseInt(strMonth, 10);
	if (isNaN(intMonth)) 
	{
		for (i = 0;i<12;i++) 
		{
			if (strMonth.toUpperCase() == strMonthArray[i].toUpperCase()) 
			{
				intMonth = i+1;
				strMonth = strMonthArray[i];
				i = 12;
   			}
		}
		if (isNaN(intMonth)) 
		{
			err = 3;
			return false;
		}
	}
	intYear = parseInt(strYear, 10);
	if (isNaN(intYear)) 
	{
		err = 4;
		return false;
	}
	if (intMonth>12 || intMonth<1)
	{
		err = 5;
		return false;
	}
	if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1))

	{
		err = 6;
		return false;
	}
	if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1))
	{
		err = 7;
		return false;
	}
	if (intMonth == 2)
	{
		if (intday < 1) 
		{
			err = 8;
			return false;
		}
		if (LeapYear(intYear) == true) 
		{
			if (intday > 29) 
			{
				err = 9;
				return false;
			}
		}
		else 
		{
			if (intday > 28)
			{
				err = 10;
				return false;
			}
		}
	}
	if (strDatestyle == "US") 
	{
		field.value = strMonthArray[intMonth-1] + seperator + strday+ seperator + strYear;
	}
	else
	{
		field.value = strday + seperator + strMonthArray[intMonth-1] + seperator + strYear;
	}
return true;
}
function LeapYear(intYear) 
{
	if (intYear % 100 == 0) 
	{
		if (intYear % 400 == 0) 
		{ 
			return true;
		}
	}
	else 
	{
		if ((intYear % 4) == 0) 
		{ 
			return true; 
		}
	}
	return false;
}
function isXPSP2()
{ // returns 0 if not WinXP SP2 returns 22 (height of status bar) if it is.
	var g_fIsSP2 = (window.navigator.userAgent.indexOf("SV1") != -1);
	if (g_fIsSP2)
	{
   		return true;
	}
	else
	{
   		return false;
	}
}		



function ViewSource()
{
	parent.document.location = 'view-source:' + parent.document.location.href;
}

function AddOptionToListBox(listBox, value, text)
{
	listBox[listBox.length] = new Option(text, value);
}

function DeleteOptionFromListBoxByValue(listBox, value)
{
	var deletedOne = true;
	
	while (deletedOne)
	{
		deletedOne = false;
		for (var i = listBox.options.length - 1; i >= 0; i--)
		{
			if (listBox.options[i].value == value)
			{
				listBox.options[i] = null;
				deletedOne = true;
			}
		}
	}
}

function DeleteOptionFromListBoxByText(listBox, text)
{
	var deletedOne = true;
	
	while (deletedOne)
	{
		deletedOne = false;
		for (var i = listBox.options.length - 1; i >= 0; i--)
		{
			if (listBox.options[i].text == text)
			{
				listBox.options[i] = null;
				deletedOne = true;
			}
		}
	}
}

function EmptyListBox(listBox)
{
	for (var i = listBox.options.length - 1; i >= 0; i--)
	{
		listBox.options[i] = null;
	}
}

// Function to sort a list box by its TEXT attribute.
function SortListBoxByText(listBox)
{
	SortListBox(listBox, "Text");
}

// Function to sort a list box by its VALUE attribute.
function SortListBoxByValue(listBox)
{
	SortListBox(listBox, "Value");
}

// Function to sort a list box by either its TEXT or its VALUE attribute.
function SortListBox(listBox, byTextOrValue)
{
	var a = new Array();
	
	// First, put the listbox into an array.
	for (var i = 0 ; i < listBox.options.length ; i++)
	{
		if (byTextOrValue == "Value")
		{
			a[i] = [listBox.options[i].value, listBox.options[i].text];
		}
		else
		{
			a[i] = [listBox.options[i].text, listBox.options[i].value];
		}
	}
	
	// Sort the array - sorts by the value in the first dimension.
	a.sort();
	
	// Replace the options in the listbox.
	for (var i = 0 ; i < a.length ; i++)
	{
		listBox.options[i] = new Option(a[i][0], a[i][1]);
	}
}


/*************************************************************************\
isNumber(Form object)
Returns true if the form element characters given are valid number
\*************************************************************************/
function isNumber(obj)
{
	if ( obj.value.length == 0 )
	{
		alert("Amount is empty");
		obj.focus();
		obj.select();
		return false;
	}
	if ( isNaN(Number(obj.value)))
	{
		alert("Invalid amount!");
		obj.focus();
		obj.select();
		return false;
	}
	return true;
}
/*************************************************************************\
isNum(number)
Returns true if the form element characters given are valid number
\*************************************************************************/
function isNum(val)
{
	if ( isNaN(Number(val)))
	{
		//ErrorBox("Invalid amount!");
		return false;
	}
	return true;
}




function isDefined(object)
{ 
	return (typeof(object) != "undefined")? true: false;
}



		
//  -----------------------------------------------------------------------------
//  Function: TextareaMaxLength(oTextarea, intLimit)
//  
//  Description
//  	This function places a maxlength for a textarea
//  
//  Parameters
//  	field - this is the textarea that you want to check
//  	maxlen - this is the maxlength 
//  
//  Example use
//  	<textarea onkeyup="return TextareaMaxLength(this, 300);"></textarea>
//  
//  -----------------------------------------------------------------------------

function TextareaMaxLength(field, maxlen)
{
	if (field.value.length > maxlen)
	{
		field.value = field.value.substring(0, maxlen);
	}
}

	function CloseWindow(control)
	{
		//check if name has changed
		var hasChangedControl = control; 
		//var hasChangedControl = document.getElementById("_ctl0_nameHasChanged");
		
		if(hasChangedControl != null && hasChangedControl.value == "true")
		{
			window.returnValue = "Changed";
		}
		else
			window.returnValue = "Close";
		
		//close window
		//BypassHourglass();
		window.close();
	}

/*************************************************************************\
CaseFirstLetters(textbox)
Capitalizes first letter of each word of the textbox
\*************************************************************************/
function CaseFirstLetters(txt)
{
	var aryNames = txt.value.split(' ');
	var nNames = aryNames.length;
	for (var i = 0; i < nNames; i++)
	{
		aryNames[i] = aryNames[i].substr(0, 1).toUpperCase() + aryNames[i].substr(1);
	}
	txt.value = aryNames.join(' ');
}
