	function writeCheckBoxTipoPassword(testo,threeInputs){
		document.getElementById("passViewer").innerHTML = "<div class=\"puzzleFieldSetInputBoxInvert\" style=\"width:250px;\"><label for=\"viewchar\">"+testo+"</label><input name=\"viewchar\" type=\"checkbox\" id=\"viewchar\" value=\"\" onclick=\"cambiaTipoPassword(this,"+threeInputs+");\" /><br class=\"ClearLeft\" /></div>";
	}

	function cambiaTipoPassword(checkBoxx,threeInputs){
		var campo1 = document.getElementById("password");
		var campo2 = document.getElementById("password2");
		
			if(threeInputs != undefined) var campo3 = document.getElementById("oldpassword");
		
		(checkBoxx.checked) ? tipo = "text" : tipo = "password";
		var newNode1 = document.createElement("input");
		newNode1.setAttribute('name', 'password');
		newNode1.setAttribute('id', 'password');
		newNode1.setAttribute('type', tipo);
		newNode1.setAttribute('value', campo1.value);
		campo1.parentNode.replaceChild(newNode1,campo1);
		
		var newNode2 = document.createElement("input");
		newNode2.setAttribute('name', 'password2');
		newNode2.setAttribute('id', 'password2');
		newNode2.setAttribute('type', tipo);
		newNode2.setAttribute('value', campo2.value);
		campo2.parentNode.replaceChild(newNode2,campo2);
		
			if(threeInputs != undefined){
				var newNode3 = document.createElement("input");
				newNode3.setAttribute('name', 'oldpassword');
				newNode3.setAttribute('id', 'oldpassword');
				newNode3.setAttribute('type', tipo);
				newNode3.setAttribute('value', campo3.value);
				campo3.parentNode.replaceChild(newNode3,campo3);
			}
	}
	function _getElementById(idElemento,target){
		var elemento;
		
		if(target == undefined){
		
			if(document.getElementById){
				elemento = document.getElementById(idElemento);
			}else{
				elemento = document.all[idElemento];
			}
			
		}else{
			eval("var target = "+target);
			if(document.getElementById){
				elemento = target.document.getElementById(idElemento);
			}else{
				elemento = target.document.all[idElemento];
			}
		
		}
		return elemento;
	}
	
	function disableEnable(idElemento,target){
		if(_getElementById(idElemento,target)){
			if(_getElementById(idElemento,target).disabled == true){
				_getElementById(idElemento,target).disabled = false;
			}else{
				_getElementById(idElemento,target).disabled = true;
			}
		}
	}
	function disabilita(id){
			if(id == undefined) id = "submit";
		document.getElementById(id).disabled = "disabled";
	}

	function addEvList(type,listener,el){
			if(!el) el = document;
			if(el.addEventListener){
				/*MOZILLA -  se "true" tutti gli eventi del tipo specificato saranno gestiti dal listener indicato prima di venir iniviati agli elementi nella gerarchia del DOM*/
				el.addEventListener(type, listener, true); 
				return true;
			}else if(el.attachEvent){
				/*IE*/
				return el.attachEvent("on"+type, listener);
			}
	}
	
	function keyPress(numEv,func,e){
		var keycode;
			if(window.event){
				keycode = window.event.keyCode;
			}else if(e){
				keycode = e.which;
			}else{
				return true;
			}
			if(keycode == numEv){
					if(typeof(func) === "function") func.call(this,e);
					//if(window.event) event.keyCode = 0;
				return false;
			}
			
		return true;
	}
	
	function stopEvent(e){
		if(window.event){
			event.cancelBubble = true;
			event.returnValue  = false;
			event.keyCode      = 0;
			return false;
		}else if(e){
			e.stopPropagation();
			e.preventDefault();
		}else{
			return false;
		}
	}
	
	function onRightClick(funcOn,funcOff){
			if(typeof(funcOn) === "function"){
				addEvList("contextmenu",funcOn);
					if(typeof(funcOff) === "function") addEvList("click",funcOff);
			}
		addEvList("contextmenu",stopEvent);
	}
	
	function getSelectedText(){
			if(window.getSelection){
				txt = window.getSelection();
			}else if(document.getSelection){
				txt = document.getSelection();
			}else if(document.selection){
				txt = document.selection.createRange().text;
			}else{
				return;
			}
		return txt;
	}
	
	function addLoadEvent(func){
		var oldOnLoad = window.onload;
			if (typeof window.onload != 'function') {
				window.onload = func;
			}else{
				window.onload = function(){
								if (oldOnLoad){
									oldOnLoad();
								}
							func();
											};
			}
	}
	function addUnloadEvent(func){
		var oldOnUnload = window.onunload;
			if (typeof window.onunload != 'function') {
				window.onunload = func;
			}else{
				window.onunload = function(){
								if (oldOnUnload){
									oldOnUnload();
								}
							func();
											};
			}
	}

	function addResizeEvent(func){
		var oldOnResize = window.onresize;
			if (typeof window.onresize != 'function') {
				window.onresize = func;
			}else{
				window.onresize = function(){
								if (oldOnResize){
									oldOnResize();
								}
							func();
											};
			}
			
	}

