﻿var TRange = null;
function UpdateMappaContext(framemap) {
   if (framemap.contentWindow) {
      framemap.contentWindow.document.forms[0].submit();
   } else {
      framemap.window.document.forms[0].submit();
   }
}
function containsDOM(container, containee) {
   var isParent = false;
   do {
      if ((isParent = container == containee))
         break;
      containee = containee.parentNode;
   }
   while (containee != null);
   return isParent;
}

function checkMouseEnter(element, evt) {
   if (element.contains && evt.fromElement) {
      return !element.contains(evt.fromElement);
   }
   else if (evt.relatedTarget) {
      return !containsDOM(element, evt.relatedTarget);
   }
}

function checkMouseLeave(element, evt) {
   if (element.contains && evt.toElement) {
      return !element.contains(evt.toElement);
   }
   else if (evt.relatedTarget) {
      return !containsDOM(element, evt.relatedTarget);
   }
}
function GetSizeWindowHeight() {
   var myHeight = 0;
   if (typeof (window.innerHeight) == 'number') {
      //Non-IE
      myHeight = window.innerHeight;
   } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
      //IE 6+ in 'standards compliant mode'
      myHeight = document.documentElement.clientHeight;
   } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
      //IE 4 compatible
      myHeight = document.body.clientHeight;
   }
   return myHeight;
}
function GetSizeWindowWidth() {
   var myWidth = 0;
   if (typeof (window.innerWidth) == 'number') {
      //Non-IE
      myWidth = window.innerWidth;
   } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
      //IE 6+ in 'standards compliant mode'
      myWidth = document.documentElement.clientWidth;
   } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
      //IE 4 compatible
      myWidth = document.body.clientWidth;
   }
   return myWidth;
}
var tooltip = function () {
   var id = 'tt';
   var top = 3;
   var left = 3;
   var maxw = 300;
   var speed = 10;
   var timer = 20;
   var endalpha = 95;
   var alpha = 0;
   var tt, t, c, b, h;
   var ie = document.all ? true : false;
   var TimeoutId = 0;
   var ulu;
   var ull;
   return {
      show: function (Text, delay, width) {
         if (TimeoutId > 0) {
            this.hide();
         } else {
            document.onmousemove = this.pos;
            TimeoutId = window.setTimeout("tooltip.now('" + Text + "', " + width + ")", delay);
         }
      },
      now: function (v, w) {
         if (tt == null) {
            tt = document.createElement('div');
            tt.setAttribute('id', id);
            t = document.createElement('div');
            t.setAttribute('id', id + 'top');
            c = document.createElement('div');
            c.setAttribute('id', id + 'cont');
            b = document.createElement('div');
            b.setAttribute('id', id + 'bot');
            tt.appendChild(t);
            tt.appendChild(c);
            tt.appendChild(b);
            document.body.appendChild(tt);
            tt.style.opacity = 0;
            tt.style.filter = 'alpha(opacity=0)';
            document.onmousemove = this.pos;
         }
         tt.style.display = 'block';
         c.innerHTML = v;
         tt.style.width = w ? w + 'px' : 'auto';
         if (!w && ie) {
            t.style.display = 'none';
            b.style.display = 'none';
            tt.style.width = tt.offsetWidth;
            t.style.display = 'block';
            b.style.display = 'block';
         }
         if (tt.offsetWidth > maxw) { tt.style.width = maxw + 'px' }
         h = parseInt(tt.offsetHeight) + top;
         tt.style.top = (ulu - h) + 'px';
         tt.style.left = (ull + left) + 'px';
         clearInterval(tt.timer);
         tt.timer = setInterval(function () { tooltip.fade(1) }, timer);
      },
      pos: function (e) {
         var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;
         var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;
         ulu = u;
         ull = l;
         if (tt) {
            tt.style.top = (u - h) + 'px';
            tt.style.left = (l + left) + 'px';
         }
      },
      fade: function (d) {
         var a = alpha;
         if ((a != endalpha && d == 1) || (a != 0 && d == -1)) {
            var i = speed;
            if (endalpha - a < speed && d == 1) {
               i = endalpha - a;
            } else if (alpha < speed && d == -1) {
               i = a;
            }
            alpha = a + (i * d);
            tt.style.opacity = alpha * .01;
            tt.style.filter = 'alpha(opacity=' + alpha + ')';
         } else {
            clearInterval(tt.timer);
            if (d == -1) { tt.style.display = 'none' }
         }
      },
      hide: function () {
         if (TimeoutId > 0) {
            clearTimeout(TimeoutId);
            TimeoutId = 0;
         }
         if (tt) {
            clearInterval(tt.timer);
            tt.timer = setInterval(function () { tooltip.fade(-1) }, timer);
         }
      }
   };
} ();
function OpenModLessWindow(url, parent, argsIE, argsFF, width, height, argsDef) {
   var mywin;
   var left = (screen.width - width) / 2;
   var top = (screen.height - height) / 2;
   if (window.showModelessDialog) {
      position = "dialogLeft:" + left + "; dialogTop:" + top;
      if (argsDef) {
         mywin = window.showModelessDialog(url, parent, argsIE + position);
      }else{
         mywin = window.showModelessDialog(url, parent, argsIE + position + ";resizable:1; help:0; scrollbars:1;");
      }
   } else {
      position = "left=" + left + ", top=" + top;
      if (argsDef) {
         mywin = window.open(url, null, argsFF + position);
         mywin.dialogArguments = parent;
      } else {
         mywin = window.open(url, null, argsFF + "," + position + ",alwaysRaised=yes,dependent=yes,status=no,toolbar=no,location=no,menubar=no,directories=no,resizable=1,scrollbars=1");
         mywin.dialogArguments = parent;
      }
   }
   return mywin;
}
function rgbConvert(str) {
   str = str.replace(/rgb\(|\)/g, "").split(",");
   str[0] = parseInt(str[0], 10).toString(16).toLowerCase();
   str[1] = parseInt(str[1], 10).toString(16).toLowerCase();
   str[2] = parseInt(str[2], 10).toString(16).toLowerCase();
   str[0] = (str[0].length == 1) ? '0' + str[0] : str[0];
   str[1] = (str[1].length == 1) ? '0' + str[1] : str[1];
   str[2] = (str[2].length == 1) ? '0' + str[2] : str[2];
   return ('#' + str.join(""));
}
function openricercatext() {
   var mywin = null;
   mywin = OpenModLessWindow("a", window, 'dialogWidth:400px; dialogHeight:20px;resizable:no; help=no; scrollbars:0;', 'Width=400px, Height=20px,resizable=0; help=0; scrollbars=0;', 400, 20, true)
   newwindow = mywin;
   newdocument = newwindow.document;
   var Stringapage = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>Caronte - sw per la gestione cimiteriale</title>';
   Stringapage = Stringapage + '<link href="style.css" rel="stylesheet" type="text/css" /><script type="text/javascript" language="javascript1.2" src="js/applicationroutine.js">'
   Stringapage = Stringapage + '</' + 'script></head><body><div style="text-align:center;">Inserire il testo da cercare<br /> <input type="text" id="searchtext" style=" width:250px;" />';
   Stringapage = Stringapage + '&nbsp;&nbsp;&nbsp;&nbsp; <input type="button" value="Cerca nella pagina" onclick="findString(document.getElementById(' + chr(39) + 'searchtext' + chr(39) + ').value, window.dialogArguments);" />';
   Stringapage = Stringapage + '</div></body></html>';
   newdocument.write(Stringapage);
   newdocument.close();
}
function findString(str, finestra) {
   if (!finestra) { finestra = self; }
   if (parseInt(navigator.appVersion) < 4) return;
   var strFound;
   if (window.find) {
      strFound = finestra.find(str);
      if (strFound && finestra.getSelection && !finestra.getSelection().anchorNode) {
         strFound = finestra.find(str);
      }
      if (!strFound) {
         strFound = finestra.find(str, 0, 1);
         while (finestra.find(str, 0, 1)) continue
      }
   }
   else if (navigator.appName.indexOf("Microsoft") != -1) {
      if (TRange != null) {
         TRange.collapse(false)
         strFound = TRange.findText(str)
         if (strFound) TRange.select()
      }
      if (TRange == null || strFound == 0) {
         TRange = finestra.document.body.createTextRange()
         strFound = TRange.findText(str)
         if (strFound) TRange.select()
      }
   }
   else if (navigator.appName == "Opera") {
      alert("Opera browsers not supported, sorry...")
      return;
   }
   if (!strFound) alert("String '" + str + "' not found!")
   return;
}

