function apriFrase(lingua) {
	var page = "showCat.php?l="+lingua;
	var width = 320;
	var height = 200;
	var resizable = "no";
	var status = "no";
	var scrollbars = "yes";
	url = window.open(page,"_blank","height="+height+",width="+width+",resizable="+resizable+",status="+status+",scrollbars="+scrollbars);
	url.focus();	
}

function apriCredits(lingua) {
	var page = "showCredits.php?l="+lingua;
	var width = 320;
	var height = 260;
	var resizable = "no";
	var status = "no";
	var scrollbars = "yes";
	url = window.open(page,"_blank","height="+height+",width="+width+",resizable="+resizable+",status="+status+",scrollbars="+scrollbars);
	url.focus();	
}

function controlloRivenditore(nomeForm, l){
	thisForm=eval('document.'+nomeForm);
	if(thisForm.nome.value==''){
		if (l==1){	
			alert("Inserire il nome");
		}
		if (l==2){	
			alert("Insert name");
		}
		if (l==3){	
			alert("Insertar el nombre");
		}
		thisForm.nome.focus();
		return;
	}
	if(thisForm.cognome.value==''){
		if (l==1){	
			alert("Inserire il cognome");
		}
		if (l==2){	
			alert("Insert last name");
		}
		if (l==3){	
			alert("Insertar el nombre pasado");
		}
		thisForm.cognome.focus();
		return;
	}
	if(thisForm.email.value==''){
		if (l==1){	
			alert("Inserire l'email");
		}
		if (l==2){	
			alert("Insert email");
		}
		if (l==3){	
			alert("Insertar el email");
		}
		thisForm.email.focus();
		return;
	}
	if (l==1){	
		if(thisForm.privacy.checked == false){
			alert("Bisogna accettare le condizioni sulla privacy per proseguire");
			thisForm.privacy.focus();
			return;
		}
	}
	thisForm.submit();
}


function controlloInvia(nomeForm, l){
	thisForm=eval('document.'+nomeForm);
	if(thisForm.nome.value==''){
		if (l==1){	
			alert("Inserire il nome");
		}
		if (l==2){	
			alert("Insert name");
		}
		if (l==3){	
			alert("Insertar el nombre");
		}
		thisForm.nome.focus();
		return;
	}
	if(thisForm.cognome.value==''){
		if (l==1){	
			alert("Inserire il cognome");
		}
		if (l==2){	
			alert("Insert last name");
		}
		if (l==3){	
			alert("Insertar el nombre pasado");
		}
		thisForm.cognome.focus();
		return;
	}
	if(thisForm.via.value==''){
		if (l==1){	
			alert("Inserire la via");
		}
		if (l==2){	
			alert("Insert street");
		}
		if (l==3){	
			alert("Insertar el Straße");
		}
		thisForm.via.focus();
		return;
	}
	if(thisForm.citta.value==''){
		if (l==1){	
			alert("Inserire la città");
		}
		if (l==2){	
			alert("Insert city");
		}
		if (l==3){	
			alert("Insertar el ciudad");
		}
		thisForm.citta.focus();
		return;
	}
	if(thisForm.email.value==''){
		if (l==1){	
			alert("Inserire l'email");
		}
		if (l==2){	
			alert("Insert email");
		}
		if (l==3){	
			alert("Insertar el email");
		}
		thisForm.email.focus();
		return;
	}
	if (l==1){	
		if(thisForm.privacy.checked == false){
			alert("Bisogna accettare le condizioni sulla privacy per proseguire");
			thisForm.privacy.focus();
			return;
		}
	}
	if(thisForm.name!="contattaci"){
		if(thisForm.destinatario.checked == true){
			if(thisForm.nome1.value==''){
				if (l==1){	
					alert("Inserire il nome");
				}
				if (l==2){	
					alert("Insert name");
				}
				if (l==3){	
					alert("Insertar el nombre");
				}
				thisForm.nome1.focus();
				return;
			}
			if(thisForm.cognome1.value==''){
				if (l==1){	
					alert("Inserire il cognome");
				}
				if (l==2){	
					alert("Insert last name");
				}
				if (l==3){	
					alert("Insertar el nombre pasado");
				}
				thisForm.cognome1.focus();
				return;
			}
			if(thisForm.via1.value==''){
				if (l==1){	
					alert("Inserire la via");
				}
				if (l==2){	
					alert("Insert street");
				}
				if (l==3){	
					alert("Insertar el Straße");
				}
				thisForm.via1.focus();
				return;
			}
			if(thisForm.citta1.value==''){
				if (l==1){	
					alert("Inserire la città");
				}
				if (l==2){	
					alert("Insert city");
				}
				if (l==3){	
					alert("Insertar el ciudad");
				}
				thisForm.citta1.focus();
				return;
			}
			if(thisForm.email1.value==''){
				if (l==1){	
					alert("Inserire l'email");
				}
				if (l==2){	
					alert("Insert email");
				}
				if (l==3){	
					alert("Insertar el email");
				}
				thisForm.email1.focus();
				return;
			}
		}
	}
	thisForm.submit();
}

