// callHTML
	function callHTML ()
	{
		alert (document.getElementById('item1').innerHTML)
	}

// writeHTML
	function writeHTML ()
	{
		var el = document.getElementById('item1');
		el.innerHTML = "Nuovo contesto visualizzato nel DIV";
	}


// setInnerHTML
	function setInnerHTML(el, html, dontClear)
	{
		while (el.hasChildNodes() && !dontClear)
		{
			el.removeChild(el.firstChild)
		}
		
		var tagIdxStart = html.indexOf("<")
		var counterTagIdxStart = html.indexOf("</")
		var tagIdxEnd =  html.indexOf(">")
		
		if (tagIdxStart == -1)
		  {
		  	var txtNode = document.createTextNode (html)
		  	el.appendChild(txtNode)
		  }	
		  else if (counterTagIdxStart == tagIdxStart)
		  {
		  	setInnerHTML(el, html.substring(0, tagIdxStart), true)
		  	setInnerHTML(el.parentNode, html.substring(tagIdxEnd+1), true)
	  	  }
	  	  else
	  	  {
		  	setInnerHTML(el, html.substring(0, tagIdxStart), true)
	  	  	var tagName = html.substring(tagIdxStart+1,tagIdxEnd+1)
	  	  	var Node = document.createElement (tagName)
	  	  	el.appendChild(node)
	  	  	if (tagName == "BR" || tag =="HR")
	  	  		setInnerHTML(el, html.substring(tagIdxEnd+1),true)
	  	  		else
	  	  		setInnerHTML(node, html.substring(tagIdxEnd+1),true)
	  	  }
	}
// getInnerHTML
	function getInnerHTML(el){
		var s = ""
		if (el.hasChildNodes())
		{
			for (var i = 0; i < el.childNodes.lenght; i++)
			{
				if (el.childNodes[i].hasChildNodes())
				{
					var ns = getInnerHTML(el.childNodes[i])
					s += ("<"+el.childNodes[i].nodeName+">" + ns + "</"+ 
							el.childNodes[i].nodeName + ">")
				}
				if (el.childNodes[i].nodeName == "BR" || 
					el.childNodes[i].nodeName == "HR")
					s +="<" + el.childNodes[i].nodeName + ">" 
					s += (el.childNodes[i].nodeValue) ? el.childNodes[i].nodeValue : ""
			}
		}
		else
		{
			s += el.nodeValue 
		}
		return s
	}

// Gestione Menu
	function ContenutoFisso(elFromID, elToID){
		var to = document.getElementById(elToID)
		if (elFromID){
				var from = document.getElementById(elFromID);
				setInnerHTML(to, getInnerHTML(from));
		}
		else{
			setInnerHTML(to, '');
		}
	}

	function ContenutoVariabile(elID, isDisplayed){
		document.getElementById(elID).style.display = (isDisplayed) ? 'block' : 'none';
	}

	function tableEspandibile(whichTable, show){
		document.getElementById(whichTable).style.display = (show) ? 'block' : 'none';
	}
	

	function ContenutoTable(whichTable, show){
		var to = document.getElementById(whichTable).style.display = (show) ? 'block' : 'none';
		if (whichTable){
				var from = document.getElementById(whichTable);
				setInnerHTML(to, getInnerHTML(from));
		}
		else{
			setInnerHTML(to, '');
		}
	}

//  window predimensionate -->

// Apri Windows copyright
function finestra() {
	window.open("","copyright","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=290,height=280");
}
//

// Apri Windows Proponi Notizia 
function News() {
	window.open("","News","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=620,height=530");
}
//

// Apri Windows auguri
function auguri() {
	window.open("","auguri","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=480,height=280");
}
//

// Apri Windows OROSCOPO SEGNO
function segni(URL) {
newWindow = window.open(URL, "segni", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=490,height=280")
}


function closeWindow() {
newWindow.close()
}

// End window predimensionate -->

// Cambio Canale 
function channel () {
		document.location.href = document.myChannel.canali.options[document.myChannel.canali.selectedIndex].value;
}
// -->


// Sniffer identifica il Browser utilizzato
function clientSniffer ()
	{
		var agent = navigator.appName
		this.isIE = function()
		{
			return (agent == "Microsoft Internet Explorer" && document.all)
		}
		this.isNS = function () { return (agent == "Netscape") }
		this.getVersione = function ()
			{
			if (this.isNS()) return parseInt (navigator.appVersion)
			if (this.isIE())
				{
				var vIdx = navigator.appVersion.indexOf ("MSIE ") + ("MSIE ").length
				return parseInt (navigator.appVersion.substring(vIdx, vIdx+3))
				}
				return 0
			}
			this.isDOM = function()
				{
				return document.getElementById ? true : false
				}
	} 

// TIP Appunti a comparsa
var cs = new clientSniffer();
function displayTip (elID, show, evt, tiptext) 
	{
		if (cs.isDOM())
			{
				var popMenu= document.getElementById(elID)
				setInnerHTML (popMenu, tiptext)
				popMenu.style.left = (cs.isNS()) ? (evt.clientX +5) + "px": (event.clientX + 5) + "px"
				 popMenu.style.top = (cs.isNS()) ? (evt.clientX +5) + "px": (event.clientY + 5) + "px"
				 popMenu.style.visibility = "visible"
				 popMenu.style.visibility = (show) ? "visible" : "hidden"
			}
			else
			{
				var el= (cs.isNS()) ? document.layers[elID] : document.all[elID]
				if (cs.isNS()) 
					{
						with (el.document)
							{
								open ()
								write ("<table border=0><tr><td>")
								write (tiptext)
								write("</td></tr></table>")				
								close ()
							}
					}
				else
					{
						el.innerHTML = tiptext
					} 
				el.moveTo (evt.pageX + 10, evt.pageY + 10)
				el.visibility = (show) ? "show" : "hide"
			}
	}
// -->

function mostraLayer(myEvent)
	{
	myObj=document.getElementById(myEvent).style;
	myObj.left = myEvent.clientX + window.pageXOffset + "px";
	myObj.top  = myEvent.clientY + window.pageYOffset + "px";
	myObj.visibility = "visible";
	}

function chiudiLayer(myEvent)
	{
	myObj=document.getElementById(myEvent).style;
	myObj.visibility = "hidden";
	}