function showloadingpanel(visible, pathimg) {
   if (visible) {
      if (document.getElementById("showloadingpanel")) { return; }
      var newDiv2 = document.createElement("DIV");
      newDiv2.id = "showloadingpanel";
      newDiv2.style.position = "absolute";
      newDiv2.style.left = "0px";
      newDiv2.style.top = "0px";
      newDiv2.style.height = "100%";
      newDiv2.style.width = "100%";
      newDiv2.style.Zindex = "100";
      newDiv2.style.lineHeight = "0px";
      var version = 999;
      if (navigator.appVersion.indexOf("MSIE") != -1) { version = parseFloat(navigator.appVersion.split("MSIE")[1]); }
      if (version < 9) {
         newDiv2.style.backgroundColor = "#000000";
         newDiv2.style.filter = "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
      } else {
         newDiv2.style.backgroundColor = "rgba(0, 0, 0, 0.5)";
      }
      //newDiv2.style.backgroundColor = "rgba(0, 0, 0, 0.5)";
      //newDiv2.style.backgroundColor = "#000000";
      //newDiv2.style.opacity = "0.60";
      //newDiv2.style.filter = "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
      //newDiv2.style.filter = "alpha(style=0,opacity=60)";
      //newDiv2.style.MozOpacity = "0.60";
      //newDiv2.style.border = "0.60";
      if (window.event) {
         document.body.insertBefore(newDiv2);
      } else {
         document.body.appendChild(newDiv2);
      }
      var NewImg = document.createElement("IMG");
      if (pathimg) {
         NewImg.src = "images/" + pathimg + ".gif";
      } else {
         NewImg.src = "images/loading.gif";
      }
      if (window.event) {
         newDiv2.insertBefore(NewImg);
      } else {
         newDiv2.appendChild(NewImg);
      }
      NewImg.style.position = "relative";
      var offleft = (newDiv2.offsetWidth / 2);
      offleft = offleft - (NewImg.offsetWidth / 2);
      var offtop = (newDiv2.offsetHeight / 2);
      offtop = offtop - (NewImg.offsetHeight / 2);
      NewImg.style.left = offleft + "px";
      NewImg.style.top = offtop + "px"; ;
   } else {
      if (!document.getElementById("showloadingpanel")) { return; }
      var objdiv = document.getElementById("showloadingpanel").parentNode;
      if (navigator.appVersion.indexOf("MSIE")>=0) {
         document.getElementById("showloadingpanel").removeNode(true);
      } else {
         document.getElementById("showloadingpanel").parentNode.removeChild(document.getElementById("showloadingpanel"));
      }
   }
}
// color picker
function rendiinvisibile(idid) {
   if (document.getElementById('colorpicker')) {
      document.getElementById('colorpicker').style.visibility = "hidden";
      if (document.getElementById("colorpicker")) {
         var objdiv = document.getElementById("colorpicker").parentNode;
         if (navigator.appVersion.indexOf("MSIE") >= 0) {
            document.getElementById("colorpicker").offsetParent.removeNode(true);
         } else {
            objdiv.removeChild(objdiv.childNodes[0]);
         }
      }
   }
   if (idid) {
      source = document.getElementById(idid);
      source.value = source.value.toUpperCase();
      if (source.value) {
         var espressione = /^#[A-F0-9]{6}$/;
         if (!espressione.test(source.value)) {
            alert("colore non valido");
            source.value = ""
            source.style.backgroundColor = "#FFFFFF";
         } else {
            source.style.backgroundColor = source.value;
         }
      }   
   }   
}
function settacolore(e, idid) {
   var ns6 = document.getElementById && !document.all
   var ie = document.all
   var artabus = ''
   source = ie ? event.srcElement : e.target
   if (source.tagName == "TABLE") return
   while (source.tagName != "TD" && source.tagName != "HTML") source = ns6 ? source.parentNode : source.parentElement
   if (idid) {
	  document.getElementById(idid).style.backgroundColor = source.bgColor.toUpperCase();
      document.getElementById(idid).value = source.bgColor.toUpperCase();
   }
}
function CreaColorPicker(idid) {
   var total = 1657;
   var X = Y = j = RG = B = 0;
   var aR = new Array(total);
   var aG = new Array(total);
   var aB = new Array(total);
   var parserHtml = "";
   var espressione = /^#[A-F0-9]{6}$/;
   if (!espressione.test(idid.value) && idid.value) {
      alert("colore non valido");
      idid.value = ""
      idid.style.backgroundColor = "#FFFFFF";
   } else {
      idid.style.backgroundColor = idid.value;
   }
   idid.onblur = function() { rendiinvisibile(idid.id); };
   /*if (idid.onblur) {
      
   } else if (idid.attachEvent) {
      idid.attachEvent('onblur', function() { rendiinvisibile(idid.id) });
   } */
   idid.maxLength = 7;
   if (document.getElementById("colorpicker")) {
      var objdiv = document.getElementById("colorpicker").parentNode;
      if (navigator.appVersion.indexOf("MSIE") >= 0) {
         objdiv.removeNode(true);
      }else{
         objdiv.removeChild(objdiv.childNodes[0]);
      }   
   }
   for (var i = 0; i < 256; i++) {
      aR[i + 510] = aR[i + 765] = aG[i + 1020] = aG[i + 5 * 255] = aB[i] = aB[i + 255] = 0;
      aR[510 - i] = aR[i + 1020] = aG[i] = aG[1020 - i] = aB[i + 510] = aB[1530 - i] = i;
      aR[i] = aR[1530 - i] = aG[i + 255] = aG[i + 510] = aB[i + 765] = aB[i + 1020] = 255;
      if (i < 255) { aR[i / 2 + 1530] = 127; aG[i / 2 + 1530] = 127; aB[i / 2 + 1530] = 127; }
   }
   var hexbase = new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F");
   var i = 0; var jl = new Array();
   for (x = 0; x < 16; x++) for (y = 0; y < 16; y++) jl[i++] = hexbase[x] + hexbase[y];
   parserHtml = parserHtml + '<' + 'table id="colorpicker" style="cursor:crosshair;" border="0" cellspacing="0" cellpadding="0" onMouseover="settacolore(event, ' + chr(39) + idid.id + chr(39) + ')" onClick="rendiinvisibile(' + chr(39) + idid.id + chr(39) + ')">';
   var H = W = 63;
   for (Y = 0; Y <= H; Y++) {
      s = '<' + 'tr height=2>'; j = Math.round(Y * (510 / (H + 1)) - 255)
      for (X = 0; X <= W; X++) {
         i = Math.round(X * (total / W))
         R = aR[i] - j; if (R < 0) R = 0;if (R > 255 || isNaN(R)) R = 255;
         G = aG[i] - j; if (G < 0) G = 0;if (G > 255 || isNaN(G)) G = 255;
         B = aB[i] - j; if (B < 0) B = 0;if (B > 255 || isNaN(B)) B = 255;
         s = s + '<' + 'td width=2 bgcolor=#' + jl[R] + jl[G] + jl[B] + '><' + '/td>';
      }
      parserHtml = parserHtml + s + '<' + '/tr>';
   }
   parserHtml = parserHtml + '<' + '/table>';
   var newDiv = document.createElement("DIV");
   newDiv.innerHTML = parserHtml;
   newDiv.style.position = "absolute";
   var oLeft = 0;
   var oTop = 0;
   var pi = idid;
   while (pi) {
      oLeft = oLeft + pi.offsetLeft;
      oTop = oTop + pi.offsetTop;
      pi = pi.offsetParent;
   }
   newDiv.style.left = oLeft+"px";
   newDiv.style.top = oTop + idid.offsetHeight + "px";
   if (window.event) {
      document.body.insertBefore(newDiv);
   } else {
      document.body.appendChild(newDiv);
   }
}

