function trim(inputString) {
   // Removes leading and trailing spaces from the passed string. Also removes
   // consecutive spaces and replaces it with one space. If something besides
   // a string is passed in (null, custom object, etc.) then return the input.
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }
   return retValue; // Return the trimmed string back to the user
} // Ends the "trim" function

function CheckName(Name){
	var valid = 1;
	var BadChars ="0123456789!~-+@#$%^&*(){\_=><}/|";
	var i = 0;
	for (i =0; i <= Name.length -1; i++) {
	  for(j =0; j <= BadChars.length -1; j++) {
	    if ( Name.charAt(i) == BadChars.charAt(j)) {
            valid = 0;
	     break;
	  } // End if statement
	 } // End for loop
	  if(valid==0) break;
	} // End for loop
	if (valid==1 ) return true;
	else
	{
	alert("The name contains invalid characters");
	return false;
	}
}// End of Check Name function


function CheckPhoneNumber(TheNumber) {
if (TheNumber.length==1){
if (TheNumber.charAt(0)==0) return false;
}
if (TheNumber.length<7) return false;
	var valid = 1
	var GoodChars = "0123456789-+/ ,"
	var i = 0
	for (i =0; i <= TheNumber.length -1; i++) {
	 if (GoodChars.indexOf(TheNumber.charAt(i)) == -1) {
	  valid = 0
	 } // End if statement
	} // End for loop
	return valid
}// End of Check phone number


function checkEnter(e){ 
var characterCode  ;
characterCode = e.keyCode ;
if(characterCode == 13){
	 return false; 
	 }
	 else{
	 return true;
	 }
}// End of checkEnter

function isDigit (c) {
  return ( (c >= '0') && (c <=  '9') )
}
// End of digit checking

function Trim (field) {
	var val=field.value;
	while(''+val.charAt(0)==' ') {
		field.value=val.substring (1,val.length);
		val=field.value;
	}
} // End of triming function

