function isEMail(s)
	{
		if(((s.indexOf("@"))==-1) || ((s.indexOf("."))==-1))
		{
			return true ;  
		}else{
			var x=s;
			var ctr=0;
			var dot=0;
			for(j=0;j<x.length;j++)
			{
				if(x.charAt(j)=="@"){
					ctr++;
				}
				if(x.charAt(j)=="."){
					dot++;
				}
			}
			if(ctr!=1){
				return true;
			}else{
				return false;
			}
		}
	}
function valid_phone_format(phone_num){

var re= /\D/;
// test for this format: (xxx)xxx-xxxx
var re2 = /^\({1}\d{3}\)\d{3}-\d{4}/; 
// test for this format: xxx-xxx-xxxx
//var re2 = /^\d{3}-\d{3}-\d{4}/;

//for (i=0; i<nums.length;i++){
var num=phone_num;
//alert(num);alert(num.length);
var newNum;
 if (num != "" && re2.test(num)!=true){
   if (num != ""){
     while (re.test(num)){
     num = num.replace(re,"");
     }
   }
	//alert(num.length);   
  if (num.length != 10){
    return false
      }
   else {
     // for format (xxx)xxx-xxxx
     newNum = '(' + num.substring(0,3) + ')' + num.substring(3,6) + '-' + num.substring(6,10);
	 //alert("rajesh");
	 //alert (newNum);
     // for format xxx-xxx-xxxx
     // newNum = num.substring(0,3) + '-' + num.substring(3,6) + '-' + num.substring(6,10);
     return newNum;
     }
   }
   else{
   return num;
   }
 // }
}
  
	function isValidEmail(s)
	{
		var myRe;
		var myArr;
		myRe = new RegExp("\[^a-zA-Z0-9_@.-]");
		//myRe=/[`~\#\$\{\}\;\:\"@,.|></]/;
		myArr=myRe.test(s);
		if(myArr){ 
			return myArr
		}else{
			if(s.length<=3){
				return true;
			}
			ch=isEMail(s)
			if(ch){
				return true;
			}else{
				return false;
			}
		}
	}
	function isAlphaNumeric(s)
	{
		var myRe;
		var myArr;
		myRe = new RegExp("\[a-zA-Z0-9_]");
		myArr=myRe.test(s);
		return myArr;	
	}
	function isCharacter(s)
	{
		var myRe;
		var myArr;
		myRe = new RegExp("\[^a-zA-Z]");
		myArr=myRe.test(s);
		return myArr;	
	}
	function isNumeric(s)
	{
		var myRe;
		var myArr;
		myRe = new RegExp("\[^0-9]");
		myArr=myRe.test(s);
		return myArr;	
	}
	function isZip(s)
	{
		var myRe;
		var myArr;
		myRe = new RegExp("\[^0-9a-zA-Z]");
		myArr=myRe.test(s);
		return myArr;	
	}
	function isPhone(s)
	{
		var myRe;
		var myArr;
		myRe = new RegExp("\[^0-9/-/(/)]");
		myArr=myRe.test(s);
		return myArr;	
	}
	function isPhone_new(string) {
	if (string.search(/^([0-9]){3} [0-9]{3}-[0-9]{4}$/) != -1)
		return true;
	else
		return false;
}
function isPhone1(string) {
	if (string.search(/^\([0-9]{3}\) [0-9]{3}-[0-9]{4}$/) != -1)
		return true;
	else
		return false;
}
	function checkAddress(s)
	{
		var x=s;
		for(j=0;j<x.length;j++)
		{ 
			var char_code= x.charCodeAt(j);
			if(char_code==32 || (char_code>=65 && char_code<=90) || (char_code>=97 && char_code<=122) || (char_code>=48 && char_code<=57) || char_code==44 || char_code==45 ||char_code==46 || char_code==47 || char_code==35 || char_code==33 ||char_code==63 ||char_code==61 || char_code==10 || char_code==13 || char_code==39 || char_code==34)
			{
			}else{
				return true;
				break;
			}		
		}
	}
	function isCharwithSpc(s)
	{
		var x=s;
		for(j=0;j<x.length;j++)
		{ 
			var char_code= x.charCodeAt(j);
			if(char_code==32 || (char_code>=65 && char_code<=90) || (char_code>=97 && char_code<=122) || (char_code>=48 && char_code<=58) || char_code==46 || char_code==63 || char_code==33 || char_code==39  || char_code==44)
			{
			}else{
				return true;
				break;
			}		
		}
	}
	function isCity(s)
	{
		var x=s;
		for(j=0;j<x.length;j++)
		{ 
			var char_code= x.charCodeAt(j);
			if(char_code==32 || (char_code>=65 && char_code<=90) || (char_code>=97 && char_code<=122))
			{
			}else{
				return true;
				break;
			}		
		}
	}



function trim(s) {
  while (s.substring(0,1) == ' ') {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') {
    s = s.substring(0,s.length-1);
  }
  return s;
}