var affect_textbox_count = 0,
	affect_textbox_pointer;

/*
* increases/decreases a textbox numeric content by change_value
* the target has the form.textbox format
*/
function affect_textbox(target, action, limit, change_value)
{
	target = document.getElementById(target);

	if (isNaN(target.value) || target.value == "")
	{
		target.value = (change_value > 0 ? change_value : 0);
	}
	else
	{
		var current_value = parseInt(target.value);

		if (change_value > 0)
		{
			target.value = (current_value + change_value > limit ? limit : current_value + change_value);
		}
		else
		{
			target.value = (current_value + change_value < limit ? limit : current_value + change_value);
		}
	}

	if (action)
	{
		eval(action);
	}
}

/*
* the affect_textbox function is called while the mouse button is pressed
*/
function keep_affect_textbox(target, action, limit, change_value)
{
	affect_textbox_count++;
	affect_textbox(target, action, limit, change_value);
	affect_textbox_pointer = setTimeout('keep_affect_textbox("' + target + '","' + action + '",' + limit + ',' + change_value + ')', affect_textbox_count < 10 ? 400 : (affect_textbox_count < 20 ? 200 : 80));
}

/*
* stops calling the affect_textbox function
*/
function clear_affect_textbox()
{
	clearTimeout(affect_textbox_pointer);
	affect_textbox_count = 0;
}
