// JavaScript Document
// Funzioni per la gestione del carrello
// Glassico - 2006 groncoUEB - gronco.ac@tin.it

function carrello(nomeFunzione)
{
	if (nomeFunzione=='aggiorna')
	{		
		for (var i=0; i<document.form_carrello.elements.length; i++) 
		{
			var elem = document.form_carrello.elements[i];
			if (elem.name.indexOf("qta") != -1) 
			{
				if (FieldIsEmpty(elem)) 
				{
					alert ("Quantità non corrette");
					return false;
				}
				if (!FieldIsEmpty(elem)) 
				{
					if(!isIntero(elem))
					return false;
				}
			}
		}
		document.form_carrello.action="index.php?action=aggiorna";
		document.form_carrello.submit();
	}
	if (nomeFunzione=='acquista')
	{
		document.form_carrello.action="index.php?action=acquista&step=99";
		document.form_carrello.submit();
	}
	if (nomeFunzione=='aggiorna_riepilogo')
	{		
		for (var i=0; i<form_carrello.elements.length; i++) 
		{
			var elem = form_carrello.elements[i];
			if (elem.name.indexOf("qta") != -1) 
			{
				if (FieldIsEmpty(elem)) 
				{
					alert ("Quantità non corrette");
					return false;
				}
				if (!FieldIsEmpty(elem)) 
				{
					if(!isIntero(elem))
					return false;
				}
			}
		}
		document.form_carrello.action="index.php?action=acquista&step=5";
		document.form_carrello.submit();
	}
	
}

