function writeFlash(p) {
	var w = parseInt(p['width']);
	var h = parseInt(p['height']);
	var b = p['base'];
	var qp=false;
	var s1 = new SWFObject(p['src'],"single",w,h,"7");
//	for (n in p)
//		s1.addParam(n,n[p]);
	s1.addVariable("width",w);
	s1.addVariable("height",h);
	s1.addParam("wmode","opaque");
	if(b) s1.addParam('base',b);
	if(p['flashvars']) {
		qp = p['flashvars'].toQueryParams('&amp;');
		if(qp['streamName']) {
			s1.addParam("allowfullscreen","true");
			s1.addVariable("file",qp['streamName']+'.flv');
			s1.addVariable("image",qp['preview']);
		} else {
			alert('No flash video specified');	
		}
	}
	document.write(s1.getSWFHTML());
}

function writeShockWave(p) {
	writeEmbed(
	'166B1BCA-3F9C-11CF-8075-444553540000',
	'http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,1,0',
	'application/x-director',
		p
	);
}

function writeQuickTime(p) {
	writeEmbed(
		'02BF25D5-8C17-4B23-BC80-D3488ABDDC6B',
		'http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0',
		'video/quicktime',
		p
	);
}

function writeRealMedia(p) {
	writeEmbed(
		'CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA',
		'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0',
		'audio/x-pn-realaudio-plugin',
		p
	);
}

function writeWindowsMedia(p) {
	p.url = p.src;
	writeEmbed(
		'6BF52A52-394A-11D3-B153-00C04F79FAA6',
		'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701',
		'application/x-mplayer2',
		p
	);
}

function writeEmbed(cls, cb, mt, p) {
	var h = '', n;

	h += '<object classid="clsid:' + cls + '" codebase="' + cb + '"';
	h += typeof(p.id) != "undefined" ? 'id="' + p.id + '"' : '';
	h += typeof(p.name) != "undefined" ? 'name="' + p.name + '"' : '';
	h += typeof(p.width) != "undefined" ? 'width="' + p.width + '"' : '';
	h += typeof(p.height) != "undefined" ? 'height="' + p.height + '"' : '';
	h += typeof(p.align) != "undefined" ? 'align="' + p.align + '"' : '';
	h += '>';

	for (n in p)
		h += '<param name="' + n + '" value="' + p[n] + '">';

	h += '<embed type="' + mt + '"';

	for (n in p)
		h += n + '="' + p[n] + '" ';

	h += '></embed></object>';

	document.write(h);
}

// attiva mainMenu per Internet Explorer **************************
function startList() {
	if (document.all&&document.getElementById) {
		var mm = $("mainMenu");
		if(mm) {
			navRoot = mm.select(".voce");
			for (i=0; i<navRoot.length; i++) {
				node = navRoot[i];
				node.onmouseover=function() {
					this.className+=" over";
				};
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				};
			}
		}
	}
};
// ********************************************* //


function gestImg() {
	voci = $$("#mainMenu .voce");
	for(i=0; i<voci.length; i++) {
		voce = voci[i];
		voce.observe('mouseover', changeImg);
		voce.observe('mouseout', restoreImg);
	}
}

function changeImg(event) {
	element = Event.element(event);
	while(!element.hasClassName('voce')) {
		element = element.ancestors()[0];
	}
	
	img = $('i' + $(element).id);
	src = img.src.replace('n.gif','o.gif');
	img.src = src;
}

function restoreImg(event) {
	element = Event.element(event);
	while(!element.hasClassName('voce')) {
		element = element.ancestors()[0];
	}
	
	img = $('i' + $(element).id);
	src = img.src.replace('o.gif','n.gif');
	img.src = src;
}

function chiudiBanner() {
	$('banner').hide();
}

Event.observe(window, 'load', startList);
Event.observe(window, 'load', gestImg);