function CheckData(lang)
{
    proceed = true;

    if(document.Cash.denominazione.value == "")
    {
        proceed = false;

        obj = document.Cash.denominazione;

        if(lang == "it")
            msg = "Inserire il proprio nome o ragione sociale";
        else
            msg = "Please enter your full name";
    }

    if(document.Cash.indirizzo.value == "" && proceed == true)
    {
        proceed = false;

        obj = document.Cash.indirizzo;

        if(lang == "it")
            msg = "Inserire il proprio indirizzo";
        else
            msg = "Please enter your address";
    }

    if(document.Cash.CAP.value == "" && proceed == true)
    {
        proceed = false;

        obj = document.Cash.CAP;

        if(lang == "it")
            msg = "Inserire il proprio Codice\ndi Avviamento Postale (CAP)";
        else
            msg = "Please enter your ZIP code";
    }

    if(document.Cash.citta.value == "" && proceed == true)
    {
        proceed = false;

        obj = document.Cash.citta;

        if(lang == "it")
            msg = "Inserire la propria cittą";
        else
            msg = "Please enter your city";
    }

    if(document.Cash.provincia.value == "" && proceed == true)
    {
        proceed = false;

        obj = document.Cash.provincia;

        if(lang == "it")
            msg = "Inserire la propria provincia";
        else
            msg = "Please enter your province/county";
    }

    if(parseInt(document.Cash.paese.value) == -1 && proceed == true)
    {
        proceed = false;

        obj = document.Cash.paese;

        if(lang == "it")
            msg = "Inserire la propria nazione";
        else
            msg = "Please enter your country";
    }

    if(document.Cash.tel.value == "" && proceed == true)
    {
        proceed = false;

        obj = document.Cash.tel;

        if(lang == "it")
            msg = "Inserire il proprio numero di telefono";
        else
            msg = "Please enter your phone number";
    }

    if(document.Cash.email.value == "" && proceed == true)
    {
        proceed = false;

        obj = document.Cash.email;

        if(lang == "it")
            msg = "Inserire il proprio indirizzo e-mail";
        else
            msg = "Please enter your e-mail address";
    }

    if(chkem(document.Cash.email.value) == false && proceed == true)
    {
        proceed = false;

        obj = document.Cash.email;

        if(lang == "it")
            msg = "Inserire un indirizzo e-mail valido";
        else
            msg = "Please enter a valid e-mail address";
    }

    if(document.Cash.fattura[0].checked == true && proceed == true)
    {
        if(document.Cash.partita_iva.value == "")
        {
            proceed = false;

            obj = document.Cash.partita_iva;

            if(lang == "it")
                msg = "Inserire la partita IVA o codice fiscale";
            else
                msg = "Please enter your VAT number";
        }
    }

    if(document.Cash.destaddr[0].checked == true && proceed == true)
    {
        if(document.Cash.dest_denominazione.value == "" && proceed == true)
        {
            proceed = false;

            obj = document.Cash.dest_denominazione;

            if(lang == "it")
                msg = "Inserire il nome del destinatario";
            else
                msg = "Please enter the name of the recipient";
        }

        if(document.Cash.dest_indirizzo.value == "" && proceed == true)
        {
            proceed = false;

            obj = document.Cash.dest_indirizzo;

            if(lang == "it")
                msg = "Inserire l'indirizzo di destinazione";
            else
                msg = "Please enter shipping address";
        }

        if(document.Cash.dest_CAP.value == "" && proceed == true)
        {
            proceed = false;

            obj = document.Cash.dest_CAP;

            if(lang == "it")
                msg = "Inserire il Codice di Avviamento\nPostale (CAP) di destinazione";
            else
                msg = "Please enter shipping ZIP code";
        }

        if(document.Cash.dest_citta.value == "" && proceed == true)
        {
            proceed = false;

            obj = document.Cash.dest_citta;

            if(lang == "it")
                msg = "Inserire la cittą di destinazione";
            else
                msg = "Please enter shipping city";
        }

        if(document.Cash.dest_provincia.value == "" && proceed == true)
        {
            proceed = false;

            obj = document.Cash.dest_provincia;

            if(lang == "it")
                msg = "Inserire la provincia di destinazione";
            else
                msg = "Please enter shipping province/county";
        }

        if(parseInt(document.Cash.dest_paese.value) == -1 && proceed == true)
        {
            proceed = false;

            obj = document.Cash.dest_paese;

            if(lang == "it")
                msg = "Inserire la nazione di destinazione";
            else
                msg = "Please enter shipping country";
        }

        if(document.Cash.dest_tel.value == "" && proceed == true)
        {
            proceed = false;

            obj = document.Cash.dest_tel;

            if(lang == "it")
                msg = "Inserire il numero di telefono della destinazione";
            else
                msg = "Please enter shipping phone number";
        }

        if(document.Cash.dest_email.value != "" && proceed == true)
        {
            if(chkem(document.Cash.dest_email.value) == false)
            {
                proceed = false;

                obj = document.Cash.dest_email;

                if(lang == "it")
                    msg = "Inserire un indirizzo e-mail valido";
                else
                    msg = "Please enter a valid e-mail address";
            }
        }
    }

    if(parseInt(document.Cash.punti_usati.value) > parseInt(document.Cash.pts.value) && proceed == true)
    {
        proceed = false;

        obj = document.Cash.punti_usati;

        if(lang == "it")
            msg = "In questo ordine puoi usare al\nmassimo " + document.Cash.pts.value + " punti";
        else
            msg = "In this order you can use a\nmaximum of " + document.Cash.pts.value + " points";

        document.Cash.punti_usati.value = document.Cash.pts.value;
    }

    var paysel = 0;

    for(i=0; i<document.Cash.tipo_pagamento.length; i++)
    {
        if(document.Cash.tipo_pagamento[i].checked == "1")
            paysel++;
    }

    if(paysel == 0)
    {
        if(document.Cash.tipo_pagamento.checked == "1")
            paysel++;
    }

    if(paysel != 1 && proceed == true)
    {
        proceed = false;

        obj = document.Cash.dest_email;

        if(lang == "it")
            msg = "Indicare la modalitą di pagamento";
        else
            msg = "Please select a payment type";
    }

    if(proceed == true)
    {
        document.Cash.proceed1.disabled=true;
        document.Cash.proceed2.disabled=true;
        document.Cash.submit();
    }
    else
    {
        alert(msg);

        obj.focus();

        return;
    }
}

