<!--

function formatPhoneNum(fieldObj)
{
	 //var fieldObj = document.frm_edit.work_phone;
	 var theString = Trim(fieldObj.value);
	 if(theString !=""){
     var theCount = 0;
     var newString = "";
     var myString = theString;
     var theLen = myString.length;
		 
		 var ext="";
		 var arr=myString.split("ex");
		 if(arr.length>1){
		 	ext = " ex" + arr[1];
		 }
		 	myString=arr[0];
			
     for ( var i = 0 ; i < theLen ; i++)
     {
     // Character codes for ints 1 - 9 are 48 - 57
          if ( (myString.charCodeAt(i) >= 48 ) && (myString.charCodeAt(i) <= 57) )
          newString = newString + myString.charAt(i);   
     }
		 // Now the validation to determine that the remaining string is 9 characters.
     if (newString.length == 10 )
     {
			// Now the string has been stripped of other chars it can be reformatted to ###-##-#### 
				var newLen = newString.length;
				var newPhone = "(";
				for ( var i = 0 ; i < newLen ; i++ )
				{
					 if ( ( i == 2 )  ){
							newPhone = newPhone + newString.charAt(i) + ") ";
					 }else if ( ( i == 5 ) ){
							newPhone = newPhone + newString.charAt(i) + "-";
					 }else{
							newPhone = newPhone + newString.charAt(i);
					 }
				}
				fieldObj.value = newPhone + ext;
				return true;
     }else{
				alert("The phone number you entered "+theString+" does not contian the correct number of digits");
				//fieldObj.focus();
				return false;
     }
	}
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

function number_format( number, decimals, dec_point, thousands_sep ) { 
    var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals;
    var d = dec_point == undefined ? "." : dec_point;
    var t = thousands_sep == undefined ? "," : thousands_sep, s = n < 0 ? "-" : "";
    var i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
    
    return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
}



//-->