        $(document).ready(function() {

			// HEADER MENU
			var i = 0;
			var header_menu = "";
			$("#header > ul > li").each(function() {
				if (i!=0) header_menu += "|";
				header_menu += $(this).html();
				i++;
			});
			
			$("#header").html(header_menu);


			// MENU ORIZZONTALE E LATERALE + ACCORDION
			i = 0;
			$(".nav_h").append("<ul></ul>");
			$(".nav_v").append("<ul class=\"father\"></ul>");

			$("#nav > ul > li").each(function() {
				if (i<3)
					$(this).appendTo(".nav_h ul");
					else
					$(this).appendTo(".nav_v ul.father");
				i++;
			});
			
			$(".nav_h li:last").css("background","none");
			
			$(".acc").click(function(e) {
				e.preventDefault();
				if (!$(this).hasClass("selacc")) {
					$(".selacc").removeClass("selacc");
					$("ul.child").slideUp();
					$(this).addClass("selacc");
					$(this).next("ul").slideDown();
				}
			});
			
			$(".acc").each(function() {
				if ($(this).hasClass("sel")) {
					$(this).addClass("selacc");
					$(this).next("ul").show();
				}
			});
			
	
			// FOOTER 
			i = 0;
			var footer_menu = "";
			$("#footer > ul > li").each(function() {
				if (i!=0) footer_menu += "|";
				footer_menu += $(this).html();
				i++;
			});
			
			var footer_p = $("#footer p").html();
			$("#footer").empty();
			$("#footer").append("<div class=\"left\"><p></p></div><div class=\"right\"></div>");
			
			$("#footer .left p").html(footer_p);
			$("#footer .right").html(footer_menu);
			
			$("#footer").before("<div style=\"clear: both;\"></div>");
						
		});
		
		function hide_ul() {
			$("li.l1").show().removeClass("l1_sel");
			$("li.l1 > ul.l2").hide();
			$("li.l2").show().removeClass("l2_sel");
			$("li.l2 > ul.l3").hide();
			$("li.l3").show();

		}
		
		function parify_heights() {
//			$("#sidebar").height("");
//			$("#content").height("");
			var box_primopiano_height = $("#box_primopiano").height();
			var location_height = 0;
			
			$("ul.l2").each(function() {
				if (($(this).find("li").size()*25)>location_height) location_height = $(this).find("li").size()*25;
			});
			
			var box_richieste_height = $("#box_richieste").height();
			var collezione_toolbar_height = $("#collezione_toolbar").height();
			
			if (location_height<180) location_height = 180;
			$(".panel").height(location_height);
			
//			alert(location_height);
			var ricerca_height = location_height
//			alert(ricerca_height);

			if (box_primopiano_height>ricerca_height) {
				if (box_primopiano_height<215) box_primopiano_height = 215;
				$("#ricerca").height(box_primopiano_height);
				$("#box_primopiano").height(box_primopiano_height);
			} else {
				if (ricerca_height<215) ricerca_height = 215;
				$("#box_primopiano").height(ricerca_height);
				$("#ricerca").height(ricerca_height);
			}

			if (box_richieste_height>collezione_toolbar_height) {
				$("#collezione_toolbar").height(box_richieste_height);
				$("#box_richieste").height(box_richieste_height);
			} else {
				$("#box_richieste").height(collezione_toolbar_height);
				$("#collezione_toolbar").height(collezione_toolbar_height);
			}

		}

		function indirizzoEmailValido(indirizzo) {
			if (window.RegExp) { 
				var nonvalido = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
				var valido = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$";
				var regnv = new RegExp(nonvalido);
				var regv = new RegExp(valido);
					
					if (!regnv.test(indirizzo) && regv.test(indirizzo)) return true;
		
				return false;
		
			} else {
		
				if(indirizzo.indexOf("@") >= 0) return true;
		
				return false;
		
			}
		}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