function ConfirmOrder(lang, mode)
{
    var vfound = false;
    var vlen = document.Ship.vettore.length;

    for(i=0; i<vlen; i++)
    {
        if(document.Ship.vettore[i].checked == true)
            vfound = true;
    }

    if(vfound == false)
    {
        if(lang == "it")
            msg = "Selezionare una modalitą di spedizione";
        else
            msg = "Please select a shipping method";

        alert(msg);

        return;
    }

    if(mode == "c")
    {
        if(lang == "it")
            msg = "Si desidera procedere con il pagamento\ne con l'invio di questo ordine?";
        else
            msg = "Do you wish to proceed with payment\nand to send this order?";
    }
    else
    {
        if(lang == "it")
            msg = "Si conferma l'invio di questo ordine?";
        else
            msg = "Do you confirm sending this order?";
    }

    if(confirm(msg))
    {
        document.order.proceedbtn.onclick=SelectCourier;
        document.order.proceedbtn.disabled=true;
        document.order.submit();
    }
}

function SelectCourier()
{
    document.order.proceedbtn.onclick=SelectCourier;
    document.order.proceedbtn.disabled=true;
    document.order.action="";

    document.Ship.submit();
}

function DisableDestAddress(status)
{
    document.Cash.dest_denominazione.disabled = status;
    document.Cash.dest_indirizzo.disabled = status;
    document.Cash.dest_CAP.disabled = status;
    document.Cash.dest_citta.disabled = status;
    document.Cash.dest_provincia.disabled = status;
    document.Cash.dest_paese.disabled = status;
    document.Cash.dest_tel.disabled = status;
    document.Cash.dest_email.disabled = status;

    if(status == true)
    {
        document.Cash.dest_denominazione.value = "";
        document.Cash.dest_indirizzo.value = "";
        document.Cash.dest_CAP.value = "";
        document.Cash.dest_citta.value = "";
        document.Cash.dest_provincia.value = "";
        document.Cash.dest_paese.value = "-1";
        document.Cash.dest_tel.value = "";
        document.Cash.dest_email.value = "";
    }
}

function DisableInvoice(status)
{
    document.Cash.partita_iva.disabled = status;

    if(status == true)
        document.Cash.partita_iva.value = "";
}

