// 'button' is set in the jsp
// errors
errors['numberFormat'] = "Please make sure your phone number is in the correct format.<br>Make the necessary changes, then click <B>\"" + button + "\"</B> again.<BR>";
errors['numberLength'] = "The phone number length incorrect.<br>Make the necessary changes, then click <B>\"" + button + "\"</B> again.<BR>";

//----------------------------------------------------------
function okPhoneNumber(number,area,exchange,lastFour,ext)
{		
	var mainNumber = area.value + exchange.value + lastFour.value;
	
	// if the field is not there, the check is not required
	if( area == null && exchange == null && lastFour == null )
		return true;

	
	// do not presume that it is a required field (required fields have their own checking)
	if( mainNumber == '' )
		return true;
	

	var regexp = /^[0-9]+$/;

        if(mainNumber.search(regexp) == -1)
	{
		error('numberFormat',area);
		return false;
	}

        if(ext.search(regexp) == -1)
	{
		error('numberFormat',ext);
		return false;
	}


	if ( mainNumber.length != 10 )
	{		
         	error('numberLength',area);  
    		return false;
	}
	
	return true;
}
