
var InternetExplorer=navigator.userAgent.indexOf("MSIE")!=-1;
var Firefox         =navigator.userAgent.indexOf("Firefox")!=-1;
var GoogleChrome    =navigator.userAgent.indexOf("Chrome")!=-1;

//  da utilizzare con    if(InternetExplorer) { .... }


function SubmitSEARCH()
       {
          var q=document.getElementById("q").value;          var regExp = /\s+/g;
                                                     q=q.replace(regExp,'')
           if(q.length>3)
             {
                CommArea.action          ="index.php";
                CommArea.target          ="_self";
                CommArea.userID.value    ="<?php echo $userID;?>";
                CommArea.fromPage.value  ="<?php echo $serverPage;?>";
                CommArea.nextPage.value  ="QUERY";
                CommArea.index.value     ="<?php echo $typeINDEX;?>";
                CommArea.query.value     =document.getElementById("q").value;
                CommArea.submit();
             }
       }

function ManageBoxCRESTANI()
       {
           if(document.getElementById("BoxCRESTANI").style.visibility=="hidden")
             {
                     document.getElementById("BoxCRESTANI").style.visibility="visible";
          var boxTOP=document.getElementById("BoxCRESTANI").offsetTop,
              boxPOS=document.getElementById("BoxCRESTANI").style.position,
              boxStT=document.getElementById("BoxCRESTANI").style.top,
              boxStL=document.getElementById("BoxCRESTANI").style.left,
              boxOfT=document.getElementById("BoxCRESTANI").offsetTop,
              boxOfL=document.getElementById("BoxCRESTANI").offsetLeft,
              txtPOT=document.getElementById("DarioCrestani").offsetTop,
              txtPOL=document.getElementById("DarioCrestani").offsetLeft;

                                //document.getElementById("BoxCRESTANI").innerHTML="<pre>".boxPOS+" style:"+boxStT+" "+boxStL+" offset:"+boxOfT+" "+boxOfL+"<br>"+txtPOT+" "+txtPOL;
                       
                     document.getElementById("BoxCRESTANI").style.top=(txtPOT-boxOfT-120)+"px";
                     document.getElementById("BoxCRESTANI").style.left=(txtPOL-375)+"px";

                                //document.getElementById("BoxCRESTANI").innerHTML=boxTOP
             }
        else
             {
                     document.getElementById("BoxCRESTANI").style.visibility="hidden";
                     document.getElementById("BoxCRESTANI").style.top="10px";
                     document.getElementById("BoxCRESTANI").style.left="10px";
             }
       }

function OpenBoxSearchLOG()
       {                                            
           if(document.getElementById("lQl").style.visibility=="hidden")
             {
                     document.getElementById("lQl").style.visibility="visible";
          var boxTOP=document.getElementById("lQl").offsetTop,
              boxPOS=document.getElementById("lQl").style.position,
              boxStT=document.getElementById("lQl").style.top,
              boxStL=document.getElementById("lQl").style.left,
              boxOfT=document.getElementById("lQl").offsetTop,
              boxOfL=document.getElementById("lQl").offsetLeft,
              txtPOT=document.getElementById("q").offsetTop,
              txtPOL=document.getElementById("q").offsetLeft;
                       
                     document.getElementById("lQl").style.top=(txtPOT-boxOfT+30)+"px";  var t=txtPOT-boxOfT;
                     document.getElementById("lQl").style.left=(txtPOL-12)+"px";   

                //   document.getElementById("lQl").innerHTML="inpT:"+txtPOT+" boxT:"+boxOfT+"("+t+")<br>inpL:"+txtPOL+" boxL:"+boxOfL;
             }
       }

function CloseBoxSearchLOG()
       {
                     document.getElementById("lQl").style.visibility="hidden";
                     document.getElementById("lQl").style.top="10px";
                     document.getElementById("lQl").style.left="10px";
       }


function RemanageRelativeBOX()
       {
             if(document.getElementById("BoxCRESTANI").style.visibility=="visible")
               {txtPOL=document.getElementById("DarioCrestani").offsetLeft;
                       document.getElementById("BoxCRESTANI").style.left=(txtPOL-375)+"px";}
             if(document.getElementById("lQl").style.visibility=="visible")
               {txtPOL=document.getElementById("q").offsetLeft;
                       document.getElementById("lQl").style.left=(txtPOL-12)+"px";}
       }

function OcchielloBOXposition(event,occhiello,titolo)
        { 
        var titolo_OffsetTop =document.getElementById(titolo).scrollTop;
        var titolo_OffsetLeft=document.getElementById(titolo).scrollLeft;
        var body_scrollTop =document.body.scrollLeft;
        var body_scrollLeft=document.body.scrollTop;        

        var occ_txt=document.getElementById(occhiello).innerHTML;     

         // alert(occ_height);
         //        var occ_len=occ_txt.length;  
         //                                                                          var deltaTop=50; 
         //                                                   if(parseInt(occ_len)>215) {deltaTop=70; }

        var occ_height=document.getElementById(occhiello).offsetHeight;
                                                                            var deltaTop=40; 
                                                   if(parseInt(occ_height)>30) {deltaTop=56; }
                                                   if(parseInt(occ_height)>59) {deltaTop=76; }
                                                   if(parseInt(occ_height)>75) {deltaTop=94; }

          document.getElementById(occhiello).style.position = "absolute";
          document.getElementById(occhiello).style.display  = "inline";
	  document.getElementById(occhiello).style.left=event.clientX-100+"px";
          document.getElementById(occhiello).style.top=event.clientY-deltaTop+body_scrollLeft+"px";
        }
        


