function round(number, decPlaces) 
{
	// rounds number to X decimal places, defaults to 2
	decPlaces = (!decPlaces ? 2 : decPlaces);
	var outStr = Math.round(number * Math.pow(10, decPlaces)) / Math.pow(10, decPlaces);

	if (decPlaces == 2)
	{
		var str = outStr + " ";
	
		if (str.indexOf(".") < 0)
			outStr += ".00";
		else
		if (str.indexOf(".1 ") >= 0 ||
			str.indexOf(".2 ") >= 0 ||
			str.indexOf(".3 ") >= 0 ||
			str.indexOf(".4 ") >= 0 ||
			str.indexOf(".5 ") >= 0 ||
			str.indexOf(".6 ") >= 0 ||
			str.indexOf(".7 ") >= 0 ||
			str.indexOf(".8 ") >= 0 ||
			str.indexOf(".9 ") >= 0 ||
			str.indexOf(".0 ") >= 0)
			outStr += "0";
	}

	return outStr;
}

function trim(str)
{
	var i, j, x;
	var outString;
	
	str = str + ' ';
	
	for (i = 0; i < str.length; i++)
		if (str.charAt(i) > ' ')
			break;			

	for (j = str.length - 1; j >= 0; j--)
		if (str.charAt(j) > ' ')
			break;

	outString = "";

	for (x = i; x <= j; x++)
		outString += str.charAt(x);
		
	return outString;
}

function isBlank(str)
{
	var string;

	string = trim(str);
	if (string.length)
		return false;
		
	return true;
}

function isDigit(x)
{
	if (!x.length)
		return false;
		
	if (x < '0' || x > '9')
		return false;
		
	return true;
}

function isFloat(str)
{	
	var dotCtr = 0;
	var digitCtr = 0;
	var i;
	
	str = trim(str);

	if (!str.length)
		return false;
	
	for (i = 0; i < str.length; i++)
	{
		if (str.charAt(i) != '-' &&	!isDigit(str.charAt(i)) && str.charAt(i) != '.')
			return false;
			
		if (i > 0)
			if (str.charAt(i) == '-')
				return false;
				
		if (str.charAt(i) == '.')
			dotCtr += 1;

		if (isDigit(str.charAt(i)))
			digitCtr++;
	}
	
	if (dotCtr > 1 || digitCtr == 0)
		return false;
			
	return true;
}

function isInteger(str)
{	
	var i;

	str = trim(str);
		
	if (!str.length)
		return false;
		
	for (i = 0; i < str.length; i++)
	{
		if (str.charAt(i) != '-' &&	!isDigit(str.charAt(i)))
			return false;

		if (i > 0)
			if (str.charAt(i) == '-')
				return false;
	}
			
	return true;
}

function isPositiveInteger(str)
{	
	var i;
	
	str = trim(str);

	if (!str.length)
		return false;
		
	for (i = 0; i < str.length; i++)
		if (!isDigit(str.charAt(i)))
			return false;
			
	return true;
}

function isPositiveFloat(str)
{	
	var i;
	var dotCtr;

	str = trim(str);

	if (!str.length)
		return false;

	if (str == ".")
		return false;
		
	dotCtr = 0;
	
	for (i = 0; i < str.length; i++)
	{
		if (!isDigit(str.charAt(i)) && str.charAt(i) != '.')
			return false;
			
		if (str.charAt(i) == '.')
			dotCtr += 1;
	}
	
	if (dotCtr > 1)
		return false;
			
	return true;
}

function editBlank(fieldObj, msg)
{
	if (fieldObj.disabled)
		return true;

	if (isBlank(fieldObj.value))	
	{
		if (msg == "")
			msg = "Required field"
			
		alert(msg);
		fieldObj.focus();
		return false;
	}	
	
	return true;
}	

function editInteger(fieldObj, msg)
{

	if (fieldObj.disabled)
		return true;

	if (!fieldObj.value.length || fieldObj.value == '-')
	{
		fieldObj.value = '0';
		return true;
	}

	if (!isInteger(fieldObj.value))
		{
			if (msg == "")
				msg = "Value must be a numeric integer";
				
			alert(msg);
			fieldObj.select();
			return false;
		}

	if (!fieldObj.value.length || fieldObj.value == '-')
		fieldObj.value = '0';
	
	return true;
}	

function editFloat(fieldObj, msg)
{
	if (fieldObj.disabled)
		return true;

	if (!fieldObj.value.length || fieldObj.value == '-')
	{
		fieldObj.value = '0';
		return true;
	}

	if (!isFloat(fieldObj.value))
		{
			if (msg == "")
				msg = "Value must be numeric";
				
			alert(msg);
			fieldObj.select();
			return false;
		}

	if (!fieldObj.value.length || fieldObj.value == '-')
		fieldObj.value = '0';
	
	return true;
}	

function editPositiveInteger(fieldObj, msg)
{
	if (fieldObj.disabled)
		return true;

	if (!fieldObj.value.length)
	{

		fieldObj.value = '0';
		return true;
	}

	if (!isPositiveInteger(fieldObj.value))
	{
		if (msg == "")
			msg = "Value must be a positive numeric integer";
			
		alert(msg);
		fieldObj.select();
		return false;
	}
		
	return true;
}

function editPositiveFloat(fieldObj, msg)
{
	if (fieldObj.disabled)
		return true;

	if (!fieldObj.value.length)
	{
		fieldObj.value = '0';
		return true;
	}

	if (!isPositiveFloat(fieldObj.value))
	{
		if (msg == "")
			msg = "Value must be a positive numeric number";
			
		alert(msg);
		fieldObj.select();
		return false;
	}
		
	return true;
}

function disableForm(formObj)
{
	var i;

	for (i = 0; i < formObj.length; i++)
	{
		if (formObj.elements[i].type == "hidden")
			continue;

		formObj.elements[i].disabled = true;
	}
}

function enableAllButtons(formObj)
{
	for (var i = 0; i < formObj.length; i++)
		if (formObj.elements[i].type == "button" || formObj.elements[i].type == "submit")
			formObj.elements[i].disabled = false;
}

function isDateDelimiter(c)
{
	if (c != '/' && c != '-')
		return false;
		
	return true;
}

