String.prototype.replaceAll=function(s1, s2) {
        return this.replace(new RegExp(s1,"g"), s2);
}
String.prototype.replaceAll=function(s1, s2) {
        var str = this;
        var pos = str.indexOf(s1);
        while (pos > -1){
                str = str.replace(s1, s2);
                pos = str.indexOf(s1);
        }
        return (str);
}


function checkPhone(phoneField)
{
	phoneNum=phoneField.value;
	phoneNum=phoneNum.replaceAll(" ","");
	phoneNum=phoneNum.replaceAll("-","");
	phoneNum=phoneNum.replaceAll("(","");
	phoneNum=phoneNum.replaceAll(")","");
	if (phoneNum != "")
	{
		phoneNum=phoneNum.substr(0,3) + '-' + phoneNum.substr(3,3) + '-' + phoneNum.substr(6,4) + ' ' + phoneNum.substr(10,50);
		phoneField.value=phoneNum;
	}
}