/* - - - - - - - - - - - - - - - - - - - - - - -
 JavaScript
 venerdì 6 giugno 2008 12.47.56
 - - - - - - - - - - - - - - - - - - - - - - - */

function controllaContenuti() {
        var oTitolo = document.getElementById("titoloNotizia");
        var oTesto = document.getElementById("testoNotizia");

        var oErrore = document.getElementById("erroreNews");

        if (oTitolo.value == ""){
            oTitolo.style.backgroundColor = "#FF7C7C";
            oErrore.innerHTML = "I Campi In Rosso Sono Obbligatori!";
            oErrore.style.color = "#ffffff";
            oErrore.style.backgroundColor = "#FF0000";
            oErrore.style.padding = "5px";
           return null;
        }
        else{
        oTitolo.style.backgroundColor = "";
        oErrore.innerHTML = "";
        }
        if (oTesto.value == ""){
            oTesto.style.backgroundColor = "#FF7C7C";
            oErrore.innerHTML = "I Campi In Rosso Sono Obbligatori!";
            oErrore.style.color = "#ffffff";
            oErrore.style.backgroundColor = "#FF0000";
            oErrore.style.padding = "5px";
           return null;
        }
        else{
        oTesto.style.backgroundColor = "";
        oErrore.innerHTML = "";
        }

document.form_contenuti.action = "index.php?sel=up_contenuti";
document.form_contenuti.submit();

}
function controllaLink() {
        var oTitolo = document.getElementById("titoloNotizia");
        var oTesto = document.getElementById("urlNotizia");

        var oErrore = document.getElementById("erroreNews");

        if (oTitolo.value == ""){
            oTitolo.style.backgroundColor = "#FF7C7C";
            oErrore.innerHTML = "I Campi In Rosso Sono Obbligatori!";
            oErrore.style.color = "#ffffff";
            oErrore.style.backgroundColor = "#FF0000";
            oErrore.style.padding = "5px";
           return null;
        }
        else{
        oTitolo.style.backgroundColor = "";
        oErrore.innerHTML = "";
        }
        if (oTesto.value == ""){
            oTesto.style.backgroundColor = "#FF7C7C";
            oErrore.innerHTML = "I Campi In Rosso Sono Obbligatori!";
            oErrore.style.color = "#ffffff";
            oErrore.style.backgroundColor = "#FF0000";
            oErrore.style.padding = "5px";
           return null;
        }
        else{
        oTesto.style.backgroundColor = "";
        oErrore.innerHTML = "";
        }

document.form_contenuti.action = "index.php?sel=link_admin&sel_2=up_link";
document.form_contenuti.submit();

}

function controllaAggiornamento() {
        var oTitolo = document.getElementById("titoloNotizia");
        var oTesto = document.getElementById("testoNotizia");

        var oErrore = document.getElementById("erroreNews");

        if (oTitolo.value == ""){
            oTitolo.style.backgroundColor = "#FF7C7C";
            oErrore.innerHTML = "I Campi In Rosso Sono Obbligatori!";
            oErrore.style.color = "#ffffff";
            oErrore.style.backgroundColor = "#FF0000";
            oErrore.style.padding = "5px";
           return null;
        }
        else{
        oTitolo.style.backgroundColor = "";
        oErrore.innerHTML = "";
        }
        if (oTesto.value == ""){
            oTesto.style.backgroundColor = "#FF7C7C";
            oErrore.innerHTML = "I Campi In Rosso Sono Obbligatori!";
            oErrore.style.color = "#ffffff";
            oErrore.style.backgroundColor = "#FF0000";
            oErrore.style.padding = "5px";
           return null;
        }
        else{
        oTesto.style.backgroundColor = "";
        oErrore.innerHTML = "";
        }

document.form_contenuti.action = "index.php?sel=aggiornamento_admin&sel_2=up_aggiornamento";
document.form_contenuti.submit();

}

