


function clearCharacters( oCtrl ) {
	oCtrl.value = oCtrl.value.replace(/\D/g,'');
}

function focusNext( oCtrl, NextCtrlID ) {
	if(oCtrl.value.length==3)
	{
		if (document.getElementById(NextCtrlID))
			document.getElementById(NextCtrlID).focus();
	}
}

function check3Phone( PhoneFieldID1, PhoneFieldID2, PhoneFieldID3, isRequired )
{
	
	if( (document.getElementById(PhoneFieldID1)) && (document.getElementById(PhoneFieldID2)) && (document.getElementById(PhoneFieldID3)) )
	{
		var PhoneField1 = document.getElementById(PhoneFieldID1);
		var PhoneField2 = document.getElementById(PhoneFieldID2);
		var PhoneField3 = document.getElementById(PhoneFieldID3);
		
		if ((PhoneField1.value.length > 0 ) || (PhoneField2.value.length > 0) || (PhoneField3.value.length > 0)) {
			
			if (PhoneField1.value.length < 3 ) {
				alert('This field must be a 3 digit from an U.S. phone number (like 415-555-1212)');
				PhoneField1.focus();
				return false;
			}
			if (PhoneField2.value.length < 3) {
				alert('This field must be a 3 digit from an U.S. phone number (like 415-555-1212)');
				PhoneField2.focus();
				return false;
			}
			if (PhoneField3.value.length < 4) {
				alert('This field must be a 4 digit from an U.S. phone number (like 415-555-1212)');
				PhoneField3.focus();
				return false;
			}
		}
		else
		{
			if ( isRequired ) 
			{
				alert("Please enter Phone ");
				PhoneField1.focus();
				return false;
			}
		}
	}
	
	return true;
}


function isZip (str) // format NNNNN or NNNNN-NNNN
{
	if (str.length!=5 && str.length!=10)
	{	
		return false;
	
	}
		
	for (var i=0; i < str.length; i++) 
	{
		if(str.length == 5 && parseInt(str.charAt(i)) != str.charAt(i))
		{
			return false;
		}
		if(str.length == 10 && str.charAt(5) != "-")
		{
			return false;
		}			
		if(str.length == 10 && (i != 5 && parseInt(str.charAt(i)) != str.charAt(i)))		
		{		
			return false;
		}
	}

	return true;
} 


function isEmail(string) {
    if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
        return true;
    else
        return false;
}

// Check whether string s is empty.

function isEmpty(s){
  return ((s == null) || (s.length == 0));
}

// Returns true if string s is empty or whitespace characters only.
function isWhitespace (s){ 
    //return (isEmpty(s)) ;
      return ((s == null) || (s.replace( / /g, "").length == 0));
}







