﻿function OpenWin(pagina, nomepagina, larghezza, altezza, scroll) {
    LeftPosition = (screen.width) ? (screen.width - larghezza) / 2 : 0;
    TopPosition = (screen.height) ? (screen.height - altezza) / 2 : 0;
    settings = 'height=' + altezza + ',width=' + larghezza + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=' + scroll + ',resizable=yes'
    fine = window.open(pagina, nomepagina, settings)
    fine.focus()
}

//Form Contatti

function FocusTextBoxCognome1(campo) {
    if (document.form1.cognome.value == campo) document.form1.cognome.value = "";
}

function BlurTextBoxCognome1(campo) {
    if (document.form1.cognome.value == '') document.form1.cognome.value = campo;
}

function FocusTextBoxNome1(campo) {
    if (document.form1.nome.value == campo) document.form1.nome.value = "";
}

function BlurTextBoxNome1(campo) {
    if (document.form1.nome.value == '') document.form1.nome.value = campo;
}

function FocusTextBoxRagione1(campo) {
    if (document.form1.ragione.value == campo) document.form1.ragione.value = "";
}

function BlurTextBoxRagione1(campo) {
    if (document.form1.ragione.value == '') document.form1.ragione.value = campo;
}

function FocusTextBoxTelefono1(campo) {
    if (document.form1.telefono.value == campo) document.form1.telefono.value = "";
}

function BlurTextBoxTelefono1(campo) {
    if (document.form1.telefono.value == '') document.form1.telefono.value = campo;
}

function FocusTextBoxEmail1(campo) {
    if (document.form1.email.value == campo) document.form1.email.value = "";
}

function BlurTextBoxEmail1(campo) {
    if (document.form1.email.value == '') document.form1.email.value = campo;
}

function FocusTextBoxMerceologico1(campo) {
    if (document.form1.merceologico.value == campo) document.form1.merceologico.value = "";
}

function BlurTextBoxMerceologico1(campo) {
    if (document.form1.merceologico.value == '') document.form1.merceologico.value = campo;
}

function Italia_o_Europa() {
    if (document.form1.area.value == "Italia") {
        document.getElementById("liv_stato").style.display = 'none'
        document.getElementById("liv_provincia").style.display = ''
        document.form1.stato.disabled = "true"
        document.form1.provincia.disabled = ""
    }
    else if (document.form1.area.value == "U.E.") {
        document.getElementById("liv_stato").style.display = ''
        document.getElementById("liv_provincia").style.display = 'none'
        document.form1.provincia.disabled = "true"
        document.form1.stato.disabled = ""
    }
    else {
        document.getElementById("liv_stato").style.display = 'none'
        document.getElementById("liv_provincia").style.display = 'none'
        document.form1.provincia.disabled = "true"
        document.form1.stato.disabled = "true"
    }
}

function ValidaCheck(lingua) {
    if (document.form1.autorizzo.checked == false) {
        if (lingua == "ita") alert("Impossibile procedere senza \nautorizzare il trattamento dei dati personali (D.Lgs. 196/2003)");
        if (lingua == "ing") alert("It's not possible submit this form \nwithout authorization to manage your personal data (D.Lgs. 196/2003)");
        return (false);
    }
}
//Form RMA

function FocusTextBoxSocieta(campo) {
    if (document.form2.societa.value == campo) document.form2.societa.value = "";
}

function BlurTextBoxSocieta(campo) {
    if (document.form2.societa.value == '') document.form2.societa.value = campo;
}

function FocusTextBoxIndirizzo(campo) {
    if (document.form2.indirizzo.value == campo) document.form2.indirizzo.value = "";
}

function BlurTextBoxIndirizzo(campo) {
    if (document.form2.indirizzo.value == '') document.form2.indirizzo.value = campo;
}

function FocusTextBoxRiferimento(campo) {
    if (document.form2.riferimento.value == campo) document.form2.riferimento.value = "";
}

function BlurTextBoxRiferimento(campo) {
    if (document.form2.riferimento.value == '') document.form2.riferimento.value = campo;
}

function FocusTextBoxTelRiferimento(campo) {
    if (document.form2.telriferimento.value == campo) document.form2.telriferimento.value = "";
}

function BlurTextBoxTelRiferimento(campo) {
    if (document.form2.telriferimento.value == '') document.form2.telriferimento.value = campo;
}

function FocusTextBoxEmail(campo) {
    if (document.form2.email.value == campo) document.form2.email.value = "";
}

function BlurTextBoxEmail(campo) {
    if (document.form2.email.value == '') document.form2.email.value = campo;
}