function PrinterSheet(status)
     {
                   if(status=="START") 
                                      { PrinterSheetWait(); }
                                 else
                                      {
                                           sheet="TOP";  
                                           loop =0;
                                               clearInterval(SheetWait); 
                                       SheetFeed=setInterval("PrinterSheetFeed()",800);
                                      }
     }

function PrinterSheetWait()
     {
                                      SheetWait=setInterval("PrinterSheet(\"RUN\")",6000);
     }


function PrinterSheetFeed()
     {
         PrinterPDFobj=document.getElementById("PrinterPDF");
         TextPrint_obj=document.getElementById("VrsPrt");

               switch(sheet)
                     {
                       case "TOP":                                             loop++;
                                      sheet="UP"; 
                                      PrinterPDFobj.style.backgroundPosition="-36px 0px";
                                      TextPrint_obj.style.color="#e00000";
                                      break;
                       case "UP":     sheet="DOWN"; 
                                      PrinterPDFobj.style.backgroundPosition="-72px 0px";
                                      TextPrint_obj.style.color="#0000c0";
                                      break;
                       case "DOWN":   sheet="BOTTOM"; 
                                      PrinterPDFobj.style.backgroundPosition="-108px 0px";
                                      TextPrint_obj.style.color="#00d000";
                                      break;
                       case "BOTTOM": sheet="TOP"; 
                                      PrinterPDFobj.style.backgroundPosition="0px 0px";
                                      TextPrint_obj.style.color="#884040";
                                      break;
                            default : sheet="UP"; 
                                      PrinterPDFobj.style.backgroundPosition="0px 0px";
                                      TextPrint_obj.style.color="#884040";
                     }
                     
          if(loop>3) {
                        clearInterval(SheetFeed); TextPrint_obj.style.color="#884040";PrinterSheetWait(); 
                     }                        

     }


function SubmitIndex(serverPage,searchQUERY)
       {
         CommArea.action          ="index.php";
         CommArea.target          ="_self";
         CommArea.userID.value    ="Zetamente";
         CommArea.fromPage.value  =serverPage;
         CommArea.nextPage.value  ="homepage";
         CommArea.dayPage.value   ="00000000";
         CommArea.seqPage.value   ="000";
         CommArea.query.value     =searchQUERY;
         CommArea.index.value     =document.getElementById("inputINDEX").value;
         CommArea.actionPage.value="INDEX";
         CommArea.submit();
       }



var xmlhttp;
                             /*  The LogClick() function is executed every time a click is pushed on the PDF version button
                                                         the function executes the following:

                                                           - Calls the GetXmlHttpObject() function to create an XMLHTTP object
                                                           - Defines the URL (filename) to send to the server
                                                           - Adds a parameter (q) to the URL 
                                                             with the content of the input field
                                                           - Adds a random number to prevent the server 
                                                             from using a cached file
                                                           - Each time the readyState property changes, 
                                                             the stateChanged() function will be executed
                                                           - Opens the XMLHTTP object with the given URL
                                                           - Sends an HTTP request to the server
                              */                            
function LogClick(obj)
       {                                 
           xmlhttp=GetXmlHttpObject();
        if(xmlhttp==null)
          {
            alert ("Your browser does not support XMLHTTP!"); return;
          }

       var url="lib/ius_log[obj].php?o="+obj;

           xmlhttp.onreadystatechange=stateChanged;
           xmlhttp.open("GET",url,true);
           xmlhttp.send(null);
       }
                                                          // -----------------------------------------
                                                          //  executes every time the state 
                                                          //    of the XMLHTTP object changes
                                                          // ---------
                                                          //  When the state changes to 4 ("complete"), 
                                                          //   the content of the txtHint placeholder 
                                                          //    is filled with the response text
                                                          // -----------------------------------------
function stateChanged()
       {
            // document.getElementById("TimeNOTIFY").innerHTML=xmlhttp.readyState;

        if(xmlhttp.readyState==4)
          {
            // document.getElementById("TimeNOTIFY").innerHTML=xmlhttp.responseText;
          }
       } 
                                                           // -------- ============== --------- 
                                                           // creating XMLHttpRequest object 
                                                           //           for different browsers
                                                           // -------- ============== ---------
function GetXmlHttpObject()
       {
         if(window.XMLHttpRequest)
           {                          // code for IE7+, Firefox, Chrome, Opera, Safari
        return new XMLHttpRequest();
           }

         if(window.ActiveXObject)
           {                          // code for IE6, IE5
        return new ActiveXObject("Microsoft.XMLHTTP");
           }
        return null;
       }

