
function rollOver(menuvoice) {
	document.getElementById('menu_' + menuvoice).style.display = "none";
	document.getElementById('menu_' + menuvoice +'_over').style.display = "inline";
}
function rollOut(menuvoice) {
	document.getElementById('menu_' + menuvoice).style.display = "inline";
	document.getElementById('menu_' + menuvoice +'_over').style.display = "none";
}


function checkForm() {

	var richiesti = new Array();
	var etichette = new Array();
	var required = 0
	var stringa = 'I seguenti campi obbligatori non sono stati compilati: \n';
	
	etichette.push('Nome / Ragione Sociale', 'E-Mail', 'Partita Iva / Codice Fiscale', 'Numero di telefono', 'Indirizzo', "Localita'", 'Provincia', 'CAP');
	richiesti.push('formNome', 'formMail', 'formIVA', 'formTelefono', 'formIndirizzo', 'formLocalita', 'formProvincia', 'formCap');
  
  required=1;
  for (i=0; i<3; i++)
  {
    if (document.altroRecapito.formCDP[i].checked==true) { 
      required=0;
    }
    if (document.getElementById('formCDP'+i).checked==true) {
      required=0;
    }
  }
  if (required==1) {
      stringa = stringa + "\nModalita' di pagamento";
  }
  
	for(i=0; i < richiesti.length; i++){
		if (document.getElementById(richiesti[i])!=null) {
      if (document.getElementById(richiesti[i]).value == '') {
  			required = 1;
  			stringa = stringa + '\n' + etichette[i];
  		}
		}
		else
		{
			required = 1;
		  stringa = "PER DEVELOPMENT: manca ID "+richiesti[i];		  
		}
	}
	
	if (!document.getElementById('formMail').value.match(/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i))
	{
    required = 1;
    stringa = stringa + '\n' + 'Indirizzo mail non valido.';     
  }
  
  if (!document.getElementById('formCap').value.match(/[0-9]{5}/i))
	{
    required = 1;
    stringa = stringa + '\n' + 'CAP non valido.';     
  }
  
  if (!document.getElementById('formTelefono').value.match(/[0-9 ()+\/-]+/i))
	{
    required = 1;
    stringa = stringa + '\n' + 'Numero telefono non valido.';     
  }
  
  if (!document.getElementById('formIVA').value.match(/[0-9]{11}|\w{6}\d{2}\w\d{2}\w\d{3}\w/i))
	{
    required = 1;
    stringa = stringa + '\n' + 'Codice Fiscale/Partita IVA non valido.';     
  }
/*	
	if((document.contattiForm.formPrivacy.checked == false)) {
		
		stringa = stringa + '\nDevi accettare il trattamento dei dati personali';
		required = 1;
	}
	
	if(document.contattiForm.formParcoauto.selectedIndex == 0) {
		stringa = stringa + '\nDevi selezionare il tuo parco auto';
		required = 1;
	}
*/	
	if(required == 0) {
	  return true;
	} else {
		alert(stringa);
		return false;
	}
}

function confirmDeleteCart() {
	return confirm('Confermi cacellazione dell\'ordine in corso?');
}

function confirmSendCart() {
  if (checkForm()) {
    //document.getElementById("formIva2").value = document.getElementById("formIVA").value; 
  	if(confirm('Confermi l\'invio dell\'ordine in corso?')) {
  		document.altroRecapito.submit();
  	} else {
  		return false;
  	}
  }
  else
  {
     return false;
  }
}

function printPage() {
	if(confirm('Vuoi stampare questo ordine?')) {
		print();
	} else {
		return false;
	}
}
