﻿
function validazioneClientChkCerca()
{
   //se tutti i checkbox sono falsi allora torno un messaggio che mi dice di selezionare la categoria
   if( (document.getElementById("chkGuide").checked==false) & (document.getElementById("chkNews").checked==false) & (document.getElementById("chkArticoli").checked==false) & (document.getElementById("chkNormative").checked==false)  )
   {
      //alert("checkbox news, normative, articoli e guide falsi, postback interrotto");
      document.getElementById("lblMessageCerca").innerHTML  = "selezionare almemo una categoria";
      return false;
   }
   //se invece almenu uno dei checkbox è pieno...
   else
   {
      //se la textbox del cerca è vuota allora impedisco la ricerca
      if(document.getElementById("txtCercaHome").value != "" )
      {
        return true;
      }
      else
      {
        document.getElementById("lblMessageCerca").innerHTML  = "inserire un testo di ricerca";
        return false;
      }
   }
}


function disabilitaLogin() {
document.getElementById("btnLogin").disabled = true;
}
function abilitaLogin() {
document.getElementById("btnLogin").disabled = false;
}

function pressioneInvioCerca()
{
    //alert("pressioneInvioCerca()");
    //vedo se devo ricercare o meno
    if( validazioneClientChkCerca() == true)
    {
        //devo redirigere la pagina al cerca
        //alert("devo redirigere la pagina al cerca perchè ho almeno un pulsante checcato");
        var strCerca = "cerca.aspx?ricerca=" + document.getElementById('txtCercaHome').value;
        
        //riempio la stringa di ricerca
        if(document.getElementById("chkGuide").checked==true)
            strCerca += "&guide=true";
        if(document.getElementById("chkNews").checked==true)
            strCerca += "&news=true";
        if(document.getElementById("chkArticoli").checked==true)
           strCerca += "&articoli=true";
        if(document.getElementById("chkNormative").checked==true)
           strCerca += "&normative=true";
           
        location.href = strCerca;
    }
    else
    {
        //alert("NON devo redirigere la pagina al cerca");
    }
}