function isValidDate(str)
{
	var len;
	var pos1;
	var pos2;
	var pos3;
	var pos4;
	var pos5;
	var pos6;
	var pos7;
	var pos8;
	var month;
	var day;
	var year;
	
	str = trim(str);
	
	len = str.length;
	
	pos1 = str.substring(0, 1);
	pos2 = str.substring(1, 2);
	pos3 = str.substring(2, 3);
	pos4 = str.substring(3, 4);
	pos5 = str.substring(4, 5);
	pos6 = str.substring(5, 6);
	pos7 = str.substring(6, 7);
	pos8 = str.substring(7, 8);

	/*	
	if (isPositiveInteger(str))
	{
		month = pos1 + pos2;
		day = pos3 + pos4;
		year = pos5 + pos6;
		
		if (len == 8)
			year += pos7 + pos8;
		else
		if (len != 6)
			return null;				
	}
	else
	*/
	if (isDigit(pos1) && isDateDelimiter(pos2) && isDigit(pos3) && isDateDelimiter(pos4))
	{
		month = pos1;
		day = pos3;
		year = str.substring(4, len);		
	}
	else
	if (isPositiveInteger(pos1 + pos2) && isDateDelimiter(pos3) && isPositiveInteger(pos4 + pos5) && isDateDelimiter(pos6))
	{
		month = pos1 + pos2;
		day = pos4 + pos5;
		year = str.substring(6, len);
	}
	else
	if (isDigit(pos1) && isDateDelimiter(pos2) && isPositiveInteger(pos3 + pos4) && isDateDelimiter(pos5))
	{
		month = pos1;
		day = pos3 + pos4;
		year = str.substring(5, len);
	}
	else
	if (isPositiveInteger(pos1 + pos2) && isDateDelimiter(pos3) && isDigit(pos4) && isDateDelimiter(pos5))
	{
		month = pos1 + pos2;
		day = pos4;
		year = str.substring(5, len);
	}
	else
		return null;				

	if (month < 1 || month > 12)
		return null;				
	   
	if (day < 1 || day > 31)
		return null;				

	if (!isPositiveInteger(year))
		return null;				
	   
	if (year.length == 3)
		return null;				

	if (year.length == 4 && (year < 1753 || year > 9999))
		return null;				

	if ((month == 4 || month == 6 || month == 9 || month == 11) && day == 31)
		return null;				

	// february, leap year
	if (month == 2)
	{	
		var g = parseInt(year / 4); // feb
		if (isNaN(g))
			return null;				

		if (day > 29)
			return null;				
					
		if (day == 29 && ((year / 4) != parseInt(year / 4)))
			return null;				
	}
	
	if (month.length == 1)
		month = '0' + month;
		
	if (day.length == 1)
		day = '0' + day;
		
	if (year.length == 1 || year.length == 3)
		year = '0' + year;
		
	return month + '/' + day + '/' + year;
}

function getMonth(str)
{
	var date;
	var month;
	
	date = isValidDate(str);
	if (!date)
		return null;
		
	month = date.substring(0, 2);

	month -= 0;	
	return month;
}

function getDate(str)
{
	var date;
	var day;

	date = isValidDate(str);
	if (!date)
		return null;
		
	day = date.substring(3, 5);

	day -= 0;	
	return day;
}

function getWeek(str)
{
	var month;
	var date;
	var day;
	var year;
	var dayOfWeek;
	var x;
	
	if (!isValidDate(str))	
		return null;
		
	month = getMonth(str)
	month--;

	day = getDate(str);
	year = getYear(str);

	date = new Date(year, "01", day);
	dayOfWeek = date.getDay();
	
	x = parseInt(dayOfWeek) + parseInt(day);
	
	if (x < 8)
		return 1;
		
	if (x < 15)
		return 2;
		
	if (x < 22)
		return 3;
		
	if (x < 29)
		return 4;
		
	return 5;
}

function dateOfWeekStarting(week, year, month)
{
	var day;
	var date;
	var dayOfWeek;
	
	switch (parseInt(week)) {
	case 1:
		day = 1;
		break;
	case 2:
		day = 8
		break;
	case 3:
		day = 15;
		break
	case 4:
		day = 22;
		break;
	case 5:
		day = 29;
		break;
	default:
		return null;
	}
	
	month--;
	date = new Date(year, month, day);
	dayOfWeek = date.getDay();
	
	return addCalendarDays(++month + '/' + day + '/' + year, -dayOfWeek);	
}

function dateOfWeekEnding(week, year, month)
{
	return addCalendarDays(dateOfWeekStarting(week, year, month),6);
}

function getYear(str)
{
	var date;
	var year;

	date = isValidDate(str);
	
	if (!date)
		return null;
		

	year = date.substring(6, date.length);
	switch (year.length) {
	case 3:
		year = '2' + year;
		break;
	case 2:
		if (year > 49)
			year = "19" + year;
		else
			year = "20" + year;
		break;
	case 1:
		year = "200" + year;
		break;
	}
	
	year -= 0;
	return year;
}

function getDay(str)
{
	var month;
	var date;
	var day;
	var year;	
	
	if (!isValidDate(str))	
		return null;
		
	month = getMonth(str)
	month--;
	day = getDate(str);
	year = getYear(str);

	date = new Date(year, month, day);
	return date.getDay();
}

function addCalendarDay(str)
{
	var month;
	var day;
	var year;
	var newDate;
	var date;
	
	if (!isValidDate(str))
		return null;
		
	month = getMonth(str);
	day = getDate(str);
	year = getYear(str);

	day -= 0;
	day++;
	
	newDate = month + '/' + day + '/' + year;
	date = isValidDate(newDate);	
	if (date)
		return date;
	
	day = 1;
	month++;
	newDate = month + '/' + day + '/' + year;	
	date = isValidDate(newDate);
	if (date)

		return date;
		
	month = 1;
	year++;
	newDate = month + '/' + day + '/' + year;	
	date = isValidDate(newDate);
	if (date)
		return date;
		
	return null;
}

function subtractCalendarDay(str)
{
	var month;
	var day;
	var year;
	var newDate;

	if (!isValidDate(str))
		return null;
		
	month = getMonth(str);
	day = getDate(str);
	year = getYear(str);

	day--;
	if (day == 0)
	{
		month--;
		
		if (month == 0)
		{
			month = 12;
			year--;
		}
		
		switch (month) {
		case 4 :
		case 6 :
		case 9 :
		case 11 :
			day = 30;
			break;
		case 2 :		
			if (year / 4 == parseInt(year / 4))
				day = 29;
			else
				day = 28;
			break;	
		default:
			day = 31;	
		}
	}
	
	newDate = month + '/' + day + '/' + year;	
	return isValidDate(newDate);	
}

