function __SafeOpen(strUrl, strName, strParm) {
   refChild = open(strUrl, strName, strParm);
   if (!refChild)
      alert('L\'operazione richiesta prevede l\'apertura di una finestra separata, ma le attuali impostazioni di protezione non lo consentono. Per poter lavorare correttamente e\' necessario consentire l\'apertura di finestre separate all\'interno di stir.zucchetti.it.');
   return refChild;
}
var pvcTop = 0;
var pvcLeft = 0;
function PvcInChild(strUrl) {
   pvcTop += 40;
   pvcLeft += 40;
   pvcChild = __SafeOpen(strUrl, '', 'top=' + pvcTop + ',left=' + pvcLeft + ',' +
      'width=640,height=480,dependent=no,resizable=yes,titlebar=no,' +
      'menubar=no,toolbar=no,personalbar=no,scrollbars=yes,status=yes');
   if (pvcChild)
      pvcChild.focus();
}
function NavInChild(strUrl) {
   navChild = __SafeOpen(strUrl, '',
      'width=640,height=480,dependent=no,resizable=yes,titlebar=no,' +
      'menubar=no,toolbar=yes,personalbar=no,scrollbars=yes,status=yes');
   if (navChild)
      navChild.focus();
}
function HelpInChild(strUrl) {
   helpChild = __SafeOpen(strUrl, 'HelpInChild',
      'width=640,height=480,dependent=no,resizable=yes,titlebar=no,' +
      'menubar=no,toolbar=no,personalbar=no,scrollbars=yes,status=no');
   if (helpChild)
      helpChild.focus();
}
function LogInChild(strUrl) {
   logChild = __SafeOpen(strUrl, '',
      'width=640,height=480,dependent=no,resizable=yes,titlebar=no,' +
      'menubar=no,toolbar=yes,personalbar=no,scrollbars=yes,status=yes');
   if (logChild)
      logChild.focus();
}
function ActivInChild(strUrl) {
   activChild = __SafeOpen(strUrl, '',
      'width=640,height=480,dependent=no,resizable=yes,titlebar=no,' +
      'menubar=yes,toolbar=no,personalbar=no,scrollbars=yes,status=yes');
   if (activChild)
      activChild.focus();
}
function DocInChild(strUrl) {
   docChild = __SafeOpen(strUrl, '',
      'width=640,height=480,dependent=no,resizable=yes,titlebar=no,' +
      'menubar=no,toolbar=no,personalbar=no,scrollbars=yes,status=yes');
   if (docChild)
      docChild.focus();
}
function PalInChild(strUrl) {
   palChild = __SafeOpen(strUrl, 'PalInChild',
      'width=640,height=480,dependent=no,resizable=yes,titlebar=no,' +
      'menubar=no,toolbar=no,personalbar=no,scrollbars=yes,status=no');
   if (palChild)
      palChild.focus();
}
function RmtInChild(strUrl) {
   rmtChild = __SafeOpen(strUrl, 'RmtInChild',
      'width=220,height=260,dependent=no,resizable=yes,titlebar=no,' +
      'menubar=no,toolbar=no,personalbar=no,scrollbars=yes,status=no');
   if (rmtChild)
      rmtChild.focus();
}
function TogglePane(strPane) {
   var theDiv = document.getElementById(strPane);
   if (theDiv) {
      if (theDiv.style.display == '') {
         if (theDiv.className == 'svchild')  theDiv.style.display = 'none';
         if (theDiv.className == 'svchild1') theDiv.style.display = 'block';
      }
      theDiv.style.display = (theDiv.style.display == 'none' ? 'block' : 'none');
   }
}
function FromPane(strRef, strUrl) {
   var bFound = false;
   for (var i = 0; i < document.anchors.length; i++) {
      if (document.anchors[i].name == strRef) {
         bFound = true;
         break;
      }
   }
   if (!bFound) strUrl += '?idAll=1';
   strUrl += '#' + strRef;
   location.href = strUrl;
}
function BannerTimer() {
   if (!document.fbanner) return;
   var nCur = Number(document.fbanner.fbcur.value);
   var nTot = Number(document.fbanner.fbtot.value);
   var nLen = Number(document.fbanner.fblen.value);
   var sVal = document.fbanner.fbtext.value;
   if (sVal.replace(/ /g, '') == '') {
      nCur++;
      if (nCur == nTot)
         nCur = 0;
      document.fbanner.fbcur.value = nCur;
      var sMsg = '';
      if (nTot == 1) sMsg = document.fbanner.fbcont.value;
      else           sMsg = document.fbanner.fbcont[nCur].value;
          sVal = '';
      for (var k = 0; k < nLen + sMsg.length; k++)
         sVal = sVal + ' ';
   }
   var sMsg = '';
   if (nTot == 1) sMsg = document.fbanner.fbcont.value;
   else           sMsg = document.fbanner.fbcont[nCur].value;
   for (var k = 0; k < sVal.length && sVal.charAt(k) == ' '; k++)
      ;
   var p = nLen + sMsg.length - k;
   sVal = sVal.substring(1) + (p < sMsg.length ? sMsg.charAt(p) : ' ');
   document.fbanner.fbtext.value = sVal;
   setTimeout("BannerTimer()", 100);
}
function ToggleCheck(strForm, strChk, boolVal) {
   var rSvc = eval('document.' + strForm + '.' + strChk);
   if (rSvc.length) {
      for (var i = 0; i < rSvc.length; i++)
         rSvc[i].checked = boolVal;
   } else {
      rSvc.checked = boolVal;
   }
}
function UpdateCheck(strForm, strWhat, strFrom) {
   var rFrom = eval('document.' + strForm + '.' + strFrom);
   if (rFrom.checked)
      ToggleCheck(strForm, strWhat, rFrom.checked);
}
function IsArray(refObj) {
   return refObj.length && !refObj.options ? true : false;
}
function GetObjValue(refObj) {
   var valObj = '';
   if (refObj.type.substr(0, 6) == 'select') {
      if (refObj.selectedIndex != -1)
         valObj = refObj.options[refObj.selectedIndex].value;
   } else {
      if (refObj.value)
         valObj = refObj.value;
   }
   return valObj;
}
function LockOnField(formName, fieldName, msg, defvalue) {
   if(__bInLockTimeout)
      return;
   __bInLockTimeout = true;
   if (msg != '') {
      eval('document.' + formName + '.' + fieldName + '.value = \'' + defvalue + '\';');
      alert(msg + '.');
   }
   setTimeout('FocusOnField(\''+formName+'\', \''+fieldName+'\');', 1);
}
var __bInLockTimeout = false;
function FocusOnField(formName, fieldName){
   eval('document.' + formName + '.' + fieldName + '.focus();');
   __bInLockTimeout = false;
}
function CheckContent(strWhat) {
   var chPos = 0;
   var nLen = strWhat.length;
   var strRet = '';
   while (chPos < nLen && strWhat.charAt(chPos) == ' ')
      chPos++;
   if (chPos < nLen) {
      strRet = strWhat.substring(chPos, nLen);
      nLen = strRet.length;
      chPos = nLen - 1;
      while (chPos >= 0 && strRet.charAt(chPos) == ' ')
         chPos--;
      strRet = strRet.substring(0, chPos + 1);
   }
   return strRet == '' ? false : true;
}
function CheckNumber(strWhat) {
   var chPos = 0;
   var nLen = strWhat.length;
   if (strWhat == '')
      return true;
   while (chPos < nLen) {
      if (strWhat.charAt(chPos) < '0' || strWhat.charAt(chPos) > '9')
         return false;
      chPos++;
   }
   return true;
}
function CheckSignedNumber(strWhat) {
   if (strWhat == '')
      return true;
   var refExp = /^(\+|\-)?\d*$/;
   return refExp.test(strWhat) ? true : false;
}
function CheckFloat(strWhat, strSep) {
   var i = strWhat.indexOf(strSep);
   if (i == -1) return CheckNumber(strWhat);
   var strInt = strWhat.substr(0, i);
   var strDec = strWhat.substr(i + 1, strWhat.length - i - 1);
   return CheckNumber(strInt) && CheckNumber(strDec);
}
function CheckSignedFloat(strWhat, strSep) {
   var i = strWhat.indexOf(strSep);
   if (i == -1) return CheckSignedNumber(strWhat);
   var strInt = strWhat.substr(0, i);
   var strDec = strWhat.substr(i + 1, strWhat.length - i - 1);
   return CheckSignedNumber(strInt) && CheckNumber(strDec);
}
function CheckEmpty(strWhat) {
   return CheckNumber(strWhat) ? (strWhat == '0' ? true : false) : !CheckContent(strWhat);
}
function CheckSignedEmpty(strWhat) {
   return CheckSignedNumber(strWhat) ? (strWhat == '0' ? true : false) : !CheckContent(strWhat);
}
function CheckDate(strVal) {
   if (strVal == '')
      return true;
   var ck1 = strVal.substr(2, 1);
   var ck2 = strVal.substr(5, 1);
   if (ck1 != '/')
      return false;
   if (ck2 != '/')
      return false;
   var strDay = strVal.substr(0, 2);
   var strMonth = strVal.substr(3, 2);
   var strYear = strVal.substr(6, 4);
   if (strDay.length != 2)
      return false;
   if (strMonth.length != 2)
      return false;
   if (strYear.length != 4)
      return false;
   if (!CheckNumber(strDay))
      return false;
   if (!CheckNumber(strMonth))
      return false;
   if (!CheckNumber(strYear))
      return false;
   var numDay = Number(strDay);
   var numMonth = Number(strMonth) - 1;
   var numYear = Number(strYear);
   var refDate = new Date(numYear, numMonth, numDay);
   if (numDay != refDate.getDate())
      return false;
   if (numMonth != refDate.getMonth())
      return false;
   if (numYear != refDate.getFullYear())
      return false;
   return true;
}
function CheckDayMonth(strVal, strYear) {
   if (strVal == '')
      return true;
   if (strVal.length != 4)
      return false;
   if (strVal.indexOf(' ') != -1)
      return false;
   var strDay = strVal.substr(0, 2);
   var strMonth = strVal.substr(2, 2);
   if (!CheckNumber(strDay))
      return false;
   if (!CheckNumber(strMonth))
      return false;
   if (!CheckNumber(strYear))
      return false;
   var numDay = Number(strDay);
   var numMonth = Number(strMonth) - 1;
   var numYear = Number(strYear);
   var refDate = new Date(numYear, numMonth, numDay);
   if (numDay != refDate.getDate())
      return false;
   if (numMonth != refDate.getMonth())
      return false;
   if (numYear != refDate.getFullYear())
      return false;
   return true;
}
function CheckHourMin(strVal) {
   if (strVal == '')
      return true;
   if (strVal.length != 4)
      return false;
   if (strVal.indexOf(' ') != -1)
      return false;
   var strHour = strVal.substr(0, 2);
   var strMin = strVal.substr(2, 2);
   if (!CheckNumber(strHour))
      return false;
   if (!CheckNumber(strMin))
      return false;
   var numHour = Number(strHour);
   var numMin = Number(strMin);
   if (numHour < 0 || numHour > 23)
      return false;
   if (numMin < 0 || numMin > 59)
      return false;
   return true;
}
function CheckSubset(strObj, strRef) {
   return strRef.indexOf(strObj + '|') != -1 ? true : false;
}
function CheckPassword(strWhat) {
   return strWhat.indexOf(' ') == -1 && strWhat.indexOf('\t') == -1 ? true : false;
}
function CheckPasswordDigits(strWhat) {
   for (var i = 0; i < strWhat.length; i++) {
      if (strWhat.charAt(i) < '0' || strWhat.charAt(i) > '9')
         continue;
      return true;
   }
   return false;
}
function CheckPasswordLength(strWhat, nLength) {
   return strWhat.length < nLength ? false : true;
}
function CheckLBound(strWhat, strWith) {
   if (!CheckNumber(strWhat))
      return strWhat && strWhat < strWith ? false : true;
   else {
      numWhat = Number(strWhat); numWith = Number(strWith);
      return numWhat && numWhat < numWith ? false : true;
   }
}
function CheckSignedLBound(strWhat, strWith) {
   if (!CheckSignedNumber(strWhat))
      return strWhat && strWhat < strWith ? false : true;
   else {
      numWhat = Number(strWhat); numWith = Number(strWith);
      return numWhat && numWhat < numWith ? false : true;
   }
}
function CheckUBound(strWhat, strWith) {
   if (!CheckNumber(strWhat))
      return strWhat && strWhat > strWith ? false : true;
   else {
      numWhat = Number(strWhat); numWith = Number(strWith);
      return numWhat && numWhat > numWith ? false : true;
   }
}
function CheckSignedUBound(strWhat, strWith) {
   if (!CheckSignedNumber(strWhat))
      return strWhat && strWhat > strWith ? false : true;
   else {
      numWhat = Number(strWhat); numWith = Number(strWith);
      return numWhat && numWhat > numWith ? false : true;
   }
}
function CheckAvail(strForm, strObj) {
   var rObj = eval('document.' + strForm + '.' + strObj);
   return rObj ? true : false;
}
function CheckSafeContent(strForm, strObj) {
   var rObj = eval('document.' + strForm + '.' + strObj);
   if (IsArray(rObj)) {
      for (var i = 0; i < rObj.length; i++) {
         if (!CheckContent(GetObjValue(rObj[i])))
            return false;
      }
   } else {
      if (!CheckContent(GetObjValue(rObj)))
         return false;
   }
   return true;
}
function CheckSafeNumber(strForm, strObj) {
   var rObj = eval('document.' + strForm + '.' + strObj);
   if (IsArray(rObj)) {
      for (var i = 0; i < rObj.length; i++) {
         if (!CheckNumber(GetObjValue(rObj[i])))
            return false;
      }
   } else {
      if (!CheckNumber(GetObjValue(rObj)))
         return false;
   }
   return true;
}
function CheckSafeSignedNumber(strForm, strObj) {
   var rObj = eval('document.' + strForm + '.' + strObj);
   if (IsArray(rObj)) {
      for (var i = 0; i < rObj.length; i++) {
         if (!CheckSignedNumber(GetObjValue(rObj[i])))
            return false;
      }
   } else {
      if (!CheckSignedNumber(GetObjValue(rObj)))
         return false;
   }
   return true;
}
function CheckSafeFloat(strForm, strObj, strSep) {
   var rObj = eval('document.' + strForm + '.' + strObj);
   if (IsArray(rObj)) {
      for (var i = 0; i < rObj.length; i++) {
         if (!CheckFloat(GetObjValue(rObj[i]), strSep))
            return false;
      }
   } else {
      if (!CheckFloat(GetObjValue(rObj), strSep))
         return false;
   }
   return true;
}
function CheckSafeSignedFloat(strForm, strObj, strSep) {
   var rObj = eval('document.' + strForm + '.' + strObj);
   if (IsArray(rObj)) {
      for (var i = 0; i < rObj.length; i++) {
         if (!CheckSignedFloat(GetObjValue(rObj[i]), strSep))
            return false;
      }
   } else {
      if (!CheckSignedFloat(GetObjValue(rObj), strSep))
         return false;
   }
   return true;
}
function CheckSafeEmpty(strForm, strObj) {
   var rObj = eval('document.' + strForm + '.' + strObj);
   if (IsArray(rObj)) {
      for (var i = 0; i < rObj.length; i++) {
         if (!CheckEmpty(GetObjValue(rObj[i])))
            return false;
      }
   } else {
      if (!CheckEmpty(GetObjValue(rObj)))
         return false;
   }
   return true;
}
function CheckSafeSignedEmpty(strForm, strObj) {
   var rObj = eval('document.' + strForm + '.' + strObj);
   if (IsArray(rObj)) {
      for (var i = 0; i < rObj.length; i++) {
         if (!CheckSignedEmpty(GetObjValue(rObj[i])))
            return false;
      }
   } else {
      if (!CheckSignedEmpty(GetObjValue(rObj)))
         return false;
   }
   return true;
}
function CheckSafeDate(strForm, strObj) {
   var rObj = eval('document.' + strForm + '.' + strObj);
   if (IsArray(rObj)) {
      for (var i = 0; i < rObj.length; i++) {
         if (!CheckDate(GetObjValue(rObj[i])))
            return false;
      }
   } else {
      if (!CheckDate(GetObjValue(rObj)))
         return false;
   }
   return true;
}
function CheckSafeDayMonth(strForm, strObj, valYear) {
   var rObj = eval('document.' + strForm + '.' + strObj);
   if (IsArray(rObj)) {
      for (var i = 0; i < rObj.length; i++) {
         if (!CheckDayMonth(GetObjValue(rObj[i]), valYear))
            return false;
      }
   } else {
      if (!CheckDayMonth(GetObjValue(rObj), valYear))
         return false;
   }
   return true;
}
function CheckSafeHourMin(strForm, strObj) {
   var rObj = eval('document.' + strForm + '.' + strObj);
   if (IsArray(rObj)) {
      for (var i = 0; i < rObj.length; i++) {
         if (!CheckHourMin(GetObjValue(rObj[i])))
            return false;
      }
   } else {
      if (!CheckHourMin(GetObjValue(rObj)))
         return false;
   }
   return true;
}
function CheckSafeFlag(strForm, strObj) {
   var rObj = eval('document.' + strForm + '.' + strObj);
   if (IsArray(rObj)) {
      for (var i = 0; i < rObj.length; i++) {
         if (!rObj[i].checked)
            return false;
      }
   } else {
      if (!rObj.checked)
         return false;
   }
   return true;
}
function CheckSafeLBound(strForm, strObj, strWith) {
   var rObj = eval('document.' + strForm + '.' + strObj);
   if (IsArray(rObj)) {
      for (var i = 0; i < rObj.length; i++) {
         if (!CheckLBound(GetObjValue(rObj[i]), strWith))
            return false;
      }
   } else {
      if (!CheckLBound(GetObjValue(rObj), strWith))
         return false;
   }
   return true;
}
function CheckSafeSignedLBound(strForm, strObj, strWith) {
   var rObj = eval('document.' + strForm + '.' + strObj);
   if (IsArray(rObj)) {
      for (var i = 0; i < rObj.length; i++) {
         if (!CheckSignedLBound(GetObjValue(rObj[i]), strWith))
            return false;
      }
   } else {
      if (!CheckSignedLBound(GetObjValue(rObj), strWith))
         return false;
   }
   return true;
}
function CheckSafeUBound(strForm, strObj, strWith) {
   var rObj = eval('document.' + strForm + '.' + strObj);
   if (IsArray(rObj)) {
      for (var i = 0; i < rObj.length; i++) {
         if (!CheckUBound(GetObjValue(rObj[i]), strWith))
            return false;
      }
   } else {
      if (!CheckUBound(GetObjValue(rObj), strWith))
         return false;
   }
   return true;
}
function CheckSafeSignedUBound(strForm, strObj, strWith) {
   var rObj = eval('document.' + strForm + '.' + strObj);
   if (IsArray(rObj)) {
      for (var i = 0; i < rObj.length; i++) {
         if (!CheckSignedUBound(GetObjValue(rObj[i]), strWith))
            return false;
      }
   } else {
      if (!CheckSignedUBound(GetObjValue(rObj), strWith))
         return false;
   }
   return true;
}
function CheckSafeValueOf(strForm, strObj, strRef) {
   var rRef = eval('document.' + strForm + '.' + strRef);
   var rObj = eval('document.' + strForm + '.' + strObj);
   if (IsArray(rObj)) {
      for (var i = 0; i < rObj.length; i++) {
         if (!CheckUBound(GetObjValue(rObj[i]), GetObjValue(rRef)))
            return false;
      }
   } else {
      if (!CheckUBound(GetObjValue(rObj), GetObjValue(rRef)))
         return false;
   }
   return true;
}
function CheckSafeSubset(strForm, strObj, strRef) {
   var rObj = eval('document.' + strForm + '.' + strObj);
   if (IsArray(rObj)) {
      for (var i = 0; i < rObj.length; i++) {
         if (!CheckSubset(GetObjValue(rObj[i]), strRef))
            return false;
      }
   } else {
      if (!CheckSubset(GetObjValue(rObj), strRef))
         return false;
   }
   return true;
}
function DateValidate(formName, fieldName, lockFieldName){
   var strDate = '';
   strDate += eval('document.'+formName+'.'+fieldName+'_d.value')+'/';
   strDate += eval('document.'+formName+'.'+fieldName+'_m.value')+'/';
   strDate += eval('document.'+formName+'.'+fieldName+'_Y.value');
   if (strDate == '//')
      return true;
   if (!CheckDate(strDate)) {
      LockOnField(formName, fieldName+lockFieldName, '', '');
      return false;
   }
   return true;
}
function __doInitialize() {
   BannerTimer();
}