function ricerca_archivio_news()
{
//prima nel document.location mettevo anche "&idsezione="  +document.forms[1].elements[9].value
document.location="archivio_news.asp?giornoi=" +document.forms[1].elements[1].value  +"&mesei="  +document.forms[1].elements[2].value  +"&annoi=" +document.forms[1].elements[3].value   +"&giornof=" +document.forms[1].elements[4].value   +"&mesef=" +document.forms[1].elements[5].value   +"&annof=" +document.forms[1].elements[6].value  +"&parolachiave=" +document.forms[1].elements[7].value    +"&idlivello="  +document.forms[1].elements[8].value 
}

function controlla_contatto()
{
 
 var reem=/@/i;
 if (document.forms[1].elements[1].value.search(reem) <0) 
  {alert("Errore, inserire l'indirizzo email")}
    else
       {
 		if (new Number(document.forms[1].elements[2].value)==0)
				{alert("Errore, specificare l'oggetto")}
				else
				{
					if (new Number(document.forms[1].elements[3].value)==0)
						{alert("Errore, specificare il testo")}
							else
							{
                             document.forms[1].submit()
                            }
                }
        }                      

 
}

function ricerca()
{
  document.forms[0].submit()
}

function ricerca_IOC(numero_form_in_collection)
{
  document.forms[numero_form_in_collection].submit()
}


function chk_login_IOC()
{
  var re_usn=/((^(([a-z]|[A-Z]|[0-9]){4,20}))$){1,1}/g;
  
  if (! document.forms[0].username.value.match(re_usn))
    {
       alert("Errore, inserire lo username, almeno 4 [e al massimo 20] caratteri alfanumerici")
       
    }
     else
         {
             if (! document.forms[0].password.value.match(re_usn))
				{
				   alert("Errore, inserire la password, almeno 4 [e al massimo 20] caratteri alfanumerici")
				  
				}
				 else
				      {
				         document.forms[0].submit()
				         //return true;
				      }
         }
}


//-----------------------------------------
	var dtCh= "/";
	var minYear=2000;
	var maxYear=2100;

function Is_Data_corretta(dtStr,str_nome_campo)
{
		//alert("as")
		var daysInMonth = DaysArray(12)
		//if (!dtStr)  prima era attivo questo if....perchè? la fx non faceva il test corretto sulla data...
		//	return true		
		var pos1=dtStr.indexOf(dtCh)
		var pos2=dtStr.indexOf(dtCh,pos1+1)
		var strDay=dtStr.substring(0,pos1)
		var strMonth=dtStr.substring(pos1+1,pos2)
		var strYear=dtStr.substring(pos2+1)
		strYr=strYear
		if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
		if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
		for (var i = 1; i <= 3; i++) {
			if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
		}
		month=parseInt(strMonth)
		day=parseInt(strDay)
		year=parseInt(strYr)
		if (pos1==-1 || pos2==-1){
			alert(str_nome_campo +" deve avere il formato : gg/mm/aaaa")
			return false
		}
		if (strMonth.length<1 || month<1 || month>12){
			alert(str_nome_campo + " non corretta")
			return false
		}
		if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
			alert(str_nome_campo +" non corretta")
			return false
		}
		if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
			alert("La " +str_nome_campo + " deve avere il formato : gg/mm/aaaa")
			return false
		}
		if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
			alert(str_nome_campo + " non corretta")
			return false
		}
	return true
}


	
	function daysInFebruary (year){
		// February has 29 days in any year evenly divisible by four,
	    // EXCEPT for centurial years which are not also divisible by 400.
	    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
	}
	function DaysArray(n) {
		for (var i = 1; i <= n; i++) {
			this[i] = 31
			if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
			if (i==2) {this[i] = 29}
	   } 
	   return this
	}
    function stripCharsInBag(s, bag){
		var i;
	    var returnString = "";
	    // Search through string's characters one by one.
	    // If character is not in bag, append to returnString.
	    for (i = 0; i < s.length; i++){   
	        var c = s.charAt(i);
	        if (bag.indexOf(c) == -1) returnString += c;
	    }
	    return returnString;
	}
	function isInteger(s){
		var i;
	    for (i = 0; i < s.length; i++){   
	        // Check that current character is number.
	        var c = s.charAt(i);
	        if (((c < "0") || (c > "9"))) return false;
	    }
	    // All characters are numbers.
	    return true;
	}
//-------------------------------------	


function ricerca_delibere()
{
  var bool_ok_filtri
   bool_ok_filtri=true;

  if (new Number(document.forms[0].dal.value)!=0  )
    {
	 if ( !Is_Data_corretta(document.forms[0].dal.value,'Data Dal')  )
           {
               bool_ok_filtri=false;
		   }
    }
    else
        {
            if (new Number(document.forms[0].al.value)!=0)
               {
                 alert("Errore, se si specifica la data 'Al' occorre specificare anche la data 'Dal' e viceversa")
                 bool_ok_filtri=false;    
               }

        }

    
  if ( bool_ok_filtri)

    {
       if (new Number(document.forms[0].al.value)!=0  )
        {
			if ( !Is_Data_corretta(document.forms[0].al.value,'Data Al')  )
			{
				bool_ok_filtri=false;
			}
        } 
        else
             {
                if (new Number(document.forms[0].dal.value)!=0)
                   {
                      alert("Errore, se si specifica la data 'Dal' occorre specificare anche la data 'Al' e viceversa")
                      bool_ok_filtri=false;
                   }
             }
    }      

    if ( bool_ok_filtri)

    {
       if (new Number(document.forms[0].numero.value)!=0  )
        {
	       if ( isNaN(document.forms[0].numero.value)  )
			{
				alert("Errore, inserire un valore numerico per il campo 'Numero'")
				bool_ok_filtri=false;
			}
        } 
    }      
     
    if (bool_ok_filtri)
     {
        document.forms[0].submit()
     }

}

function get_pwd_IOC()
{
  if (new Number(document.forms[0].email.value)==0)
    {
      alert("Errore, specificare l'indirizzo email presso cui ricevere i dati di accesso")
    }
     else
         {
           var reem=/@/i;
           if (document.forms[0].email.value.search(reem) < 0)
             {
               alert("Errore, specificare un indirizzo email sintatticamente valido")
             }
              else
                  {
                    /*if (new Number(document.forms[0].username.value)==0)
                       {
                         alert("Errore, specificare lo username")
                       }
                        else
                             {*/
                               document.forms[0].submit()
                             //}  
                  }
         }
}

function scarica_37(percorso) 
{
 alert(percorso)
//var win = window.open(percorso);
//win.window.document.execCommand('SaveAs',null,percorso);
document.execCommand('SaveAs',null,percorso);
//win.window.close();
}



function traducilinktoblank() 
 { 
   for (var i=0; i<document.links.length; i++) 
     {
       //window.alert(document.links[i].className.search("blank"))

       if (document.links[i].className.search("blank")==0) 
       {
           { document.links[i].target="_blank"; } 
       } 
     }
         
 }
window.onload=traducilinktoblank;