var isOpera = navigator.userAgent.indexOf("Opera") > -1;
var isIE = navigator.userAgent.indexOf("MSIE") > 1 && !isOpera;
var isMoz = navigator.userAgent.indexOf("Mozilla/5.") == 0 && !isOpera;
var LIN = querystring('lin');

var debug=false

      function openHELP(lingua){
			   window.open('home/help/'+lingua+'.htm', '', 'top=0,left=0,width=600,height=500,location=no,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,status=no')
			}
			
      function UploadPopUp(cartella,nomeform,nomecampo,maxMB,tipo){
					var c="<iframe src='UploadFile.asp?OggettoForm="+nomecampo+"&maxMB="+maxMB+"&cartella="+cartella+"&tipo="+tipo+"&lingua="+lingua+"' frameborder='0' style='overflow:hidden;' width='456' height='200'></iframe>"
					var t=""
					if (lingua=="ITA"){
					   t="Upload File"
					}else{
					   t="Upload File"
					}
					showObox(c,0,{w:480,h:210,titolo:t});
      }
			
		  function CercaSito(){
		     $("btncerca").disabled=true;
		     $("CercaSito").submit();
				 showtip("searching...",80);
			}
	 
    	function ManageList(id_lista,n_item){
    		 /*
    		 <dl id='id_dl'>
    				 <dt onclick=ManageList('id_dl',0);>TITOLO 1</dt>				 
    			 			 <dd>descrizione 1</dd>"
    				 <dt onclick=ManageList('id_dl',1);>TITOLO 2</dt>				 
    			 			 <dd>descrizione 2</dd>"
    		 </dl>
    		 */
    		// se n_item == undefined, apre/chiude tutto l'albero
    		if(typeof(n_item)=="undefined"){
      		var zDT=document.getElementById(id_lista).getElementsByTagName('dt');	
    			
    			for (var n_item = 0; n_item <= zDT.length-1; n_item ++) {
    			   ManageList(id_lista,n_item)
    			}
    			
    		}else{
      		var zDD=document.getElementById(id_lista).getElementsByTagName('dd');
      		var zDT=document.getElementById(id_lista).getElementsByTagName('dt');			
      			 if(zDD[n_item].style.display=="block"){
      					ChangeStyle(zDD[n_item],'display:none');
    						ChangeStyle(zDT[n_item],'color:#333366');
          			ChangeStyle(zDT[n_item],'background-image:images/ico_piu.gif');
          	 }else{
      					ChangeStyle(zDD[n_item],'display:block');
    						ChangeStyle(zDT[n_item],'color:#ff0000');
      					ChangeStyle(zDT[n_item],'background-image:images/ico_meno.gif');
          	 }
    		}
    	}
	 
      function RegistraVoto(voto,id_doc,lin){
         HttpRequest("documentazione.asp?action=voto&voto=" + voto + "&id=" + id_doc + "&lin=" + lin,"voto");
      }
			
			function PopUpImg(titolo,immagine){
			   win=window.open('popup.htm?'+titolo+'&'+immagine,'', 'top=0,left=0,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no');
				 win.focus();
			}

      function ChangeStyle(obj,stile){
  			  /** es: ChangeStyle(idDiv,"display:block") **/
  			  stile=LCase(stile)
          var parametri = stile.split(':');
  				
  				if(typeof(obj)!="object"){
    				obj = $(obj);
    					if (obj){
    					}else{
							   if (debug){
    					   alert("fx:ChangeStyle:" + obj+ " non esiste!")
								 }
    						 return;
    					}
  				}
  				
					//alert("fx:ChangeStyle")
					
					//setStyle(obj, stile) 
					//alert()
					//return;
					
          for (var i = 0; i < parametri.length; i= i + 2) {
              switch (parametri[i]) {
                 case "text-decoration":
                      obj.style.textDecoration=parametri[i+1];
      								break;
                 case "background-image":
                      obj.style.backgroundImage="url("+parametri[i+1]+")";
      								break;	
                 case "background":
                      obj.style.background=parametri[i+1];
      								break;	
                 case "display":
                      obj.style.display=parametri[i+1];
      								break;	
                 case "visibility":
                      obj.style.visibility=parametri[i+1];
      								break;	
                 case "color":
                      obj.style.color=parametri[i+1];
      								break;	
                 case "border":
                      obj.style.border=parametri[i+1];
      								break;	
                 case "border-bottom":
                      obj.style.borderBottom=parametri[i+1];
      								break;		
                 default:
                      alert("Nessuno style definito")
        							break;
              }
          }
			}
	
	
      function HTMLdecode(str) {
        return unescape(str);
      }

  
      function SetContenutoObj(idDiv,contenuto){
				  
					$(idDiv).update(contenuto); 
					/*
					el = $(idDiv);
					if (el){
					}else{
					   if (debug){
					   alert("fx:SetContenutoObj: " + idDiv+ " non esiste!")
						 }
						 return;
					}

            switch (el.nodeName){
               		 case "DIV":
                      el.innerHTML = contenuto;
											break;
               		 case "SPAN":
                      el.innerHTML = contenuto;
											break;	
               		 case "TD":
                      el.innerHTML = contenuto;
											break;
               		 case "INPUT" :
                      el.value = contenuto;
											break;
               		 case "DD" :
                      el.value = contenuto;
											break;
									 default:
                      alert(contenuto);
											break;
            }
						*/
      }
		
			//*************************************************************************************************************
			//*************************************** AGGIUNGE EVENTI DINAMICAMENTE ***************************************

      function addEvent(elm, evType, fn, useCapture){ //addEvent(window, "load", editbox_init);
        if (elm.addEventListener){
           elm.addEventListener(evType, fn, useCapture);
           return true;
        } else if (elm.attachEvent){
           var r = elm.attachEvent("on"+evType, fn);
           return r;
        } else {
           alert("Please upgrade your browser to use full functionality on this page");
        }
      }

      // Adds event to window.onload without overwriting currently assigned onload functions.
      // Function found at Simon Willison's weblog - http://simon.incutio.com/
      function addLoadEvent(func)
      {	
      	var oldonload = window.onload;
      	if (typeof window.onload != 'function'){
          	window.onload = func;
      	} else {
      		window.onload = function(){
      		oldonload();
      		func();
      		}
      	}
      //addLoadEvent(initLightbox);	// run initLightbox onLoad
      }
			
			//************************************************** FINE *****************************************************
			//*************************************************************************************************************

			//*************************************************************************************************************
			//***************************************** SEGNALAZIONI E PROPOSTE *******************************************
			
			
      function GetContenuto(action,id,lin){
         HttpRequest("segnalazioni_ajax.asp?action=" + action + "&id=" + id + "&lin=" + lin,"testo",1);
         SelectCollectionItem(0,"item_" + id,"MenuTabsOptions","#808080","#3568CC");
      }
      
      function GetStorico(action,protocollo,lin){
         HttpRequest("segnalazioni_ajax.asp?action=" + action + "&protocollo=" + protocollo + "&lin=" + lin,"testo",1);
         //SelectCollectionItem(0,"item_" + id,"MenuTabsOptions");
      }
			
      function GetContent(protocollo,action,id,lin){
         HttpRequest("pdca_ajax.asp?action=" + action + "&id=" + id + "&lin=" + lin + "&protocollo=" + protocollo,"testo",1);
         SelectCollectionItem(0,"item_" + id,"MenuTabsOptions","#808080","#3568CC");
      }
      
      function GetHistory(action,protocollo,lin){
         HttpRequest("pdca_ajax.asp?action=" + action + "&protocollo=" + protocollo + "&lin=" + lin,"testo",1);
         //SelectCollectionItem(0,"item_" + id,"MenuTabsOptions");
      }
      
      var opened="";
      
      function EspandiStorico(link,id_div){
        if (link.indexOf("action=assegnato")>0){
        }else{

          if (opened==id_div){
        		   SetContenutoObj(id_div,'');	
							 opened=""; 				
        	}else{
               HttpRequest(link,id_div,0);					
							 opened=id_div; 				
        	}	
        }
      }

      function ToggleStorico(id_div){
  			 var ico="";			
  	     $("testo_storico_"+id_div).toggle();
  			 if ($("testo_storico_"+id_div).style.display=="none"){
  			    ico="images/ico_piu.gif"
  			 }else{
  			    ico="images/ico_meno.gif"
  			 }
  			 $("ico_storico_"+id_div).src=ico;
      }
			//************************************************** FINE *****************************************************
			//*************************************************************************************************************

			//*************************************************************************************************************
			//*************************************************** AJAX ****************************************************

      function HttpRequest(){
      	var args = HttpRequest.arguments;
				//*** HttpRequest(link,obj,options)		
				//*** args[0] = link a pagina asp da elaborare
				//*** args[1] = id oggetto (DIV,SPAN,INPUT,etc...) dove restituire il risultato
				//*** args[2] = options
				  
				  SetContenutoObj(args[1],"loading...");
			
				  var onSuccessFx=""
					if((args.length-1)>=2){
						 var fi = LCase(args[2]).indexOf("onsuccess");
						 if (fi>=0){
						    fi=LCase(args[2]).indexOf(":",fi);
						 		fe=LCase(args[2]).indexOf(")",fi);
								l=fe-fi
						    onSuccessFx=args[2].substr(fi+1, l+1).trim();
						 }
      	  }

					if (onSuccessFx!=""){
					   new Ajax.Updater(args[1], args[0], {asynchronous:true,
						 		 											 					 evalScripts:true,									 										 															 
                                    						 onSuccess:eval(onSuccessFx),
																								 onFailure:HttpRequestError
                                    						 }); 	
					}else{
					   new Ajax.Updater(args[1], args[0], {asynchronous:true,
						 		 											 					 evalScripts:true,
																								 onFailure:HttpRequestError																									 																								
						 		 											 					 }); 	
					} 	 

        	var myGlobalHandlers = {
        		onCreate: function(){
							Element.show('systemWorking')
        		},
        		onComplete: function() {
        			if(Ajax.activeRequestCount == 0){
        				Element.hide('systemWorking')
        			}
        		}
        	};

        	Ajax.Responders.register(myGlobalHandlers);					

      }
			
      var HttpRequestError= function(t) {
			   if (lingua=="ITA"){
  			    alert("Si è verificato un errore imprevisto nella richiesta.\nImpossibile proseguire.");
						hideObox();
				 }else{
  			    alert("An unexpected error is occured.\nRequest aborted.");
						hideObox();
				 }
				 document.write (t.responseText)
      }

			
			//************************************************** FINE *****************************************************
			//*************************************************************************************************************

			//*************************************************************************************************************      			
			//*********************************************** DATAPICKER **************************************************


      var ns6=document.getElementById&&!document.all
      var ie4=document.all
      
      var Selected_Month;
      var Selected_Year;
      var Current_Date = new Date();
      var Current_Month = Current_Date.getMonth();
      
      var Days_in_Month = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
      var Month_Label;
      var Current_Year = Current_Date.getFullYear();
      if (Current_Year < 1000)
      Current_Year+=1900
      
      var HTML_String="";
      var calLanguage="";
      var Selected_calId="";
      //var inputId="";
      var Today = Current_Date.getDate();
      
      
      
      function Skip(Selected_calId,Direction) {
         if (Direction == '+') {
            if (Selected_Month == 11) {
               Selected_Month = 0;
               Selected_Year++;
            }else{
               Selected_Month++;
            }
         }else{
            if (Selected_Month == 0) {
               Selected_Month = 11;
               Selected_Year--;
            }else{
               Selected_Month--;
            }
         }
         Make_Calendar(Selected_calId, Selected_Year, Selected_Month);
      }
      
      function Make_Calendar(Selected_calId, Year, Month) {
				 if (typeof(Year)=="undefined"){
				    Year=Current_Year
				 }
				 if (typeof(Month)=="undefined"){
				    Month=Current_Month
				 }
				 
         Selected_Month=Month;
         Selected_Year= Year;
				 
      	 if (calLanguage=="ITA"){
      	    Month_Label = new Array('Gennaio', 'Febbraio', 'Marzo', 'Aprile', 'Maggio', 'Giugno', 'Luglio', 'Agosto', 'Settembre', 'Ottobre', 'Novembre', 'Dicembre');
      			WeekDay_label = new Array('D', 'L', 'M', 'M', 'G', 'V', 'S');
      			Etichetta = new Array('Oggi','Mese Precedente','Mese Successivo');
      	 }else{
      	    Month_Label = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
      			WeekDay_label = new Array('S', 'M', 'T', 'W', 'T', 'F', 'S');
      			Etichetta = new Array('Today','Previous Month','Next Month');
      	 }
      	 
         var First_Date = new Date(Year, Month, 1);
      	 
         if (Month == 1) {
            Days_in_Month[1] = ((Year % 400 == 0) || ((Year % 4 == 0) && (Year % 100 !=0))) ? 29 : 28;
         }
      	
         var First_Day = First_Date.getDay() + 1;
         if (((Days_in_Month[Month] == 31) && (First_Day >= 6)) ||
             ((Days_in_Month[Month] == 30) && (First_Day == 7))) {
            var Rows = 6;
         }
         else if ((Days_in_Month[Month] == 28) && (First_Day == 1)) {
            var Rows = 4;
         }
         else {
            var Rows = 5;
         }

         TwoDigitYear=Year.toString().substring(Year.toString().length - 2, Year.toString().length);
      	 
      	 var Heading  =  "";
      
      	 Heading = "<a href='#' onclick=Skip('"+Selected_calId+"','-'); TITLE='" + Etichetta[1] + "'><img src='images/ico_pag_precedente.gif' border=0></a> ";
      	 
      	 Heading = Heading + "<select onChange=Make_Calendar('"+Selected_calId+"','"+Selected_Year+"',this.value) style='background:#EAEAEA;font-family:Tahoma;font-size:11px;width:100px;'>";
      //	  onChange=Make_Calendar('"+Selected_calId+"', Selected_Year, this.value)
             for (j=0;j<Month_Label.length;j++) {
      	        Heading = Heading + "<option value='" + j + "'";
      					   if (j==Month){
      					      Heading = Heading + " selected";
      					   }
      	        Heading = Heading + ">" + Month_Label[j] + " " + TwoDigitYear + "</option>";
             }
      
      	 Heading = Heading + "</select> <a href='#' onclick=Skip('"+Selected_calId+"','+'); TITLE='" + Etichetta[2] + "'><img src='images/ico_pag_prossima.gif' border=0></a>";
         
      	 if (document.all){
            HTML_String="<IFRAME id='iframe' style='position:absolute;top:0px;left:0px;width:140px;height:164px;' src='javascript:false;' frameBorder='1' scrolling='no'></IFRAME>"
      	 }
      	 //
         HTML_String += '<table style="position:absolute;top:0px;left:0px;background:#FFFFFF;width:140px;height:164px;font-family:Tahoma;font-size:11px;border:1px solid #808080;" cellspacing=0 cellpadding=2>';
      
         HTML_String += '<tr><td colspan=7 align=center style=background:#EAEAEA;>' + Heading + '</td></tr>';
      
         HTML_String += '<tr>';
      	 
      	 for (j=0;j<WeekDay_label.length;j++) {
      	    HTML_String += '<td style="text-align:center;font-weight:bold;border-bottom:1px solid #808080;">' + WeekDay_label[j] + '</td>';
      	 }
      
         HTML_String += '</tr>';
      
         var Day_Counter = 1;
         var Loop_Counter = 1;
         for (var j = 1; j <= Rows; j++) {
            HTML_String += '<tr ALIGN="center" VALIGN="middle">';
            for (var i = 1; i < 8; i++) {
               if ((Loop_Counter >= First_Day) && (Day_Counter <= Days_in_Month[Month])) {
      				 
      				    Current_Data=Day_Counter.toString()+"/0"+Current_Month.toString()+"/"+Current_Year.toString()
      						//alert(Day_Counter+"/0"+Current_Month+"/0"+Current_Year)
                  if ((Day_Counter == Today) && (Year == Current_Year) && (Month == Current_Month)) {
                     HTML_String += '<td><b><a href=javascript:Set_Data("'+Selected_calId+'",'+Day_Counter+'); style="font-size:11px;color:#FF0000;" title="' + Etichetta[0] + '">' + Day_Counter + '</a></b></td>';
                  }
                  else {
      						   if ((i==1) || (i==7)){color="#808080";}else{color="#000000";}
                     HTML_String += '<td onmouseover=this.style.background="#EAEAEA" onmouseout=this.style.background="#FFFFFF"><a href="#" onclick=Set_Data("'+Selected_calId+'",'+Day_Counter+');  style="font-size:11px;color:'+color+';text-decoration:none;">' + Day_Counter + '</a></td>';
                  }
      						
      						
                  Day_Counter++;   
      						//Set_Data('+Day_Counter+'); 
               }
               else {
                  HTML_String += '<td> </td>';
               }
               Loop_Counter++;
            }
            HTML_String += '</tr>';
         }
         HTML_String += '<tr><td colspan=7 align=center style="border-top:1px solid #808080;background:#EAEAEA;color:#FFFFFF;"><a href=# style=font-size:11px; onclick=Set_Data("'+Selected_calId+'","")>reset</a> | <a href=# style=font-size:11px; onclick=Make_Calendar("'+Selected_calId+'")>oggi</a> | <a href=# style=font-size:11px; onclick=Reset_Calendar("'+Selected_calId+'")>chiudi</a></td></tr></table>';
      
         Print_Calendar(Selected_calId);
      }
      
      function Print_Calendar(Selected_calId){
      	 $(Selected_calId+"_Calendar").innerHTML = HTML_String;
      }
      
      function Reset_Calendar(Selected_calId){
      	 $(Selected_calId+"_Calendar").innerHTML = "";
      }
      
      function Set_Data(Selected_calId,gg){
         if (gg!=""){
        	 gg="00"+gg
        	 gg=gg.substring(gg.toString().length - 2, gg.toString().length);
           mm=new Number(Selected_Month)+1
        	 mm="00"+mm
        	 mm=mm.substring(mm.toString().length - 2, mm.toString().length);
        	 yyyy=Selected_Year
         	 $(Selected_calId).value=gg+"/"+mm+"/"+yyyy;
      	 }else{
         	 $(Selected_calId).value="";
      	 }
      	 Reset_Calendar(Selected_calId);
      }
      
      function DataPicker(){
         var args = DataPicker.arguments;
      	 Selected_calId=args[0];
      	 calLanguage=args[1];
      	 
      	 if((args.length-1)>=2){
      	    defValue=args[2];
      	 }else{
      	    defValue=""
      	 }

         Year=Current_Year
         Month=Current_Month
				 
      	 if (defValue!=""){
				   if (defValue!="?"){
      		   Month=new Number(defValue.substring(3, 5))-1 //*** mese a base 0 in javascript 
        	   Year=defValue.substring(6, 10)
        	 }
      	 }

         if (calLanguage==null){calLanguage = "ING";}else{calLanguage=args[1];}

      	 if((args.length-1)>=3){
      	    holder=args[3];
      	 }else{
      	    holder=""
      	 }
				 
         dp="<input type='text' class='form1' id='" + Selected_calId + "' name='" + Selected_calId + "' value='" + defValue + "' READONLY style='width:80px;'>";
         dp=dp+"<input type='button' name='cmdCal' style=margin-left:1px;border:0px;background-image:url('images/cal.gif');height:16px;width:16px;cursor:pointer; onclick=Make_Calendar('"+Selected_calId+"','"+Year+"','"+Month+"');>";
         dp=dp+"<div id='"+Selected_calId+"_Calendar' style='position:absolute;z-index:+100;'></div>"
         
      	 if (holder!=""){
      			new Insertion.After(holder, dp);
      	 }else{
      	    document.writeln(dp);
      	 }
      }
      
			//************************************************** FINE *****************************************************
			//*************************************************************************************************************

			//*************************************************************************************************************
			//*********************************************** oBox (Overlay Box) ******************************************
        
        var nshowObox=0;
        
        function showObox()
        {
          var args = showObox.arguments;
					
              var link=args[0];
              var mode=args[1];				//*** mode=0 -> args[0] è il contenuto dell'oBox; mode=1 -> args[0] è il link per la richiesta AJAX
							var options=args[2];
							var altezza=0;
							var larghezza=0;							
							var target="new";
							var overflow="hidden";
							var parameters="";
							var titolo="";
							
              // *** gestione oggetto Hash delle opzioni ,{ciccio:1,pippo:2}
							if (typeof(options)=="object"){
                  var h = $H(options);
                     h.each(function(pair) {
                     //alert(pair.key + ' = "' + pair.value + '"');
										 if (pair.key=="h"){altezza=pair.value;}
										 if (pair.key=="w"){larghezza=pair.value;}
										 if (pair.key=="overflow"){overflow=pair.value;}
										 if (pair.key=="target"){target=pair.value;}
										 if (pair.key=="titolo"){titolo=pair.value;}
										 if (pair.key=="form"){parameters=Form.Serialize($(pair.value));} 
                  });
							}

        			if(larghezza==0 || altezza==0){
        			   var arrayPageSize = getPageSize();
        			   larghezza=arrayPageSize[0]-80;
        				 altezza=arrayPageSize[3]-80;
        			}else{
        			   larghezza=new Number(larghezza)
        				 altezza=new Number(altezza)
        			}		
							
        			SetAllSelectVisibility("hidden");

        	if (target!="self"){ //se target = self devo riutillizare l'ultimo oBox esistente
        			nshowObox=nshowObox+1
        
        	    var objBody = document.getElementsByTagName("body").item(0);
        			
            	var arrayPageSize = getPageSize();
            	var arrayPageScroll = getPageScroll();
        
        		  // center lightbox and make sure that the top and left values are not negative and the image placed outside the viewport
        		  var lightboxTop = arrayPageScroll[1] + ((arrayPageSize[3] - 35 - altezza) / 2);
        		  var lightboxLeft = ((arrayPageSize[0] - larghezza) / 2);
        						
        		  // crea ombra se non esiste già
        			if (!$('overlay')){
            	var objOverlay = document.createElement("div");
                	objOverlay.setAttribute("id","overlay");
            			objOverlay.onclick = function () {hideObox(nshowObox); return false;}
                	objOverlay.style.position = 'absolute';
                	objOverlay.style.top = "0px";
                	objOverlay.style.left = "0px";
                	objOverlay.style.zIndex = "90";
                 	objOverlay.style.width = "100%";
                	objOverlay.style.height = (arrayPageSize[1]-5 + "px");
                	objOverlay.style.display = "block";
              objBody.appendChild(objOverlay);	
							//setOpacity(objOverlay,80) 
							new Effect.Opacity(objOverlay, {duration:0.0, from:0.1, to:0.8})

        			}
							
            	// crea contenitore
        			xpos=(lightboxLeft < 0) ? "0px" : lightboxLeft + "px";
        			ypos=(lightboxTop < 0) ? "0px" : lightboxTop + "px";			
        			
            	var objLightbox = document.createElement("div");
                	objLightbox.setAttribute('id','lightbox'+nshowObox);
        					objLightbox.style.position = 'absolute';
        					objLightbox.style.zIndex = '100';
                	objLightbox.style.top = ypos
                	objLightbox.style.left = xpos
objLightbox.style.display = "none";
              		objLightbox.style.width = larghezza+"px";
									
                	objLightbox.style.height = (altezza+25)+"px"; //*** 25 altezza caption
              objBody.appendChild(objLightbox);		
        
        				var top = "<table style='width:100%;height:100%;text-align:left;' border='0' cellpadding='0' cellspacing='0'>"
            				top= top+ "<tr style='height:24px;'>"
        						
            					top= top+ "<td style='vertical-align:top;width:5px;'>"
            						top= top+ "<img src='images/top-left.gif' style='width:5px;height:24px;'>"
            					top= top+ "</td>"
        							
            					top= top+ "<td style='vertical-align:top;width:100%;background-image:url(images/top.gif);background-repeat:repeat-x;text-align:right;'><span class='oBoxtitle'>"+titolo+"</span><a href='javascript:hideObox("+nshowObox+");' title='Close'><img src='images/close.gif' border='0' onmouseover=close.src='images/close_over.png' onmouseout=close.src='images/close.png'></a></td>"
        							
              				top= top+ "<td style='vertical-align:top;width:19px;'>"
              					top= top+ "<a href='javascript:hideObox("+nshowObox+");' title='Close'><img name='close' src='images/close.png' style='width:19px;height:24px;' border='0' onmouseover=this.src='images/close_over.png' onmouseout=this.src='images/close.png'></a>"
              				top= top+ "</td>"
        							
              				top= top+ "<td style='vertical-align:top;width:15px;'>"
              				 top= top+ "<img src='images/top-right.gif' style='width: 7px; height: 24px;'>"
              				top= top+ "</td>"
        							
            				top= top+ "</tr>"
        						
            				top= top+ "<tr>"
            				  top= top+ "<td style='vertical-align: top; width: 5px; background-image: url(images/left-border.gif);'></td>"
        							
            					top= top+ "<td bgcolor='#FFFFFF' colspan='2' style='vertical-align:top;'>"
											
              		var bottom = "</td>"
        					
            				  bottom= bottom+ "<td style='vertical-align:top;background-image:url(images/right-border.png);'></td>"
        							
            				bottom= bottom+ "</tr>"
        						
            				bottom= bottom+ "<tr style='height:5px;'>"
        						
            				  bottom= bottom+ "<td style='vertical-align:top;height:5px;'>"
            					  bottom= bottom+ "<img src='images/left-bottom.gif' style='width:5px;height:5px;'>"
            					bottom= bottom+ "</td>"
        							
            					  bottom= bottom+ "<td style='vertical-align:top;background-image: url(images/bottom.png);;background-repeat:repeat-x;text-align: right;'></td>"
        								
            					bottom= bottom+ "<td style='vertical-align: top;'>"
            					  bottom= bottom+ "<img src='images/resize.png' style='width:19px;height:5px;' border='0'>"
            					bottom= bottom+ "</td>"
        							
            					bottom= bottom+ "<td style='vertical-align: top;'>"
            					  bottom= bottom+ "<img src='images/low-right.png' style='width:7px;height:5px;' border='0'>"
            					bottom= bottom+ "</td>"
        							
            				bottom= bottom+ "</tr>"

										bottom= bottom+ "</table>";
        
        				var content = "<div id='lightboxContent"+nshowObox+"' style='width:100%;height:"+(altezza-5)+"px;overflow:"+overflow+";background:#FFFFFF;' class='lightboxContent'></div>"; // altezza - altezza bottom
        

				
              	objLightbox.innerHTML = top + content + bottom
        	
            		//objLightbox.style.display = 'block';
Effect.toggle(objLightbox,'appear', {duration:0.7})
        
        	}
        	switch (mode) {
                 case 1:
          					 HttpRequest(link,"lightboxContent"+nshowObox,"evalScripts:true");
              			 break;
                 default :
              	     SetContenutoObj("lightboxContent"+nshowObox,decodeURIComponent(link));
              			 break;
        	}
        	//return false;
        
        }
        
        function hideObox(quale)
        {
					objOverlay = $('overlay');
					if(typeof(quale)=="undefined"){
             //*** se non viene specificato quale Obox chiudere, gli chiudo tutti
             for (var i = 1; i <= nshowObox; i ++) {			 
                objLightboxChild = $('lightbox'+i);
          	    objLightboxChild.parentNode.removeChild(objLightboxChild)
          	    nshowObox=nshowObox-1	
             }
						 objOverlay.parentNode.removeChild(objOverlay)
						 
             SetAllSelectVisibility("visible");	
        	   return;
        	}

        	objLightbox = $('lightbox'+quale);
        	objLightbox.parentNode.removeChild(objLightbox)
        	if(quale==1){//elimina l'ombra sole se si sta chiudendo il 1° degli oBox (quello con "Z minore")
        	   if(nshowObox>1){
        		     //se si sta chiudendo la finestra principale (n°1) allora chiudo ancke tutte le altre
                  for (var i = 2; i <= nshowObox; i ++) {
        					   	objLightboxChild = $('lightbox'+i);
        							objLightboxChild.parentNode.removeChild(objLightboxChild)
        							nshowObox=nshowObox-1	
                  }
        		 }
						 objOverlay.parentNode.removeChild(objOverlay)
             SetAllSelectVisibility("visible");		 
        	}
        	if(quale>1){
					   //se si sta chiudendo una finestra ke non è quella cn Z + basso,rivisualizzo solo le select della finestra immediatamente precendete in Z
        	   objLightboxPrev = $("lightbox" + (new Number(quale)-1));
             var ss = objLightboxPrev.getElementsByTagName("select"); 
             for(var i=0; i<ss.length; i++){ 
                ss[i].style.visibility = "visible"; 
             } 	
					}
						 
        	nshowObox=nshowObox-1	
        }

				
        // getPageScroll()
        // Returns array with x,y page scroll values.
        
        function getPageScroll(){
        
        	var yScroll;
        
        	if (self.pageYOffset) {
        		yScroll = self.pageYOffset;
        	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
        		yScroll = document.documentElement.scrollTop;
        	} else if (document.body) {// all other Explorers
        		yScroll = document.body.scrollTop;
        	}
        
        	arrayPageScroll = new Array('',yScroll) 
        	return arrayPageScroll;
        }
        
        // getPageSize()
        // Returns array with page width, height and window width, height
				
        function getPageSize(){
        	
        	var xScroll, yScroll;
        	
        	if (window.innerHeight && window.scrollMaxY) {	
        		xScroll = document.body.scrollWidth;
        		yScroll = window.innerHeight + window.scrollMaxY;
        	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
        		xScroll = document.body.scrollWidth;
        		yScroll = document.body.scrollHeight;
        	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
        		xScroll = document.body.offsetWidth;
        		yScroll = document.body.offsetHeight;
        	}
        	
        	var windowWidth, windowHeight;
        	if (self.innerHeight) {	// all except Explorer
        		windowWidth = self.innerWidth;
        		windowHeight = self.innerHeight;
        	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
        		windowWidth = document.documentElement.clientWidth;
        		windowHeight = document.documentElement.clientHeight;
        	} else if (document.body) { // other Explorers
        		windowWidth = document.body.clientWidth;
        		windowHeight = document.body.clientHeight;
        	}	
        	
        	// for small pages with total height less then height of the viewport
        	if(yScroll < windowHeight){
        		pageHeight = windowHeight;
        	} else { 
        		pageHeight = yScroll;
        	}
        
        	// for small pages with total width less then width of the viewport
        	if(xScroll < windowWidth){	
        		pageWidth = windowWidth;
        	} else {
        		pageWidth = xScroll;
        	}
        
        
        	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
        	return arrayPageSize;
        }

			//************************************************** FINE *****************************************************
			//*************************************************************************************************************
  		
      function getPageCoords (element){
        var coords = {x: 0, y: 0}; 
        while (element) { 
          coords.x += element.offsetLeft; 
          coords.y += element.offsetTop; 
          element = element.offsetParent; 
        } 
        return coords; 
      } 

		  var page,npage,CurrentNumPag,NumPag,obj_placeholder
					page=1
					
      function CambiaPagina(link,id_div,RecordsPerPage,azione,event){
    
				 obj_placeholder=$(id_div)
				 CurrentNumPagObj=$("CurrentNumPag")
				 NumPag=new Number($("NumPag").value)
				 
      	 CurrentNumPagValue=new Number(CurrentNumPagObj.value)
         var errore=false;
         var numerico = new RegExp("[^0-9]");
				 
				 if(Ajax.activeRequestCount>0){
      		  errore=true;//** evita richiesta multiple (0->una richiesta attiva)
				 }else{
          	 if (CurrentNumPagValue<1 || CurrentNumPagValue>NumPag){
          		  errore=true;
								if (lingua=="ITA"){
          			   alert("Sono ammessi solo valori numerici tra 1 e "+NumPag);
								}else{
          			   alert("You can use only values between 1 and "+NumPag);
								}
          	 } 
          	 if(numerico.test(CurrentNumPagValue)){
                errore=true;
								if (lingua=="ITA"){
          			   alert("Sono ammessi solo valori numerici tra 1 e "+NumPag);
								}else{
          			   alert("You can use only values between 1 and "+NumPag);
								}
          	 }		

           	 if (errore==false){
          	   	page=CurrentNumPagValue;									 
                switch (azione) {
                   case "next":
          								 if (CurrentNumPagValue<NumPag){
          								    page=CurrentNumPagValue+1;
          								 }else{
          								    errore=true;
															if (page==1){
                								if (lingua=="ITA"){
                          			   showtip("Non ci son altre pagine",140);hidetip(500);
                								}else{
  															   showtip("This is the only page",140);hidetip(500);
                								}
															}else{
                								if (lingua=="ITA"){
                          			   showtip("Questa è l\'ultima pagina",140);hidetip(500);
                								}else{
  															   showtip("This is the last page",140);hidetip(500);
                								}
															}
          								 }
          							break;
          							
                   case "last":
          								 if (CurrentNumPagValue<NumPag){
          							      page=NumPag;
          								 }else{
          								    errore=true;
															if (page==1){
                								if (lingua=="ITA"){
                          			   showtip("Non ci son altre pagine",140);hidetip(500);
                								}else{
  															   showtip("This is the only page",140);hidetip(500);
                								}
															}else{
                								if (lingua=="ITA"){
                          			   showtip("Questa è l\'ultima pagina",140);hidetip(500);
                								}else{
  															   showtip("This is the last page",140);hidetip(500);
                								}
															}								
          								 }
          							break;
          							
                   case "prev":
          								 if (CurrentNumPagValue-1>0){
          							      page=CurrentNumPagValue-1;
          								 }else{
          								    errore=true;
															if (page==1){
                								if (lingua=="ITA"){
                          			   showtip("Non ci son altre pagine",140);hidetip(500);
                								}else{
  															   showtip("This is the only page",140);hidetip(500);
                								}
															}else{
                								if (lingua=="ITA"){
                          			   showtip("Questa è la prima pagina",150);hidetip(500);
                								}else{
  															   showtip("This is the first page",150);hidetip(500);
                								}
															}
          								 }
          							break;	
          							
                   case "first":
          								 if (CurrentNumPagValue>1){
          							      page=1;
          								 }else{
          								    errore=true;
															if (page==1){
                								if (lingua=="ITA"){
                          			   showtip("Non ci son altre pagine",140);hidetip(500);
                								}else{
  															   showtip("This is the only page",140);hidetip(500);
                								}
															}else{
                								if (lingua=="ITA"){
                          			   showtip("Questa è la prima pagina",150);hidetip(500);
                								}else{
  															   showtip("This is the first page",150);hidetip(500);
                								}
															}
          								 }
          							break;	
          
          									
                   case "gotopage":
          	
                        page=CurrentNumPagValue;
    							 
          							break;							
                } 
          	 }
				 }
				 
         if (errore==false){
				 
      	 	 $("first").src="images/ico_pag_prima_gray.gif"
					 $("prev").src="images/ico_pag_precedente_gray.gif" 
      		 $("last").src="images/ico_pag_ultima_gray.gif"
      		 $("next").src="images/ico_pag_prossima_gray.gif" 
					 CurrentNumPagObj.disabled=true;
					 //setOpacity(obj_placeholder,40)		
					 
					 new Effect.Opacity(obj_placeholder, {duration:0.1, from:1.0, to:0.3});
					 Element.show('systemWorking')
    			 if (lingua=="ITA"){
    			    showtip("Caricamento pagina " + page,140);
    			 }else{
    			    showtip("Loading page " + page,100);
    			 }
					 
					 //new Ajax.Updater(id_div,link+"&page="+page+"&RecordsPerPage="+RecordsPerPage+"&lin="+LIN, {onSuccess:handlerCambiaPagina});
		 		   new Ajax.Request(link+"&page="+page+"&RecordsPerPage="+RecordsPerPage+"&lin="+LIN, {onSuccess:handlerCambiaPagina});
      	 }
		}

    var handlerCambiaPagina = function(t) { 
							var risultato=t.responseText
							//*** ripulisco DOM ***
              var children = obj_placeholder.childNodes;
              	   for (var i = 0; i < children.length; i++) 
              	   {
              			//alert(i+"."+children[i].tagName) 
                    obj_placeholder.removeChild(children[i]);
                   }	
							//***
              obj_placeholder.innerHTML=risultato
							
        			var npage=new Number(page)
							new Effect.Opacity(obj_placeholder, {duration:0.2, from:0.3, to:1.0});
				
        			if (npage>1){
        		     $("first").src="images/ico_pag_prima.gif"
        			   $("prev").src="images/ico_pag_precedente.gif" 
        			}else{
        			   $("first").src="images/ico_pag_prima_gray.gif"
        			   $("prev").src="images/ico_pag_precedente_gray.gif" 
        			}		
        			if (npage<NumPag){
        		     $("last").src="images/ico_pag_ultima.gif"
        			   $("next").src="images/ico_pag_prossima.gif" 
        			}else{
        			   $("last").src="images/ico_pag_ultima_gray.gif"
        			   $("next").src="images/ico_pag_prossima_gray.gif" 
        			}
  						CurrentNumPagObj.disabled=false;
        			CurrentNumPagObj.value=page;	
							Element.hide('systemWorking')
							hidetip();
							InitDataGrid(obj_placeholder)		
      }
					

			function InitDataGrid(PlaceHolder)
      {
					if(typeof(PlaceHolder)!="object"){
						obj_PlaceHolder = $(PlaceHolder);
					}					
							var TagTable = obj_PlaceHolder.getElementsByTagName('TABLE')
							for (var i = 0; i < TagTable.length; i++)
              {
                var TagTr = TagTable.item(i).getElementsByTagName('TR')
                for (var i = 1; i < TagTr.length; i++) // i=1 -> la prima riga (i=0) è l'intestazione
                  {
                    TagTr.item(i).onmouseover = function()
                    {
                       this.className = 'TR_hover'
                    }							 
                    TagTr.item(i).onmouseout = function()
                    {
                       this.className = TagTrOut(this.id)
              			}
									}
				     	 }
      }
					
			function TagTrOut(TRid){
			   TRid=Right(TRid,(Len(TRid)-1))
				 if(TRid % 2==0){c="TRdg1";}else{c="TRdg2";};
				 return c
			}
			
			/*
      function setOpacity(obj,opacity){
      opacity=(opacity==100) ? 99.999 : opacity;
      // IE/Win
      obj.style.filter = "alpha(opacity:"+opacity+")";
      // Safari<1.2, Konqueror
      obj.style.KHTMLOpacity = opacity/100;
      // Older Mozilla and Firefox
      obj.style.MozOpacity = opacity/100;
      // Safari 1.2, newer Firefox and Mozilla, CSS3
      obj.style.opacity = opacity/100;
      } 
      
      function fadeIn(objId,opacity){
      if(!document.getElementById) return;
      obj = document.getElementById(objId);
      if(opacity <= 100){
        setOpacity(obj,opacity);
        opacity += 10;
        window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
        }
      } 
			*/
			
    function querystring(whichOne){ 
       var pairs = location.search.substring(1).split('&');
       var r = "";
       var tp = new Array();
       for (var i = 0; i < pairs.length; i ++) {
       tp = pairs[i].split('=');
       if (LCase(whichOne) == LCase(tp[0]))
          r = unescape(tp[1].replace(/\+/g, " "));
       }
       return r;
    }

		function GoLink(){
		   var args = GoLink.arguments;
			 Element.show('systemWorking')
		   location.href=args[0];
		}
		
    function CopiaContenutoDiv(idDivDa,idDivA){
		   if(!$(idDivA)){
			    alert("fx:CopiaContenutoDiv:" + idDivA + " non esiste")
			 }
		   if(!$(idDivDa)){
			    alert("fx:CopiaContenutoDiv:" + idDivDa + " non esiste")
			 }
    	 $(idDivA).innerHTML=$(idDivDa).innerHTML
    }
		
		function SetAllSelectVisibility(visibility){
       var ss = document.getElementsByTagName("select"); 
       for(var i=0; i<ss.length; i++){ 
          ss[i].style.visibility = visibility; 
       } 	
		}
		
    function SelectCollectionItem(){
      // *** argomenti: stile,id,CtrlName,VALOREproprietàFF,VALOREproprietàON
    //var x=document.getElementById("TabStrip1")
    //alert("I am a " + x.tagName + " " + x.attributes + " element")
    //alert(x.length + " elements!")
       var args = SelectCollectionItem.arguments;
    	 //	 args[0] = style da modificare: 0 -> color
			 //		 				 	 			 							1 -> backgroundPosition
    	 //	 args[1] = id item collection	da selezionare
    	 //	 args[2] = id contenitore collection
       
			 var CtrlName_Children=$(args[2]).childNodes;
       
    	 //*** resetta tutte elementi collezione *** stato OFF ***
    	 for(x=0;x<CtrlName_Children.length;x++){
			 		var obj=CtrlName_Children.item(x)

    	    if(obj.id!="ignora"){   					
  						if (typeof obj.innerHTML!="undefined"){
        				 switch (args[0]) {
                     case 0:
        									 obj.style.color=args[3]//'#C0C0C0'
                        break;
                     case 1:
													 //obj.style.backgroundPosition="0 0"
													 obj.className=""
                        break;
                     default:
                        break;
                  }
							}
    			}
					
    	 }
			 
    	 var obj=$(args[1])//args[1]

			 if (obj){
    	 //*** evidenzia elemento selezionato collezione *** stato ON ***
       switch (args[0]) {
              case 0:
                   obj.style.color=args[4]//'#FF0000'
                break;
              case 1:
				 					 obj.className="TabStripMenuCurrent"
                break;
              default:
              	break;
       }
			 } 
    }
		
    function FullScreen(url){
       var str = "left=0,screenX=0,top=0,screenY=0,status=1,menubar=0,";
       if (window.screen) {
          var ah = screen.availHeight - 50;
          var aw = screen.availWidth - 10;
          str += ",height=" + ah;
          str += ",innerHeight=" + ah;
          str += ",width=" + aw;
          str += ",innerWidth=" + aw;
       }else{
          str += ",resizable";
       }
       window.open(url, "", str);
    }
		
    function OpenPopUp(url,width,height,scrollbars,menubar,resizable){
		var top=((screen.availHeight-height)<0)?0:parseInt(((screen.availHeight-height)/2)-10)
		var left=((screen.availWidth-width)<0)?0:parseInt(((screen.availWidth-width)/2)-30)
		var str = "left="+left+",top="+top+",width="+width+",height="+height+",scrollbars="+scrollbars+",menubar="+menubar+",resizable="+resizable+",location=0,toolbar="+menubar
		popup=window.open(url, "", str);
		popup.focus();
    }

		function show_calcolatrice(form){
		   //alert(form);
    		  var top=parseInt(((screen.availHeight-180)/2)-30)
    		  var left=parseInt(((screen.availWidth-160)/2)-30)
			
        	var WinCalcolatrice = window.open("", "Calendar","top="+top+",left="+left+",width=160,height=180,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=no,status=no");
        	//WinCalcolatrice.opener = self;
					
        	WinCalcolatrice.document.writeln("<html>");
        	WinCalcolatrice.document.writeln("<head><title>Numeric Pad</title>");
        	WinCalcolatrice.document.writeln("<style>TD{font-family:Tahoma;color:#2B2B80;font-size:12px;text-align:center;border:1px ridge #FFFFFF;height:30px;}A{text-decoration:none;}.button{font-family:Tahoma;color:#2B2B80;font-size:12px;text-align:center;border:1px ridge #FFFFFF;width:30px;height:30px;}.buttonO{font-family:Tahoma;color:#ff0000;font-size:12px;text-align:center;border:1px ridge #FFFFFF;width:30px;height:30px;background:#EAEAEA;}.dispay{font-family:Tahoma;font-size:20px;text-align:center;border:1px ridge #FFFFFF;width:132px;height:30px;background:#EAEAEA;}</style>");
					WinCalcolatrice.document.writeln("<SCRIPT>function SetO(){if(dispay.value!=''){opener." + form + ".value=dispay.value;opener." + form + ".focus();window.close();}else{alert('Invalid Null value');}}function SetN(n){dispay.value=dispay.value+n;}</SCRIPT>");
        	WinCalcolatrice.document.writeln("</head>");
        	WinCalcolatrice.document.writeln("<body onload='this.focus();' align='center' bgcolor='#EAEAEA'>");
					WinCalcolatrice.document.writeln("<input class='dispay' type='text' name='dispay' value='' READONLY>");			
					     	
					   var Bottoni=new Array("0","1","2","3","4","5","6","7","8","9",".","ce");
	
								for (i=0;i<=11;i++){
								   if((i==4) || (i==8) || (i==12)){WinCalcolatrice.document.writeln("<br>");}
									    if(Bottoni[i]=="ce"){
      					         WinCalcolatrice.document.writeln("<input onclick=\"dispay.value='';\" onmouseover=\"this.className='buttonO'\" onmouseout=\"this.className='button'\" class='button' type='button' name='' value='"+Bottoni[i]+"'>");
											}else{
      					         WinCalcolatrice.document.writeln("<input onclick=\"SetN('"+Bottoni[i]+"');\" onmouseover=\"this.className='buttonO'\" onmouseout=\"this.className='button'\" class='button' type='button' name='' value='"+Bottoni[i]+"'>");
											}
								}
      					WinCalcolatrice.document.writeln("<br><input onclick=\"SetO();\" onmouseover=\"this.className='buttonO'\" onmouseout=\"this.className='button'\" class='button' style='width:132px;' type='button' name='' value='Inserisci'>");								 																					
		}	
	
		function Conferma(msg){
			 //modalità d'uso:
			 //su altri INPUT ->onchange=""if(Conferma('aaa?')){Fcorso.submit();};""
			 //su input SUBMIT -> return Conferma(msg);
		   var messaggio = window.confirm(msg);
			 if(messaggio){
			    return true;
			 }else{
			    return false;
			 }
		}
		
    //  UTILIZZO -> nomestringa.trim()
  	String.prototype.trim = function()
  	{
  	    return this.replace(/(^\s*)|(\s*$)/g, "");
  	}
		
		function AutoClose(tempo){
		   window.setTimeout("self.close();",tempo)
		}

    function Replace(StringToReplace, StringToChange, StringChangedIn){
       return StringToReplace.replace(StringToChange, StringChangedIn);
    }

    function LCase(Value) {
    	return Value.toString().toLowerCase();
    }
    function UCase(Value) {
    	return Value.toString().toUpperCase();
    }
    function Len(Expression) {
    	return Expression.toString().length;
    }
    function Left(Str, Length) {
    	if (Length < 0) {
    		alert("Invalid Length argument\n\nLeft function (js2vb.js)"); return "";
    	}
    	return Str.substring(0, Length);
    }
    function Right(Str, Length) {
    	if (Length < 0) {
    		alert("Invalid Length argument\n\nRight function (js2vb.js)"); return "";
    	}
    	return Str.substring(Len(Str) - Length, Len(Str));
    }
    function Mid(Str, Start, Length) {
    	if (Length < 1) {
    		alert("Invalid Length argument\n\nMid function (js2vb.js)"); return "";
    	}
    	if (Start < 0) {
    		alert("Invalid Start argument\n\nMid function (js2vb.js)"); return "";
    	}
    	return Str.substring(Start, Start + Length);
    }
    function InStr(Start, String1, String2, Compare) {
    	if (Start < 1) {
    		alert("Invalid Start argument\n\nInStr function (js2vb.js)"); return "";
    	}
    	if (Start > Len(String1)) return 0;
    	if (Len(String2) == 0) return Start;
    	if (Compare == 1) {String1 = LCase(String1); String2 = LCase(String2);}
    	if (Start > 1) {
    		var index = Right(String1, Len(String1) - Start + 1).indexOf(String2)
    		if (index == -1) {return 0;} else {return index + Start;}
    	} else {
    		return String1.indexOf(String2) + 1
    	}
    }
    function InStrRev(StringCheck, StringMatch, Start, Compare) {
    	if (Start == 0 || Start < -1) {
    		alert("Invalid Start argument\n\nInStrRev function (js2vb.js)"); return "";
    	}
    	if (Len(StringMatch) == 0) return Start;
    	if (Compare == 1) {StringCheck = LCase(StringCheck); StringMatch = LCase(StringMatch);}
    	if (Start > 1) {
    		return Left(StringCheck, Start).lastIndexOf(StringMatch) + 1;
    	} else {
    		return StringCheck.lastIndexOf(StringMatch) + 1;
    	}
    }
    function IsNull(Expression) {
    	return (Expression == null);
    }
    function IsEmpty(Expression) {
    	return (Expression.toString().length == 0);
    }
    function IsObject(Expression) {
    	return (typeof Expression == "object");
    }
    function IsArray(VarName) {
    	return (VarName.constructor.toString().indexOf("Array") == -1);
    }
    function IsDate(Expression) {
    	var test = new Date(Date.parse(Expression));
    	return !(isNaN(test.getYear()));
    }


