
var stepperTimer;

function goStepper(id, delta, min) {
	var value = parseFloat(document.getElementById(id).value);

	value += delta;
	if (value < min)
		value = min;

	value = Math.round(value*Math.pow(10,1))/Math.pow(10,1);

	document.getElementById(id).value = value;
	stepperTimer = setTimeout("goStepper('" + id + "'," + delta + "," + min + ")", 150);
}

function checkMinimum(id, min)
{
	var value = parseFloat(document.getElementById(id).value);
	if (value < min) {
		document.getElementById(id).value = min;
		alert("Beklager, men minstebestilling for dette produktet er " + min);
	}
}

function stopStepper(id) {
	clearTimeout(stepperTimer);
	return;
	var value = parseInt(document.getElementById(id).value);
	if (value > 0)
		value--;
	document.getElementById(id).value = value;
}

function addToCart(product, amount) {
	document.location.href = 'handlevogn/add/' + product + '/' + amount;
//	alert('Prod: ' + product + ' - amount: ' + amount);
}

function updateCart(product) {
	var valueBox = 'amt' + product;
	document.location.href = 'handlevogn/updateAmount/' + product + '/' + document.getElementById(valueBox).value;
}




var pointsStepperTimer;

function goPointsStepper(id, delta, min, max) {
	var value = parseInt(document.getElementById(id).value);

	value += delta;
	if (value < min) {
		value = min;
	} else if (value > max) {
		value = max;
	}

	document.getElementById(id).value = value;
	pointsStepperTimer = setTimeout("goPointsStepper('" + id + "'," + delta + "," + min + "," + max +")", 20);
}

function stopPointsStepper(id) {
	clearTimeout(pointsStepperTimer);
	return;
	var value = parseInt(document.getElementById(id).value);
	if (value > 0)
		value--;
	document.getElementById(id).value = value;
}

function addToCart(product, amount) {
	document.location.href = ROOT_PATH + 'handlevogn/add/' + product + '/' + amount;
//	alert('Prod: ' + product + ' - amount: ' + amount);
}

function updateCart(product) {
	var valueBox = 'amt' + product;
	document.location.href = ROOT_PATH + 'handlevogn/updateAmount/' + product + '/' + document.getElementById(valueBox).value;
}

