
//*************************************************************************************
//*************************************************************************************
//*************************************************************************************

function OverOutRicButton(action) {
    elem=document.getElementById('btnG');
    if (action==1)
        elem.src="/images/template/bt_ric_down.gif"
    else 
        elem.src="/images/template/bt_ric.gif"
}



function showLinkArea(elem){
    var ce = 0;
    if(elem.style.display == 'none' || elem.style.display == ''){
        elem.style.display='block';
    }
    else{
        elem.style.display='none';
    }
}				


function resetSottoaree() {

    //alert(document.searchform.area.value);
    if (document.searchform.area.value!="") {
        var f = document.searchform;
        //alert(f.area.value);
        //alert(f.sottoarea);
        var temp = my_aree[f.area.value];
        //alert(my_aree[f.area.value]);
        f.sottoarea.options.length = temp.length+1;
        f.sottoarea.options[0].value = "";
        f.sottoarea.options[0].text = "Tutte";
        f.sottoarea.options[0].selected = true;
	for(i = 0; i<temp.length; i++) {
	    f.sottoarea.options[i+1].value = temp[i][0];
	    f.sottoarea.options[i+1].text = temp[i][1];
	    f.sottoarea.options[i+1].selected = false;
	    //alert(temp[i][0]+", "+temp[i][1]);
	}

    } else {
        var f = document.searchform;
        f.sottoarea.options.length = 1;
        f.sottoarea.options[0].value = "";
        f.sottoarea.options[0].text = "Tutte";
        f.sottoarea.options[0].selected = true;
    }
}



        /**
         * Apre una nuova finestra del browser secondo i parametri passati in input
         * controllando che tipo di browser ha fatto la richiesta e dimensionando la
         * finestra nel modo pi opportuno in base ai parametri ricevuti
         */
        function nuova(url,target,widthEx,heightEx,widthNav,heightNav,toolbar,location,status,menubar,scrollbars,resizable)
        {
                if(widthNav == null)
                        widthNav = widthEx;
                if(heightNav == null)
                        heightNav = heightEx;
                if(toolbar == null)
                        toolbar = 'no';
                if(location == null)
                        location = 'no';
                if(status == null)
                        status = 'no';
                if(menubar == null)
                        menubar = 'no';
                if(scrollbars == null)
                        scrollbars = 'no';
                if(resizable == null)
                        resizable = 'no';

                var width = widthEx;
                var height = heightEx;
                if(navigator.appName == "Netscape")
                {
                        width = widthNav;
                        height = heightNav;
                }
                desktop = window.open(url, target, "toolbar="+toolbar+",location="+location+
		           ",status="+status+",menubar="+menubar+",scrollbars="+scrollbars+
			   ",width="+width+",height="+height+",resizable="+resizable+"");
                desktop.focus();
        }

//*************************************************************************************
//*************************************************************************************
//*************************************************************************************

function LunghezzaMinima(campo,nome,lun)
{ if (campo.value.length<lun) { alert("Attenzione: il campo '"+nome+"' è troppo corto! (min."+lun+" caratteri)"); campo.focus(); return true; } return false; }

function checkedbox(campo,nome)
{ if (campo.checked==false) { alert("Attenzione: il campo '"+nome+"' deve esssere selezionato"); return true; } return false; }

function IsDifferent(campo1,campo2,nome1,nome2)
{ if (campo1.value!=campo2.value) { alert("Attenzione: i campi '"+nome1+"' e '"+nome2+"' devono essere uguali!"); campo1.focus(); return true; } return false; }

function TestoVuoto(campo,nome)
{ 
    if (campo.value=="") { 
	alert("Attenzione: il campo '"+nome+"' è obbligatorio!");  return true; } 
    return false; 
}

function StringaVuotaLista(campo,nome)
{ 
    var indice=campo.selectedIndex; 
    if (indice==0) { 
	alert("Attenzione: il campo '"+nome+"' è obbligatorio!"); 
	return true;     
    } 
    return false; 
}

function ErrorString(campo,nomeCampo)
{ var st=campo.value; for (var k=0;k<st.length;k++) if ((st.charAt(k)>="0") && (st.charAt(k)<="9")) { alert("Attenzione: Il campo "+nomeCampo+" non deve contenere caratteri numerici."); campo.focus(); return true; } return false; }  

function ErrorNumber(campo,nomeCampo)
{ var st=campo.value; for (var k=0;k<st.length;k++) if ( ((st.charAt(k)<"0") || (st.charAt(k)>"9")) && (st.charAt(k)!="-") && (st.charAt(k)!="+") && (st.charAt(k)!=".")   ) { alert("Attenzione: Il campo "+nomeCampo+" deve contenere caratteri numerici."); campo.focus(); return true; } return false; }  


function ErrorEmail(campo)
{ var st=campo.value; 
  if (  (st.indexOf("@")==-1) ||
       	(st.indexOf(".")==-1) || 
		(st.length < 6) ||
		(st.indexOf("@.")!=-1) ||
       	(st.indexOf("@@")!=-1) 
     ) {  alert("Attenzione: indirizzo E- mail non valido."); campo.focus(); return true;} return false;
}

function ErrorTel(campo,nomeCampo)
{var st=campo.value;
 var car;
  for (var k=0;k<st.length;k++)
  { car=st.charAt(k);
    if (
        ((car<'0') || (car>'9'))
//        &&
//        ((car != '+') && (car !='/') && (car !='-'))
       )
     { alert("Attenzione: numero di "+nomeCampo+" non valido.");
       campo.focus();
       return true;
     }
  }
  return false;
}  

//************************************************************************************

//*************************************************************************************
//*************************************************************************************
//*************************************************************************************

function CheckFormNewsletter() {
    ok=1;

    if ( 
           TestoVuoto(document.getElementById("nome"),"Nome") 
        || TestoVuoto(document.getElementById("cognome"),"Cognome") 
        || ErrorEmail(document.getElementById("email"),"Email") 
	|| StringaVuotaLista(document.getElementById("prof"),"Professione")
        || TestoVuoto(document.getElementById("via"),"Via") 
        || TestoVuoto(document.getElementById("num"),"Numero") 
        || TestoVuoto(document.getElementById("cap"),"CAP") 
        || LunghezzaMinima(document.getElementById("cap"),"CAP",5) 
        || TestoVuoto(document.getElementById("citta"),"citta") 
	|| checkedbox(document.getElementById("legge"),"Trattamento dati personali")
/**/
       ) ok=0;

    if (ok) 
	return true; 
    else 
	return false;
       
};


//***************************************************************

function OverOutGenButton(button,image) {
    elem=document.getElementById(button);
    elem.src=image;
}

function OverOutAButton(button,image) {
    elem=document.getElementById(button);
    elem.src="/images/accesso/"+image;
}

function OverOutOButton(button,image) {
    elem=document.getElementById(button);
    elem.src="/images/opere/"+image;
}



													