function formatPhone(num)
{ 
  var _return=false;
  /*
   * 7181238748 to 1(718)123-8748
   */ 

  if(num.length != 10)
  { 
    /* 
     * if user did not enter 10 digit phone number then simply print whatever user entered 
     */ 
	_return=_OUTPUT?num:false;
  } 
  else
  { 
    /* formating phone number here */ 
	_return="(";
	var ini = num.substring(0,3);
	_return+=ini+") ";
	var st = num.substring(3,6);
	_return+=st+"-";
	var end = num.substring(6,10);
	_return+=end;
  }
  return _return; 
}

/**
 * DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

function echeck(str,tlShowMsg) {
		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		if ((str==null)||(str=="")){
		   return true;
		}

		if (str.indexOf(at)==-1){
		   if(tlShowMsg==true){   
		   		alert("Invalid E-mail ID");
		   }
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   if(tlShowMsg==true){   
		   		alert("Invalid E-mail ID");
		   }
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		   if(tlShowMsg==true){   
		   		alert("Invalid E-mail ID");
		   }
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		   if(tlShowMsg==true){   
		   		alert("Invalid E-mail ID");
		   }
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		   if(tlShowMsg==true){   
		   		alert("Invalid E-mail ID");
		   }
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		   if(tlShowMsg==true){   
		   		alert("Invalid E-mail ID");
		   }
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1){
		   if(tlShowMsg==true){   
		   		alert("Invalid E-mail ID");
		   }
		    return false;
		 }

 		 return true;				
	}