function FocusTextBoxQ1(campo) {
    if (document.form2.q1.value == campo) document.form2.q1.value = "";
}

function BlurTextBoxQ1(campo) {
    if (document.form2.q1.value == '') document.form2.q1.value = campo;
}

function FocusTextBoxQ2(campo) {
    if (document.form2.q2.value == campo) document.form2.q2.value = "";
}

function BlurTextBoxQ2(campo) {
    if (document.form2.q2.value == '') document.form2.q2.value = campo;
}

function FocusTextBoxQ3(campo) {
    if (document.form2.q3.value == campo) document.form2.q3.value = "";
}

function BlurTextBoxQ3(campo) {
    if (document.form2.q3.value == '') document.form2.q3.value = campo;
}

function FocusTextBoxQ4(campo) {
    if (document.form2.q4.value == campo) document.form2.q4.value = "";
}

function BlurTextBoxQ4(campo) {
    if (document.form2.q4.value == '') document.form2.q4.value = campo;
}

function FocusTextBoxQ5(campo) {
    if (document.form2.q5.value == campo) document.form2.q5.value = "";
}

function BlurTextBoxQ5(campo) {
    if (document.form2.q5.value == '') document.form2.q5.value = campo;
}

function FocusTextBoxQ6(campo) {
    if (document.form2.q6.value == campo) document.form2.q6.value = "";
}

function BlurTextBoxQ6(campo) {
    if (document.form2.q6.value == '') document.form2.q6.value = campo;
}

function FocusTextBoxQ7(campo) {
    if (document.form2.q7.value == campo) document.form2.q7.value = "";
}

function BlurTextBoxQ7(campo) {
    if (document.form2.q7.value == '') document.form2.q7.value = campo;
}

function FocusTextBoxQ8(campo) {
    if (document.form2.q8.value == campo) document.form2.q8.value = "";
}

function BlurTextBoxQ8(campo) {
    if (document.form2.q8.value == '') document.form2.q8.value = campo;
}

function FocusTextBoxQ9(campo) {
    if (document.form2.q9.value == campo) document.form2.q9.value = "";
}

function BlurTextBoxQ9(campo) {
    if (document.form2.q9.value == '') document.form2.q9.value = campo;
}

function FocusTextBoxQ10(campo) {
    if (document.form2.q10.value == campo) document.form2.q10.value = "";
}

function BlurTextBoxQ10(campo) {
    if (document.form2.q10.value == '') document.form2.q10.value = campo;
}

function FocusTextBoxQ11(campo) {
    if (document.form2.q11.value == campo) document.form2.q11.value = "";
}

function BlurTextBoxQ11(campo) {
    if (document.form2.q11.value == '') document.form2.q11.value = campo;
}

function FocusTextBoxQ12(campo) {
    if (document.form2.q12.value == campo) document.form2.q12.value = "";
}

function BlurTextBoxQ12(campo) {
    if (document.form2.q12.value == '') document.form2.q12.value = campo;
}

function FocusTextBoxM1(campo) {
    if (document.form2.m1.value == campo) document.form2.m1.value = "";
}

function BlurTextBoxM1(campo) {
    if (document.form2.m1.value == '') document.form2.m1.value = campo;
}

function FocusTextBoxM2(campo) {
    if (document.form2.m2.value == campo) document.form2.m2.value = "";
}

function BlurTextBoxM2(campo) {
    if (document.form2.m2.value == '') document.form2.m2.value = campo;
}

function FocusTextBoxM3(campo) {
    if (document.form2.m3.value == campo) document.form2.m3.value = "";
}

function BlurTextBoxM3(campo) {
    if (document.form2.m3.value == '') document.form2.m3.value = campo;
}

function FocusTextBoxM4(campo) {
    if (document.form2.m4.value == campo) document.form2.m4.value = "";
}

function BlurTextBoxM4(campo) {
    if (document.form2.m4.value == '') document.form2.m4.value = campo;
}

function FocusTextBoxM5(campo) {
    if (document.form2.m5.value == campo) document.form2.m5.value = "";
}

function BlurTextBoxM5(campo) {
    if (document.form2.m5.value == '') document.form2.m5.value = campo;
}

function FocusTextBoxM6(campo) {
    if (document.form2.m6.value == campo) document.form2.m6.value = "";
}

function BlurTextBoxM6(campo) {
    if (document.form2.m6.value == '') document.form2.m6.value = campo;
}

function FocusTextBoxM7(campo) {
    if (document.form2.m7.value == campo) document.form2.m7.value = "";
}

