﻿// JScript File



  function FormatUSPhoneNo(control, event)
    {
	    var isNS4 = (navigator.appName=="Netscape")?1:0;
    	
	    if(!isNS4)
	    {
		    if((event.keyCode >= 48 && event.keyCode <= 57) || (event.keyCode == 8))
		    {
			    if ((control.value.length == 1) && ('' != control.value.charAt(0)))
				    control.value = "" + control.value;
			    if(control.value.length == 0)
				    if(event.keyCode != 8)
					    control.value = control.value + "";
			    if(control.value.length == 3)
				    if(event.keyCode != 8)
					    control.value = control.value + "-";
			    /*if(control.value.length == 8)
				    if(event.keyCode != 8)
					    control.value = control.value + "-";*/
			    if(control.value.length == 7)
				    if(event.keyCode != 8)
					    control.value = control.value + "-";
    					
			    event.returnValue = true;
		    }
		    else
		    {
		        if(event.keyCode == 0)
		        {
		            return true;
		        }
		        else
		        {
			        event.returnValue = false;
			    }
		    }
	    }
	    else
	    {
    	    
		    if((event.which >= 48 && event.which <= 57) || (event.which == 8))
		    {		
			    if ((control.value.length == 1) && ('' != control.value.charAt(0)))
				    control.value = "" + control.value;
			    if(control.value.length == 0)
				    if(event.which != 8)
					    control.value = control.value + "";
			    if(control.value.length == 3)
				    if(event.which != 8)
					    control.value = control.value + "-";
			    /*if(control.value.length == 8)
				    if(event.which != 8)
					    control.value = control.value + "-";*/
			    if(control.value.length == 7)
				    if(event.which != 8)
					    control.value = control.value + "-";
    					
			    event.returnValue = true;
    					
			    return  true;
		    }
		    else
		    {
		        if(event.which == 0)
		        {
		            return true;
		        }
		        else
		        {
			        return  false;
			    }
		    }	
	    }
	    
	    return true;
	    
    }
    