function CPhoneInput()
{
}


CPhoneInput.create = function(tb)
{
	if (typeof(tb) == "string")
	{
		tb = document.getElementById(tb);
	}
	
	var obj = new CPhoneInput();
	
	obj.ctlid = tb.id;

	tb.onkeypress = CPhoneInput.onKeyPress;
	
	tb.setAttribute("maxlength", 16);
	
	return obj;
}


CPhoneInput.prototype.getText = function(str)
{
	str = str || document.getElementById(this.ctlid).value;
	return str;
}


CPhoneInput.prototype.setText = function(str)
{
	document.getElementById(this.ctlid).value = str;
}


CPhoneInput.onKeyPress = function(ev)
{
	var ev = window.event || ev;
	if (ev.which == 0 && ev.keyCode != 0) return true;
	
	if (ev.ctrlKey) return true;
	
	var cc = ev.charCode || ev.keyCode;

	if (cc < 32) return true;
	
	if (cc < 48 || cc > 57) return false;
	
	return true;
}
