function Trim(s) 
   {
   	// Remove leading spaces and carriage returns
   	while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r'))
   	 { s = s.substring(1,s.length); }
     
   	// Remove trailing spaces and carriage returns
 while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r'))
   	 { s = s.substring(0,s.length-1); }
     
   	return s;
   }
   
   
function check_phone(inputtxt)  
{  
  var phoneno = /^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/;  
  if((inputtxt.match(phoneno))){  
    	return true;  
	} else {          
		return false;  
	}  
}  

function checkEmail(str){		   
   var filter=/^.+@.+\..{2,3}$/ 		
   if (filter.test(str))		
		 {		  		
			return true;
		 }		
	  else		
		 {       						
		 return false;		
		 }  
}   

function isAlphaNum(s){ 
	p = /([0-9].*[a-z])|([a-z].*[0-9])/g;
	return p.test(s);
}

function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
}
function numOnly(field, event)
{
 var key,keychar;

 if (window.event)
   key = window.event.keyCode;
 else if (event)
    key = event.which;
 else
    return true;
 
 keychar = String.fromCharCode(key);

var valid_str="0123456789.";
  // then check for the numbers 

 if ((key==null) || (key==0) || (key==8) || 
     (key==9) || (key==13) || (key==27) )
   return true;

  else if ((valid_str.indexOf(keychar) > -1))
         {
           window.status = "";
           return true;
         }
       else
         {
           window.status = "Field accepts Alphabetical characters only"; 
           return false;
         }
	return false;	 
 }