var isBrowserBadIE = false;
var isBrowserIE = false;
if(navigator.appVersion.indexOf("MSIE")!=-1){
	var temp = navigator.appVersion.split("MSIE");
	temp = parseFloat(temp[1]);
	isBrowserBadIE = (temp <= 5.5 ? true : false);
	isBrowserIE = true;
}

function mbLoad(id, content, sel, add, extra) { // Caricamento del framework Menu
	if(add == 'undefined' || !add)
		add = '';
	if(extra == 'undefined' || !extra)
		extra = '';
	for(i=1; i<content.length; i++) {
		var dom = document.getElementById(id+content[i]).getElementsByTagName('a');
		document.getElementById(id+content[i]).onmouseover = Function('mbOver("'+id+'", '+content[i]+', "'+add+'", "'+extra+'")');
		document.getElementById(id+content[i]).title = dom[0].title;
		document.getElementById(id+content[i]).onclick = Function('mbClick("'+id+'", '+content[i]+')');
		document.getElementById(id+content[i]).onmouseout = Function('mbOut("'+id+'", '+content[i]+', "'+add+'", "'+extra+'")');
		// Aggiusto alcuni bugs CSS di IE
		if(id == 'ms' && isBrowserBadIE)
			document.getElementById(id+content[i]).style.width = '169px';
		else if(id == 'ms' && isBrowserIE)
			document.getElementById(id+content[i]).style.width = '143px';
	}
	if(sel != '') {
		// Aggiusto alcuni bugs CSS di IE
		if(id == 'ms' && isBrowserBadIE)
			document.getElementById(id+sel).style.width = '169px';
		else if(id == 'ms' && isBrowserIE)
			document.getElementById(id+sel).style.width = '143px';
	}
}

function mbOver(id, num, add, extra) { // Sono sopra all'oggetto
	document.getElementById(id+num).className = extra+'liOver';
	window.status = document.getElementById(id+num).getElementsByTagName('a')[0].href;
	// Aggiusto alcuni bugs CSS di IE
	if(isBrowserBadIE)
		document.getElementById(id+num).style.cursor = 'hand';
}

function mbOut(id, num, add, extra) { // Esco dall'oggetto
	document.getElementById(id+num).className = (add ? add+' ' : '')+extra+'liOut';
	window.status = '';
	// Aggiusto alcuni bugs CSS di IE
	if(isBrowserBadIE)
		document.getElementById(id+num).style.cursor = 'default';
}

function mbClick(id, num) { // Premo sull'oggetto
	var dom = document.getElementById(id+num).getElementsByTagName('a');
	if(!dom[0].onclick)
		window.location.href = dom[0].href;
}

function loadFlash(file, height, width) {
	// Cerco di superare i problemi tecnici con i flash in IE!!!
	document.write("<OBJECT CLASSID='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' WIDTH='"+width+"' HEIGHT='"+height+"' ");
	document.write("CODEBASE='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0'> ");
	document.write("<PARAM NAME='MOVIE'  VALUE='"+URL_TEMA_REMOTO+"/_flash/"+file+".swf'> ");
	document.write("<PARAM NAME='QUALITY' VALUE='high'> ");
	document.write("<param name='menu' value='false' /> ");
	document.write("<EMBED SRC='"+URL_TEMA_REMOTO+"/_flash/"+file+".swf' ");
	document.write("WIDTH='"+width+"' HEIGHT='"+height+"' QUALITY='high' menu='false' "); 
	document.write("PLUGINSPAGE='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'> ");
	document.write("</EMBED> </OBJECT> ");
}

function loadFlashShared(file, height, width) {
	// Cerco di superare i problemi tecnici con i flash in IE!!!
	document.write("<OBJECT CLASSID='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' WIDTH='"+width+"' HEIGHT='"+height+"' ");
	document.write("CODEBASE='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0'> ");
	document.write("<PARAM NAME='MOVIE'  VALUE='"+URL_LABEL_REMOTO+"/shared/"+file+"'> ");
	document.write("<PARAM NAME='QUALITY' VALUE='high'> ");
	document.write("<param name='menu' value='false' /> ");
	document.write("<EMBED SRC='"+URL_LABEL_REMOTO+"/shared/"+file+"' ");
	document.write("WIDTH='"+width+"' HEIGHT='"+height+"' QUALITY='high' menu='false' "); 
	document.write("PLUGINSPAGE='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'> ");
	document.write("</EMBED> </OBJECT> ");
}

function openDemo(tipo, connessione) {
	switch(connessione) {
		case 'modem':
			var h = 200;
			var w = 300;
			var res = 'no';
			break;
		default:
			var h = 600;
			var w = 800;
			var res = 'yes';
			break;
	}
	
	window.open('/demo.e4b?n='+tipo+'&t='+connessione+'&w='+w+'&h='+h, 'openDemo', 'width='+w+',height='+h+',resizable='+res+',fullscreen=no,menubar=no,toolbar=no,location=no,scrollbars=no,status=no');
}
