var menu1=new Array(0,"Home","home16x16.png","index.htm",0,
1,"Products","download_16x16.png","products.htm",1,
0,"Forum","forum_16x16.png","forum.php5",0,
0,"Info","info_16x16.png","info.htm",0,
0,"Important message","white_16x16.png","important.htm",0);

var menu2=new Array(2,"TV's server","logo_16.png","server.php",0,
0,"TV's Media service","media_service_16x16.png","media_service.htm",0,
0,"TV's Switch desktop","switch_desktop_16x16.png","desktopswitch.htm",0,
0,"Rundll32 clone","rundll16.png","rundll32_clone.htm",0,
3,"TV's API search","api_16x16.png","api_index.htm",0,
0,"Oldies but goodies","oldies_16x16.png","",0);

var menu3=new Array(0,"Skins","white_16x16.png","server.php?page=skins",0,
0,"Information","white_16x16.png","server.php?page=info",0,
0,"Requirements","white_16x16.png","server.php?page=requirements",0,
0,"FAQ","white_16x16.png","server.php?page=faq",0,
0,"Change log","white_16x16.png","server.php?page=log",0,
0,"Add-in","white_16x16.png","server.php?page=addin",0);

var menu4=new Array(0,"DLL versions","white_16x16.png","versions.php5",0,
0,"Result","white_16x16.png","api_index.htm",0);


var menu=new Array();
menu[0]=menu1;
menu[1]=menu2;
menu[2]=menu3;
menu[3]=menu4;

var HideMenuval=0;

//document.writeln("<body bgcolor=\"darkgray\" link=\"black\" vLink=\"black\" aLink=\"black\" style=\"overflow:hidden\" onLoad=\"resize();\" onResize=\"resize();\">");
document.writeln("<body bgcolor=\"#004978\" text=\"#B8E5A8\" vlink=\"#B4B4B4\" alink=\"#FFFFFF\" link=\"#B8E5A8\" style=\"overflow:hidden\" onLoad=\"resize();\" onResize=\"resize();\">");

document.writeln("<div id=\"logo\" style=\"background-color: #006998; width: 100%; height:62px; top:0px; left:0px; POSITION: absolute;z-index: 3; overflow:hidden\"><img src=\"img/logo.png\"></div>");
document.writeln("<img id=\"pushbut\" src=\"img/but_upb.png\" onmouseout=\"this.src='img/but_upb.png'; RefreshImages();\" onmousemove=\"this.src='img/but_moveb.png'; RefreshImages();\" onmousedown=\"this.src='img/but_downb.png'; RefreshImages();\" onmouseup=\"this.src='img/but_upb.png'; RefreshImages(); ShowLeftBar(1);\" style=\"position: absolute;z-index: 1;\">");
document.writeln("<div id=\"left_menu\" style=\"background-color: #004978; top:62px; left:0px; height:100%; width:245px;POSITION: absolute; overflow:auto\">");

FixMenu();
DoMenu(0,160);

document.writeln("</div><div id=\"Copyright\" style=\"background-color:#006998; height:20px;width:100%; position: absolute; display: block;overflow:auto; z-index: 3;\">TV's software Copyright(c) 2002-2009</div>");

document.writeln("<div id=\"body\" style=\"background-color:#004978; top:62px; left:245px; height:100%;width:100%; position: absolute; display: block;overflow:auto\">");

resize();
function PaintPNGImage(Image) {
window.document.writeln(GetPNGImage(Image));
}