function BlurTextBoxM7(campo) {
    if (document.form2.m7.value == '') document.form2.m7.value = campo;
}

function FocusTextBoxM8(campo) {
    if (document.form2.m8.value == campo) document.form2.m8.value = "";
}

function BlurTextBoxM8(campo) {
    if (document.form2.m8.value == '') document.form2.m8.value = campo;
}

function FocusTextBoxM9(campo) {
    if (document.form2.m9.value == campo) document.form2.m9.value = "";
}

function BlurTextBoxM9(campo) {
    if (document.form2.m9.value == '') document.form2.m9.value = campo;
}

function FocusTextBoxM10(campo) {
    if (document.form2.m10.value == campo) document.form2.m10.value = "";
}

function BlurTextBoxM10(campo) {
    if (document.form2.m10.value == '') document.form2.m10.value = campo;
}

function FocusTextBoxM11(campo) {
    if (document.form2.m11.value == campo) document.form2.m11.value = "";
}

function BlurTextBoxM11(campo) {
    if (document.form2.m11.value == '') document.form2.m11.value = campo;
}

function FocusTextBoxM12(campo) {
    if (document.form2.m12.value == campo) document.form2.m12.value = "";
}

function BlurTextBoxM12(campo) {
    if (document.form2.m12.value == '') document.form2.m12.value = campo;
}

function FocusTextBoxT10(campo) {
    if (document.form2.t10.value == campo) document.form2.t10.value = "";
}

function BlurTextBoxT10(campo) {
    if (document.form2.t10.value == '') document.form2.t10.value = campo;
}

function FocusTextBoxT11(campo) {
    if (document.form2.t11.value == campo) document.form2.t11.value = "";
}

function BlurTextBoxT11(campo) {
    if (document.form2.t11.value == '') document.form2.t11.value = campo;
}

function FocusTextBoxT12(campo) {
    if (document.form2.t12.value == campo) document.form2.t12.value = "";
}

function BlurTextBoxT12(campo) {
    if (document.form2.t12.value == '') document.form2.t12.value = campo;
}

function ValidaCheck2(lingua) {
    if (document.form2.societa.value == "Societa" || document.form2.societa.value == "Company") {
        alert(":: Inserire la Società / Insert Company ::");
        return (false);
    }

    if (document.form2.indirizzo.value == "Indirizzo" || document.form2.indirizzo.value == "Address") {
        alert(":: Inserire l'indirizzo / Insert Address ::");
        return (false);
    }

    if (document.form2.riferimento.value == "Riferimento" || document.form2.riferimento.value == "Reference") {
        alert(":: Inserire il riferimento / Insert Reference ::");
        return (false);
    }

    if (document.form2.telriferimento.value == "Tel. Riferimento" || document.form2.telriferimento.value == "Reference Phone") {
        alert(":: Inserire il Telefono di Riferimento / Insert Reference Phone ::");
        return (false);
    }

    if (document.form2.corriere.value == "") {
        alert(":: Inserire il Corriere Convenzionato / Insert Delivery agreement ::");
        return (false);
    }

    if (document.form2.referente.value == "") {
        alert(":: Inserire il Referente / Insert Reference ::");
        return (false);
    }

    if (document.form2.note.value == "") {
        alert(":: Inserire la Descrizione Guasto / Insert Failure description ::");
        return (false);
    }

    if (document.form2.email.value != "Email") {
        InString = isTextString(document.form2.email.value)
        if ((!(document.form2.email.value.match(/@/))) || (!(document.form2.email.value.match(/\./))) || (InString == 0)) {
            alert(":: Indirizzo E-mail errato / E-mail incorrect ::");
            document.form2.email.focus();
            return (false);
        }
        return (true);
    }
    else {
        alert(":: Inserire l'E-mail / Insert E-mail ::");
        return (false);
    }

    if (document.form2.autorizzo.checked == false) {
        if (lingua == "ita") alert("Impossibile procedere senza \nautorizzare il trattamento dei dati personali (D.Lgs. 196/2003)");
        if (lingua == "ing") alert("It's not possible submit this form \nwithout authorization to manage your personal data (D.Lgs. 196/2003)");
        return (false);
    }

}

function isTextString(InString) {
    if (InString.length == 0) return (false);
    var RefString = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_.";
    for (Count = 0; Count < InString.length; Count++) {
        TempChar = InString.substring(Count, Count + 1);
        if (RefString.indexOf(TempChar, 0) >= 0)
            return (true);
    }
    return (false);
}