/*
addLoadEvent(nameOfSomeFunctionToRunOnPageLoad);
addLoadEvent(function() {
  codice qui 
});
*/
	function getRadioCheckedValue(radioObj){	
		for(var i = 0; i < radioObj.length; i++){
			if(radioObj[i].checked) return radioObj[i].value;
		}
	}
	
	function menu_popup(link){
		var lar  = 900;
		var alt  = 600;
		var prop = 'height='+alt+',width='+lar+',top='+parseInt((screen.availHeight-alt)/2)+',left='+parseInt((screen.availWidth-lar)/2)+',scrollbars=yes,resizable=yes,toolbar=no,menubar=no,location=no,status=no';
		window.open(link,"_from_menu",prop);
	}

	/*function xmlhttpInstance(){
		var xmlhttp = null;
			if(window.XMLHttpRequest){// Mozilla, Safari, ...
				xmlhttp = new XMLHttpRequest();
					if(xmlhttp.overrideMimeType){
						xmlhttp.overrideMimeType('text/xml');
					}
			}else if(window.ActiveXObject){// IE
					try{
						xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
					}catch (e){
						try{
							xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
						}catch (e){
							alert("Errore: Impossibile creare l'istanza XMLHTTP!");
						}
					}
			}
		return xmlhttp;
	}
	
	function ajaxDo(url,funzioneDone,div,funzioneLoaded,asynchronous,method){

		var readyState = {
			INATTIVO:	0,
			INIZIALIZZATO:	1,
			RICHIESTA:	2,
			RISPOSTA:	3,
			COMPLETATO:	4
		};

		var statusText = new Array();
		statusText[100] = "Continue";
		statusText[101] = "Switching Protocols";
		statusText[200] = "OK";
		statusText[201] = "Created";
		statusText[202] = "Accepted";
		statusText[203] = "Non-Authoritative Information";
		statusText[204] = "No Content";
		statusText[205] = "Reset Content";
		statusText[206] = "Partial Content";
		statusText[300] = "Multiple Choices";
		statusText[301] = "Moved Permanently";
		statusText[302] = "Found";
		statusText[303] = "See Other";
		statusText[304] = "Not Modified";
		statusText[305] = "Use Proxy";
		statusText[306] = "(unused, but reserved)";
		statusText[307] = "Temporary Redirect";
		statusText[400] = "Bad Request";
		statusText[401] = "Unauthorized";
		statusText[402] = "Payment Required";
		statusText[403] = "Forbidden";
		statusText[404] = "Not Found";
		statusText[405] = "Method Not Allowed";
		statusText[406] = "Not Acceptable";
		statusText[407] = "Proxy Authentication Required";
		statusText[408] = "Request Timeout";
		statusText[409] = "Conflict";
		statusText[410] = "Gone";
		statusText[411] = "Length Required";
		statusText[412] = "Precondition Failed";
		statusText[413] = "Request Entity Too Large";
		statusText[414] = "Request-URI Too Long";
		statusText[415] = "Unsupported Media Type";
		statusText[416] = "Requested Range Not Satisfiable";
		statusText[417] = "Expectation Failed";
		statusText[500] = "Internal Server Error";
		statusText[501] = "Not Implemented";
		statusText[502] = "Bad Gateway";
		statusText[503] = "Service Unavailable";
		statusText[504] = "Gateway Timeout";
		statusText[505] = "HTTP Version Not Supported";
		statusText[509] = "Bandwidth Limit Exceeded";
		
		var 			
			appendRandom      = true,
			appendRandomValue = "ajaxRnd",
			massimaAttesa     = 5;
		
		var 
			useDegradableHref  = true,
			xmlhttp            = xmlhttpInstance();
		
			if(!xmlhttp){
					if(typeof(funzioneLoaded) === "function") funzioneLoaded.call(this);
				return useDegradableHref;
			}
			
		var
			useDegradableHref = false,
			parameters        = null,
			getMethod         = "get",
			postMethod   	  = "post",	
			urlParam          = url.split("?"),
			url               = urlParam[0],
			dataChiamata      = new Date(),
			inizioChiamata    = dataChiamata.getTime(),
			verificaTempoTrascorso,
			bugLoading;

			if(asynchronous == undefined) asynchronous = true;
			if(method == undefined)       method       = getMethod;
			
			if(method == getMethod){
				if(urlParam[1] != undefined){
					url = url+"?"+urlParam[1];
				}
				
				if(appendRandom){
					if(urlParam[1] != undefined){
						url = url+"&"+appendRandomValue+"="+Math.random();
					}else{
						url = url+"?"+appendRandomValue+"="+Math.random();
					}
				}
			}
			
			
			if(method == postMethod){
				if(urlParam[1] != undefined){
					parameters = urlParam[1];
				}
				
				if(appendRandom){
					if(urlParam[1] != undefined){
						parameters = parameters+"&"+appendRandomValue+"="+Math.random();
					}else{
						parameters = appendRandomValue+"="+Math.random();
					}
				}
				
			}

		//bugLoading = window.setTimeout(function(){
								xmlhttp.open(method, url, asynchronous);
								xmlhttp.setRequestHeader("connection", "close");
									
									if(method == postMethod) xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
									
									if(asynchronous) xmlhttp.onreadystatechange = function(){
																						if(xmlhttp.readyState === readyState.COMPLETATO){
																							verificaTempoTrascorso = function(){};
																								if(statusText[xmlhttp.status] === "OK" || statusText[xmlhttp.status] === "Not Modified"){
																										if(typeof(funzioneDone) === "function")   funzioneDone.call(this, xmlhttp.responseText, div);
																										if(typeof(funzioneLoaded) === "function") funzioneLoaded.call(this);
																								}else{
																									alert("Errore:\n" + xmlhttp.statusText);
																										if(typeof(funzioneLoaded) === "function") funzioneLoaded.call(this);
																								}
																						}else if(massimaAttesa < 1000){
																							massimaAttesa          = massimaAttesa * 1000;
																							verificaTempoTrascorso = function(){
																														dataChiamata = new Date();
																															if((dataChiamata.getTime() - inizioChiamata) > massimaAttesa){
																																xmlhttp.onreadystatechange = function(){return;};
																																xmlhttp.abort();
																																alert("Spiacente, richiesta fallita.\nLa prego di ritentare tra qualche istante.");
																																	if(typeof(funzioneLoaded) === "function") funzioneLoaded.call(this);
																															}else{
																																setTimeout(verificaTempoTrascorso, 100);
																															}
																														};
																							verificaTempoTrascorso();
																						}
																							
																					};

																																				
									try{
										xmlhttp.send(parameters);
											if(!asynchronous){
												if(typeof(funzioneDone) === "function")   funzioneDone.call(this, xmlhttp.responseText, div);
												if(typeof(funzioneLoaded) === "function") funzioneLoaded.call(this);
											}
									}catch (e){
										xmlhttp.abort();
										alert("Spiacente, richiesta fallita.\nLa prego di ritentare tra qualche istante.");
											if(typeof(funzioneLoaded) === "function") funzioneLoaded.call(this);
									}
									
									//window.clearTimeout(bugLoading);
			
							//},1);
									
		return useDegradableHref;		
	}*/
	