function GetPNGImage(Image) {
if(navigator.appName=="Microsoft Internet Explorer"){
//Ie is to lazy to automatic transparent png images
return("<img src=\"img/white_16x16.png\" border=\"0\" style=\"filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + Image + "', sizingMethod='image');\">");
} else {
//Firfox&Opera do make the image transparent
return("<img border=\"0\" src=\"" + Image + "\">");
}}

function back() {
//window.document.writeln("<br><br><font size=3>TV's software copyright(c) 2002-2008</font>");
RefreshImages();
}

function RefreshImages() {
var lists = document.getElementsByTagName("IMG");
var tmpwidth=0;
var tmpheight=0;
for (var x = 0; x < lists.length; x++) {
	if((navigator.appName=="Microsoft Internet Explorer") && (lists[x].src.substring(lists[x].src.length-3,lists[x].src.length)=="png")){
		tmpwidth = lists[x].width;
		tmpheight = lists[x].height;
		lists[x].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + lists[x].src + "', sizingMethod='image');";
		lists[x].src = "img/tric16.gif";
		lists[x].width = tmpwidth;
		lists[x].height = tmpheight;
	}
	lists[x].border=0;
}}

function getHeight() { 
  var myWidth = 0, myHeight = 0; 
  if( typeof( window.innerWidth ) == 'number' ) { 
    //Non-IE 
    myHeight = window.innerHeight; 
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { 
    //IE 6+ in 'standards compliant mode' 
    myHeight = document.documentElement.clientHeight; 
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { 
    //IE 4 compatible 
    myHeight = document.body.clientHeight; 
  } 
  return myHeight; 
}

function getWidth() { 
  var myWidth = 0, myHeight = 0; 
  if( typeof( window.innerWidth ) == 'number' ) { 
    //Non-IE 
    myWidth = window.innerWidth;  
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { 
    //IE 6+ in 'standards compliant mode' 
    myWidth = document.documentElement.clientWidth; 
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { 
    //IE 4 compatible 
    myWidth = document.body.clientWidth; 
  } 
  return myWidth; 
}

function ShowLeftBar(show) {
	var image_up="";
	var image_down="";
	var image_move="";
	var newshow="0";
	if(show==0) {
		image_up="img/but_upb.png";
		image_down="img/but_downb.png";
		image_move="img/but_moveb.png";
		newshow="1";
	} else {
		image_up="img/but_upa.png";
		image_move="img/but_movea.png";
		image_down="img/but_downa.png";
	}

	document.getElementById("pushbut").onmouseup=new Function("this.src='"+image_up+"'; RefreshImages(); ShowLeftBar("+newshow+");");
	document.getElementById("pushbut").onmousedown=new Function("this.src='"+image_down+"'; RefreshImages();");
	document.getElementById("pushbut").onmouseout=new Function("this.src='"+image_up+"'; RefreshImages();");
	document.getElementById("pushbut").onmousemove=new Function("this.src='"+image_move+"'; RefreshImages();");
	document.getElementById("pushbut").src=image_up;
	HideMenuval=show;
	RefreshImages();
	resize();
}

function resize() {
	if(HideMenuval==0) {
		document.getElementById("body").style.left=245;
		document.getElementById("body").style.width=getWidth()-245;
		document.getElementById("pushbut").style.left=225-document.getElementById("pushbut").style.width-20;
		document.getElementById("left_menu").style.visibility = "visible";


	} else {
		document.getElementById("body").style.left=40;
		document.getElementById("body").style.width=getWidth()-40;
		document.getElementById("pushbut").style.left=10;
		document.getElementById("left_menu").style.visibility = "hidden";
		
	}
	document.getElementById("body").style.top=62;
	document.getElementById("body").style.height=getHeight()-62-20;

	document.getElementById("logo").style.width=getWidth();

	document.getElementById("left_menu").style.height=getHeight()-62-20;

	document.getElementById("pushbut").style.top=(getHeight()-document.getElementById("pushbut").style.height-40)/2;

	document.getElementById("left_menu").style.width=245;

	document.getElementById("Copyright").style.top=getHeight()-20;
	document.getElementById("Copyright").style.left=0;
	document.getElementById("Copyright").style.width=getWidth();
	
}

function FixMenu() {
if(menu[pagemenu][(pageId*5)]!=0) {
	menu[pagemenu][(pageId*5)+4] = 1;
}
EnableMenu(pagemenu);
}

function EnableMenu(MenuId) {
for (var x = 0; x in menu; x++) {
	for (var i = 0; i in menu[x]; i++) {
		if((menu[x][i]==MenuId) && (MenuId!=0)) {
			menu[x][i+4]=1;
			EnableMenu(x);
		}
		i=i+4;
	}
}}

function DoMenu(menuId,width) {
	document.writeln(GetMenu(menuId,width));
}


function GetMenu(menuId,width) {
	var menux=menu[menuId];
	var finalmenu="";
	var thewidth=0;
	if(width!=0) {
		thewidth="width:"+width;
	}
	for (var x = 0; x in menux; x++) {
		if(menux[x]==0) {
			finalmenu = finalmenu + "<div style=\""+thewidth+"\">";
			if(!((pagemenu==menuId) && ((x/5)==pageId))) {
				finalmenu = finalmenu + "<a href=\""+menux[x+3]+"\">";
			}
			finalmenu = finalmenu + "<img border=\"0\" src=\"img/point.png\"><img border=\"0\" src=\"img/"+menux[x+2]+"\">";
			if(!((pagemenu==menuId) && ((x/5)==pageId))) {
				finalmenu = finalmenu + "<span style=\"color: #B8E5A8\" onmouseover=\"this.style.background= '#006998'\" onmouseout=\"this.style.background= '#004978'\">"
			} else {
				finalmenu = finalmenu + "<span style=\"background-color: #004978;\">";
			}
			finalmenu = finalmenu + menux[x+1] + "</span>";
			if(!((pagemenu==menuId) && ((x/5)==pageId))) {
				finalmenu = finalmenu + "</a>";
			}
			finalmenu = finalmenu + "</div>";
		} else {
			finalmenu = finalmenu + "<div id=\""+menux[x+3]+"1\"  style=\""+thewidth+"\">"+GetShowHideTag(menux[x+4],menuId,x,width)+"</div>";
		}
		x=x+4;
	}
	return(finalmenu);
}

function GetShowHideTag(show,menuId, subId,width) {
	menu[menuId][subId+4]=show;
	var finalmenu="";
	var name="Show All";
	var scriptname="ShowMenu";
	var imagename="+";
	if(show==1) {
		name="Collapse All";
		scriptname="HideMenu";
		imagename="-";
	}
		
	finalmenu = finalmenu + "<span title=\""+name+"\"><img border=\"0\" onmouseup=\""+scriptname+"("+menuId+","+subId+","+width+")\" id=\""+menu[menuId][subId+3]+"1\" src=\"img/"+imagename+".png\"></span>";
	if(!((pagemenu==menuId) && ((subId/5)==pageId))) {
		finalmenu = finalmenu + "<a href=\""+menu[menuId][subId+3]+"\">";
	}
	finalmenu = finalmenu + "<img border=\"0\" src=\"img/"+menu[menuId][subId+2]+"\">";
 	if(!((pagemenu==menuId) && ((subId/5)==pageId))) {
		finalmenu = finalmenu + "<span style=\"color: #B8E5A8\" onmouseover=\"this.style.background= '#006998'\" onmouseout=\"this.style.background= '#004978'\">";
	} else {
		finalmenu = finalmenu + "<span style=\"background-color: #004978\">";
	}
	finalmenu = finalmenu + menu[menuId][subId+1] + "</span>";
 	if(!((pagemenu==menuId) && ((subId/5)==pageId))) {
		finalmenu = finalmenu + "</a>";
	}
	if(show==1) {
		finalmenu = finalmenu + "<div id=\""+menu[menuId][subId+3]+"\" style=\"padding-left: 16px\">"+ GetMenu(menu[menuId][subId],width) + "</div>";
	}
	return(finalmenu);
}

function HideMenu(menuId, subId,width) {
	var menuhandle=document.getElementById(menu[menuId][subId+3]+"1");
	menuhandle.innerHTML = GetShowHideTag(0,menuId,subId,width);
	RefreshImages();
}

function ShowMenu(menuId, subId,width) {
	var menuhandle=document.getElementById(menu[menuId][subId+3]+"1");
	menuhandle.innerHTML = GetShowHideTag(1,menuId,subId,160);
	RefreshImages();
}