function validateSSN(ctrl)
{
	var sSSN=ctrl.value;
	if(sSSN.length>0)
	{
		if(!validSSN(sSSN))
		{
			alert("Please enter a valid social security number in the format '999-99-9999'.");
			ctrl.focus();
			return false;
		}
		ctrl.value=formatSSN(sSSN);
	}
	return true;
}

function validateZipCode(ctrl)
{
	var sZip=ctrl.value;
	if(sZip.length>0)
	{
		if(!validZip(sZip))
		{
			alert("Please enter a valid zip code in the format '99999-9999'.");
			ctrl.focus();
			return false;
		}
		ctrl.value=formatZip(sZip);
	}
	return true;
}

function validateCurrency(ctrl /*[,allowNegative]*/)
{
	var allowNegative = false;
	if (( arguments.length > 1 ) && ( typeof(arguments[1]) == "boolean" ))
	{
		var allowNegative = arguments[1];
	}
	
	var sPayment=ctrl.value;
	if(sPayment.length>0)
	{
		if(!validCurrency(sPayment))
		{
			alert("Please enter a valid monetary amount.");
			ctrl.focus();
			return false;
		}
		
		if ( allowNegative == false )
		{
			if ( parseFloat(stripNonNumeric(sPayment)) < 0 )
			{
				alert("Please enter a valid positive monetary amount.");
				ctrl.focus();
				return false;
			}
		}
		ctrl.value=formatCurrency(sPayment);
	}
	return true;
}

function validatePhone(ctrl)
{
	var sPhone=ctrl.value;
	if(sPhone.length>0)
	{
		if(!validPhone(sPhone))
		{
			alert("Please enter a valid telephone number in the format '(999)999-9999'.");
			ctrl.focus();
			return false;
		}
		ctrl.value=formatPhone(sPhone);
	}
	return true;
}

function validateDate(ctrl)
{
	var sDate=ctrl.value;
	if(sDate.length>0)
	{
		if(!validDate(sDate))
		{
			alert("Please enter a valid date in the format 'MM/DD/YYYY'.");
			ctrl.focus();
			return false;
		}
		ctrl.value=formatDate(sDate);
	}
	return true;
}