function addCalendarDays(str, days)
{
	var date;
	var j;
	
	if (!isValidDate(str))
		return null;

	date = str;
	
	if (!days)
		return date;
		
	if (days > 0)
		for (j = 1; j <= days; j++)

			date = addCalendarDay(date);
	else
		for (j = days; j < 0; j++)
			date = subtractCalendarDay(date);
		
	return date;
}

function addBusinessDay(str)
{
	var newDate;
	var dayOfWeek;

	if (!isValidDate(str))
		return null;
		
	dayOfWeek = getDay(str);
	
	switch (dayOfWeek) {
	case 5:
	case 6:
		newDate = addCalendarDays(str, 3);
		break;
	case 0:
		newDate = addCalendarDays(str, 2);
		break;
	default:
		newDate = addCalendarDays(str, 1);		
	}

	return newDate;
}

function subtractBusinessDay(str)
{
	var newDate;
	var dayOfWeek;

	if (!isValidDate(str))
		return null;
		
	dayOfWeek = getDay(str);
	
	switch (dayOfWeek) {
	case 1:
	case 0:
		newDate = addCalendarDays(str, -3);
		break;
	case 6:
		newDate = addCalendarDays(str, -2);
		break;
	default:
		newDate = addCalendarDays(str, -1);		
	}
		
	return newDate;		
}

function addBusinessDays(str, days)
{
	var date;
	var i;
	
	if (!isValidDate(str))
		return null;

	date = str;
	
	if (!days)

		return date;
		
	if (days > 0)
		for (i = 1; i <= days; i++)
			date = addBusinessDay(date);
	else
		for (i = days; i < 0; i++)
			date = subtractBusinessDay(date);
		
	return date;
}

function checkAmPm(rest)
{
	if (rest == "AM" || rest == " AM")
		return "AM";
		
	if (rest == "PM" || rest == " PM")
		return "PM";

	return null;
}

function isValidTime(str)
{
	var pos1;
	var pos2;
	var pos3;
	var pos4;
	var pos5;
	var pos6;
	var pos7;
	var pos8;
	var pos9;
	var pos10;
	var pos11;
	var hours;
	var minutes;
	var seconds;
	var rest;

	str = str.toUpperCase();
	
	pos1 = str.substring(0, 1);
	pos2 = str.substring(1, 2);
	pos3 = str.substring(2, 3);
	pos4 = str.substring(3, 4);
	pos5 = str.substring(4, 5);
	pos6 = str.substring(5, 6);
	pos7 = str.substring(6, 7);
	pos8 = str.substring(7, 8);
	pos9 = str.substring(8, 9);
	pos10 = str.substring(9, 10);
	pos11 = str.substring(10, 11);

	minutes = '';
	seconds = '';
		

	if (isPositiveInteger(pos1) && pos2 == ':' && isPositiveInteger(pos3) && pos4 == ':')
	{//h:m:s xx OR h:m:ss xx
		hours = pos1;
		minutes = pos3;

		if (isPositiveInteger(pos5))
			seconds = pos5
		else
			return false;
			
		if (isPositiveInteger(pos6))
		{
			seconds += pos6;
			rest = str.substring(6, str.length);			
		}	
		else			
			rest = str.substring(5, str.length);			
		
		amPm = checkAmPm(rest);
		
		if (!amPm)
			return false;
	}
	else
	if (isPositiveInteger(pos1) && pos2 == ':' && isPositiveInteger(pos3) && (pos4 == ' ' || pos4 == 'A' || pos4 == 'P'))
	{ //h:m xx
		hours = pos1;
		minutes = pos3;
		
				
		rest = str.substring(3, str.length);
		amPm = checkAmPm(rest);
		
		if (!amPm)
			return false;
	}
	else
	if (isPositiveInteger(pos1) && pos2 == ':' && isPositiveInteger(pos3) && isPositiveInteger(pos4) && pos5 == ':')
	{//h:mm:s xx OR h:mm:ss xx
		hours = pos1;
		minutes = pos3 + pos4;
		
		if (isPositiveInteger(pos6))
			seconds = pos6
		else
			return false;
			
		if (isPositiveInteger(pos7))
		{
			seconds += pos7;
			rest = str.substring(7, str.length);			
		}	
		else			
			rest = str.substring(6, str.length);			

		amPm = checkAmPm(rest);
		
		if (!amPm)
			return false;		
	}
	else
	if (isPositiveInteger(pos1) && pos2 == ':' && isPositiveInteger(pos3) && isPositiveInteger(pos4) && (pos5 == ' ' || pos5 == 'A' || pos5 == 'P'))
	{ //h:mm xx
		hours = pos1;
		minutes = pos3 + pos4;
		
				
		rest = str.substring(4, str.length);
		amPm = checkAmPm(rest);
		
		if (!amPm)
			return false;
	}
	else
	if (isPositiveInteger(pos1) && isPositiveInteger(pos2) && pos3 == ':' && isPositiveInteger(pos4) && pos5 == ':')
	{//hh:m:s xx OR hh:m:ss xx
		hours = pos1 + pos2;
		minutes = pos4;
		
		if (isPositiveInteger(pos6))
			seconds = pos6
		else
			return false;
			
		if (isPositiveInteger(pos7))
		{
			seconds += pos7;
			rest = str.substring(7, str.length);			
		}	
		else			
			rest = str.substring(6, str.length);			

		amPm = checkAmPm(rest);
		
		if (!amPm)
			return false;		
	}
	else
	if (isPositiveInteger(pos1) && isPositiveInteger(pos2) && pos3 == ':' && isPositiveInteger(pos4) && pos5 == ' ')
	{//hh:m xx
		hours = pos1 + pos2;
		minutes = pos4;
		
		rest = str.substring(5, str.length);
		amPm = checkAmPm(rest);
		
		if (!amPm)
			return false;
	}
	else
	if (isPositiveInteger(pos1) && isPositiveInteger(pos2) && pos3 == ':' && isPositiveInteger(pos4) && isPositiveInteger(pos5) && pos6 == ':')
	{//hh:mm:s xx OR hh:mm:ss xx
		hours = pos1 + pos2;
		minutes = pos4 + pos5;
		
		if (isPositiveInteger(pos7))
			seconds = pos7
		else
			return false;
			
		if (isPositiveInteger(pos8))
		{
			seconds += pos8;
			rest = str.substring(8, str.length);			
		}	
		else			
			rest = str.substring(7, str.length);			

		amPm = checkAmPm(rest);
		
		if (!amPm)
			return false;		
	}
	else
	if (isPositiveInteger(pos1) && isPositiveInteger(pos2) && pos3 == ':' && isPositiveInteger(pos4) && isPositiveInteger(pos5) && (pos6 == ' '|| pos6 == 'A' 
|| pos6 == 'P'))
	{//hh:mm xx
		hours = pos1 + pos2;
		minutes = pos4 + pos5;
				
		rest = str.substring(5, str.length);
		amPm = checkAmPm(rest);
		
		if (!amPm)
			return false;
	}
	else
	if (isPositiveInteger(pos1))
	{//h xx OR hh xx
		hours = pos1;
		
		if (isPositiveInteger(pos2))
		{
			hours += pos2;			
			rest = str.substring(2, str.length);			
		}	
		else			
			rest = str.substring(1, str.length);

		amPm = checkAmPm(rest);
		
		if (!amPm)
			return false;
			
	}
	else
		return false;
	
	
	if (hours < 0 || hours > 12)
		return false;
		

	if (minutes < 0 || minutes > 59)
		return false;


	if (seconds < 0 || seconds > 59)
		return false;

	return true;
}

