// JavaScript Document

function centra() {
	var centro = (document.body.clientWidth - document.getElementById("pg").offsetWidth) / 2;
	var pgHeight = document.getElementById("pg").offsetHeight > document.body.clientHeight ? document.getElementById("pg").offsetHeight : document.body.clientHeight;
	document.getElementById("bg").style.height = pgHeight + "px";
	document.getElementById("pg").style.left = centro + "px";
	document.getElementById("bg").style.left = centro + "px";
}

function mostraPagina() {
	document.getElementById("pg").style.visibility = "visible";
	document.getElementById("ldr").style.display = "none";
}

function ridimensiona_videoBox(id, lrg, alt, mrg) {
	if (obj = document.getElementById('videoBox' + id)) {
		if (lrg > 0) { obj.style.width = lrg + "px"; }
		if (alt > 0) { 
			obj.style.height = (alt + mrg) + "px"; 
			obj.style.marginBottom = (-mrg) + "px";
			if (obj1 = document.getElementById('cntVideoBox' + id)) { obj1.style.zIndex = "0"; }
		}
	}
}

function primoPiano_videoBox(id, zindex) {
	if (obj1 = document.getElementById('cntVideoBox' + id)) { 
		obj1.style.zIndex = zindex; 
	}
}


function caricaTV(id, tt, l, a, sc, sb, as, sd, ar, wl, fs) {
	if (sc == 'true') { a += 25; }
	if (sb == 'true') { a += 25; }
	//document.write ('<object classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" type="application/x-oleobject" width="' + l + '" height="' + a + '" id="' + id + '" title="' + tt + '">');
	document.write ('<object classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" type="application/x-mplayer2" width="' + l + '" height="' + a + '" id="' + id + '" title="' + tt + '">');
	document.write ('	<param name="AutoStart" value="' + as + '">');
	document.write ('	<param name="ShowControls" value="' + sc + '">');
	document.write ('	<param name="ShowStatusBar" value="' + sb + '">');
	document.write ('	<param name="ShowDisplay" value="' + sd + '">');
	document.write ('	<param name="AutoRewind" value="' + ar + '">');
	document.write ('	<param name="windowlessVideo" value="' + wl + '">');
	document.write ('	<param name="SendPlayStateChangeEvents" value="true">');
	document.write ('	<param name="stretchToFit" value="false">');
	document.write ('	<param name="FullScreen" value="' + fs + '">');
	document.write ('	<embed ');
	document.write ('		type="application/x-mplayer2" ');
	document.write ('		pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/MediaPlayer/" ');
	document.write ('		width="' + l + '" height="' + a + '" ');
	document.write ('		autostart="' + as + '" ');
	document.write ('		showcontrols="' + sc + '" ');
	document.write ('		showstatusbar="' + sb + '" ');
	document.write ('		showdisplay="' + sd + '" ');
	document.write ('		autorewind="' + ar + '" ');
	document.write ('		windowlessVideo="' + wl + '" ');
	document.write ('		fullScreen="' + fs + '" ');
	document.write ('		SendPlayStateChangeEvents="true" ');
	document.write ('		stretchToFit="false">');
	document.write ('	</embed>');
	document.write ('</object>');
}

function caricaVideo (id, titolo) {
	TVmon = document.getElementById(id);
	mtdT="";
	for (mtd in TVmon) { 
		mtdT = mtdT + ", " + mtd 
	}
	//alert (mtdT);
	TVmon.URL= titolo;
	TVmon.start();
	//TVmon.play(); 
}

function videoNewsPlay(idBoxTV, idTV, idImg, idBtPlay, titolo) {
	BoxTV = document.getElementById(idBoxTV);
	Img = document.getElementById(idImg);
	btnPlay = document.getElementById(idBtPlay);
	BoxTV.style.visibility = "visible";
	Img.style.visibility = "hidden";
	btnPlay.style.visibility = "hidden";
	caricaVideo(idTV, titolo);	
}
