function CVNumeric_checkValidity()
{
	if (this.value=="")
	{
		CValidateBase_invalid(this, "Empty Field");
		return;
	}
	
	var idx = this.value.indexOf("-", 0);
	if (idx > 0)
	{
		// we have one minus sign, but it's in the wrong place
		this.value = "-"
				+ this.value.slice(0, idx)
				+ this.value.slice(idx + 1);
	}
	
	var nVal = new Number(this.value);
	
	if (nVal.toString()=="NaN")
	{
		CValidateBase_invalid(this, "Not a number");
		return;
	}
	else if (nVal < this.min)
	{
		if (event.type != "keyup")
		{
			this.value = this.min;
		}
		else
		{
			CValidateBase_invalid(this, "Too low ("+this.value+" < " + this.min + ")");
		}
	}
	else if (nVal > this.max)
	{
		if (event.type != "keyup")
		{
			this.value = this.max;
		}
		else
		{
			CValidateBase_invalid(this, "Too high ("+this.value+" > " + this.max + ")");
		}
	}
		
	if (this.value < 0)
	{
		this.style.color=this.negcolor;
	}
	else
	{
		this.style.color=this.poscolor;
	}
}

function CVNumeric(el)
{
	CValidateBase(el);

	if (Number(el.min) >= Number(el.max))
	{
		alert("min >= max!: " + el.id);
		return;
	}

	el.checkValidity = CVNumeric_checkValidity;
	el.numeric=true;
	el.noenter=false;
	if (el.min != null)
	{
		el.negative=(el.min < 0);
	}
	if (!el.negcolor)
	{
		el.negcolor="red";
	}
	if (!el.poscolor)
	{
		el.poscolor="black";
	}
	
	// This can't be done automatically by the base class
	// ...Shame...
	el.checkValidity();
}

bindings.vnumeric = new CBinding(CVNumeric);
