var tvId="tv"; 
var tvWidth=720; 
var tvHeight=494+90; 
var firstShow=true; 
var tvVisible=false;

function getAvailableWidth(){
	var calcWidth=0;
	if(window.innerWidth)calcWidth=window.innerWidth;
	else calcWidth=(document.compatMode=='CSS1Compat'?document.documentElement.clientWidth:document.body.clientWidth);
	return calcWidth;
}
function getAvailableHeight(){
	var calcHeight=0;
	if(window.innerHeight) calcHeight=window.innerHeight;
	else calcHeight=(document.compatMode=='CSS1Compat'?document.documentElement.clientHeight:document.body.clientHeight);
	return calcHeight;
}
function toggleTv(){
	if(firstShow){
		var style=document.getElementById(tvId).style;
		style.left=Math.round((getAvailableWidth()-tvWidth)/2)+"px";
		style.top=Math.round((getAvailableHeight()-tvHeight)/2)+"px";
		firstShow=false;
	}
	if(tvVisible){
		document.getElementById('tv').style.display='none';
		tvVisible=false;
	}
	else{
		var style=document.getElementById('tv').style;
		style.left=Math.round((getAvailableWidth()-tvWidth)/2)+"px";
		style.top=Math.round((getAvailableHeight()-tvHeight)/2)+"px";
		style.display='block';
		tvVisible=true;
	}
}
function initTv(){
	var element=document.getElementById(tvId);
	if(element==null) return;
	var style=element.style;
	if(style==null) return;
	style.visibility="visible";
	style.position="absolute";
	style.width=tvWidth+"px";
	style.height=tvHeight+"px";
}
function loadTv(){
	toggleTv();
}
