window._DEBUG=false;

window.AssoloUtils = new Object();
window.AssoloUtils.Browser = new Object();
window.AssoloUtils.Browser.isMozilla = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined') && (typeof HTMLDocument!='undefined');
window.AssoloUtils.Browser.isIE = window.ActiveXObject ? true : false;
window.AssoloUtils.Browser.isFirefox = (navigator.userAgent.toLowerCase().indexOf("firefox")!=-1);
window.AssoloUtils.Browser.isSafari = (navigator.userAgent.toLowerCase().indexOf("Browser.isSafari")!=-1);
window.AssoloUtils.Browser.isOpera = (typeof window.opera != 'undefined'); 

window._DEBUG_WINDOW = null;

window.AssoloUtils.init = function ()
{
    try {
        if (window.top != window) {
            window._DEBUG=window.top._DEBUG;
            if (window.top._DEBUG) {
                function getDebugWindow() {
                    if (window.top._DEBUG_WINDOW) {
                        window._DEBUG_WINDOW = window.top._DEBUG_WINDOW;
                    } else {
                        setTimeout(getDebugWindow,50);
                    }
                }
                setTimeout(getDebugWindow,50);
            }
        } else {
            if (window._DEBUG) {
                window._DEBUG_WINDOW = window.open("","DEBUG_WINDOW","scrollbars=1,menubar=1,resizable=1,width=350,height=250"); 
                if (window._DEBUG_WINDOW) {
                    window._DEBUG_WINDOW.document.body.innerHTML = "<br><br>PROGRAM STARTED <input type='button' value=' svuota ' onclick='document.getElementById(\"DEBUG\").innerHTML = \"\"'><br><br>\n<div id=\"DEBUG_COORD\"></div><div id=\"DEBUG\"></div>";
                    window._DEBUG_WINDOW.document.documentElement.style.overflow = "scroll";
                }
            }
        }
    }
    catch(err) {
        // cross site, no debug allowed!!!
    }
}

window.AssoloUtils.debug = function (msg, ishtml){
	if (window._DEBUG && window._DEBUG_WINDOW) {
		var d = window._DEBUG_WINDOW.document;
        if (d) {
            var my_date = new Date();
            dateStr = ""+my_date.getFullYear()+"."+(my_date.getMonth()+1)+"."+my_date.getDate() +" "+my_date.getHours() +":"+my_date.getMinutes() +"."+my_date.getSeconds() +","+my_date.getMilliseconds();
            if (ishtml) {
                d.getElementById("DEBUG").innerHTML+='<br> - '+dateStr+": "+msg+'\n';
            } else {
                d.getElementById("DEBUG").appendChild(d.createElement("br"));
                d.getElementById("DEBUG").appendChild(d.createTextNode(' - '+dateStr+": "+msg+'\n'));
            }
        }
	}
}
window.AssoloUtils.debugMouseMove = function (X,Y){
	if ((window._DEBUG) && (window._DEBUG_WINDOW) && (window._DEBUG_WINDOW.document) && (window._DEBUG_WINDOW.document.getElementById("DEBUG_COORD")))
		window._DEBUG_WINDOW.document.getElementById("DEBUG_COORD").innerHTML = "("+X+";"+Y+")";
}

window.AssoloUtils.str_replace = function(search, replace, subject) {
	var f = search, r = replace, s = subject;
	var ra = r instanceof Array, sa = s instanceof Array, f = [].concat(f), r = [].concat(r), i = (s = [].concat(s)).length;
 
	while (j = 0, i--) {
		if (s[i]) {
			while (s[i] = (s[i]+'').split(f[j]).join(ra ? r[j] || "" : r[0]), ++j in f){};
		}
	};
	return sa ? s : s[0];
}

window.AssoloUtils.in_array = function(myvalue, myarray) {
    var found = false, i;
 
    for (i in myarray) {
        if (myarray[i] == myvalue) {
            found = true;
            break;
        }
    }
 
    return found;
}

window.AssoloUtils.array_search = function( myvalue, myarray ) {
    var i = '';
 
    for (i in myarray) {
        if ( myarray[i] == myvalue ){
            return i;
        }
    }
 
    return false;
}

window.AssoloUtils.typeOf = function(value) {
    var s = typeof value;
    if (s === 'object') {
        if (value) {
            if (value instanceof Array) {
                s = 'array';
            }
        } else {
            s = 'null';
        }
    }
    return s;
}

window.AssoloUtils.strpos = function(mystr, findtxt) {
    return (mystr+'').indexOf(findtxt, 0);
}