function extractDate(str)
{
	var divider;
	var date;
	var time;
	
	str = trim(str);
	
	if (isValidDate(str))
		return str;
	
	divider = str.indexOf(' ');
	
	if (divider < 0)
		return null;			
	
	date = str.substring(0, divider);
	
	if (!isValidDate(date))			
		return null;
		
	time = str.substring(divider + 1, str.length);
		
	if (isBlank(time))
		return date;
		
	if (!isValidTime(time))
		return null;
		
	return date;
}

function extractTime(str)
{
	var divider;
	var date;
	var time;
	
	time = "";
	
	str = trim(str);
	
	if (isValidTime(str))
		return str;
	
	divider = str.indexOf(' ');
	
	if (divider < 0)
		return time;			
	
	date = str.substring(0, divider);
	
	if (!isValidDate(date))			
		return null;
		
	time = str.substring(divider + 1, str.length);
	if (isBlank(time))
		return time;
		
	if (!isValidTime(time))
		return null;
		
	return time;
}

function isValidDateTime(str)
{
	var divider;
	var date;
	var time;
	
	str = trim(str);
	
	if (isValidDate(str) || isValidTime(str))
		return true;
	
	divider = str.indexOf(' ');
	
	date = str.substring(0, divider);

	
	if (divider < 0)
		return false;
	
	if (!isValidDate(date))			
		return false;
		
	time = str.substring(divider + 1, str.length);
		
	if (isBlank(time))
		return true;
		
	if (!isValidTime(time))
		return false;
		
	return true;
}

function editDateTime(fieldObj, msg)
{
	if (fieldObj.disabled)
		return true;

	var divider;
	var date;
	var time;
	var pos1;
	var pos2;
	var pos3;
	var pos4;
	var pos5;
	var pos6;
	var pos7;
	var pos8;
	var month;
	var day;
	var year;
	var date;
	var dateTime;
	
	
	fieldObj.value = trim(fieldObj.value);

	str = fieldObj.value;
	
	divider = str.indexOf(' ');
	
	if (isValidTime(str) || isValidDate(str))
		;
	else
	if (divider < 0)
	{
		date = str
		if (isPositiveInteger(date))
		{
			month = date.substring(0, 1) + date.substring(1, 2);
			day = date.substring(2, 3) + date.substring(3, 4);
			year = date.substring(4, 5) + date.substring(5, 6) + date.substring(6, 7) + date.substring(7, 8);
		
			fieldObj.value = month + '/' + day + '/' + year
		}	
	}
	else
	{
		date = str.substring(0, divider);
		time = str.substring(divider + 1, str.length);
			
		if (isPositiveInteger(date))
		{
			month = date.substring(0, 1) + date.substring(1, 2);
			day = date.substring(2, 3) + date.substring(3, 4);
			year = date.substring(4, 5) + date.substring(5, 6) + date.substring(6, 7) + date.substring(7, 8);
	
			fieldObj.value = month + '/' + day + '/' + year + ' ' + time;
		}
	}
	
	if (!isValidDateTime(fieldObj.value))
	{
		if (msg == "")
			msg = "Invalid date/time.  Correct format is : Month/Day/Year hh:mm:ss xx";
			
		alert(msg);
		fieldObj.select();
		return false;
	}	
	
	return true;
}

function editTime(fieldObj, msg)
{
	if (fieldObj.disabled)
		return true;

	fieldObj.value = trim(fieldObj.value);

	if (!isValidTime(fieldObj.value) || fieldObj.value.length < 6)
	{
		if (msg == "")
			msg = "Invalid time.  Correct format is : hh:mm:ss xx";
			
		alert(msg);
		fieldObj.select();
		return false;
	}	
	
	return true;
}

function editDate(fieldObj, msg)
{
	if (fieldObj.disabled)
		return true;

	var pos1;
	var pos2;
	var pos3;
	var pos4;
	var pos5;
	var pos6;
	var pos7;
	var pos8;
	var month;
	var day;
	var year;

	fieldObj.value = trim(fieldObj.value);

	pos1 = fieldObj.value.substring(0, 1);
	pos2 = fieldObj.value.substring(1, 2);
	pos3 = fieldObj.value.substring(2, 3);
	pos4 = fieldObj.value.substring(3, 4);
	pos5 = fieldObj.value.substring(4, 5);
	pos6 = fieldObj.value.substring(5, 6);
	pos7 = fieldObj.value.substring(6, 7);
	pos8 = fieldObj.value.substring(7, 8);

	if (isPositiveInteger(fieldObj.value))
	{
		month = pos1 + pos2;
		day = pos3 + pos4;
		year = pos5 + pos6 + pos7 + pos8;

		
		fieldObj.value = month + '/' + day + '/' + year;
	}
	
	if (!isValidDate(fieldObj.value))
	{
		if (msg == "")
			msg = "Invalid date.  Correct format is : Month/Day/Year";
			
		alert(msg);
		fieldObj.select();
		return false;
	}

	// Convert 2 digit year to 4 digits


	if (!isPositiveInteger(pos2) && !isPositiveInteger(pos4))
	{ 	// m/d/....
		month = "0" + fieldObj.value.substring(0, 1);
		day = "0" + fieldObj.value.substring(2, 3);
		year = fieldObj.value.substring(4, fieldObj.value.length);
	}
	else
	if (!isPositiveInteger(pos3) && !isPositiveInteger(pos5))
	{ 	// mm/d/....
		month = fieldObj.value.substring(0, 2);
		day = "0" + fieldObj.value.substring(3, 4);
		year = fieldObj.value.substring(5, fieldObj.value.length);
	}
	else
	if (!isPositiveInteger(pos2) && !isPositiveInteger(pos5))
	{ 	// m/dd/....
		month = "0" + fieldObj.value.substring(0, 1);
		day = fieldObj.value.substring(2, 4);
		year = fieldObj.value.substring(5, fieldObj.value.length);
	}
	else
	{ // mm/dd/....
		month = fieldObj.value.substring(0, 2);
		day = fieldObj.value.substring(3, 5);
		year = fieldObj.value.substring(6, fieldObj.value.length);
	}
	
	if (year.length == 2)
	{
		if (parseInt(year) < 71)

			year = "20" + year;
		else
			year = "19" + year;
	}
	else
	if (year.length == 1)
	{
		year = "200" + year;
	}

	fieldObj.value = month + '/' + day + '/' + year;

	return true;
}

