
//this function checks if SSN is a number of 9 characters and format it as
// xxx-xx-xxxx

function ValidateCardIDNumber()
 {
 var CardID = document.getElementById('sId');
 var template = /^\d{9}$|^\z\z\d{7}$/
 var cardvalue = CardID.value
 
 if (!template.test(cardvalue))
	{
	alert('The card ID number should be 9 character long');
	CardID.value='';
	CardID.focus();
	return
	}
	}
 
 /*var nums = CardID.value.replace(/[^0-9]/ig, '');
 if (!nums)
	 { 
	 
	 //alert ('Social Security should be only numbers');
	 //SSN.value ='';
	 //SSN.focus();
	 //return;
	} 
	if (nums.length == 9)
	 {
	//SSN.value = nums.substring(0, 3) + '-' + 
	//nums.substring(3, 5) + '-' + 
	//nums.substring(5, 9); 
	}
	 else 
	 { 
		alert('Card ID number should be 9 character long');
		CardID.value = ''; 
		CardID.focus();
		
	}*/
	

function FormatPhone()
 {
 var Phone = document.getElementById('sPhone');
 var nums = Phone.value.replace(/[^0-9]/ig, '');
 if (!nums)
	 { 
	 return;
	} 
	if (nums.length == 10)
	 {
	Phone.value = nums.substring(0, 3) + '-' + 
	nums.substring(3, 6) + '-' + 
	nums.substring(6, 10); 
	}
	 
}	

function Trim(sString) 
{
	while (sString.substring(0,1) == ' ')
	{
		sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' ')
	{
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}