function controllaUserAdmin () {
        var oNome = document.getElementById("nome");
        var oCognome = document.getElementById("cognome");
        var oUser = document.getElementById("user");
        var oPass = document.getElementById("pass");
        var oEmail = document.getElementById("email");

        var oErroreNome = document.getElementById("erroreNome");
        var oErroreUser = document.getElementById("erroreUser");

        if (oNome.value == ""){
            oNome.style.backgroundColor = "#FF7C7C";
            oErroreNome.innerHTML = "Devi inserire il nome!";
            oErroreNome.style.color = "#ffffff";
            oErroreNome.style.backgroundColor = "#FF0000";
            oErroreNome.style.padding = "5px";
            return null;

        }
        else{
        oNome.style.backgroundColor = "";
        oErroreNome.innerHTML = "";
        oErroreNome.style.backgroundColor = "#FFffff";
        }

        if (oCognome.value == ""){
              oCognome.style.backgroundColor = "#FF7C7C";
              oErroreNome.innerHTML = "I Campi In Rosso Sono Obbligatori!";
              oErroreNome.style.color = "#ffffff";
              oErroreNome.style.backgroundColor = "#FF0000";
              oErroreNome.style.padding = "5px";
           return null;
        }else{
        oCognome.style.backgroundColor = "";
        oErroreNome.innerHTML = "";
        oErroreNome.style.backgroundColor = "#FFffff";
        }


        if (oUser.value == ""){
            oUser.style.backgroundColor = "#FF7C7C";
            oErroreUser.innerHTML = "I Campi In Rosso Sono Obbligatori!";
            oErroreUser.style.color = "#ffffff";
            oErroreUser.style.backgroundColor = "#FF0000";
            oErroreUser.style.padding = "5px";
           return null;
        }
        else { if (oUser.value.length < 6){
                  oUser.style.backgroundColor = "#FF7C7C";
                  oErroreUser.innerHTML = "Il nome utente deve contenere almeno 6 caratteri alfanumerici!";
                  oErroreUser.style.color = "#ffffff";
                  oErroreUser.style.backgroundColor = "#FF0000";
                  oErroreUser.style.padding = "5px";
                  return null;
                  } else {
                         if ( /^[a-z0-9]+$/.test(oUser.value) ) {
                         oUser.style.backgroundColor = "";
                         oErroreUser.innerHTML = "";
                         oErroreUser.style.backgroundColor = "#FFffff";
                         } else {
                         oUser.style.backgroundColor = "#FF7C7C";
                         oErroreUser.innerHTML = "Il nome utente non è valido. Utilizza solo lettere minuscole e numeri!";
                         oErroreUser.style.color = "#ffffff";
                         oErroreUser.style.backgroundColor = "#FF0000";
                         oErroreUser.style.padding = "5px";
                         return null;
                         }
                  }
        }

        if (oPass.value == ""){
            oPass.style.backgroundColor = "#FF7C7C";
            oErroreUser.innerHTML = "I Campi In Rosso Sono Obbligatori!";
            oErroreUser.style.color = "#ffffff";
            oErroreUser.style.backgroundColor = "#FF0000";
            oErroreUser.style.padding = "5px";
           return null;
        }
        else { if (oPass.value.length < 6){
                  oPass.style.backgroundColor = "#FF7C7C";
                  oErroreUser.innerHTML = "La password deve contenere almeno 6 caratteri alfanumerici!";
                  oErroreUser.style.color = "#ffffff";
                  oErroreUser.style.backgroundColor = "#FF0000";
                  oErroreUser.style.padding = "5px";
                  return null;
                  } else {
                         if ( /^[a-z0-9]+$/.test(oPass.value) ) {
                         oPass.style.backgroundColor = "";
                         oErroreUser.innerHTML = "";
                         oErroreUser.style.backgroundColor = "#FFffff";
                         } else {
                         oPass.style.backgroundColor = "#FF7C7C";
                         oErroreUser.innerHTML = "La password non è valida. Utilizza solo lettere minuscole e numeri!";
                         oErroreUser.style.color = "#ffffff";
                         oErroreUser.style.backgroundColor = "#FF0000";
                         oErroreUser.style.padding = "5px";
                         return null;
                         }
                  }
        }

        if (oEmail.value == ""){
            oEmail.style.backgroundColor = "#FF7C7C";
            oErroreUser.innerHTML = "I Campi In Rosso Sono Obbligatori!";
            oErroreUser.style.color = "#ffffff";
            oErroreUser.style.backgroundColor = "#FF0000";
            oErroreUser.style.padding = "5px";
           return null;
        } else {
          var strEmail = oEmail.value;
          if ( /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(strEmail) )  {
              oEmail.style.backgroundColor = "";
              oErroreUser.innerHTML = "";
              oErroreUser.style.backgroundColor = "#FFffff";
          } else {
            oEmail.style.backgroundColor = "#FF7C7C";
            oErroreUser.innerHTML = "Inserire un indirizzo e-mail valido!";
            oErroreUser.style.color = "#ffffff";
            oErroreUser.style.backgroundColor = "#FF0000";
            oErroreUser.style.padding = "5px";
           return null;
          }
        }



document.form_utenti.action = "index.php?sel=up_users";
document.form_utenti.submit();

}
function controllaUserModAdmin () {
        var oNome = document.getElementById("nome");
        var oCognome = document.getElementById("cognome");
        var oUser = document.getElementById("user");
        var oPass = document.getElementById("pass");
        var oEmail = document.getElementById("email");

        var oErroreNome = document.getElementById("erroreNome");
        var oErroreUser = document.getElementById("erroreUser");

        if (oNome.value == ""){
            oNome.style.backgroundColor = "#FF7C7C";
            oErroreNome.innerHTML = "Devi inserire il nome!";
            oErroreNome.style.color = "#ffffff";
            oErroreNome.style.backgroundColor = "#FF0000";
            oErroreNome.style.padding = "5px";
            return null;
        }
        else{
        oNome.style.backgroundColor = "";
        oErroreNome.innerHTML = "";
        oErroreNome.style.backgroundColor = "#FFffff";
        }

        if (oCognome.value == ""){
              oCognome.style.backgroundColor = "#FF7C7C";
              oErroreNome.innerHTML = "I Campi In Rosso Sono Obbligatori!";
              oErroreNome.style.color = "#ffffff";
              oErroreNome.style.backgroundColor = "#FF0000";
              oErroreNome.style.padding = "5px";
           return null;
        }else{
        oCognome.style.backgroundColor = "";
        oErroreNome.innerHTML = "";
        oErroreNome.style.backgroundColor = "#FFffff";
        }



        if (oPass.value != ""){
               if (oPass.value.length < 6){
                  oPass.style.backgroundColor = "#FF7C7C";
                  oErroreUser.innerHTML = "La password deve contenere almeno 6 caratteri alfanumerici!";
                  oErroreUser.style.color = "#ffffff";
                  oErroreUser.style.backgroundColor = "#FF0000";
                  oErroreUser.style.padding = "5px";
                  return null;
                  } else {
                         if ( /^[a-z0-9]+$/.test(oPass.value) ) {
                         oPass.style.backgroundColor = "";
                         oErroreUser.innerHTML = "";
                         oErroreUser.style.backgroundColor = "#FFffff";
                         } else {
                         oPass.style.backgroundColor = "#FF7C7C";
                         oErroreUser.innerHTML = "La password non è valida. Utilizza solo lettere minuscole e numeri!";
                         oErroreUser.style.color = "#ffffff";
                         oErroreUser.style.backgroundColor = "#FF0000";
                         oErroreUser.style.padding = "5px";
                         return null;
                         }
                  }
        } else {
                 oPass.style.backgroundColor = "";
                 oErroreUser.innerHTML = "";
                 oErroreUser.style.backgroundColor = "#FFffff";
        }




document.form_utenti.action = "index.php?sel=up_users";
document.form_utenti.submit();

}