// end color picker

var defaulbackcolor = "#FFFFFF";
var defaulcolor = "#000000";
var defaulfocusbackcolor = "#FFFFCC";
var defaulfocuscolor = "#000000";
function unfocuscomune(obj, type, bkcolor, fontcolor) {
    if (bkcolor) {
        obj.style.backgroundColor = bkcolor;
    } else {
        obj.style.backgroundColor = defaulbackcolor;
    }
    if (fontcolor) {
        obj.style.Color = fontcolor;
    } else {
        obj.style.Color = defaulcolor;
    }
    obj.value = obj.value.toUpperCase();
    if (document.getElementById("rectrighe")) {
       for (var i = 10; i > 0; i--) {
          if (i == 1) {
              setTimeout("destroydiv('" + document.getElementById("rectrighe").id + "')", 50 * (10 - i));
          } else {
              setTimeout("setOpacity('" + i + "','" + document.getElementById("rectrighe").id + "')", 50 * (10 - i));
          }
       }
      // document.getElementById("rectrighe").style.display = "none";
    }
}
function focuscomune(obj, bkcolor, fontcolor) {
   if (bkcolor) {
      obj.style.backgroundColor = bkcolor;
   } else {
      obj.style.backgroundColor = defaulfocusbackcolor;
   }
   if (fontcolor) {
      obj.style.Color = fontcolor;
   } else {
      obj.style.Color = defaulfocuscolor;
   }
   obj.onkeypress = keycomune;
}
function focustext(obj, type, bkcolor, fontcolor) {
   if (type == "data") {
      obj.onkeypress = keydata;
   } else if (type == "num") {
      obj.onkeypress = keynum;
   } else if (type == "ora") {
      obj.onkeypress = keyora;
   } else if (type == "val") {
      obj.onkeypress = keyval;
   } else if (type == "clr") {
      CreaColorPicker(obj);
   }
   if (type != 'clr') {
      if (bkcolor) {
         obj.style.backgroundColor = bkcolor;
      } else {
         obj.style.backgroundColor = defaulfocusbackcolor;
      }
      if (fontcolor) {
         obj.style.Color = fontcolor;
      } else {
         obj.style.Color = defaulfocuscolor;
      }
   }   
}
function unfocustext(obj, type, bkcolor, fontcolor, UpperCase) {
   if (type != 'clr') {
      if (bkcolor) {
         obj.style.backgroundColor = bkcolor;
      } else {
         obj.style.backgroundColor = defaulbackcolor;
      }
      if (fontcolor) {
         obj.style.Color = fontcolor;
      } else {
         obj.style.Color = defaulcolor;
      }
	  if(UpperCase==null){ UpperCase = 1; }
      if(UpperCase==1){
	     obj.value = obj.value.toUpperCase();
	  }
   }   
   if (type == "data") {
       if (obj.value) {
           if (validadata(obj) == false) {
               alert("Data non valida. La data deve essere scritta nel formato gg/mm/aaaa.");
               obj.value = "";
               obj.focus();
               obj.select();
           }
       }
   } else if (type == "num") {
       if (obj.value) {
           if (validanum(obj) == false) {
               alert("numero non valido.");
               obj.value = "";
               obj.focus();
               obj.select();
           }
       }
   } else if (type == "ora") {
       if (obj.value) {
           if (validaora(obj) == false) {
               alert("ora non valida.");
               obj.value = "";
               obj.focus();
               obj.select();
           }
       }
   } else if (type == "val") {
       if (obj.value) {
           if (validaval(obj) == false) {
               alert("numero a precisione doppia non valido.");
               obj.value = "";
               obj.focus();
               obj.select();
           }
       }
   }   
}
function keycomune(evt) {
   var obj;
   if (window.event) {
      obj = window.event.srcElement;
   } else {
      obj = evt.srcelement ? evt.srcelement : evt.target;
   }
   leftdiv = 0
   var li = obj;
   while (li) {
      leftdiv = leftdiv + li.offsetLeft;
      li = li.offsetParent;
   }
   topdiv = 0
   var lo = obj;
   while (lo) {
      topdiv = topdiv + lo.offsetTop;
      lo = lo.offsetParent;
   }
   topdiv = topdiv + obj.offsetHeight + 1;
   var newdiv;
   if (!document.getElementById("rectrighe")) {
      var strobjlist = "<div id='riga1' class='selrighe' onmouseover=" + String.fromCharCode(34) + "this.style.backgroundColor='#454442'; this.style.color='#A6B6DA'" + String.fromCharCode(34) + " onmouseout=" + String.fromCharCode(34) + "this.style.backgroundColor='#FFFFFF'; this.style.color='#000000'" + String.fromCharCode(34) + ">a</div>";
      strobjlist = strobjlist + "<div id='riga2' class='selrighe' onmouseover=" + String.fromCharCode(34) + "this.style.backgroundColor='#454442'; this.style.color='#A6B6DA'" + String.fromCharCode(34) + " onmouseout=" + String.fromCharCode(34) + "this.style.backgroundColor='#FFFFFF'; this.style.color='#000000'" + String.fromCharCode(34) + ">b</div>";
      strobjlist = strobjlist + "<div id='riga3' class='selrighe' onmouseover=" + String.fromCharCode(34) + "this.style.backgroundColor='#454442'; this.style.color='#A6B6DA'" + String.fromCharCode(34) + " onmouseout=" + String.fromCharCode(34) + "this.style.backgroundColor='#FFFFFF'; this.style.color='#000000'" + String.fromCharCode(34) + ">c</div>";
      strobjlist = strobjlist + "<div id='riga4' class='selrighe' onmouseover=" + String.fromCharCode(34) + "this.style.backgroundColor='#454442'; this.style.color='#A6B6DA'" + String.fromCharCode(34) + " onmouseout=" + String.fromCharCode(34) + "this.style.backgroundColor='#FFFFFF'; this.style.color='#000000'" + String.fromCharCode(34) + ">d</div>";
      strobjlist = strobjlist + "<div id='riga5' class='selrighe' onmouseover=" + String.fromCharCode(34) + "this.style.backgroundColor='#454442'; this.style.color='#A6B6DA'" + String.fromCharCode(34) + " onmouseout=" + String.fromCharCode(34) + "this.style.backgroundColor='#FFFFFF'; this.style.color='#000000'" + String.fromCharCode(34) + ">e</div>";
      strobjlist = strobjlist + "<div id='riga6' class='selrighe' onmouseover=" + String.fromCharCode(34) + "this.style.backgroundColor='#454442'; this.style.color='#A6B6DA'" + String.fromCharCode(34) + " onmouseout=" + String.fromCharCode(34) + "this.style.backgroundColor='#FFFFFF'; this.style.color='#000000'" + String.fromCharCode(34) + ">f</div>";
      strobjlist = strobjlist + "<div id='riga7' class='selrighe' onmouseover=" + String.fromCharCode(34) + "this.style.backgroundColor='#454442'; this.style.color='#A6B6DA'" + String.fromCharCode(34) + " onmouseout=" + String.fromCharCode(34) + "this.style.backgroundColor='#FFFFFF'; this.style.color='#000000'" + String.fromCharCode(34) + ">g</div>";
      strobjlist = strobjlist + "<div id='riga8' class='selrighe' onmouseover=" + String.fromCharCode(34) + "this.style.backgroundColor='#454442'; this.style.color='#A6B6DA'" + String.fromCharCode(34) + " onmouseout=" + String.fromCharCode(34) + "this.style.backgroundColor='#FFFFFF'; this.style.color='#000000'" + String.fromCharCode(34) + ">h</div>";
      strobjlist = strobjlist + "<div id='riga9' class='selrighe' onmouseover=" + String.fromCharCode(34) + "this.style.backgroundColor='#454442'; this.style.color='#A6B6DA'" + String.fromCharCode(34) + " onmouseout=" + String.fromCharCode(34) + "this.style.backgroundColor='#FFFFFF'; this.style.color='#000000'" + String.fromCharCode(34) + ">i</div>";
      strobjlist = strobjlist + "<div id='riga10' class='selrighe' onmouseover=" + String.fromCharCode(34) + "this.style.backgroundColor='#454442'; this.style.color='#A6B6DA'" + String.fromCharCode(34) + " onmouseout=" + String.fromCharCode(34) + "this.style.backgroundColor='#FFFFFF'; this.style.color='#000000'" + String.fromCharCode(34) + ">l</div>";
      var newdiv = document.createElement('div');
      var divIdName = "rectrighe";
      newdiv.setAttribute('id', divIdName);
      newdiv.style.display = "none";
      newdiv.style.width = "200px";
      newdiv.innerHTML = strobjlist;
      document.body.appendChild(newdiv);
   } else {
      newdiv = document.getElementById("rectrighe");
   }
   if (newdiv.style.display != "block"){
      newdiv.style.position = "absolute";
      newdiv.style.left = leftdiv + "px";
      newdiv.style.top = topdiv + "px";
      newdiv.style.border = "solid 1px #E1E1E1";
      setOpacity("1", newdiv.id);
      newdiv.style.display = "block";
      for (var i = 0; i < 11; i++) {
         setTimeout("setOpacity('" + i + "','" + newdiv.id + "')", 50*i);
      }    
   }   
}
function keydata(evt) {
   var key = "";
   var obj;
   if (window.event) {
      key = window.event.keyCode;
      obj = window.event.srcElement;
   } else {
      key = (window.Event) ? evt.which : evt.keyCode;
      obj = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
   }
   var ValidChars = "0123456789/" + String.fromCharCode(8) + String.fromCharCode(0);
   if (ValidChars.indexOf(String.fromCharCode(key)) == -1) {
      return false;
   }
}
function keyora(evt) {
   var key = "";
   if (window.event) {
      key = window.event.keyCode;
   } else {
      key = (window.Event) ? evt.which : evt.keyCode;
   }
   var ValidChars = "0123456789:" + String.fromCharCode(8) + String.fromCharCode(0);
   if (ValidChars.indexOf(String.fromCharCode(key)) == -1) {
       return false;
   }
}
function keynum(evt) {
   var key = "";
   var obj;
   if (window.event) {
      key = window.event.keyCode;
      obj = window.event.srcElement;
   } else {
      key = (window.Event) ? evt.which : evt.keyCode;
      obj = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
   }
   var ValidChars = "0123456789" + String.fromCharCode(8) + String.fromCharCode(0);
   if (ValidChars.indexOf(String.fromCharCode(key)) == -1) {
      return false;
   }
}
function keyval(evt) {
   var key = "";
   if (window.event) {
      key = window.event.keyCode;
   } else {
      key = (window.Event) ? evt.which : evt.keyCode;
   }
   var ValidChars = "0123456789,." + String.fromCharCode(8) + String.fromCharCode(0);
   if (ValidChars.indexOf(String.fromCharCode(key)) == -1) {
      return false;
   }
}
function validadata(obj) {
   var stringa = obj.value
   var espressione = /^[0-9]{2}\/[0-9]{2}\/[0-9]{4}$/;
   if (!espressione.test(stringa)) {
      return false;
   } else {
      anno = parseInt(stringa.substr(6), 10);
      if (anno < 1800) { return false; } 
      mese = parseInt(stringa.substr(3, 2), 10);
      giorno = parseInt(stringa.substr(0, 2), 10);
      var data = new Date(anno, mese - 1, giorno);
      if (data.getFullYear() == anno && data.getMonth() + 1 == mese && data.getDate() == giorno) {
         return true;
      } else {
         return false;
      }
   }
}
function validaora(obj) {
    var stringa = obj.value
    var espressione = /^[0-9]{2}\:[0-9]{2}$/;
    if (!espressione.test(stringa)) {
        return false;
    } else {
        var ora = parseInt(stringa.substr(0, 2), 10);
        var minuti = parseInt(stringa.substr(3, 2), 10);
        if (ora > 23 || ora < 0) {
           return false;
        }
        if (minuti > 59 || minuti < 0) {
           return false;
        }
        return true;
    }
}
function validanum(obj) {
   return isnumeric(obj.value);
}
function validaval(obj) {
   if(isnumeric(obj.value)) {
      var num = 0.00;
      num = obj.value.replace(",", ".");
      obj.value = parseFloat(num).toFixed(2).replace(".", ",");
      return true;
   } else {
      return false;
   }   
}
function setOpacity(value, obj) {
    if (document.getElementById(obj)) {
        document.getElementById(obj).style.opacity = value / 10;
        document.getElementById(obj).style.filter = 'alpha(opacity=' + value * 10 + ')';
    }
}
function destroydiv(obj) {
    if (document.getElementById(obj)) {
        document.getElementById(obj).style.display = "none";
    }
}
function colormenu(obj, firstcolor, endcolor, fontcolor, typegradient) {
   setGradient(obj, firstcolor, endcolor, typegradient); //'#5571F2', 0);
   obj.style.color = fontcolor;
}
function trim(stringa){ 
   while (stringa.substring(0,1) == ' '){
      stringa = stringa.substring(1, stringa.length);
   }
   while (stringa.substring(stringa.length-1, stringa.length) == ' '){
      stringa = stringa.substring(0,stringa.length-1);
   }
   return stringa;
}
function mid(String, Start, Length)
{
    if (String == null)
        return (false);
    
    if (Start > String.length)
        return '';
    
    if (Length == null || Length.length == 0)
        return (false);
 
    return String.substr((Start - 1), Length);
}
function val(String){
   if(!isNaN(String)){
      return parseFloat(String);
   } else {
      return 0;
   }   
}
function instr(String1, String2){
    var a = 0;
    if (String1 == null || String2 == null)
        return (false);
    String1 = String1.toLowerCase();
    String2 = String2.toLowerCase();
    a = String1.indexOf(String2);
    if (a == -1)
        return 0;
    else
        return a + 1;
}
function right(string, len) {
   return string.substr(string.length - len);
}
function isdate(date) {
   var stringa = date;
   var espressione = /^[0-9]{2}\/[0-9]{2}\/[0-9]{4}$/;
   if (!espressione.test(stringa)) {
      return false;
   } else {
      anno = parseInt(stringa.substr(6), 10);
      if (anno < 1800) { return false; }
      mese = parseInt(stringa.substr(3, 2), 10);
      giorno = parseInt(stringa.substr(0, 2), 10);
      var data = new Date(anno, mese - 1, giorno);
      if (data.getFullYear() == anno && data.getMonth() + 1 == mese && data.getDate() == giorno) {
         return true;
      } else {
         return false;
      }
   }
}
function istime(time) {
   var stringa = time
   var espressione = /^[0-9]{2}\:[0-9]{2}$/;
   if (!espressione.test(stringa)) {
      return false;
   } else {
      var ora = parseInt(stringa.substr(0, 2), 10);
      var minuti = parseInt(stringa.substr(3, 2), 10);
      if (ora > 23 || ora < 0) {
         return false;
      }
      if (minuti > 59 || minuti < 0) {
         return false;
      }
      return true;
   }
}
function isnumeric(number) {
   number = String(number).replace(",", ".");
   if (number.lenght == 0) { return false; }
   return !isNaN(number);
}
function chr(AscNumber) {
   return String.fromCharCode(AscNumber);
}
function asc(chart) {
   return chart.charCodeAt(0);
}
function fiscale(cognome, nome, datanascita, sesso, codcomuneistat) {
var cogn = "";
var cons = "";
var Pari1 = "";
var Pari11 = "";
var dispari = "";
var cfp = "";
var riempie = "";
var s = 0;
var p = 0;
var voca = "";
var mese = "";
var lu1 = "";
var nu1 = "";
var ss = "";
var lu2 = "";
var nu2 = "";
var i = 0;
var co = "";
var n = 0;
var hu11 = "";
var nu11 = "";
var nom = "";
var cont = 0;
var coris = "";
var giorno = "";
var gi = "";
var g = "";
var anno = "";
var Ms = "";
var CF = "";
var a = 0;
var b = 0;
var ric = 0;
var c = 0;
var d = 0;
var e = 0;
var finale = "";

   cons = "BCDFGHLMNPQRSTVWKXYJZ";
   voca = "AEIOU";
   mese = "ABCDEHLMPRST";
   Pari1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
   Pari11 = "0123456789";
   dispari = "0100050709131517192102041820110306081214161022252423";
   riempie = "XXX";
   nome = trim(nome).toUpperCase();
   cognome = trim(cognome).toUpperCase();
   sesso = trim(sesso).toUpperCase();
   lu1 = nome;
   nu1 = lu1.length;
   lu2 = cognome
   nu2 = lu2.length;
   cogn = " ";
   for(i=1; i<nu1; i++){
      co = mid(lu1, i, 1);
      for(n=1; n<cons.length; n++){
         if(co == mid(cons, n, 1)) { cogn = cogn + co; }
      }
   }
   hu11 = trim(cogn);
   nu11 = hu11.length;
   cogn = " ";
   if(nu11 < 3){
      for(i=1; i<nu1; i++){
         co = mid(lu1, i, 1)
         for(n=1; n<voca.length; n++){
            if(co == mid(voca, n, 1)){ cogn = cogn + co; }
         }
      }
   }
   cogn = trim(cogn);
   lu1 = hu11 + cogn;
   lu1 = mid(lu1, 0, 3);
   lu1 = trim(lu1);
   nu11 = lu1.length;
   if(nu11 < 3){ lu1 = lu1 + mid(riempie, 1, (3 - nu11)); }
   nom = " ";
   cont = 0;
   for(i=1; i<nu2; i++){
      co = mid(lu2, i, 1);
      for(n=1; n<cons.length;n++){
         if(co == mid(cons, n, 1)){ cont = cont + 1; }
      }
   }
   coris = " ";
   if(cont > 3){
      nom = " ";
      cont = 0;
      for(i=1; i<nu2; i++){
         co = mid(lu2, i, 1);
         for(n=1; n<cons.length;n++){
            if(co == mid(cons, n, 1)){
               cont = cont + 1;
               if(cont == 2){
                  coris = co;
               }else{
                  nom = trim(nom + co);
               }
            }
         }
      }
   } else {
      nom = " ";
      cont = 0;
      for(i=1; i<nu2; i++){
         co = mid(lu2, i, 1);
         for(n=1; n<cons.length;n++){
            if(co==mid(cons, n, 1)){ nom = trim(nom + co); }
         }
      }
   }
   hu11 = trim(hu11);
   hu11 = mid(nom, 1, 3);
   nu11 = hu11.length;
   if(nu11 < 3){
      if(coris==""){ hu11 = hu11 + trim(coris); }
   }
   nu11 = trim(hu11).length;
   if(nu11<3){
      nom = " ";
      for(i=1; i<nu2; i++){
         co = mid(lu2, i, 1);
         for(n=1; n<cons.length;n++){
            if(co==mid(voca, n, 1)){ nom = trim(nom + co); }
         }
      }
   }
   lu2 = trim(mid(hu11 + nom, 1, 3));
   if(lu2.length < 3){ lu2 = lu2 + mid(riempie, 1, (3 - lu2.length)); }
   giorno = mid(datanascita, 0, 2);
   ss = mid(datanascita, 4, 2);
   gi = trim(giorno);
   if(trim(sesso).toLowerCase()=="f"){
      g = val(datanascita) + 40
      gi = trim((string)(g));
   }
   anno = right(datanascita, 2);
   Ms = mid(mese, ss, 1);
   CF = lu1 + lu2 + anno + mid(mese, ss, 1) + gi + codcomuneistat;
   a = 0;
   for(i=2; i<=14; i=i+2){
     cfp = mid(CF, i, 1);
     if(instr(Pari1, cfp)>0){
        a = a + instr(Pari1, cfp) - 1;
     }else{
        a = a + instr(Pari11, cfp) - 1;
     }
   }
   b = 0;
   ric = 0;
   for(i=1; i<=15; i=i+2){
      cfp = mid(CF, i, 1);
      if (instr(Pari1, cfp) > 0) {
         ric = instr(Pari1, cfp) * 2 - 1;
         b = b + val(mid(dispari, ric, 2));
      } else {
         ric = instr(Pari11, cfp) * 2 - 1;
         b = b + val(mid(dispari, ric, 2));
      }
   }
   c = a + b;
   d = parseInt(c / 26);
   e = c - (d * 26);
   finale = mid(Pari1, e + 1, 1);
   CF = CF + finale;
   return CF;
}








