
function printon(){
	if (document.all) {
        if (navigator.appVersion.indexOf("5.0") == -1) {
            var OLECMDID_PRINT = 6;
            var OLECMDEXECOPT_DONTPROMPTUSER = 2;
            var OLECMDEXECOPT_PROMPTUSER = 1;
            var WebBrowser = "<OBJECT ID=\"WebBrowser1\" WIDTH=0 HEIGHT=0 CLASSID=\"CLSID:8856F961-340A-11D0-A96B-00C04FD705A2\"></OBJECT>";
            document.body.insertAdjacentHTML("beforeEnd", WebBrowser);
            WebBrowser1.ExecWB(6, 2);
            WebBrowser1.outerHTML = "";
        } else {
			self.print();
        }
    } else {
		self.print();
    }
}


function popup(sPicURL) {
window.open("foto.htm?"+sPicURL, "", "resizable=1,HEIGHT=300,WIDTH=200");
}


function verify(frm)
{

if (frm.name == 'proposta')
{


if (frm.nominativo.value == "")
    {
     errorString = "Il campo NOMINATIVO è obbligatorio";
     frm.nominativo.focus();
     alert(errorString);
     return false;
    }


	Ctrl = frm.email;
	result = false;
	space_tokens = Ctrl.value.split(" ");
	if (space_tokens.length == 1) {
	 at_tokens = Ctrl.value.split("@");
	 if (at_tokens.length == 2) {
		if (at_tokens[1].length != 0) {
			right_dot_tokens = at_tokens[1].split(".");
			if (right_dot_tokens.length >= 2) {
				if (right_dot_tokens[1].length != 0) {
					result=true;
				}
			}
		}
	}
	}
	if (!result){
		errorString = "Inserisci un'indirizzo E-MAIL valido";
		alert(errorString);
		Ctrl.focus();
		return (result);
	   }
	}
	
	if(!frm.cla1.checked){
		errorString = "E' OBBLIGATORIO selezionare entrambe le dichiarazioni del contraente!";
		alert(errorString);
		return false;	
	}
	if(!frm.cla3.checked){
		errorString = "E' OBBLIGATORIO selezionare entrambe le dichiarazioni del contraente!";
		alert(errorString);
		return false;	
	}
}

function verify_mod_modena(f){
	//verifico prima l'anagrafica
	if(f.nominativo.value==""){
		alert("NOMINATIVO obbligatorio")
		f.nominativo.focus()
		return false
	}
	
	if(f.via.value==""){
		alert("INDIRIZZO obbligatorio")
		f.via.focus()
		return false
	}
	
	if(f.civico.value==""){
		alert("CIVICO obbligatorio")
		f.civico.focus()
		return false
	}
	
	if(f.citta.value==""){
		alert("CITTA obbligatorio")
		f.citta.focus()
		return false
	}
	
	if(f.cap.value==""){
		alert("CAP obbligatorio")
		f.cap.focus()
		return false
	}
	
	if(f.prov.value=="-"){
		alert("PROVINCIA obbligatorio")
		f.prov.focus()
		return false
	}
	
	if(f.telefono.value==""){
		alert("TELEFONO obbligatorio")
		f.telefono.focus()
		return false
	}
	
	Ctrl = f.email;
	result = false;
	space_tokens = Ctrl.value.split(" ");
	if (space_tokens.length == 1) {
		at_tokens = Ctrl.value.split("@");
		if (at_tokens.length == 2) {
			if (at_tokens[1].length != 0) {
				right_dot_tokens = at_tokens[1].split(".");
				if (right_dot_tokens.length >= 2) {
					if (right_dot_tokens[1].length != 0) {
						result=true;
					}
				}
			}
		}
	}
	if (!result){
		errorString = "Inserisci un'indirizzo E-MAIL valido";
		alert(errorString);
		Ctrl.focus();
		return (result);
	}
	
	if(f.cf.value==""){
		alert("CODICE FISCALE obbligatorio")
		f.cf.focus()
		return false
	}
	
	//MODULO DI ADESIONE POLIZZA INFORTUNI
	if ((f.combinazione_infortuni.value != "-") && ((f.descrizione.value == "") || (f.lavorativa.value == "") || (f.esercitata.value == ""))) {
		alert("MODULO DI ADESIONE POLIZZA INFORTUNI: tutti i campi sono obbligatori")
		f.descrizione.focus()
		return false
	}
	
	//MODULO DI ADESIONE POLIZZA RITIRO PATENTE
	if ((f.combinazione_ritiropatente.value != "-") && ((f.numeropatente.value == "") || (f.prefettura.value == "") || (f.datarilascio.value == ""))) {
		alert("MODULO DI ADESIONE POLIZZA RITIRO PATENTE: tutti i campi sono obbligatori")
		f.numeropatente.focus()
		return false
	}
	
	//MODULO DI ADESIONE POLIZZA AUTO
	if ((f.combinazione_auto.value != "-") && ((f.marcamodello.value == "") || (f.alimentazione.value = "") || (f.cilindrata.value = "") || (f.cv.value = "") || (f.kw.value = "") || (f.antifurto.value = ""))){
		alert("MODULO DI ADESIONE POLIZZA AUTO: i campi contrassegnati con * sono obbligatori")
		f.marcamodello.focus()
		return false
	}
	else if ((f.combinazione_auto.value != "-") && ((f.classe.value = "") || (f.sinistri_ultimo_anno.value = "") || (f.sinistri_penultimo_anno.value = "") || (f.compagnia.value = "") || (f.polizza_gg2.value = "") || (f.polizza_mm2.value = "") || (f.polizza_aa2.value = ""))) {
		//Dati relativi alla polizza auto
		alert("Dati relativi alla sua polizza auto: i campi contrassegnati con * sono obbligatori")
		f.classe.focus()
		return false
	}
}

function calcolaTotali() {
	var tot = 0
	
	var abitazione = fabimo.combinazione_abitazione.value
	var infortuni = fabimo.combinazione_infortuni.value
	var ritiro_patente = fabimo.combinazione_ritiropatente.value
	var polizza_auto = fabimo.combinazione_auto.value
	
	if (!isNaN(abitazione)) {
		tot = Number(tot) + Number(abitazione)
	}
	if (!isNaN(infortuni)) {
		tot = Number(tot) + Number(infortuni)	
	}
	if (!isNaN(ritiro_patente)) {
		tot = Number(tot) + Number(ritiro_patente)
	}
	if (!isNaN(polizza_auto)) {
		tot = Number(tot) + Number(polizza_auto)	
	}
	
	fabimo.totale.value = formatDecimal(tot, 2)
}