/***********************************************
* Cool DHTML tooltip script II- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var offsetfromcursorX=12 //Customize x offset of tooltip
var offsetfromcursorY=10 //Customize y offset of tooltip

var offsetdivfrompointerX=10 //Customize x offset of tooltip DIV relative to pointer image
var offsetdivfrompointerY=14 //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).

document.write('<div id="dhtmltooltip"></div>') //write out tooltip DIV
document.write('<img id="dhtmlpointer" src="images/arrow2.gif">') //write out pointer image

var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""

var pointerobj=document.all? document.all["dhtmlpointer"] : document.getElementById? document.getElementById("dhtmlpointer") : ""

function ietruebody(){
    return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function showtip(thetext, thewidth, thecolor){
    if (ns6||ie){
		//document.onclick=positiontip		// mia modifica
		document.onmousemove=positiontip	
    if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
    if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
    tipobj.innerHTML=thetext
    enabletip=true
    return false
    }
}

function positiontip(e){
    if (enabletip){
    var nondefaultpos=false
    var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
    var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
    //Find out how close the mouse is to the corner of the window
    var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20
    var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20
    
    var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX
    var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY
    
    var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000
    
    //if the horizontal distance isn't enough to accomodate the width of the context menu
    if (rightedge<tipobj.offsetWidth){
    //move the horizontal position of the menu to the left by it's width
    tipobj.style.left=curX-tipobj.offsetWidth+"px"
    nondefaultpos=true
    }
    else if (curX<leftedge)
    tipobj.style.left="5px"
    else{
    //position the horizontal position of the menu where the mouse is positioned
    tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px"
    pointerobj.style.left=curX+offsetfromcursorX+"px"
    }
    
    //same concept with the vertical position
    if (bottomedge<tipobj.offsetHeight){
    tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px"
    nondefaultpos=true
    }
    else{
    tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px"
    pointerobj.style.top=curY+offsetfromcursorY+"px"
    }
    tipobj.style.visibility="visible"
    if (!nondefaultpos)
    pointerobj.style.visibility="visible"
    else
    pointerobj.style.visibility="hidden"
    }
}

function hidetip(){
    if (ns6||ie){
		   var args = hidetip.arguments;
       if(typeof(args[0])!="undefined"){
					window.setTimeout("hidetip()", args[0]); //*** timer hidetip
					return;
       }
    enabletip=false
    tipobj.style.visibility="hidden"
    pointerobj.style.visibility="hidden"
    tipobj.style.left="-1000px"
    tipobj.style.backgroundColor=''
    tipobj.style.width=''
    }
}

document.onmousemove=positiontip






//**************************** anylink *****************************

var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
var enableanchorlink=0 //Enable or disable the anchor link when clicked on? (1=e, 0=d)
var hidemenu_onclick=1 //hide menu when user clicks within menu? (1=yes, 0=no)

/////No further editting needed

var ie5=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function showhide(obj, e, visible, hidden){
if (ie5||ns6)
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (e.type=="click" && obj.display==hidden || e.type=="mouseover")
obj.display=visible
else if (e.type=="click")
obj.display=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie5 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=ie5 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie5 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
}

function dropdownmenu(obj, e, dropmenuID){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
if (typeof dropmenuobj!="undefined") //hide previous menu
dropmenuobj.style.display="none"
clearhidemenu()
if (ie5||ns6){
obj.onmouseout=delayhidemenu
dropmenuobj=document.getElementById(dropmenuID)
if (hidemenu_onclick) dropmenuobj.onclick=function(){dropmenuobj.style.display='none'}
dropmenuobj.onmouseover=clearhidemenu
dropmenuobj.onmouseout=ie5? function(){ dynamichide(event)} : function(event){ dynamichide(event)}
showhide(dropmenuobj.style, e, "block", "none")
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}
return clickreturnvalue()
}

function clickreturnvalue(){
if ((ie5||ns6) && !enableanchorlink) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie5&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function delayhidemenu(){
delayhide=setTimeout("dropmenuobj.style.display='none'",disappeardelay)
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}