function xmlhttpInstance(){
	var xmlhttp = false;
		if(window.XMLHttpRequest){// Mozilla, Safari, ...
			xmlhttp = new XMLHttpRequest();
				if(xmlhttp.overrideMimeType){
					xmlhttp.overrideMimeType('text/xml');
				}
		}else if(window.ActiveXObject){// IE
				try{
					xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
				}catch (e){
					try{
						xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
					}catch (e){
						alert("Errore: Impossibile creare l'istanza XMLHTTP!");
					}
				}
		}
	return xmlhttp;
}


/*function ajaxDo(url,funzione_e_div,asynchronous,method){
	getMethod  = "get";
	postMethod = "post";
	paramSplitter = funzione_e_div.split("|");
	funzione      = eval(paramSplitter[0]);
	div           = paramSplitter[1];
		if(asynchronous == undefined) asynchronous = true;
		if(method == undefined)       method       = getMethod;
	parameters = null;
		if(method == postMethod){
			parameters = "parametri qui";
		}
	xmlhttp = xmlhttpInstance();
		if(!xmlhttp) return;
		if(asynchronous) xmlhttp.onreadystatechange = function(){
																	if(xmlhttp.readyState == 4){
																		if(xmlhttp.status == 200 || xmlhttp.status == 304){
																			funzione.call(this, xmlhttp.responseText, div);
																		}else{
																			alert("Errore:\n" + xmlhttp.statusText);
																		}
																	}
																};
																
		xmlhttp.open(method, url, asynchronous);

		//if(method == postMethod) xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded; text/html; charset=iso-8859-1");
		if(method == postMethod) xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		
		try{
			xmlhttp.send(parameters);
		}catch (e){
			alert("Impossibile comunicare con il server!");
		}
		
		if(!asynchronous) funzione.call(this, xmlhttp.responseText, div);
}*/

	function ajaxDo(url,funzioneDone,div,funzioneLoaded,asynchronous,method){

		var readyState = {
			INATTIVO:	0,
			INIZIALIZZATO:	1,
			RICHIESTA:	2,
			RISPOSTA:	3,
			COMPLETATO:	4
		};

		var statusText = new Array();
		statusText[100] = "Continue";
		statusText[101] = "Switching Protocols";
		statusText[200] = "OK";
		statusText[201] = "Created";
		statusText[202] = "Accepted";
		statusText[203] = "Non-Authoritative Information";
		statusText[204] = "No Content";
		statusText[205] = "Reset Content";
		statusText[206] = "Partial Content";
		statusText[300] = "Multiple Choices";
		statusText[301] = "Moved Permanently";
		statusText[302] = "Found";
		statusText[303] = "See Other";
		statusText[304] = "Not Modified";
		statusText[305] = "Use Proxy";
		statusText[306] = "(unused, but reserved)";
		statusText[307] = "Temporary Redirect";
		statusText[400] = "Bad Request";
		statusText[401] = "Unauthorized";
		statusText[402] = "Payment Required";
		statusText[403] = "Forbidden";
		statusText[404] = "Not Found";
		statusText[405] = "Method Not Allowed";
		statusText[406] = "Not Acceptable";
		statusText[407] = "Proxy Authentication Required";
		statusText[408] = "Request Timeout";
		statusText[409] = "Conflict";
		statusText[410] = "Gone";
		statusText[411] = "Length Required";
		statusText[412] = "Precondition Failed";
		statusText[413] = "Request Entity Too Large";
		statusText[414] = "Request-URI Too Long";
		statusText[415] = "Unsupported Media Type";
		statusText[416] = "Requested Range Not Satisfiable";
		statusText[417] = "Expectation Failed";
		statusText[500] = "Internal Server Error";
		statusText[501] = "Not Implemented";
		statusText[502] = "Bad Gateway";
		statusText[503] = "Service Unavailable";
		statusText[504] = "Gateway Timeout";
		statusText[505] = "HTTP Version Not Supported";
		statusText[509] = "Bandwidth Limit Exceeded";
		
		var 			
			appendRandom      = true,
			appendRandomValue = "ajaxRnd",
			massimaAttesa     = 5;
		
		var 
			useDegradableHref  = true,
			xmlhttp            = xmlhttpInstance();
		
			if(!xmlhttp){
					if(typeof(funzioneLoaded) === "function") funzioneLoaded.call(this);
				return useDegradableHref;
			}
			
		var
			useDegradableHref = false,
			parameters        = null,
			getMethod         = "get",
			postMethod   	  = "post",	
			urlParam          = url.split("?"),
			url               = urlParam[0],
			dataChiamata      = new Date(),
			inizioChiamata    = dataChiamata.getTime(),
			verificaTempoTrascorso,
			bugLoading;

			if(asynchronous == undefined) asynchronous = true;
			if(method == undefined)       method       = getMethod;
			
			if(method == getMethod){
				if(urlParam[1] != undefined){
					url = url+"?"+urlParam[1];
				}
				
				if(appendRandom){
					if(urlParam[1] != undefined){
						url = url+"&"+appendRandomValue+"="+Math.random();
					}else{
						url = url+"?"+appendRandomValue+"="+Math.random();
					}
				}
			}
			
			
			if(method == postMethod){
				if(urlParam[1] != undefined){
					parameters = urlParam[1];
				}
				
				if(appendRandom){
					if(urlParam[1] != undefined){
						parameters = parameters+"&"+appendRandomValue+"="+Math.random();
					}else{
						parameters = appendRandomValue+"="+Math.random();
					}
				}
				
			}

		/*bugLoading = window.setTimeout(function(){*/
								xmlhttp.open(method, url, asynchronous);
								xmlhttp.setRequestHeader("connection", "close");
									
									if(method == postMethod) xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
									
									if(asynchronous) xmlhttp.onreadystatechange = function(){
																						if(xmlhttp.readyState === readyState.COMPLETATO){
																							verificaTempoTrascorso = function(){};
																								if(statusText[xmlhttp.status] === "OK" || statusText[xmlhttp.status] === "Not Modified"){
																										if(typeof(funzioneDone) === "function")   funzioneDone.call(this, xmlhttp.responseText, div);
																										if(typeof(funzioneLoaded) === "function") funzioneLoaded.call(this);
																								}else{
																									alert("Errore:\n" + xmlhttp.statusText);
																										if(typeof(funzioneLoaded) === "function") funzioneLoaded.call(this);
																								}
																						}else if(massimaAttesa < 1000){
																							massimaAttesa          = massimaAttesa * 1000;
																							verificaTempoTrascorso = function(){
																														dataChiamata = new Date();
																															if((dataChiamata.getTime() - inizioChiamata) > massimaAttesa){
																																xmlhttp.onreadystatechange = function(){return;};
																																xmlhttp.abort();
																																alert("Spiacente, richiesta fallita.\nLa prego di ritentare tra qualche istante.");
																																	if(typeof(funzioneLoaded) === "function") funzioneLoaded.call(this);
																															}else{
																																setTimeout(verificaTempoTrascorso, 100);
																															}
																														};
																							verificaTempoTrascorso();
																						}
																							
																					};

																																				
									try{
										xmlhttp.send(parameters);
											if(!asynchronous){
												if(typeof(funzioneDone) === "function")   funzioneDone.call(this, xmlhttp.responseText, div);
												if(typeof(funzioneLoaded) === "function") funzioneLoaded.call(this);
											}
									}catch (e){
										xmlhttp.abort();
										alert("Spiacente, richiesta fallita.\nLa prego di ritentare tra qualche istante.");
											if(typeof(funzioneLoaded) === "function") funzioneLoaded.call(this);
									}
									
									/*window.clearTimeout(bugLoading);
			
							},1);*/
									
		return useDegradableHref;		
	}
	
	
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);
  }
}


/*
<div style="border: 1px solid green;"
     onmouseover="if (checkMouseEnter(this, event)) {
                    window.status = event.type;
                  }"
     onmouseout="if (checkMouseLeave(this, event)) {
                   window.status = event.type;
                 }">


*/