function currentDate()
{
	var currentMonth;
	var dateString;
	var currentDate;
	
	currentDate = new Date();
	
	currentMonth = currentDate.getMonth() + 1;
	
	dateString = currentMonth + '/' + currentDate.getDate() + '/' + currentDate.getYear();
	
	return dateString;
}

function currentTime()
{
	var hours;
	var minutes;
	var seconds;
	var amPm;
	var timeString;
	
	var currentDate;
	
	currentDate = new Date();
	
	hours = currentDate.getHours();
	if (hours > 12)
	{
		hours -= 12;
		amPm = "PM";
	}	
	else
	{
		amPm = "AM";
		if (hours == 0)
			hours = 12;
	}
	
	if (hours < 10)
		hours = "0" + hours;
		
	minutes = currentDate.getMinutes();
	if (minutes < 10)
		minutes = "0" + minutes;
	
	seconds = currentDate.getSeconds();
	if (seconds < 10)
		seconds = "0" + seconds;

	timeString = hours + ':' + minutes + ':' + seconds + ' ' + amPm;
	
	return timeString;
}

function setToCurrentDate(dateObj)
{	
	dateObj.value = currentDate();
}

function setToCurrentDateTime(dateObj)
{	
	dateObj.value = currentDate() + ' ' + currentTime();
}

function fieldObjSub(frmName, fieldObj)
{
	var i;
	
	for (i = 0; i < frmName.length; i++)
		if (frmName.elements[i].name == fieldObj.name)
			return i;
	
	return -1;
}

function focusNext(frmName, fieldObj)
{
	var i;
	
	i = fieldObjSub(frmName, fieldObj);
	
	if (i < 0)
		return;
		
	i++;
	for (i = i; i < frmName.length; i++)
		if (frmName.elements[i].disabled == false)
		{
			frmName.elements[i].focus();
			break;
		}			
}

function formattedPhoneNo(str)
{
	var areaCode, exchange, ext, number;
	
	if (!isPositiveInteger(str))
		return str;
		
	areaCode = str.substring(0,3);
	exchange = str.substring(3,6);
	ext = str.substring(6,str.length);
	
	number = areaCode + '-' + exchange + '-' + ext;
	

	return number;	
}

function isValidPhoneNumber(str)
{
	var areaCode, exchange, ext, number;

	areaCode = str.substring(0,3);
	firstDash = str.substring(3,4);
	exchange = str.substring(4,7);
	secondDash = str.substring(7,8);
	ext = str.substring(8,str.length);

	if (!isPositiveInteger(areaCode))
		return false;

	if (firstDash != "-")
		return false;

	if (!isPositiveInteger(exchange))
		return false;

	if (secondDash != "-")
		return false;

	if (!isPositiveInteger(ext))
		return false;

	return true;
}

function editPhoneNumber(fieldObj, msg)
{
	if (fieldObj.disabled)
		return true;

	if (isPositiveInteger(fieldObj.value) && fieldObj.value.length == 10)
	{
		fieldObj.value = formattedPhoneNo(fieldObj.value);
		return true;
	}

	if (!isValidPhoneNumber(fieldObj.value))
	{
		if (msg == "")
			msg = "Invalid phone number format - must be '999-999-9999'";

		alert(msg);
		fieldObj.focus();
		return false;
	}

	return true;
}

function formattedSsn(str)
{
	var first, second, third, number;
	
	if (!isPositiveInteger(str))
		return str;
		
	first = str.substring(0,3);
	second = str.substring(3,5);
	third = str.substring(5,str.length);
	
	number = first + '-' + second + '-' + third;
	
	return number;	
}

function isValidSsn(str)
{
	var first, second, third;

	if (str.length != 11)
		return false;

	first = str.substring(0,3);
	firstDash = str.substring(3,4);
	second = str.substring(4,6);
	secondDash = str.substring(6,7);
	third = str.substring(7,str.length);

	if (!isPositiveInteger(first))
		return false;

	if (firstDash != "-")
		return false;

	if (!isPositiveInteger(second))
		return false;

	if (secondDash != "-")
		return false;

	if (!isPositiveInteger(third))
		return false;

	return true;
}

function editSsn(fieldObj, msg)
{
	if (fieldObj.disabled)
		return true;

	//if (isPositiveInteger(fieldObj.value) && fieldObj.value.length == 9)
	//{
	//	fieldObj.value = formattedSsn(fieldObj.value);

	//	return true;
	//}

	if (!isValidSsn(fieldObj.value))
	{
		if (msg == "")
			msg = "Invalid Social Security# format - must be '999-99-9999'";

		alert(msg);
		fieldObj.focus();
		return false;
	}

	return true;
}

function uniCodeEncode(str)
{
	var outStr;
	var i;

	outStr = '';
	for (i = 0; i < str.length; i++)
		if (str.charAt(i) == '&')
			outStr += "&amp;";
		else
			outStr += str.charAt(i);
			
	return outStr;
}

