////////////////////////////////////////////////////////////////////////////////

function ValidateQty( frm, min )
{
	if( !min ) min = 1;
	var nQty = parseInt( frm.Q.value );
	if( isNaN( nQty ) || nQty < min || nQty > 99999 )
	{
		alert( "Please specify valid Quantity to add to Order\n\n" +
				"It must be a number between " + min + " and 99999" );
		frm.Q.value = min;
		frm.Q.focus();
		frm.Q.select();
		return false;
	}
	return true;
}

////////////////////////////////////////////////////////////////////////////////

function VerifyPkgQty( ctrl, nPkg, nOldQty )
{
	var nQty = parseInt( ctrl.value );
	if( isNaN( nQty ) || nQty <= 0 )		// Allow to specify EMPTY, INVALID or 0 (to remove)
	{
		ctrl.value = '';
		return true;
	}
	if( nQty % nPkg == 0 ) return true;		// OK, it's a multiple of nPkg

	alert( "This product is sold only in multiples of " + nPkg + "\n\n" +
			"Please correct the Qty desired to comply." );

	ctrl.value = nOldQty;
	ctrl.select();
	return false;
}

////////////////////////////////////////////////////////////////////////////////

function VerifyMinQty( ctrl, nMin, nOldQty )
{
	var nQty = parseInt( ctrl.value );
	if( isNaN( nQty ) || nQty <= 0 )		// Allow to specify EMPTY, INVALID or 0 (to remove)
	{
		ctrl.value = '';
		return true;
	}
	if( nQty >= nMin ) return true;		// OK, it's at least the specified nMin

	alert( "This product is sold in Minimum quantity of " + nMin + "\n\n" +
			"Please correct the Qty desired to comply." );

	ctrl.value = nOldQty;
	ctrl.select();
	return false;
}

////////////////////////////////////////////////////////////////////////////////