window.AssoloUtils.ltrim = function(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

window.AssoloUtils.rtrim = function(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

window.AssoloUtils.trim = function(str, chars) {
	return window.AssoloUtils.ltrim(window.AssoloUtils.rtrim(str, chars), chars);
}

window.AssoloUtils.URLDecode = function( encoded )
{
   var HEXCHARS = "0123456789ABCDEFabcdef"; 
   var plaintext = "";
   var i = 0;
   while (i < encoded.length) {
       var ch = encoded.charAt(i);
	   if (ch == "+") {
	       plaintext += " ";
		   i++;
	   } else if (ch == "%") {
			if (i < (encoded.length-2) 
					&& HEXCHARS.indexOf(encoded.charAt(i+1)) != -1 
					&& HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 ) {
				plaintext += unescape( encoded.substr(i,3) );
				i += 3;
			} else {
				alert( 'Bad escape combination near ...' + encoded.substr(i) );
				plaintext += "%[ERROR]";
				i++;
			}
		} else {
		   plaintext += ch;
		   i++;
		}
	}
   return plaintext;
};

window.AssoloUtils.urlencode = function(str) {
	return escape(str).replace(/\+/g,'%2B').replace(/%20/g, '+').replace(/\*/g, '%2A').replace(/\//g, '%2F').replace(/@/g, '%40');
}


window.AssoloUtils.SendAsyncRequest = function(method, url, mycallback, argument, myform, retrynum, IsFileUpload, allowedExtensionsRegExp, allowedExtensionsErrMsg )
{
    if (window.AssoloUtils.Browser.isIE) {
        var newDate = new Date;
        url+="&bdM="+newDate.getTime();
    }

	if (IsFileUpload) {
		window.AssoloUtils.SendAsyncRequestAdvanced(method, url, mycallback, argument, myform, retrynum, allowedExtensionsRegExp, allowedExtensionsErrMsg );
	} else {
		window.AssoloUtils.SendAsyncRequestBasic(method, url, mycallback, argument, myform, retrynum );
	}
}

window.AssoloUtils.SendAsyncRequestBasic = function(method, url, mycallback, argument, myform, retrynum ) {

	var http = null;
	var data = "";
	var IsOKToSubmit = true;
	http = window.AssoloUtils.createRequest(argument);
	
	var myRetryNum;
	if (retrynum === undefined) {
		myRetryNum = 0;
	} else {
		myRetryNum = parseInt(retrynum);
	}
	myRetryNum++;

	var curMethod = method;
	var curUrl = url; 
	var curCallback = mycallback; 
	var curForm = myform;
	var callback = function(){
		if (http.readyState == 4) 
		{
			var status = "";
			try {
			  status = http.status;
			}
			catch(e) { // firefox 2.0 workaround
				if (myRetryNum <= 3) {
					status = -1;
					setTimeout(function() {
						window.AssoloUtils.SendAsyncRequestBasic(curMethod, curUrl, curCallback, argument, curForm, myRetryNum );
					}, 100);
				} else { // give-up
					status = 200;
				}
			}
		
			if (status < 200) { 		// 1xx Informational --> do nothing
				alert("Warning: status code is " + status);
			} else if (status < 300) {	// 2xx Success
				if (window.AssoloUtils.strpos(http.responseText, "parent.location='index.php'") == -1) {
					mycallback(http);
				} else {
					var mydocument = top.document;
					while (mydocument.parent) {
						mydocument = mydocument.parent;
					}
					mydocument.location = "index.php";
					alert("Sessione Scaduta!");
				}
			} else {						// 3xx Redirection
											// 4xx Client Error
											// 5xx Server Error			
				alert("Error: status code is " + status);
			}
		}
	}
	
	if (http) {
		http.open(method, url, true);
		http.onreadystatechange = callback;
		var mysep = "";
		if (method == "GET") {
			http.send(data);
		} else if (method == "POST") {
			var theform = null;
			if (window.AssoloUtils.typeOf(myform) == "string") {
				var theform = document.getElementById(myform);
			} else {
				var theform = myform;
			}
			if (!theform) {
				alert("Errore: il Form non !");
			} else {
				var elem = theform.elements;
				for(var i = 0; i < elem.length; i++)
				{
					switch(elem[i].type)
					{
						case 'file': 
						case 'hidden':
						case 'text':
						case 'password':
						case 'button':
						case 'reset':
						case 'submit':
						case 'textarea':
							if (data) data += "&";
							data += "" + encodeURIComponent(elem[i].name) + "=" + encodeURIComponent(elem[i].value);
							break;
						case 'select-one':
							if (elem[i].options.length > 0){
                                if (data) data += "&";
                                data += "" + encodeURIComponent(elem[i].name) + "=" + encodeURIComponent(elem[i].options[elem[i].selectedIndex].value);
                            }
							break;
						case 'select-multiple':
							if (data) data += "&" + encodeURIComponent(elem[i].name) + "=";
							mysep = "";
							for(var j=0;j<elem[i].options.length;j++) {
								if(elem[i].options[j].selected) {
									data += encodeURIComponent(mysep + elem[i].options[j].value);
									if (!mysep) mysep = ",";
								}
							}
							break;
						case 'radio':
						case 'fieldset':
						case 'checkbox':
							if(elem[i].checked){
								if (data) data += "&";
								data += "" + encodeURIComponent(elem[i].name) + "=" + encodeURIComponent(elem[i].value);
							}
							break;
						default:
							if (elem[i].type!=undefined)
                                                           alert("ERRORE TIPO NON IMPLEMENTATO11111111111111111111111111111111111111111111: tipo="+elem[i].type);
					}
				}
				if (IsOKToSubmit) {
					http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
					http.send(data);
				}
			}
		} else {
			alert("Errore: Method non supportato!");
		}
	} else {
		alert("Errore: window.AssoloUtils.createRequest");
	}
}

window.AssoloUtils.SendAsyncRequestLight = function(url, mycallback, argument) {
	var http = window.AssoloUtils.createRequest(argument);
	if (http) {
		http.open("GET", url, true);
        if (mycallback) {
            http.onreadystatechange = function() { if (http.readyState == 4) { mycallback(http); } };
        }
        http.send();
	}
}
window.AssoloUtils.SendAsyncRequestLightPost = function(url, data, mycallback, argument) {
	var http = window.AssoloUtils.createRequest(argument);
	if (http) {
		http.open("POST", url, true);
		http.onreadystatechange = function() { if (http.readyState == 4) { mycallback(http); } };
        http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        http.send(data);
	}
}

window.AssoloUtils.GetRandomStr = function() {
	var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghiklmnopqrstuvwxyz";
	var string_length = 24;
	var randomstring = '';
	for (var i=0; i<string_length; i++) {
		var rnum = Math.floor(Math.random() * chars.length);
		randomstring += chars.substring(rnum,rnum+1);
	}
	return randomstring;
}

window.AssoloUtils.SendAsyncRequestAdvanced_Arr = new Array();

window.AssoloUtils.fileSubmissionReturnVal = function(retCode)
{
	if (window.AssoloUtils.SendAsyncRequestAdvanced_Arr[retCode]) {
		var myObj = window.AssoloUtils.SendAsyncRequestAdvanced_Arr[retCode];
		
        if (typeof(myObj.myform) === "string") {
            var TheFormEl = document.getElementById(myObj.myform);
        } else {
            var TheFormEl = myObj.myform;
        }
        
		if (TheFormEl) 
		{
			if (TheFormEl.elements["FileTransactionId"]) {
				TheFormEl.elements["FileTransactionId"].value = retCode;
			} else {
				var myInput = document.createElement("input");
				myInput.name = "FileTransactionId";
				myInput.id = "FileTransactionId";
				myInput.type = "hidden";
				myInput.value = retCode;
				TheFormEl.appendChild(myInput);
			}
			window.AssoloUtils.SendAsyncRequestBasic(myObj.method, myObj.url, myObj.mycallback, {}, myObj.myform, myObj.retrynum );
		}
		window.AssoloUtils.SendAsyncRequestAdvanced_Arr.splice(retCode,1); 
	} else {
		alert("return code not defined ["+retCode+"]");
	}
}

window.AssoloUtils.SendAsyncRequestAdvanced = function(method, url, mycallback, argument, myform, retrynum, allowedExtensionsRegExp, allowedExtensionsErrMsg )
{

	var IsOKToSubmit = true;
    var theform = null;

    if (typeof(myform) === "string") {
        theform = document.getElementById(myform);
    } else {
        theform = myform;
    }

	if (!theform) {
		alert("Errore #aab52: il Form '"+myform+"' non esiste!");
		IsOKToSubmit = false;
	} else {
		var elem = theform.elements;
		for(var i = 0; i < elem.length; i++) {
			if (elem[i].type == 'file') {
				var filename = elem[i].value;
				if (allowedExtensionsRegExp) {
					if (filename.search(allowedExtensionsRegExp) == -1)	{
						alert(allowedExtensionsErrMsg);
						IsOKToSubmit = false;
					}
				}
			}
		}
	}

	if (IsOKToSubmit)
	{
		if (document.getElementById("__upload_iframe__")) {
			myIFrame = document.getElementById("__upload_iframe__");
		} else {
			myIFrame = document.createElement("iframe");
			myIFrame.id="__upload_iframe__";
			myIFrame.name="__upload_iframe__";
			myIFrame.style.width="600px";
			myIFrame.style.height="200px";
			myIFrame.style.display="none";

			//document.getElementById("CheckEdImportaTDIFrame").appendChild(myIFrame); // DEBUG TEMPORANEO
			document.body.appendChild(myIFrame);
		}

		var TId = window.AssoloUtils.GetRandomStr();
		window.AssoloUtils.SendAsyncRequestAdvanced_Arr[TId] = new Object;
		window.AssoloUtils.SendAsyncRequestAdvanced_Arr[TId].method = method;
		window.AssoloUtils.SendAsyncRequestAdvanced_Arr[TId].url = url
		window.AssoloUtils.SendAsyncRequestAdvanced_Arr[TId].mycallback = mycallback;
		window.AssoloUtils.SendAsyncRequestAdvanced_Arr[TId].myform = myform;
		window.AssoloUtils.SendAsyncRequestAdvanced_Arr[TId].retrynum = retrynum;
		window.AssoloUtils.SendAsyncRequestAdvanced_Arr[TId].allowedExtensionsRegExp = allowedExtensionsRegExp;
		window.AssoloUtils.SendAsyncRequestAdvanced_Arr[TId].allowedExtensionsErrMsg = allowedExtensionsErrMsg;

		var theform_action = theform.action;
		var theform_method = theform.method;
		var theform_enctype= theform.enctype;
		var theform_target = theform.target;
		theform.action = "AAjax.php?tid="+TId;
                if (argument['OnlyFileInput'])
                theform.action+="&OnlyFileInput="+argument['OnlyFileInput'];
		theform.method = "POST";
		theform.enctype="multipart/form-data";
		theform.target = "__upload_iframe__";
		theform.submit();
		theform.action = theform_action;
		theform.method = theform_method;
		theform.enctype= theform_enctype;
		theform.target = theform_target;
	}
}


window.AssoloUtils.createRequest = function(argument)
{
	var MSXMLProgId = [ 'Microsoft.XMLHTTP', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP' ];

	var http = false;
	try {
		http = new XMLHttpRequest(); // Instantiates XMLHttpRequest in non-IE browsers and assigns to http.
	} catch(e) {
		for(var i=0; i<MSXMLProgId.length; ++i){
			try {
				http = new ActiveXObject(MSXMLProgId[i]); // Instantiates XMLHttpRequest for IE and assign to http
				break;
			} catch(e2){}
		}
	} finally {
		if (http && argument) {
			http.argument = argument;
		}
		return http;
	}
}

window.AssoloUtils.SendSyncRequestFast = function(url)
{
	if (http = window.AssoloUtils.createRequest()) {
		http.open('GET', url, false);
		http.send("");
	}
}


window.AssoloUtils.SendAsyncRequestFast = function(url)
{
	if (http = window.AssoloUtils.createRequest()) {
		http.open('GET', url, true);
		http.send("");
	}
}


window.AssoloUtils.ScrollBarWidth = 0;
window.AssoloUtils.getScrollerWidth = function() 
{
	if (!window.AssoloUtils.ScrollBarWidth) {
		var scr = null;
		var inn = null;
		var wNoScroll = 0;
		var wScroll = 0;

		// Outer scrolling div
		scr = document.createElement('div');
		scr.style.position = 'absolute';
		scr.style.top = '-1000px';
		scr.style.left = '-1000px';
		scr.style.width = '100px';
		scr.style.height = '50px';
		// Start with no scrollbar
		scr.style.overflow = 'hidden';

		// Inner content div
		inn = document.createElement('div');
		inn.style.width = '100%';
		inn.style.height = '200px';

		// Put the inner div in the scrolling div
		scr.appendChild(inn);
		// Append the scrolling div to the doc
		document.body.appendChild(scr);

		// Width of the inner div sans scrollbar
		wNoScroll = inn.offsetWidth;
		// Add the scrollbar
		scr.style.overflow = 'auto';
		// Width of the inner div width scrollbar
		wScroll = inn.offsetWidth;

		// Remove the scrolling div from the doc
		document.body.removeChild(
			document.body.lastChild);

		window.AssoloUtils.ScrollBarWidth = (wNoScroll - wScroll);
	}
	return window.AssoloUtils.ScrollBarWidth;
}

window.AssoloUtils.getDocumentScrollLeft = function(doc)
{
	doc = doc || document;
	return Math.max(document.documentElement.scrollLeft, document.body.scrollLeft);
}

window.AssoloUtils.getDocumentScrollTop = function(doc) 
{
	doc = doc || document;
	return Math.max(doc.documentElement.scrollTop, doc.body.scrollTop);
}

window.AssoloUtils.GetXY = function(el, absolutePosition)
{
/*    var patterns = {
        HYPHEN: /(-[a-z])/i, // to normalize get/setStyle
        ROOT_TAG: /^body|html$/i, // body for quirks mode, html for standards,
        OP_SCROLL:/^(?:inline|table-row)$/i
    };*/
    
    var patterns = { ROOT_TAG: /^body|html$/i }; // body for quirks mode, html for standards,

	if (document.documentElement.getBoundingClientRect) { // IE
		var box = el.getBoundingClientRect(), 
			rootNode = el.ownerDocument;
		
		return [Math.round(box.left + window.AssoloUtils.getDocumentScrollLeft(rootNode)), 
				Math.round(box.top  + window.AssoloUtils.getDocumentScrollTop(rootNode))];
	} else { // manually calculate by crawling up offsetParents
		var pos = [el.offsetLeft, el.offsetTop];
		var parentNode = el.offsetParent;

		// safari: subtract body offsets if el is abs (or any offsetParent), unless body is offsetParent
		var accountForBody = (Browser.isSafari &&
				el.style.position == 'absolute' &&
				el.offsetParent == el.ownerDocument.body);

		if (parentNode != el) {
			while (parentNode) {
				pos[0] += parentNode.offsetLeft;
				pos[1] += parentNode.offsetTop;
				if (!accountForBody && Browser.isSafari && parentNode.style.position == 'absolute' ) {
					accountForBody = true;
				}
				parentNode = parentNode.offsetParent;
			}
		}

		if (accountForBody) { //safari doubles in this case
			pos[0] -= el.ownerDocument.body.offsetLeft;
			pos[1] -= el.ownerDocument.body.offsetTop;
		} 
		parentNode = el.parentNode;

		// account for any scrolled ancestors
		while ( parentNode.tagName && (patterns || !patterns.ROOT_TAG.test(parentNode.tagName)) ) 
		{
			if (parentNode.scrollTop || parentNode.scrollLeft) {
				pos[0] -= parentNode.scrollLeft;
				pos[1] -= parentNode.scrollTop;
			}
			
			parentNode = parentNode.parentNode; 
		}

		return pos;
	}
}

window.AssoloUtils.GetXYWH = function(el)
{
	var pos = window.AssoloUtils.GetXY(el);
	try {
		var box = el.getBoundingClientRect();
		if (!box.width || !box.height) {
			return [parseInt(pos[0]), parseInt(pos[1]), parseInt(el.offsetWidth), parseInt(el.offsetHeight)];
		} else {
			return [parseInt(pos[0]), parseInt(pos[1]), parseInt(box.width), parseInt(box.height)];
		}
	} catch (e) {
		return [parseInt(pos[0]), parseInt(pos[1]), parseInt(el.offsetWidth), parseInt(el.offsetHeight)];
	}
	if (!box.width || !box.height) {
		return [parseInt(pos[0]), parseInt(pos[1]), parseInt(el.offsetWidth), parseInt(el.offsetHeight)];
	} else {
		return [parseInt(pos[0]), parseInt(pos[1]), parseInt(box.width), parseInt(box.height)];
	}
}

window.AssoloUtils.hasClass = function(ele,cls) {
	return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
}
window.AssoloUtils.addClass = function(ele,cls) {
	if (!window.AssoloUtils.hasClass(ele,cls)) ele.className += " "+cls;
}
window.AssoloUtils.removeClass = function(ele,cls) {
	if (window.AssoloUtils.hasClass(ele,cls)) {
		var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
		ele.className=ele.className.replace(reg,' ');
	}
}
window.AssoloUtils.isdefined = function(variable) {
    return (typeof(variable) == "undefined")? false: true;
}

window.AssoloUtils.print_r = function (theObj, maxtry){
	var output="<ul>";
	indentB= "<li>";
	indentE= "</li>";

	var myMaxtry = 0;
	if (maxtry === undefined) {
		myMaxtry = 10;
	} else {
		myMaxtry = parseInt(maxtry)-1;
	}
  
  var s = typeof theObj;
	if(theObj.constructor == Array || theObj.constructor == Object || s == "object") {
		for(var p in theObj){
      if (theObj[p]) {
        s = typeof theObj[p];
        if(theObj[p].constructor == Array|| theObj[p].constructor == Object || s == "object"){
          var type = (theObj[p].constructor == Array) ? "Array" : "Object";
          output += indentB+"["+p+"]("+type+")=> {";
          if (myMaxtry>0) {
            output += window.AssoloUtils.print_r(theObj[p],myMaxtry);
          } else {
            output += "...";
          }
          output += "}"+indentE;
        } else { 
          output += indentB+"["+p+"]:"+theObj[p]+"\n"+indentE; 
        }
      } else {
				output += indentB+"["+p+"]:"+theObj[p]+"\n"+indentE; 
      }
		}
	} else {
		output += indentB+"{"+s+"}"+theObj.toString()+"\n"+indentE; 
	}
	output += "</ul>";
	return output;
}

window.AssoloUtils.AddEvent = function(el, event, fnct) {
	if (window.AssoloUtils.Browser.isIE) {
		el.attachEvent('on'+event, fnct);
	} else {
		el.addEventListener(event, fnct, true);
	}
}

window.AssoloUtils.DelEvent = function(el, event, fnct) {
	/*if (window.AssoloUtils.Browser.isIE) {
		el.dettachEvent('onresize', t.Resize);
	} else {
		el.addEventListener('mousemove', t.MouseMove, true);
	}*/
}

window.AssoloUtils.parse = function(text) {

    // FROM RFC 4627
    //window.AssoloUtils.debug("window.AssoloUtils.parse("+text+")=");
    var my_JSON_object = !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(
             text.replace(/"(\\.|[^"\\])*"/g, ''))) &&
         eval('(' + text + ')');

    //window.AssoloUtils.debug(window.AssoloUtils.print_r(my_JSON_object), true);

    return my_JSON_object;
        
//    return eval('(' + text + ')');
}

window.AssoloUtils.MyConfirm = function(width,height,msg,isHTML,fnct) 
{
    this.ShadowDIV = null;
    this.PopupDIV = null;
    var myself = this;

    this.bckOverflow = document.body.style.overflow;
    this.bckScrollTop = document.body.scrollTop;
    this.bckScrollLeft = document.body.scrollLeft;
    document.body.scrollTop = 0;
    document.body.scrollLeft = 0;
    document.body.style.overflow = "hidden";

    
    function MyConfirmResize()
    {
        var w = window,d = document,AssoloWidth,AssoloHeight;

		if( typeof( w.innerWidth ) == 'number' ) {
			//Non-IE
			AssoloWidth = w.innerWidth;
			AssoloHeight = w.innerHeight;
		} else if( d.documentElement && ( d.documentElement.clientWidth || d.documentElement.clientHeight ) ) {
			//IE 6+ in 'standards compliant mode'
			AssoloWidth = d.documentElement.clientWidth;
			AssoloHeight = d.documentElement.clientHeight;
		} else if( d.body && ( d.body.clientWidth || d.body.clientHeight ) ) {
			//IE 4 compatible
			AssoloWidth = d.body.clientWidth;
			AssoloHeight = d.body.clientHeight;
		}
        
        if (myself.ShadowDIV && myself.PopupDIV) {
            myself.ShadowDIV.style.width = AssoloWidth+"px";
            myself.ShadowDIV.style.height = AssoloHeight+"px";
            myself.PopupDIV.style.top = parseInt((AssoloHeight-parseInt(myself.PopupDIV.style.height))/2)+"px";
            myself.PopupDIV.style.left = parseInt((AssoloWidth-parseInt(myself.PopupDIV.style.width))/2)+"px";
        }
    }

    function MyConfirmDo(evt)
    {
        if (fnct(myself,evt)) {        
            if (window.AssoloUtils.Browser.isIE) {
                window.detachEvent('onresize', MyConfirmResize);
            } else {
                window.removeEventListener('resize', MyConfirmResize, true);
            }      
            
            document.documentElement.removeChild(myself.ShadowDIV);
            myself.ShadowDIV = null;
            myself.PopupDIV = null;
            
            document.body.style.display = 'none';
            setTimeout(function() {
                if (isdefined(myself.bckOverflow)) {
                    document.body.style.overflow = myself.bckOverflow;
                } else {
                    document.body.style.overflow = "visible";
                }
                document.body.style.display = 'inline';
                if (isdefined(myself.bckScrollTop)) {
                    document.body.scrollTop = myself.bckScrollTop;
                }
                if (isdefined(myself.bckScrollLeft)) {
                    document.body.scrollLeft = myself.bckScrollLeft;
                }
            }, 1);
            
        }
    }
    
    var w = window,d = document,AssoloWidth,AssoloHeight;

    if( typeof( w.innerWidth ) == 'number' ) {
        //Non-IE
        AssoloWidth = w.innerWidth;
        AssoloHeight = w.innerHeight;
    } else if( d.documentElement && ( d.documentElement.clientWidth || d.documentElement.clientHeight ) ) {
        //IE 6+ in 'standards compliant mode'
        AssoloWidth = d.documentElement.clientWidth;
        AssoloHeight = d.documentElement.clientHeight;
    } else if( d.body && ( d.body.clientWidth || d.body.clientHeight ) ) {
        //IE 4 compatible
        AssoloWidth = d.body.clientWidth;
        AssoloHeight = d.body.clientHeight;
    }
    
    this.ShadowDIV = document.createElement("div");
    this.ShadowDIV.className = "_SHADOW";
    this.ShadowDIV.style.top = "0px";
    this.ShadowDIV.style.left = "0px";
    this.ShadowDIV.style.width = AssoloWidth+"px";
    this.ShadowDIV.style.height = AssoloHeight+"px";
    this.ShadowDIV.style.position="absolute";
    document.documentElement.appendChild(this.ShadowDIV);
    document.body.style.display = 'none';
    setTimeout(function() {
            document.body.style.overflow = 'hidden';
            document.body.style.display = 'inline';
    }, 1);
    
    this.PopupDIV = document.createElement("div");
    this.PopupDIV.className = "_Popup";
    this.PopupDIV.style.backgroundColor="white";
    this.PopupDIV.style.top = parseInt((AssoloHeight-height)/2)+"px";
    this.PopupDIV.style.left = parseInt((AssoloWidth-width)/2)+"px";
    this.PopupDIV.style.width = width+"px";
    this.PopupDIV.style.height = height+"px";
    this.PopupDIV.style.position="absolute";
    this.PopupDIV.style.overflow="auto";
    
    this.ShadowDIV.appendChild(this.PopupDIV);
    
    if (isHTML) {
        this.PopupDIV.innerHTML = msg;
        
        var myButtons = this.PopupDIV.getElementsByTagName("INPUT");
        for (var i in myButtons) {
            if (myButtons[i].type == "button") {
                if (window.AssoloUtils.Browser.isIE) {
                    myButtons[i].attachEvent('onclick', MyConfirmDo);
                } else {
                    myButtons[i].addEventListener('click', MyConfirmDo, true);
                }
            }
        }
    } else {
        var curTableTBody, curRow, curCell, curInput, curTable;
    
        curTable   = document.createElement("table");
        curTable.style.border="0px";
        curTable.cellPadding="10px";
        curTable.cellSpacing="0px";
        curTable.style.width="300px";
        curTable.style.height="150px";
        curTableTBody = document.createElement("TBODY");
        curTable.appendChild(curTableTBody);
        
        curRow = curTableTBody.insertRow(0);
        curCell = curRow.insertCell(0);
        curCell.colSpan = "2";
        curCell.innerHTML = window.AssoloUtils.str_replace("\n", "<br>", msg);
        
        curRow = curTableTBody.insertRow(1);
        curCell = curRow.insertCell(0);                             
        curCell.align="center";
        curCell.style.height="1px";
        curInput = document.createElement("input");
        curInput.type = "button";
        curInput.name = "si";
        curInput.value = "Si";
        curCell.appendChild(curInput);

        if (window.AssoloUtils.Browser.isIE) {
            curInput.attachEvent('onclick', MyConfirmDo);
        } else {
            curInput.addEventListener('click', MyConfirmDo, true);
        }      
        
        curCell = curRow.insertCell(1);
        curCell.align="center";
        curCell.style.height="1px";
        curInput = document.createElement("input");
        curInput.type = "button";
        curInput.name = "no";
        curInput.value = "No";
        curCell.appendChild(curInput);

        if (window.AssoloUtils.Browser.isIE) {
            curInput.attachEvent('onclick', MyConfirmDo);
        } else {
            curInput.addEventListener('click', MyConfirmDo, true);
        }        
        this.PopupDIV.appendChild(curTable);
    }        
    
    if (window.AssoloUtils.Browser.isIE) {
        w.attachEvent('onresize', MyConfirmResize);
    } else {
        w.addEventListener('resize', MyConfirmResize, true);
    }
}

window.AssoloUtils.ShowDivInfoImmagine = function(event,id,myConfigs)
{
	var mydiv = document.getElementById("__DivInfoImmagine__"+id);
	var OnlyShow = (mydiv)?true:false;
	
	var mydivs = document.getElementsByTagName("div");
	for (i=0; i< mydivs.length; i++) 
	{
		if (mydivs[i] && mydivs[i].id) 
		{
			if ((mydivs[i].id).indexOf("__DivInfoImmagine__") == 0)
			{
				if (mydivs[i].style.display != "none") {
					mydivs[i].style.display = "none";
				}
			}
		}
	}
	
	var DeltaX = 20,
		DeltaY = -100,
		DivWidth = 480,
		DivHeight = 290,
		Padding = 2,
		ClassName = "",
		GetScript = "GetInfoImmagine.php?id="+id,
		mousex = 0,
		mousey = 0;

	if (myConfigs) {
		if (!(myConfigs.DeltaX === undefined ))    DeltaX  = myConfigs.DeltaX;
		if (!(myConfigs.DeltaY === undefined ))    DeltaY  = myConfigs.DeltaY;
		if (!(myConfigs.DivWidth === undefined ))  DivWidth  = myConfigs.DivWidth;
		if (!(myConfigs.DivHeight === undefined )) DivHeight  = myConfigs.DivHeight;
		if (!(myConfigs.Padding === undefined ))   Padding  = myConfigs.Padding;
		if (!(myConfigs.ClassName === undefined ))   ClassName  = myConfigs.ClassName;
		if (!(myConfigs.GetScript === undefined ))   GetScript  = myConfigs.GetScript;
	}

	ev = event || window.event;

	if (ev.pageX || ev.pageY) { // this doesn't work on IE6!! (works on FF,Moz,Opera7)
	  mousex = ev.pageX;
	  mousey = ev.pageY;
	} else if (ev.clientX || ev.clientY) { // works on IE6,FF,Moz,Opera7
	  mousex = ev.clientX;
	  mousey = ev.clientY;
	}
	
	var myWidth = 0, 
		myHeight = 0;

	if( typeof( window.innerWidth ) == 'number' ) {	//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
		myWidth += (document.body.scrollLeft + document.documentElement.scrollLeft);
		myHeight += (document.body.scrollTop + document.documentElement.scrollTop);
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { //IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { //IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}

	if (!OnlyShow) 
	{
		var mydiv = document.createElement("DIV");
		mydiv.id = "__DivInfoImmagine__"+id;

		if (ClassName) {
			mydiv.className = ClassName;
		} else {
			mydiv.style.background = "#FFFFFF";
			mydiv.style.border = "1px solid black";
			mydiv.style.padding = Padding+"px";
			mydiv.style.fontFamily = "Arial";
			mydiv.style.fontSize = "12px";
		}
		
		mydiv.style.position = "absolute";
		mydiv.style.width = DivWidth+"px";
		mydiv.style.height = DivHeight+"px";
		mydiv.style.overflow = "hidden";
	}
	
	if  (myWidth < (mousex+DeltaX+DivWidth+2*Padding)) {
		mydiv.style.left = ""+(mousex-DeltaX-DivWidth-2*Padding)+"px";
	} else {
		mydiv.style.left = ""+(mousex+DeltaX)+"px";
	}
	if  ((mousey+DeltaY) < (document.body.scrollTop + document.documentElement.scrollTop)) {
		mydiv.style.top = ""+(document.body.scrollTop + document.documentElement.scrollTop)+"px";
	} else if  (myHeight < (mousey+DeltaY+DivHeight+2*Padding)) {
		mydiv.style.top = ""+(myHeight-DivHeight-2*Padding)+"px";
	} else {
		mydiv.style.top = ""+(mousey+DeltaY)+"px";
	}

	/* begin fix position */
	/* ################################################################# */
	var coordX1 = parseInt(mydiv.style.left);
	var coordY1 = parseInt(mydiv.style.top);
	var coordX2 = parseInt(mydiv.style.left)+DivWidth;
	var coordY2 = parseInt(mydiv.style.top)+DivHeight;

	if ((mousex >= coordX1) && (mousex <= coordX2) && (mousey >= coordY1) && (mousey <= coordY2))  
	{
		//alert(""+mousey+"-"+DeltaY+"-"+DivHeight+" > ("+document.body.scrollTop+" + "+document.documentElement.scrollTop+"");
		
		if (mousey-Math.abs(DeltaY)-DivHeight > (document.body.scrollTop + document.documentElement.scrollTop)) {
			mydiv.style.top = ""+(mousey-Math.abs(DeltaY)-DivHeight)+"px";
		} else {
			mydiv.style.top = ""+(mousey+Math.abs(DeltaY)-DivHeight)+"px";
		}
		
		coordX1 = parseInt(mydiv.style.left);
		coordY1 = parseInt(mydiv.style.top);
		coordX2 = parseInt(mydiv.style.left)+DivWidth;
		coordY2 = parseInt(mydiv.style.top)+DivHeight;

		if ((mousex >= coordX1) && (mousex <= coordX2) && (mousey >= coordY1) && (mousey <= coordY2))  
		{
			if (mousex-Math.abs(DeltaX)-DivWidth > (document.body.scrollLeft + document.documentElement.scrollLeft)) {
				mydiv.style.left = ""+(mousex-Math.abs(DeltaX)-DivWidth)+"px";
			} else {
				mydiv.style.left = ""+(mousex+Math.abs(DeltaX))+"px";
			}
		
			coordX1 = parseInt(mydiv.style.left);
			coordY1 = parseInt(mydiv.style.top);
			coordX2 = parseInt(mydiv.style.left)+DivWidth;
			coordY2 = parseInt(mydiv.style.top)+DivHeight;

			if ((mousex >= coordX1) && (mousex <= coordX2) && (mousey >= coordY1) && (mousey <= coordY2))  
			{
				mydiv.style.top = ""+(mousey+1)+"px";
				mydiv.style.left = ""+(mousex+1)+"px";
			}
		}
	}
	
	if (parseInt(mydiv.style.left) < (document.body.scrollLeft + document.documentElement.scrollLeft)) {
		mydiv.style.left = ""+(document.body.scrollLeft + document.documentElement.scrollLeft)+"px";
	} else {
		if (parseInt(mydiv.style.left) > (myWidth-DivWidth)) {
			mydiv.style.left = ""+(myWidth-DivWidth)+"px";
		}
	}
	/* ################################################################# */
	/* end fix position */
	
//top.document.getElementById("div_righttab_Stili").innerHTML = "show<br>";
	
	if (OnlyShow) {
		mydiv.style.display = "inline";	
//top.document.getElementById("div_righttab_Stili").innerHTML = "onlyshow<br>";
	} else {
//top.document.getElementById("div_righttab_Stili").innerHTML = "create<br>";
		var myCallback = function(o) { 
			mydiv.innerHTML = o.responseText;
		}
		window.AssoloUtils.SendAsyncRequest('GET', ""+GetScript+"", myCallback);
		document.body.appendChild(mydiv);
		
		var CurId = id;
		function CheckDivInfoImmagine(evt)
		{
			if (mydiv.style.display != "none") 
			{
				var targ = document.getElementById("InfoImmagine_"+CurId);
				if (targ) {
					var box = targ.getBoundingClientRect(), 
			
					ev = evt || window.event;

					if (ev.pageX || ev.pageY) { // this doesn't work on IE6!! (works on FF,Moz,Opera7)
					  mousex = ev.pageX;
					  mousey = ev.pageY;
					} else if (ev.clientX || ev.clientY) { // works on IE6,FF,Moz,Opera7
					  mousex = ev.clientX;
					  mousey = ev.clientY;
					}

					if ((box.left || box.right) && (box.top || box.bottom)) {
						if ((mousex < box.left) || (mousex > box.right) || (mousey < box.top) || (mousey > box.bottom) ) 
						{
							mydiv.style.display = "none";
							//top.document.getElementById("div_righttab_Stili").innerHTML = "da cancellare<br>";
							//top.document.getElementById("div_righttab_Stili").innerHTML = "("+mousex+" < "+box.left+") || ("+mousex+" > "+box.right+") || ("+mousey+" < "+box.top+") || ("+mousey+" > "+box.bottom+")";
						}
					} else {
						alert("ERRORE targ IS ZERO!");
						mydiv.style.display = "none";
					}
				} else {
					//alert("ERRORE targ NOT FOUND!");
					mydiv.style.display = "none";
				}
			}
		}
		
		try {
			top.document.addEventListener('mousemove',CheckDivInfoImmagine,true);
		} catch(err) {
			top.document.attachEvent('onmousemove', CheckDivInfoImmagine);
		}
		
		function unloadIt(evt) {
			try {
				top.document.removeEventListener('mousemove',CheckDivInfoImmagine,true);
			} catch(err) {
				top.document.detachEvent('onmousemove', CheckDivInfoImmagine);
			}
		}
		try {
			document.addEventListener('unload',unloadIt,true);
		} catch(err) {
			document.attachEvent('onunload', unloadIt);
		}		
	}
}

window.AssoloUtils.HideDivInfoImmagine = function(id)
{
	var mydiv = document.getElementById("__DivInfoImmagine__"+id);
	if (mydiv) {
		//document.body.removeChild(mydiv);
		mydiv.style.display = "none";
	}
}

window.AssoloUtils.MoveDivInfoImmagine = function(event,id,myConfigs)
{
	var DeltaX = 20,
		DeltaY = -100,
		DivWidth = 480,
		DivHeight = 290,
		Padding = 2,
		mousex = 0,
		mousey = 0,
		ScrollerHeight = 0,
		ScrollerWidth = 0;

	
	if (myConfigs) {
		if (!(myConfigs.DeltaX === undefined ))    DeltaX  = myConfigs.DeltaX;
		if (!(myConfigs.DeltaY === undefined ))    DeltaY  = myConfigs.DeltaY;
		if (!(myConfigs.DivWidth === undefined ))  DivWidth  = myConfigs.DivWidth;
		if (!(myConfigs.DivHeight === undefined )) DivHeight  = myConfigs.DivHeight;
		if (!(myConfigs.Padding === undefined ))   Padding  = myConfigs.Padding;
	}

	ev = event || window.event;
	
	ScrollerHeight = 0;
	ScrollerWidth = 0;
	if (ev.pageX || ev.pageY) { // this doesn't work on IE6!! (works on FF,Moz,Opera7)
      mousex = ev.pageX;
      mousey = ev.pageY;
	  ScrollerHeight = window.AssoloUtils.getScrollerWidth();
	  ScrollerWidth = window.AssoloUtils.getScrollerWidth();
    } else if (ev.clientX || ev.clientY) { // works on IE6,FF,Moz,Opera7
      mousex = ev.clientX;
      mousey = ev.clientY;
	  mousex += (document.body.scrollLeft + document.documentElement.scrollLeft);
	  mousey += (document.body.scrollTop + document.documentElement.scrollTop);
	} else {
      mousex = 0;
      mousey = 0;
	}

	var myWidth = 0, 
		myHeight = 0;

	if( typeof( window.innerWidth ) == 'number' ) {	//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
		myWidth += (document.body.scrollLeft + document.documentElement.scrollLeft - ScrollerWidth);
		myHeight += (document.body.scrollTop + document.documentElement.scrollTop - ScrollerHeight);
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { //IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
		myWidth += (document.body.scrollLeft + document.documentElement.scrollLeft);
		myHeight += (document.body.scrollTop + document.documentElement.scrollTop);
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { //IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	} else {
		myWidth = 0;
		myHeight = 0;
	}
		
	var mydiv = document.getElementById("__DivInfoImmagine__"+id);
	if (mydiv) {
		if  (myWidth < (mousex+DeltaX+DivWidth+2*Padding)) {
			mydiv.style.left = ""+(mousex-DeltaX-DivWidth-2*Padding)+"px";
		} else {
			mydiv.style.left = ""+(mousex+DeltaX)+"px";
		}
		if  ((mousey+DeltaY) < (document.body.scrollTop + document.documentElement.scrollTop)) {
			mydiv.style.top = ""+(document.body.scrollTop + document.documentElement.scrollTop)+"px";
		} else if  (myHeight < (mousey+DeltaY+DivHeight+2*Padding)) {
			mydiv.style.top = ""+(myHeight-DivHeight-2*Padding)+"px";
		} else {
			mydiv.style.top = ""+(mousey+DeltaY)+"px";
		}
		/*mydiv.innerHTML = "mousex="+mousex+"; mousey="+mousey+"";
		mydiv.innerHTML += "myWidth="+myWidth+"; myHeight="+myHeight+";";
		mydiv.innerHTML += "getScrollerWidth="+getScrollerWidth()+";";*/
		
		
		/* begin fix position */
		/* ################################################################# */
		var coordX1 = parseInt(mydiv.style.left);
		var coordY1 = parseInt(mydiv.style.top);
		var coordX2 = parseInt(mydiv.style.left)+DivWidth;
		var coordY2 = parseInt(mydiv.style.top)+DivHeight;

		if ((mousex >= coordX1) && (mousex <= coordX2) && (mousey >= coordY1) && (mousey <= coordY2))  
		{
			//alert(""+mousey+"-"+DeltaY+"-"+DivHeight+" > ("+document.body.scrollTop+" + "+document.documentElement.scrollTop+"");
			
			if (mousey-Math.abs(DeltaY)-DivHeight > (document.body.scrollTop + document.documentElement.scrollTop)) {
				mydiv.style.top = ""+(mousey-Math.abs(DeltaY)-DivHeight)+"px";
			} else {
				mydiv.style.top = ""+(mousey+Math.abs(DeltaY)-DivHeight)+"px";
			}
			
			coordX1 = parseInt(mydiv.style.left);
			coordY1 = parseInt(mydiv.style.top);
			coordX2 = parseInt(mydiv.style.left)+DivWidth;
			coordY2 = parseInt(mydiv.style.top)+DivHeight;

			if ((mousex >= coordX1) && (mousex <= coordX2) && (mousey >= coordY1) && (mousey <= coordY2))  
			{
				if (mousex-Math.abs(DeltaX)-DivWidth > (document.body.scrollLeft + document.documentElement.scrollLeft)) {
					mydiv.style.left = ""+(mousex-Math.abs(DeltaX)-DivWidth)+"px";
				} else {
					mydiv.style.left = ""+(mousex+Math.abs(DeltaX))+"px";
				}
			
				coordX1 = parseInt(mydiv.style.left);
				coordY1 = parseInt(mydiv.style.top);
				coordX2 = parseInt(mydiv.style.left)+DivWidth;
				coordY2 = parseInt(mydiv.style.top)+DivHeight;

				if ((mousex >= coordX1) && (mousex <= coordX2) && (mousey >= coordY1) && (mousey <= coordY2))  
				{
					mydiv.style.top = ""+(mousey+1)+"px";
					mydiv.style.left = ""+(mousex+1)+"px";
				}
			}
		}
		
		if (parseInt(mydiv.style.left) < (document.body.scrollLeft + document.documentElement.scrollLeft)) {
			mydiv.style.left = ""+(document.body.scrollLeft + document.documentElement.scrollLeft)+"px";
		} else {
			if (parseInt(mydiv.style.left) > (myWidth-DivWidth)) {
				mydiv.style.left = ""+(myWidth-DivWidth)+"px";
			}
		}
		/* ################################################################# */
		/* end fix position */
		
	}
}

window.AssoloUtils.getMaxZIndex = function(fromElement,curElement)
{
    var curZIndex = 0;
    var curChild = fromElement.firstChild;
    while (curChild) {
        if (curChild != curElement) {
            if ((curChild.style) && (curZIndex < parseInt(curChild.style.zIndex))) curZIndex = parseInt(curChild.style.zIndex);
        }
        curChild = curChild.nextSibling;
    }
    return curZIndex;
}

window.AssoloUtils.init();