function xmlSubmitForm(formObj, action)
{
	var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	var xmlForm;
	var i;
	
	xmlDoc.async="false";
	xmlhttp.Open("POST", action, false);

	nline = String.fromCharCode(13) + String.fromCharCode(10)
	xmlForm = "<?xml version='1.0'?>" + nline;
	xmlForm += "<FORM>" + nline;
	
	for (i = 0; i < formObj.length; i++)
	{
		if (isBlank(formObj.elements[i].name))
			return (formObj.name + ".elements[" + i + "] missing name attribute");

		xmlForm += '<' + formObj.elements[i].name + '>' + nline;

		if (formObj.elements[i].type == "checkbox" || formObj.elements[i].type == "radio")
			xmlForm += formObj.elements[i].checked;
		else
		if (formObj.elements[i].selectedIndex >= 0)
			xmlForm += uniCodeEncode(formObj.elements[i][formObj.elements[i].selectedIndex].value);
		else
			xmlForm += uniCodeEncode(formObj.elements[i].value) + nline;

		xmlForm += '</' + formObj.elements[i].name + '>' + nline;
	}
	
	xmlForm += "</FORM>";
	xmlhttp.Send(xmlForm);
	
	return xmlhttp.responseText;
}

function xmlAppendRecord(formObj, xmlDoc)
{	
	var root;
	var itemNode;
	var i;

	root = xmlDoc.documentElement;
	itemNode = xmlDoc.createElement("Record");
	xmlDoc.documentElement = root;
	
	for (i = 0; i < formObj.length; i++)
	{
		itemNode.appendChild(xmlDoc.createElement(formObj.elements[i].name));
		if (formObj.elements[i].type == "checkbox" || formObj.elements[i].type == "radio")
			itemNode.childNodes[i].text = formObj.elements[i].checked;
		else
			itemNode.childNodes[i].text = formObj.elements[i].value;
	}
	
	root.appendChild(itemNode);	
	
	return false;
}

function xmlPassRecordSet(xmlObj, action)
{	
	var xmlDoc = new ActiveXObject("Microsoft.XMLDOM")
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	
	xmlDoc.async="false";

	xmlhttp.Open("POST", action, false);
	xmlDoc.load(xmlObj.name + '.xml');

	xmlhttp.Send(xmlObj.XMLDocument);

	return xmlhttp.responseText;
}

function xmlDeleteRecordSet(xmlObj)
{
	var rootNode;
	var i;
		
	rootNode = xmlObj.documentElement;
	
	for (i = rootNode.childNodes.length - 1; i >= 0; i--)
		rootNode.removeChild(rootNode.childNodes.item(i));
}

function xmlDeleteRecord(xmlObj, keyFieldName, keyFieldValue)
{
	var rootNode;
	var i;
	var recNum;
		
	rootNode = xmlObj.documentElement;
	
	for (i = rootNode.childNodes.length - 1; i >= 0; i--)
		if (xmlGetFieldValue(xmlObj, i, keyFieldName) == keyFieldValue)
		{
			rootNode.removeChild(rootNode.childNodes.item(i));
			return true;
		}
	
	return false;
}

function xmlBinDeleteRecord(xmlObj, keyFieldName, keyFieldValue)
{
	var i;
	var rootNode;
	var upper, lower, midPoint;
	var result;
	
	rootNode = xmlObj.documentElement;
	
	lower = 0;
	upper = rootNode.childNodes.length - 1;

	while (true)
	{		
		midPoint = lower + Math.round((upper - lower) / 2);
		result = xmlGetFieldValue(xmlObj, midPoint, keyFieldName);		
		if (result == keyFieldValue)
		{
			
rootNode.removeChild(rootNode.childNodes.item(midPoint));
			return true;
		}

		if (lower == upper)
			return false;

		if (result > keyFieldValue)
			upper = midPoint - 1;
		else
			lower = midPoint + 1;
	}
}

function xmlResequence(xmlObj)
{
	var rootNode;
	var i;
	var recNum;
		
	rootNode = xmlObj.documentElement;
	
	for (i = 0; i < rootNode.childNodes.length; i++)
		xmlSetFieldValue(xmlObj, i, "xmlrecord_id", i + 1);
}

function xmlGetFieldValue(xmlObj, recno, fieldName)
{
	var rootNode;
	var i;
	
	rootNode = xmlObj.documentElement;
	
	for (i = 0; i < rootNode.childNodes(recno).childNodes.length ; i++)
		if (rootNode.childNodes(recno).childNodes(i).baseName.toUpperCase() == fieldName.toUpperCase())
			return rootNode.childNodes(recno).childNodes(i).text;
			
	return null;
}

function xmlSearchRecordSet(xmlObj, keyFieldName, keyFieldValue, resultFieldName)
{
	var i;
	var rootNode;
	
	rootNode = xmlObj.documentElement;
	
	for (i = 0; i < rootNode.childNodes.length; i++)
		if (xmlGetFieldValue(xmlObj, i, keyFieldName) == keyFieldValue)
			return xmlGetFieldValue(xmlObj, i, resultFieldName);

	return null;
}

function xmlBinSearchRecordSet(xmlObj, keyFieldName, keyFieldValue, resultFieldName)
{
	var i;
	var rootNode;
	var upper, lower, midPoint;
	var result;
	
	rootNode = xmlObj.documentElement;
	
	lower = 0;
	upper = rootNode.childNodes.length - 1;

	while (true)
	{		
		midPoint = lower + Math.round((upper - lower) / 2);
		result = xmlGetFieldValue(xmlObj, midPoint, keyFieldName);		
		if (result == keyFieldValue)
			return xmlGetFieldValue(xmlObj, midPoint, resultFieldName);

		if (lower == upper)
			return null;

		if (result > keyFieldValue)
			upper = midPoint - 1;
		else
			lower = midPoint + 1;
	}
}

function xmlSetFieldValue(xmlObj, recno, fieldName, fieldValue)
{
	var rootNode;
	var i;
	
	rootNode = xmlObj.documentElement;
	
	for (i = 0; i < rootNode.childNodes(recno).childNodes.length ; i++)
		if (rootNode.childNodes(recno).childNodes(i).baseName.toUpperCase() == fieldName.toUpperCase())
		{
			rootNode.childNodes(recno).childNodes(i).text = fieldValue;
			return true;
		}
			
	return false;
}

function xmlUpdateRecordSet(xmlObj, keyFieldName, keyFieldValue, changeFieldName, changeFieldValue)
{
	var i;
	var rootNode;
	
	rootNode = xmlObj.documentElement;
	
	for (i = 0; i < rootNode.childNodes.length; i++)
		if (xmlGetFieldValue(xmlObj, i, keyFieldName) == keyFieldValue)
			return xmlSetFieldValue(xmlObj, i, changeFieldName, changeFieldValue);

	return false;
}

