function check() {
	var tabella=document.ordini;
	var copie=0;
	var copie2=0;
	var copie3=0;
	var totcopie=0;
	var costo=new Array;
	//un po' di controlli...
	if (!(tabella.copie.checked)){
		copie=0;
		costo[0]=0;
	} else {
		copie=1;
		costo[0]=150;
	}

	if (!(tabella.copie2.checked)){
		copie2=0;
		costo[1]=0;
	} else {
		copie2=1;
		costo[1]=150;
	}
	if (!(tabella.copie3.checked)){
		copie3=0;
		costo[2]=0;
	} else {
		copie3=1;
		costo[2]=200;
	}
	totcopie=copie+copie2+copie3;
	if (!totcopie ||tabella.nazione[tabella.nazione.selectedIndex].value=="0") {
		//? zero, quindi azzeriamo il form
		tabella.costovolumi.value="0";
		tabella.europa.value="0";
		tabella.fareast.value="0";
		tabella.russia.value="0";
		tabella.latin.value="0";
		tabella.insurance.value="0";
		tabella.totale.value="0";
		tabella.rest.value="0";
	} else {
		var sw=tabella.nazione[tabella.nazione.selectedIndex].value*1;
		switch(sw) {
			case 1:
				if(totcopie==1) {
					tabella.europa.value="35";
				} else if(totcopie==2){
					tabella.europa.value="45";
				}else{
					tabella.europa.value="55";
				}
				tabella.fareast.value="0";
				tabella.russia.value="0";
				tabella.latin.value="0";
				tabella.rest.value="0";
			break;
			case 2:
				if(totcopie==1) {
					tabella.fareast.value="50";
				} else if(totcopie==2){
					tabella.fareast.value="70";
				}else {
					tabella.fareast.value='90';
				}
				tabella.europa.value="0";
				tabella.russia.value="0";
				tabella.latin.value="0";
				tabella.rest.value="0";
			break;
			case 3:
				if(totcopie==1) {
					tabella.russia.value="62";
				} else if(totcopie==2){
					tabella.russia.value="85";
				}else {
					tabella.russia.value="95";
				}
				tabella.europa.value="0";
				tabella.fareast.value="0";
				tabella.latin.value="0";
				tabella.rest.value="0";
			break;
			case 4:
				if(totcopie==1) {
					tabella.latin.value="50";
				} else if(totcopie==2){
					tabella.latin.value="70";
				}else {
					tabella.latin.value="90";
				}
				tabella.europa.value="0";
				tabella.russia.value="0";
				tabella.fareast.value="0";
				tabella.rest.value="0";
			break;
			case 5:
				if(totcopie==1) {
					tabella.rest.value="50";
				} else if(totcopie==2){
					tabella.rest.value="70";
				}else {
					tabella.rest.value="90";
				}
				tabella.europa.value="0";
				tabella.russia.value="0";
				tabella.fareast.value="0";
				tabella.latin.value="0";
			break;

		}
		tabella.costovolumi.value=costo[0]+costo[1]+costo[2];
		var as="0";
		if (tabella.assic[0].checked) as="3";
		if(totcopie && tabella.nazione[tabella.nazione.selectedIndex].value!="0" )tabella.insurance.value=as;
		tabella.totale.value=tabella.costovolumi.value*1+tabella.europa.value*1+tabella.russia.value*1+tabella.fareast.value*1+tabella.latin.value*1+tabella.insurance.value*1+tabella.rest.value*1;
	}

}
function check_dati() {
	var controllone;
	var tabella=document.ordini;
	if(tabella.nazione[tabella.nazione.selectedIndex].value!="0") tabella.nome_nazione.value=tabella.nazione[tabella.nazione.selectedIndex].text;
	var email=tabella.email.value;
	var controllo=email.match(/^.+\@(\[?)[-a-zA-Z0-9.]+\.([a-zA-Z]{2,4}|[0-9]{2,4})(\]?)$/);
	var uscita='';
	if (tabella.costovolumi.value=="0")uscita+="You've order no book\n";
	if (!tabella.nome.value) uscita+="Name is missing\n";
	if (!tabella.cognome.value) uscita+="Surname is missing\n";
	if (!tabella.indirizzo.value) uscita+="Address is missing\n";
	if (!tabella.citta.value) uscita+="City is missing\n";
	if (!tabella.nome_nazione.value) uscita+="Country is missing\n";
	if (!tabella.stato_provincia.value) uscita+="State/region is missing\n";
	if (!tabella.zip.value) uscita+="ZIP code is missing\n";
	if (controllo==controllone) uscita+="Email is missing or incorrect\n";
	if (!tabella.telefono.value) uscita+="Phone is missing\n";
	if (!tabella.fax.value) uscita+="Fax is missing\n";
	if (!tabella.privacy.checked) uscita+="The privacy is not accepted\n";

	return uscita;
}
function via_mail() {
	check();
	//controllo email
	var uscita=check_dati();
	if (uscita) {
		alert(uscita);
	} else {
		document.ordini.metodo.value='email';
		document.ordini.submit();
	}
}
function via_cc() {
	check();
	//controllo email
	var uscita=check_dati();
	if (uscita) {
		alert(uscita);
	} else {
		document.ordini.metodo.value='cc';
		document.ordini.submit();
	}
}