function addAnello(nomeForm) {
	thisForm=eval('document.'+nomeForm);
	switch (thisForm.modello.value) { 
		case '1': 
	    	prezzoBase=45; 
		break; 
  		case '2': 
			prezzoBase=50; 
		break; 
		case '3': 
    		prezzoBase=75; 
		break; 
		case '4': 
	    	prezzoBase=95; 
		break; 
  		case '5': 
			prezzoBase=28; 
		break; 
		case '6': 
    		prezzoBase=30; 
		break; 
		case '7': 
	    	prezzoBase=43; 
		break; 
  		case '8': 
			prezzoBase=63; 
		break; 
		case '9': 
    		prezzoBase=43; 
		break; 
		case '10': 
	    	prezzoBase=63; 
		break; 
  		case '11': 
			prezzoBase=420; 
		break; 
		case '12': 
    		prezzoBase=660; 
		break; 
		case '13': 
	    	prezzoBase=390; 
		break; 
  		case '14': 
			prezzoBase=630; 
		break; 
  		case '18': 
			prezzoBase=30; 
		break; 
  		case '19': 
			prezzoBase=30; 
		break; 
  		case '20': 
			prezzoBase=140; 
		break; 
  		case '21': 
			prezzoBase=45; 
		break; 
  		case '22': 
			prezzoBase=50; 
		break; 

	  	default: 
			prezzoBase=0;
	} 
	thisForm.importoAnello.value=parseFloat(prezzoBase);
	thisForm.importoSubtotale.value=(parseFloat(thisForm.importoAnello.value)*parseFloat(thisForm.quantita.value))+parseFloat(thisForm.importoPersonalizzazione.value);
}

function ricalcola(nomeForm, l) {
	thisForm=eval('document.'+nomeForm);
	switch (thisForm.modello.value) { 
		case '1': 
	    	prezzoBase=45; 
		break; 
  		case '2': 
			prezzoBase=50; 
		break; 
		case '3': 
    		prezzoBase=75; 
		break; 
		case '4': 
	    	prezzoBase=95; 
		break; 
  		case '5': 
			prezzoBase=28; 
		break; 
		case '6': 
    		prezzoBase=30; 
		break; 
		case '7': 
	    	prezzoBase=43; 
		break; 
  		case '8': 
			prezzoBase=63; 
		break; 
		case '9': 
    		prezzoBase=43; 
		break; 
		case '10': 
	    	prezzoBase=63; 
		break; 
  		case '11': 
			prezzoBase=420; 
		break; 
		case '12': 
    		prezzoBase=660; 
		break; 
		case '13': 
	    	prezzoBase=390; 
		break; 
  		case '14': 
			prezzoBase=630; 
		break; 
  		case '18': 
			prezzoBase=30; 
		break; 
  		case '19': 
			prezzoBase=30; 
		break; 
  		case '20': 
			prezzoBase=140; 
		break; 
  		case '21': 
			prezzoBase=45; 
		break; 
  		case '22': 
			prezzoBase=50; 
		break; 

	  	default: 
			prezzoBase=0;
	}
	thisForm.importoAnello.value=parseFloat(prezzoBase);
	thisForm.importoSubtotale.value=(parseFloat(thisForm.importoAnello.value)*parseFloat(thisForm.quantita.value))+parseFloat(thisForm.importoPersonalizzazione.value);
	err=0;
	if(thisForm.modello<'5' && thisForm.modello>'10'){
		if (thisForm.misura.value=='0'){
			err=1;
		}
	}
	if (thisForm.personalizzazione.checked && thisForm.testoPersonalizzazione.value==''){
		err=2;
	}
	if (err>0){
		if (err==2){
			if(l==1){
				alert("Inserire testo per la personalizzazione!")
			}
			if(l==2){
				alert("Insert name and/or date for the personalization!")
			}
			if(l==3){
				alert("¡Insertar el nombre y/o la fecha para el personalizaci&oacute;n!")
			}
			thisForm.testoPersonalizzazione.focus();
		}
	}
	else { 
		thisForm.l.value=l;
		thisForm.azione.value='update';
		thisForm.submit();
	}
}