function xmlBinUpdateRecordSet(xmlObj, keyFieldName, keyFieldValue, changeFieldName, changeFieldValue)
{
	var i;
	var rootNode;
	var upper, lower, midPoint;
	var result;
	
	rootNode = xmlObj.documentElement;
	
	lower = 0;
	upper = rootNode.childNodes.length - 1;

	while (true)
	{		
		midPoint = lower + Math.round((upper - lower) / 2);

		result = xmlGetFieldValue(xmlObj, midPoint, keyFieldName);		
		if (result == keyFieldValue)
			return xmlSetFieldValue(xmlObj, midPoint, changeFieldName, changeFieldValue);

		if (lower == upper)
			return false;

		if (result > keyFieldValue)
			upper = midPoint - 1;
		else
			lower = midPoint + 1;
	}
}

function trimFormFields(formObj)
{
	var i;
	
	for (i = 0; i < formObj.length; i++)
		formObj.elements[i].value = trim(formObj.elements[i].value);
}

function formToUpperCase(formObj)
{
	var i;
	
	for (i = 0; i < formObj.length; i++)
		if (formObj.elements[i].type == "text" || formObj.elements[i].type == "select-one" || formObj.elements[i].type == "select-multiple" || formObj.elements[i].type == "textarea" || formObj.elements[i].type == "password")
			formObj.elements[i].value = formObj.elements[i].value.toUpperCase();
}

function nthWord(inString, n)
{
	var i, j;
	var startPos;
	var str;
	var restOfStr;
	
	if (n < 1 || n > inString.length)
		return null;

	if (inString.length == 1)
		if (n == 1)
			return inString;
		else
			return null;

	str = ' ' + trim(inString) + ' ';
	
	
	//find nth non-blank character preceded by a space
	j = 0;
	for (i = 1; i < str.length; i++)
	{
		if (str.charAt(i - 1) == ' ' && str.charAt(i) > ' ')
		{
			j++;
			if (j == n)
			{
				//find trailing space
				restOfStr = str.substring(i, str.length);				
				return restOfStr.substring(0, 
				restOfStr.indexOf(' '));
			}		
		}		
	}
	
	return null;
}

function nthSubString(inString, n)
{
	return nthWord(inString, n);
}

function pad(field, length, justify, withThis)
{
	var numOfSpaces;
	var i;
	var workField;
		
	field = trim(field + ' ');
	
	if (!field.length)
		field = "";

	numOfSpaces = length - field.length;			
	
	switch (justify.toUpperCase()) {
	case "L" :
		workField = field;
		for (i = 1; i <= numOfSpaces; i++)
			workField += withThis;
		break;
	case "R" :
		workField = "";
		for (i = 1; i <= numOfSpaces; i++)
			workField += withThis;
			
		workField += field;
		break;
	}
        
	return workField;
}

function removeWord(str1, str2)
{
	var tempStr;
	var idx;
	
	tempStr = ' ' + str1 + ' ';
	
	idx = tempStr.indexOf(' ' + str2 + ' ');
	
	if (idx < 0)
		return str1;
		
	idx--;

	return str1.substring(0, idx) + str1.substring(idx + 1 + str2.length, str1.length);
}

function extractStr(str1, str2)
{
	return removeWord(str1, str2);
}

/*
function selectDropDown(formObj, value)
{
	var i;
	
	for (i = 0; i < formObj.length; i++)
		if (formObj[i].value == value)
		{
			formObj.selectedIndex = i;
			break;
		}
}
*/

function resetForm(formName)
{
	for (var i = 0; i < formName.length; i++)
	{	
	
		if (formName.elements[i].type == "text")
			formName.elements[i].value = "";
		
		if (formName.elements[i].type == "select-one")
			formName.elements[i].selectedIndex = 0;

		if (formName.elements[i].type == "select-multiple")
			formName.elements[i].selectedIndex = 0;

		if (formName.elements[i].type == "textarea")
			formName.elements[i].value = "";

		if (formName.elements[i].type == "checkbox")
			formName.elements[i].checked = false;

		if (formName.elements[i].type == "radio")
			formName.elements[i].selected = false;
	}
}

function request(name)
{
	var strptr;
	var wrkstr;
	var work_query_string;
	var srch;



	if (isBlank(name)) /* no field name specified */
		return null;

	/* precede the field name with '&' */
	wrkstr = '&' + name + '=';
    
	srch = document.location.search;
    
	srch = srch.substring(1, srch.length)
	/* work_query_string = query_string preceded by '&' */
	work_query_string = '&' + srch;
    
	/* search for field name in query string */
	strptr = 0;
        
	strptr = work_query_string.indexOf(wrkstr);
	if (strptr < 0)
		return null;

	/* advance string pointer to the contents after the '=' */
	strptr += wrkstr.length;
    
	var tempstr = work_query_string.substring(strptr, work_query_string.length)
    
	var strendptr = tempstr.indexOf('&');
    
	if (strendptr < 0)
		return tempstr;
		
	return tempstr.substring(0, strendptr);
}

function editEmail(fieldObj, msg)
{
	if (fieldObj.disabled)
		return true;

	if (!isValidEmail(fieldObj.value))
	{
		if (trim(msg) == "")
			msg = "Invalid email address";

		alert(msg);
		fieldObj.focus();
		return false;
	}

	return true;
}

function isValidEmail(email)
{
	if (trim(email) == "")
		return false;

	var pos = email.indexOf("@");

	if (pos <= 0)
		return false;

	if (pos >= email.length - 3)
		return false;

	if (!isAlphaNumeric(email.charAt(pos - 1)))
		return false;

	if (!isAlphaNumeric(email.charAt(pos + 1)))
		return false;

	pos = email.indexOf(".");
	if (pos < 1)
		return false;

	for (pos = email.length - 1; pos >= 0; pos--)
	{
		if (email.charAt(pos) == ".")
			break;
	}

	if (pos + 1 == email.length)
		return false;

	if (!isAlphaNumeric(email.charAt(pos - 1)))
		return false;

	if (!isAlphaNumeric(email.charAt(pos + 1)))
		return false;

	return true;
}

function isValidZipCode(str)
{
	if (!isPositiveInteger(str.substring(0, 5)))
		return false;

	if (str.length == 5)
		return true;

	if (str.length != 10)
		return false;

	if (str.substring(5, 6) != "-" && str.substring(5, 6) != " " && str.substring(5, 6) != "")
		return false;

	if (!isPositiveInteger(str.substring(6, str.length)))
		return false;

	return true;
}

