function FormatPhone(field)
{
	var phone = null;
	var regex = /[^0-9]/gi;

	if (field != null && field.value != null)
	{
		phone = field.value;
		phone = phone.replace(regex, "");
			
		if (phone.length > 6) field.value = "(" + phone.substring(0, 3) + ") " + phone.substring(3, 6) + "-" + phone.substring(6, 10);
		else if (phone.length > 3) field.value = "(" + phone.substring(0, 3) + ") " + phone.substring(3, 6);
		else if (phone.length > 0) field.value = "(" + phone;
		else field.value = "";
							
		window.status = phone;
	}
}

function FormatPostalCode(field)
{
	var code = null;
	var regex = /^([A-Z][0-9][A-Z]).*([0-9][A-Z][0-9])$/gi;

	if (field != null && field.value != null)
	{
		code = field.value;
		code = code.toUpperCase();

		if (regex.test(code))
		{
			code = code.replace(regex, "$1 $2");
		}

		field.value = code;
	}
}

function OpenPopup(url, w, h)
{
	window.open(url, null, "menubar=0,resizable=1,scrollbars=0,width=" + w + ",height=" + h);
	return false;
}
