﻿
var win;
var ns4 = (navigator.appName == 'Netscape' && parseInt(navigator.appVersion) == 4);
var ns6 = (document.getElementById)? true:false;
var ie4 = (document.all)? true:false;

//funzione per apertura popup
//es. chiamata
//onClick="OpenWin('mioFile.aspx','50','50','400','280','no','0','MioTitolo')"
var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height, scrollbar,resizable)
   {
     if(popUpWin)
        {
         if(!popUpWin.closed) popUpWin.close();
        }
      popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,status=no,menubar=no,scrollbars='+scrollbar+',resizable='+resizable+',width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
 }


function ShowHideLayer(szDivID, iState) //szDivID layer ID; 1 visible, 0 hidden
{
    if(ns4)	   //NN4+
    {
       document.layers[szDivID].visibility = iState ? "show" : "hide";
    }
    else if(ns6)	  //gecko(NN6) + IE 5+
    {
        var obj = document.getElementById(szDivID);
        obj.style.visibility = iState ? "visible" : "hidden";		
    }
    else if(ie4)	// IE 4
    {
        document.all[szDivID].style.visibility = iState ? "visible" : "hidden";
    }
}

function MoveLayer(szDivID, X,Y) //szDivID layer ID; 1 visible, 0 hidden
{
    if(document.layers)	   //NN4+
    {
      document.layers[szDivID].left = X;
	  document.layers[szDivID].left = Y;
    }
    else if(document.getElementById)	  //gecko(NN6) + IE 5+
    {
        var obj = document.getElementById(szDivID);
        obj.style.left=X;	
		obj.style.top=Y;	
    }
    else if(document.all)	// IE 4
    {
        document.all[szDivID].style.left =X;
		document.all[szDivID].style.left =Y;
    }
}




// Funzioni per lettura querystring
function PageQuery(q) {
if(q.length > 1) this.q = q.substring(1, q.length);
else this.q = null;
this.keyValuePairs = new Array();
if(q) {
for(var i=0; i < this.q.split("&").length; i++) {
this.keyValuePairs[i] = this.q.split("&")[i];
}
}
this.getKeyValuePairs = function() { return this.keyValuePairs; }
this.getValue = function(s) {
for(var j=0; j < this.keyValuePairs.length; j++) {
if(this.keyValuePairs[j].split("=")[0] == s)
return this.keyValuePairs[j].split("=")[1];
}
return false;
}
this.getParameters = function() {
var a = new Array(this.getLength());
for(var j=0; j < this.keyValuePairs.length; j++) {
a[j] = this.keyValuePairs[j].split("=")[0];
}
return a;
}
this.getLength = function() { return this.keyValuePairs.length; } 
}
//esempio chiamata ID=queryString("ID")
function queryString(key){
var page = new PageQuery(window.location.search); 
return unescape(page.getValue(key)); 
}

//funzioni per navigazioni ancora da querystring
function gotoAnchor(){
     var anchorRef=queryString("Nav"); // calculated value 
      if(anchorRef !=""){
       document.location=document.location + "#" + anchorRef;
      }
    }

//controlla se un campo é vuoto
function IsEmpty(entered, alertbox)
{
with (entered)
{
if (value==null || value=="")
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}