function editZipCode(fieldObj, msg)
{
	if (!isValidZipCode(fieldObj.value))
	{
		if (msg.length > 0)
			alert(msg);
		else
			alert("Invalid Zip Code Format - must be either 99999 or 99999-9999");

		fieldObj.focus();
		return false;
	}

	return true;
}

function isAlpha(str)
{	
	var i;

	str = trim(str);
		
	if (!str.length)
		return false;
		
	for (i = 0; i < str.length; i++)
	{
		if ((str.charAt(i) >= "a" && str.charAt(i) <= "z") || (str.charAt(i) >= "A" && str.charAt(i) <= "Z"))
			continue;

		return false;
	}
			
	return true;
}

function editAlpha(fieldObj, msg)
{
	if (containsNumeric(fieldObj.value))
	{
		if (msg.length > 0)
			alert(msg);
		else
			alert("Field must be alphabetic");

		fieldObj.focus();
		return false;
	}

	return true;
}

function containsNumeric(str)
{
	var i;

	str = trim(str);
		
	if (!str.length)
		return true;
		
	for (i = 0; i < str.length; i++)
		if (isDigit(str.charAt(i)))
			return true;

	return false;
}

function isAlphaNumeric(str)
{
	if (!isAlpha(str) && !isPositiveInteger(str))
		return false;

	return true;
}

function changeRow(formObj, fieldObj, fieldsPerRow)
{
	var sub = fieldObjSub(formObj, fieldObj);
	
	switch (window.event.keyCode) {
	case 40:
		sub += fieldsPerRow;
		break;
	case 38:
		sub -= fieldsPerRow;
		break;
	default:
		return;
	}
	
	if (sub < 0 || sub >= formObj.length)
		return;

	setTimeout("document." + formObj.name + ".elements[" + sub + "].focus()",175);
}

function doubleUpQuotes(str)
{
	if (str.indexOf("'") < 0)
		return str;

	var tempStr = "";

	for (var i = 0; i < str.length; i++)
	{
		tempStr += str.substring(i, i + 1);

		if (str.substring(i, i + 1) == "'")
			tempStr += "'";
	}

	return tempStr;
}

function doubleUpQuotesOnForm(formObj)
{
	for (var i = 0; i < formObj.length; i++)
	{
		if (formObj.elements[i].type != "text" && formObj.elements[i].type != "hidden")
			continue;

		formObj.elements[i].value = doubleUpQuotes(formObj.elements[i].value);
	}
}

function replaceAll(searchIn, searchFor, replaceWith)
{
	var tempStr = searchIn;
	
	while (tempStr.indexOf(searchFor) > -1)
	{
		tempStr = tempStr.replace(searchFor, replaceWith);
	}
	
	return tempStr;
}

function getCookieValue(name)
{
	var strPtr;
	var workStr;
	var workCookieString;
	var srch;


	if (isBlank(name))
		return null;

	workStr = ';' + name + '=';
    
	srch = document.cookie;
    
	workCookieString = ';' + srch;
    
	strPtr = 0;
	
	strPtr = workCookieString.indexOf(workStr);
	if (strPtr < 0)
		return null;

	strPtr += workStr.length;
    
	var tempStr = workCookieString.substring(strPtr, workCookieString.length)
    
	var strEndPtr = tempStr.indexOf(';');
    
	if (strEndPtr < 0)
		return tempStr;
		
	return tempStr.substring(0, strEndPtr);
}

function setCookieValue(name, value)
{
	document.cookie = name + "=" + value + ";";
}

function formatDate(fieldObj)
{
	var separator1 = 1;
	var separator2 = 4;
	var currentByte = fieldObj.value.substring(fieldObj.value.length - 1, fieldObj.value.length);
	var currentPos = fieldObj.value.length - 1;
	var mm = "";
	var dd = "";
	var year = "";


	if (fieldObj.value.length > 1)
		mm = fieldObj.value.substring(0, 2);

	if (fieldObj.value.length > 4)
		dd = fieldObj.value.substring(3, 5);

	if (fieldObj.value.length > 7)
		year = fieldObj.value.substring(3, fieldObj.value.length);

	if (!isDigit(currentByte))
	{
		fieldObj.value = fieldObj.value.substring(0, fieldObj.value.length - 1);
		return;
	}


	if (currentPos == 0 && currentByte > "1")
	{
		fieldObj.value = fieldObj.value.substring(0, fieldObj.value.length - 1);
		return;
	}

	if (currentPos == separator1)
	{
		if (mm > "12")
		{
			fieldObj.value = fieldObj.value.substring(0, fieldObj.value.length - 1);
			return;
		}
	}

	if (currentPos == separator2 - 1)
	{
		if (currentByte > "3" ||(mm == "02" && currentByte > "2"))
		{
			fieldObj.value = fieldObj.value.substring(0, fieldObj.value.length - 1);
			return;
		}
	}

	if (currentPos == separator2)
	{
		switch (mm) {
		case "01" :
		case "03" :
		case "05" :
		case "07" :
		case "08" :
		case "09" :
		case "10" :
		case "12" :
			if (dd > "31")
			{
				fieldObj.value = fieldObj.value.substring(0, fieldObj.value.length - 1);
				return;
			}

			break;
		case "02" :
			if (dd > "29")
			{
				fieldObj.value = fieldObj.value.substring(0, fieldObj.value.length - 1);
				return;
			}

			break
		default :
			if (dd > "30")
			{
				fieldObj.value = fieldObj.value.substring(0, fieldObj.value.length - 1);
				return;
			}
		}
	}

	if (currentPos == separator1 || currentPos == separator2)
		fieldObj.value += "/";
}

function formatNumericField(fieldObj, delimiter, separator1, separator2)
{
	var currentByte = fieldObj.value.substring(fieldObj.value.length - 1, fieldObj.value.length);
	var currentPos = fieldObj.value.length - 1;

	if (!isDigit(currentByte))
	{
		fieldObj.value = fieldObj.value.substring(0, fieldObj.value.length - 1);
		return;
	}

	if (currentPos == separator1 || currentPos == separator2)
		fieldObj.value += delimiter;
}

function formatSsn(fieldObj)
{
	formatNumericField(fieldObj, "-", 2, 5);
}

function formatPhoneNo(fieldObj)
{
	formatNumericField(fieldObj, "-", 2, 6);
}


