	function formatphone(tin){
	/* by: Jonathan will, CyTek Studios inc.
	777-2222
	(234) 234-2344
	(234) 234-2344 ex.222
	1-234-234-2344
	*/
		pin = tin.replace(/[^0-9]/g,'');
	
		var len = pin.length;
		var o="",x=0,stop=0;
	
		if(len >= 10){
			var arr = pin.split("");
	
			if(arr[0]=='1' && len >= 11){
				o +='1-';
				x = stop=1;
			}else{x=0;stop=0;}
	
			for(;x<len;x++){
				if((x==0) && !stop)o += '(';
				if((x==11 && stop) || (x==10 && !stop))		o += ' ex.';
				if(x==3 && !stop)	o += ')';
				if((x==6 && !stop) || (x==4 && stop))		o += '-';
				if(x==7 && stop)		o += '-';
				o += arr[x];
			}
	
		}else if(len >= 7){
	
			var p1 = pin.substr(0,3);
			var p2 = pin.substr(3,4);
			var p3 = pin.substr(7,(len-7));
			o = p1 + "-" + p2;
	
			
			if(p3.length) o += " ex."+p3;
		}else{
	
			o = pin;
		}
		return o;
	}
	/********************************/
	// Declaring required variables
	var digits = "0123456789";
	// non-digit characters which are allowed in phone numbers
	var phoneNumberDelimiters = "()- ";
	// characters which are allowed in international phone numbers
	// (a leading + is OK)
	var validWorldPhoneChars = phoneNumberDelimiters + "+";
	// Minimum no of digits in an international phone no.
	var minDigitsInIPhoneNumber = 10;
	/********************************/
	function isInteger(s){   var i;
	    for (i = 0; i < s.length; i++)
	    {   
	        // Check that current character is number.
	        var c = s.charAt(i);
	        if (((c < "0") || (c > "9"))) return false;
	    }
	    // All characters are numbers.
	    return true;
	}
	/********************************/
	function stripCharsInBag(s, bag){
	   var i;
	    var returnString = "";
	    // Search through string's characters one by one.
	    // If character is not in bag, append to returnString.
	    for (i = 0; i < s.length; i++){   
	        // Check that current character isn't whitespace.
	        var c = s.charAt(i);
	        if (bag.indexOf(c) == -1) returnString += c;
	    }
	    return returnString;
	}
	/********************************/
	function checkInternationalPhone(strPhone){
		s=stripCharsInBag(strPhone,validWorldPhoneChars);
		return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
	}
	/********************************/
	function validatePhone(phone){
		
		if ((phone.value==null)||(phone.value=="")){
			alert("Please Enter your Phone Number");
			phone.focus();
			return false;
		}
		if (checkInternationalPhone(phone.value)==false){
			alert("Please Enter a Valid Phone Number");
			phone.value="";
			phone.focus();
			return false;
		}
		return true;
		
	 }
	/********************************/