function cancella(nomeForm, l) {
	thisForm=eval('document.'+nomeForm);
	thisForm.l.value=l;
	thisForm.azione.value='delete';
	thisForm.submit();
}

function addDiamanti(nomeForm, valore, l) {
	thisForm=eval('document.'+nomeForm);
	if (thisForm.misura.value=='0'){
		if (l==1){
			alert("Scegliere la misura!")
		}
		if (l==2){
			alert("Choose the measure!")
		}
		if (l==3){
			alert("¡Elegir la medida!")
		}
		thisForm.misura.focus();
	}
	if (thisForm.diamanti.checked){
		thisForm.importoDiamanti.value=valore;
	}
	else {
		thisForm.importoDiamanti.value=0;
	}
	thisForm.importoSubtotale.value=parseFloat(thisForm.importoAnello.value)+parseFloat(thisForm.importoDiamanti.value)+parseFloat(thisForm.importoPersonalizzazione.value);
	thisForm.l.value=l;
	thisForm.azione.value='update';
	thisForm.submit();
}

function addPersonalizzazione(nomeForm, valore, l) {
	thisForm=eval('document.'+nomeForm);
	if (thisForm.misura.value=='0'){
		if (l==1){
			alert("Scegliere la misura!")
		}
		if (l==2){
			alert("Choose the measure!")
		}
		if (l==3){
			alert("¡Elegir la medida!")
		}
		thisForm.misura.focus();
	}
	if (thisForm.personalizzazione.checked){
		thisForm.importoPersonalizzazione.value=valore;
	}
	else {
		thisForm.importoPersonalizzazione.value=0;
	}
	thisForm.importoSubtotale.value=parseFloat(thisForm.importoAnello.value)+parseFloat(thisForm.importoPersonalizzazione.value);
	thisForm.l.value=l;
	thisForm.azione.value='update';
	thisForm.submit();
}

function addCatenina(nomeForm, valore, l) {
	thisForm=eval('document.'+nomeForm);
	if (thisForm.personalizzazione.checked){
		thisForm.importoPersonalizzazione.value=valore;
	}
	else {
		thisForm.importoPersonalizzazione.value=0;
	}
	thisForm.importoSubtotale.value=parseFloat(thisForm.importoAnello.value)+parseFloat(thisForm.importoPersonalizzazione.value);
	thisForm.l.value=l;
	thisForm.azione.value='update';
	thisForm.submit();
}

function addSpese(nomeForm, valore) {
	thisForm=eval('document.'+nomeForm);
	thisForm.importoSpedizione.value=valore;
}

function ordina(nomeForm, totale, l) {
	var thisForm=document.forms[nomeForm];
	thisForm.azione.value='OK';
	thisForm.submit();
}

function aggiorna(nomeForm, l) {
	thisForm=eval('document.'+nomeForm);
	thisForm.l.value=l;
	thisForm.azione.value='update';
	thisForm.submit();
}

