var phoneFormatOK=false;

//+++++++++++++++++++++++++++++++++++++++++++
//++ formatPhoneNum()
//+++++++++++++++++++++++++++++++++++++++++++
function formatPhoneNum(inObj){
	var tmpPN=inObj.value;
	var sOut='';
	
	if (tmpPN.length==0){
		return false;
	}
	
	for ($i=0; $i<tmpPN.length; $i++){
		tmpCode=tmpPN.charCodeAt($i);
		if ( (tmpCode>=48) && (tmpCode<=57) ){
			//is number
			sOut+=tmpPN.substr($i, 1);
		}else{
			//added to allow character phone numbers
			// ie. 1(800)New-Roof
			if ( (tmpCode>=65) && (tmpCode<=90) ){
				//is number
				sOut+=tmpPN.substr($i, 1);
			}
			if ( (tmpCode>=97) && (tmpCode<=122) ){
				//is number
				sOut+=tmpPN.substr($i, 1);
			}
		}
	}
	
	if (sOut.length==10){
		sTmp='('+sOut.substr(0, 3)+')'+sOut.substr(3, 3)+'-'+sOut.substr(6);
		sOut=sTmp;
		phoneFormatOK=true;
	}else{
		if (sOut.length==11){
			sTmp='('+sOut.substr(1, 3)+')'+sOut.substr(4, 3)+'-'+sOut.substr(7);
			sOut=sTmp;
			phoneFormatOK=true;
		}else{
			phoneFormatOK=false;
		}
	}
	
	inObj.value=sOut;
	
}