function change_page(page) {
	document.food_order.pg.value = page;
	document.food_order.submit();
}

function tagasi() {
	if (document.food_order.pg.value == '4') {
		document.food_order.pg.value = 2;
	}
	else {
		document.food_order.pg.value = document.food_order.pg.value - 1;
	}
	document.food_order.submit();
}

function edasi(rules) {
	if (document.food_order.pg.value != 3)
	{
		document.food_order.pg.value++;
		document.food_order.submit();
		return true;
	}
	if (!document.getElementById('food_pg3_email').value) {
		return false;
	}
	if (rules)
	{
		document.getElementById('rules_check').className = "normal";
		document.getElementById('page3_error').style.display = "none";
		document.food_order.pg.value++;
		document.food_order.submit();
		return true;
	} else {
		if (!rules) {
			document.getElementById('rules_check').className = "error";
			document.getElementById('page3_error').style.display = "block";
		} else {
			document.getElementById('rules_check').className = "normal";
			document.getElementById('page3_error').style.display = "none";
		}
	}
}

function suurenda(leg, food, price) {
	if (document.getElementById('qty_'+leg+'_'+food).value < 99)
	{
		document.getElementById('qty_'+leg+'_'+food).value++;
		document.getElementById('qty_show_'+leg+'_'+food).value = document.getElementById('qty_'+leg+'_'+food).value;
		document.getElementById('total_qty_'+food).innerHTML++;
		document.getElementById('total_price_'+food).innerHTML = document.getElementById('total_price_'+food).innerHTML*1 + price*1;
		total_amount += price;
		document.getElementById('total_amount').innerHTML = total_amount;
	}
	document.getElementById('page2_continue').className = 'continue_active';
	document.getElementById('page2_continue').onclick = edasi;
}

function vahenda(leg, food, price) {
	if (document.getElementById('qty_'+leg+'_'+food).value > 0)
	{
		document.getElementById('qty_'+leg+'_'+food).value--;
		document.getElementById('qty_show_'+leg+'_'+food).value = document.getElementById('qty_'+leg+'_'+food).value;
		document.getElementById('total_qty_'+food).innerHTML--;
		document.getElementById('total_price_'+food).innerHTML = document.getElementById('total_price_'+food).innerHTML*1 - price*1;
		total_amount -= price;
		document.getElementById('total_amount').innerHTML = total_amount;
	}
	if (!total_amount)
	{
		document.getElementById('page2_continue').className = 'continue_inactive';
		document.getElementById('page2_continue').onclick = function(){};
	}
}

function show_rules(art_url) {
	testwindow = window.open(art_url, "mywindow1","location=1,status=1,scrollbars=0,width=300,height=400");
	testwindow.moveTo(0,0);
}
