// JavaScript Document
function espandiMenu(idMenu){
	var ul = document.getElementById("Ul"+idMenu);
	var aImg = document.getElementById("Img"+idMenu);
	//alert(document.getElementById('menuCreato').clientHeight);
	if (ul.className == "ulMenuSecondoLiv"){
		ul.style.display = "block";
		ul.className = "ulMenuSecondoLivVisibile";
		aImg.className = "imgComprimiMenu";
		aImg.title = "Comprimi menu"
		
	} else {
		ul.style.display = "none";	
		ul.className = "ulMenuSecondoLiv";
		aImg.className = "imgEspandiMenu";
		aImg.title = "Espandi menu"
	}
}

function TargetBlank() { 
	if(document.getElementsByTagName){ 
		var msg = " (collegamento in nuova finestra)"; 
		var links = document.getElementsByTagName("a"); 
		for (i = 0; i < links.length; i++) { 
			var link = links[i]; 
			if (link.className.indexOf("targetblank") != -1){ 
				link.title += msg; 
				var fn = function () 
				{ window.open(this.href); return false; } 
				link.onclick = link.onkeypress = fn; 
			} 
		} 
	} 
}

window.onload = function() {TargetBlank();}



// FUNZIONI EREDITATE

    function popup_immagine(url) {
      new_window = window.open(url, "immagine", "resizable=yes, location=no, directories=no, status=no, menubar=no, scrollbars=yes, top=20, left=20, width=100, height=100");
//      new_window.document.open();
//      new_window.document.write("<html>\n");
//      new_window.document.write("<head>\n");
//      new_window.document.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n");
//      new_window.document.write("<title>24</title>\n");
//      new_window.document.write("</head>\n");
//      new_window.document.write("<body bgcolor=\"white\" leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\">\n");
//      new_window.document.write("<table id=\"table_image\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td>\n");
//      new_window.document.write("<img src='" + img + "' border=\"0\" name=\"Immagine\">\n");
//      new_window.document.write("<p style=\"text-align:justify; font-family:arial; font-size:8pt; padding-left:5px; padding-right:5px; margin-top:0px;\">" + title + "</p>\n");
//      new_window.document.write("</td></tr></table>\n"); 
//      new_window.document.write("</body>\n"); 
//      new_window.document.write("</html>\n");
//			new_window.document.close();
    }
// " + title + "    

    function resizeFinestra() {
			onerror = funzioneErrore;
			alert(new_window);
			alert(new_window.document);
			alert(new_window.document.images["Immagine"]);
			
      while (!new_window.document.images["Immagine"].complete) {}

      height_addon = 65;
      width_addon = 29;

      content_height = new_window.document.getElementById("table_image").clientHeight;
      content_width = new_window.document.images["Immagine"].width;

			if (content_height+100>window.screen.height) {
	      window_height = window.screen.height - 100;
			} else {
	      window_height = content_height + height_addon;
			}	

			if (content_width+100>window.screen.width) {
	      window_width = window.screen.width - 100;
			} else {
      	window_width = content_width + width_addon;
			}	
      
 			new_window.resizeTo(window_width, window_height);
   	}
   
  	function funzioneErrore() {
			// Se l'utente chiude la finestra prima che sia caricata completamente l'immagine
  	}
	
	function cambiaTesto(id, testo) {
		cerca = document.getElementById(id);
		if (cerca.value == testo) {
			cerca.value = "";
			cerca.focus();
		}
	}
	
	function ripristinaTesto(id, testo) {
		cerca = document.getElementById(id);
		if (cerca.value == "") {
			cerca.value = testo;
		}
	}
	
