// javascript per il menu espandibile con massimo un livello aperto
var prev="null";
var isIE = (document.all) ? true : false;

window.onload = function() {
	if(document.getElementsByTagName && document.getElementById) {
		buildList();
		openBlank();
		//tagboard();
		var myFlashObject = new FlashObject("graphics/movie.swf", "movie", "116", "87", 6, "#224466");
		myFlashObject.write("vflash");
		document.getElementById("nbBody").className = "jsenable";
		document.getElementById("jsMessage").style.display = "none";
    }
}

function buildList() {
	var hs = document.getElementById("nbBody").getElementsByTagName("h3");
	for(var i = 0; i < hs.length; i++) {
		hs[i].onclick = function() {
			if(this.parentNode.className != "show") {
				this.parentNode.className = "show";
				if(prev && prev != this.parentNode) prev.className = "hide";
				prev = this.parentNode;
			}
			else {
				this.parentNode.className = "hide";
			}
		}
		if(isIE) {
			hs[i].onmouseover = function() {
				this.className = "hover";
			}
			hs[i].onmouseout = function() {
				this.className = "";
			}
		}
	}
}

function openBlank() {
	var links = document.getElementsByTagName("a");
	for(var i = 0; i < links.length; i++) {
		if(links[i].className == "target-blank") {
			//links[i].title = "Link esterno, si apre in una nuova finestra";
			links[i].onclick = function() { window.open(this.href); return(false) };
		}
	}
}

function tagboard() {
	var tb = document.getElementById("tagboard");
	if(tb == null) { return false; }
	var tbh3 = tb.getElementsByTagName("h4");
	tbh3[0].parentNode.className = "hide";
	tbh3[0].firstChild.nodeValue = "Show Smart-Tag Board!";

	tbh3[0].onclick = function() {
		if(this.parentNode.className != "show") {
			this.parentNode.className = "show";
			this.firstChild.nodeValue = "Hide Smart-Tag Board!";
		}
		else {
			this.parentNode.className = "hide";
			this.firstChild.nodeValue = "Show Smart-Tag Board!";
		}
	}
}


function add2bookmark() {
	var url = document.location;
	var title = document.title;

	if (document.all) {
		window.external.AddFavorite(url, title);
	}
	else if (window.sidebar) {
		window.sidebar.addPanel(title, url, "")
	}
}

function setAsHomepage(obj) {
	if(isIE) {
		var url = document.location;
		obj.style.behavior = "url('#default#homepage')";
		obj.setHomePage(url);
	}
	else {
		alert("Sorry! Script only for IE5+.");
	}
}

function pjircChat(path) {
	var w = 640;
	var h = 480;
	var l = Math.floor((screen.width-w)/2);
	var t = Math.floor((screen.height-h)/2);
	window.open(path,'_blank','top='+t+',left='+l+',width='+w+',height='+h+',status=no, menubar=no, toolbar=no, scrollbars=no');
}
