	// JavaScript Document
	function setHashCookie(sName, sValore, iGiorni) {
	  var dtOggi = new Date()
	  var dtExpires = new Date()
	  dtExpires.setTime
		(dtOggi.getTime() + 24 * iGiorni * 3600000)
	  document.cookie = sName + "=" + escape(sValore) +
		"; expires=" + dtExpires.toGMTString();
	}
	function getHashCookie(sName) {
	  // genera un array di coppie "Nome = Valore"
	  // NOTA: i cookies sono separati da ';'
	  var asCookies = document.cookie.split("; ");
	  // ciclo su tutti i cookies
	  for (var iCnt = 0; iCnt < asCookies.length; iCnt++)
	  {
		// leggo singolo cookie "Nome = Valore"
		var asCookie = asCookies[iCnt].split("=");
		if (sName == asCookie[0]) { 
		  return (unescape(asCookie[1]));
		}
	  }
	
	  // SE non esiste il cookie richiesto
	  return("");
	}
	function delHashCookie(sName) {
	  setHashCookie(sName, "");
	}

	function getRandomNumber(range){
		return Math.floor(Math.random() * range);
	}
	function getRandomChar(){
		var chars = "0123456789abcdefghijklmnopqurstuvwxyzABCDEFGHIJKLMNOPQURSTUVWXYZ";
		return chars.substr( getRandomNumber(62), 1 );
	}
	function randomID(size){
		var str = "";
		for(var i = 0; i < size; i++)
		{
			str += getRandomChar();
		}
		return str;
	}

	//Controlla Cookie Hash
	hash = getHashCookie("hashcookie");

	//Se non siste lo crea e lo imposta
	if (hash == ""){
		hash = randomID(70);
		setHashCookie("hashcookie",hash, 365)
	} else {
		hash = getHashCookie("hashcookie");
	}

	//Imposta codice hash nel campo nascosto
	if (document.getElementById("login_hash")) document.getElementById("login_hash").value = hash;

	//Imposta checkbox autologin in base a cookie
	if (document.getElementById("chb_autologin")){
		if (getHashCookie("AutoLogin") == "true") document.getElementById("chb_autologin").checked = true; 
		 else document.getElementById("chb_autologin").checked = false;
	}

	// Assegna funzione di attivazione e disattivazione checkbox autologin
	if (document.getElementById("chb_autologin")){
		document.getElementById("chb_autologin").onclick= function(){ 
			if (document.getElementById("chb_autologin").checked){
				setHashCookie("AutoLogin","true",365);
				//alert("Auto Login Attivato");
			} else {
				disableAutoLogin();
			}
		};
	}
	
	function disableAutoLogin()
	{
			setHashCookie("AutoLogin","false",365);
			if (document.getElementById("chb_autologin")) document.getElementById("chb_autologin").checked = false;
			//alert("Auto Login Sospeso");
	}
	function startAutoLogin()
	{
		if ( document.getElementById("chb_autologin") && 
			 document.getElementById("chb_autologin").checked) 
			{
				document.getElementById("azione_info").value = "auto_login";
				document.getElementById("LoginForm").submit();
			}
	}
	
	if (getHashCookie("AutoLogin") == "true")
	{
		setTimeout ("startAutoLogin()", 10 );
	}

	//alert(hash);


