function check_compare(max_compare)
{
	var formblock= document.getElementById('compare_products_form');
	var forminputs = formblock.getElementsByTagName('input');
	
	var checkbox_choices = 0;
	for (i = 0; i < forminputs.length; i++)
	{
		var regex = new RegExp("idps", "i");
		if (regex.test(forminputs[i].getAttribute('name'))) 
		{
			// If a checkbox has been selected it will return true
			// (If not it will return false)
			if (forminputs[i].checked)
			{ 
				checkbox_choices = checkbox_choices + 1; 
				if (checkbox_choices > max_compare )
				{
					msg="Puoi selezionare fino a 4 articoli\n"
					alert(msg);
					return (false);
				}
			}
		}
		
	
	}
	return (true);

}


function check_compare_submit()
{
	var formblock= document.getElementById('compare_products_form');
	var forminputs = formblock.getElementsByTagName('input');
	
	var checkbox_choices = 0;
	for (i = 0; i < forminputs.length; i++)
	{
		var regex = new RegExp("idps", "i");
		if (regex.test(forminputs[i].getAttribute('name'))) 
		{
			// If a checkbox has been selected it will return true
			// (If not it will return false)
			if (forminputs[i].checked)
			{ 
				checkbox_choices = checkbox_choices + 1; 
			}
		}
		
	
	}
	if (checkbox_choices < 2 )
	{
		alert("Devi selezionare almeno 2 articoli per effettuare il confronto")
		return (false);
	}
	return (true);
}