/*** Inizializzazione browser (old-style) ***/ var iexplorer = 0; var ie55 = 0; //particolare per versione 5.5 di explorer var mozilla = 0; //netscape incluso var opera = 0; if (navigator.userAgent.indexOf("Opera")>=0) { opera = 1; } else if (navigator.userAgent.indexOf("MSIE")>=0) { iexplorer = 1; if (navigator.appVersion.indexOf("MSIE 5.5")>=0) { ie55 = 1; } } else if (navigator.userAgent.indexOf("Mozilla")>=0) { mozilla = 1; } else { //tentativo di riconoscere browser explorer o netscape "like" iexplorer=document.all&&document.getElementById mozilla=document.getElementById&&!document.all } //Retrocompatibilità AVNG var ie5 = iexplorer; var ns6 = mozilla; /*** Fine inizializzazione browser ***/ /* Funzioni di utilità */ function SetBoxPosition(box, leftedge, topedge, offsetx, offsety, bordersmargin) { if (!offsetx) var offsetx = 0; if (!offsety) var offsety = 0; if (!bordersmargin) var bordersmargin = 0; var boxwidth = box.offsetWidth; var boxheight = box.offsetHeight; var rightend = GetInnerWidth() + GetScrollXPosition() - bordersmargin; var bottomend = GetInnerHeight() + GetScrollYPosition() - bordersmargin; var leftedgetorightend = rightend - (leftedge + offsetx); var topedgetobottomend = bottomend - (topedge + offsety); //if the horizontal distance isn't enough to accomodate the width of the box if ( leftedgetorightend < boxwidth) { box.style.left = leftedge - boxwidth + "px" } else if ((leftedge + offsetx) < (bordersmargin)) { box.style.left= bordersmargin + "px"; } else { //"Usual" horizontal position of the box box.style.left= leftedge + offsetx + "px" } //same concept with the vertical position if ( topedgetobottomend < boxheight) { box.style.top = topedge - offsety - boxheight + "px" } else if ((topedge + offsety) < (bordersmargin)) { box.style.top= bordersmargin + "px" } else { //"Usual" vertical position of the box box.style.top = topedge + offsety +"px" } } //Dato un evento ne rileva la posizione e poisiziona un oggetto (box) function SetBoxPositionOnEvent(e, box, offsetx, offsety, bordersmargin) { var leftedge = GetClientXPosition(e) + GetScrollXPosition(); var topedge = GetClientYPosition(e) + GetScrollYPosition(); return SetBoxPosition(box, leftedge, topedge, offsetx, offsety, bordersmargin) } //Restituisce la posizione assoluta di un elemento nella pagina function GetElementXPosition(el) { if (el.offsetLeft == 0) return 0 else return el.offsetLeft+GetElementXPosition(el.offsetParent) } function GetElementYPosition(el) { if (el.offsetTop == 0) return 0 else return el.offsetTop+GetElementYPosition(el.offsetParent) } /* Written by Jonathan Snook, http://www.snook.ca/jonathan Add-ons by Robert Nyman, http://www.robertnyman.com */ function getElementsByClassName(oElm, strTagName, strClassName){ var arrElements = (strTagName == "*" && document.all)? document.all : oElm.getElementsByTagName(strTagName); var arrReturnElements = new Array(); strClassName = strClassName.replace(/\-/g, "\\-"); var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)"); var oElement; for(var i=0; i 1) q = q.substring(1, q.length); else q = null; this.keyValuePairs = new Object(); if(q) { var key_value = new Array(); for(var i=0; i < q.split("&").length; i++) { key_value = q.split("&")[i].split("="); this.keyValuePairs[key_value[0]] = key_value[1]; } } this.getKeyValuePairs = function() { return this.keyValuePairs; } this.getValue = function(s) { return this.keyValuePairs[s]; } this.getParameters = function() { return dir(this.keyValuePairs); } this.getLength = function() { return this.getParameters.length; } this.setValue = function(s,v) { this.keyValuePairs[s] = v; } this.popValue = function(s) { var v = this.getValue(s); delete this.keyValuePairs[s]; return v } this.get = function() { var q = "?"; for (var k in this.keyValuePairs) { q += k + "=" + this.keyValuePairs[k] + '&'; } return q.substring(0, q.length-1); } return this } function get_select_option(el) { return el.options[el.selectedIndex] } function InputHidden(name, value) { var hid = document.createElement('input'); hid.type="hidden"; hid.name=name; hid.value=value; return hid } /**** Dispatch errori AJAX ****/ var ajax_error_global_disappear_interval; function error_disappear() { if (GetElementById('ajax_error_details').style.display == 'none') { clearTimeout(ajax_error_global_disappear_interval); Effect.Fade('ajax_error'); } } function dispatch_xmlhttp_error(xmlhttp) { var ajax_error = GetElementById('ajax_error'); var ajax_error_details = GetElementById('ajax_error_details'); AddInnerHTML(ajax_error_details, xmlhttp.responseText); ajax_error.style.visibility='visible'; ajax_error.style.display='block'; ajax_error_global_disappear_interval = setInterval('error_disappear()', 5000); } /* trim delle stringhe */ function ltrim(str) { return str.replace(/^[ \n]+/, ''); } function rtrim(str) { return str.replace(/[ \n]+$/, ''); } function trim(str) { return ltrim(rtrim(str)); }