// SET GRADIENT FROM GRADIENT LIBRARY;







var setGradient = (function() {

   //private variables;
   var p_dCanvas = document.createElement('canvas');
   var p_useCanvas = !!(typeof (p_dCanvas.getContext) == 'function');
   var p_dCtx = p_useCanvas ? p_dCanvas.getContext('2d') : null;
   var p_isIE = /*@cc_on!@*/false;


   //test if toDataURL() is supported by Canvas since Safari may not support it

   try { p_dCtx.canvas.toDataURL() } catch (err) {
      p_useCanvas = false;
   };

   if (p_useCanvas) {

      return function(dEl, sColor1, sColor2, bRepeatY) {

         if (typeof (dEl) == 'string') dEl = document.getElementById(dEl);
         if (!dEl) return false;
         var nW = dEl.offsetWidth;
         var nH = dEl.offsetHeight;
         p_dCanvas.width = nW;
         p_dCanvas.height = nH;


         var dGradient;
         var sRepeat;
         // Create gradients
         if (bRepeatY) {
            dGradient = p_dCtx.createLinearGradient(0, 0, nW, 0);
            sRepeat = 'repeat-y';
         } else {
            dGradient = p_dCtx.createLinearGradient(0, 0, 0, nH);
            sRepeat = 'repeat-x';
         }

         dGradient.addColorStop(0, sColor1);
         dGradient.addColorStop(1, sColor2);

         p_dCtx.fillStyle = dGradient;
         p_dCtx.fillRect(0, 0, nW, nH);
         var sDataUrl = p_dCtx.canvas.toDataURL('image/png');

         with (dEl.style) {
            backgroundRepeat = sRepeat;
            backgroundImage = 'url(' + sDataUrl + ')';
            backgroundColor = sColor2;
         };
      }
   } else if (p_isIE) {

      p_dCanvas = p_useCanvas = p_dCtx = null;
      return function(dEl, sColor1, sColor2, bRepeatY) {
         if (typeof (dEl) == 'string') dEl = document.getElementById(dEl);
         if (!dEl) return false;
         dEl.style.zoom = 1;
         var sF = dEl.currentStyle.filter;
         dEl.style.filter = ' ' + ['progid:DXImageTransform.Microsoft.gradient(	GradientType=', +(!!bRepeatY), ',enabled=true,startColorstr=', sColor1, ', endColorstr=', sColor2, ')'].join('');

      };

   } else {

      p_dCanvas = p_useCanvas = p_dCtx = null;
      return function(dEl, sColor1, sColor2) {

         if (typeof (dEl) == 'string') dEl = document.getElementById(dEl);
         if (!dEl) return false;
         with (dEl.style) {
            backgroundColor = sColor2;
         };
      }
   }
})();
