// JavaScript Document


function formatPhone(phone){

   var FmtStr="";
    var index = 0;
    var LimitCheck;

    LimitCheck = phone.length;
    while (index != LimitCheck)
      {
        if (isNaN(parseInt(phone.charAt(index))))
          { }
        else
          { FmtStr = FmtStr + phone.charAt(index); }
        index = index + 1;
      }
    if (FmtStr.length == 10)
      {
        FmtStr = "(" + FmtStr.substring(0,3) + ") " + FmtStr.substring(3,6) + "-" + FmtStr.substring(6,10);
      }
    else
      {
        FmtStr=phone;
      }
    return FmtStr;
	
	
}
function isPhoneNumber(phone){
	phone = formatPhone(phone);
     var rePhoneNumber = new RegExp(/^\([1-9]\d{2}\)\s?\d{3}\-\d{4}$/);
     return rePhoneNumber.test(phone);
}
function validateEmail(email){
	var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
    return pattern.test(email);
}
