
//外部文件调用，根据程序返回值来决定是否显示wifi和4g页面
function ShowWifi()
{
	$.ajax({ 
		type:"GET",
		url:"http://"+hostip+"/get_sys",
		dataType:"xml",
		cache:false,
		success:function(data){
			var wifi_dev_exist=$(data).find("sys").children("wifi_dev_exist").text();
			var g4_dev_exist=$(data).find("sys").children("g4_dev_exist").text();
			if(wifi_dev_exist==0) {
				$("#wifi").hide();
			}
			else {
				$("#wifi").show();
			}
			if(g4_dev_exist==0){
				$("#g4").hide();
			}
			else{
				$("#g4").show();
			}
		}
	});	
}

//外部文件调用，显示菜单
function showMenu(language,first, second)
{
	if(language==0) {
		get_menu_chn(first, second);
	}
	else  {
		get_menu_eng(first, second);
	}
	$("#main-nav li ul").hide(); 
	$("#main-nav li a.current").parent().find("ul").slideToggle("slow"); 
	
	
}


//只有该文件调用，生成中文菜单
function get_menu_chn(first,second)
{
	var  menu_code = '<UL id="main-nav">';
	menu_code += '<LI>';
	if(first=='index'){menu_code += '<A class="nav-top-item no-submenu current" href="index.html">状态显示</A>';}
    else{menu_code += '<A class="nav-top-item no-submenu" href="index.html">状态显示</A>';}
    menu_code += '</LI>';
	
	if(first=="encode"){menu_code +='<LI><A class="nav-top-item current" href="OutputP1Main.html"> 编码设置</A>';}
    else {menu_code += '<LI><A class="nav-top-item" href="OutputP1Main.html"> 编码设置</A>';}	
	menu_code += '<UL>';
	
	if(second=="OutputP1Main"){menu_code += '<LI><A href="OutputP1Main.html" class="current">主码流</A></LI>';}
	else{menu_code += '<LI><A href="OutputP1Main.html">主码流</A></LI>';}	
	 if(second=="OutputP1Second1"){menu_code +='<LI><A href="OutputP1Second1.html" class="current">次码流1</A></LI>';}
	else{menu_code += '<LI><A href="OutputP1Second1.html">次码流1</A></LI>';}	
	if(second=="OutputP1Second2"){menu_code +='<LI><A href="OutputP1Second2.html" class="current">次码流2</A></LI>';}
	else{menu_code += '<LI><A href="OutputP1Second2.html">次码流2</A></LI>';}
	if(second=="OutputP1Second3"){menu_code +='<LI><A href="OutputP1Second3.html" class="current">次码流3</A></LI>';}
	else{menu_code += '<LI><A href="OutputP1Second3.html">次码流3</A></LI>';}
	if(second=="AudioEncodSet"){menu_code +='<LI><A href="AudioEncodSet.html" class="current">音频设置</A></LI>';}
	else{menu_code += '<LI><A href="AudioEncodSet.html">音频设置</A></LI>';}
	if(second=="AdvancSet"){menu_code +='<LI><A href="AdvancSet.html" class="current">高级设置</A></LI>';}
	else{menu_code += '<LI><A href="AdvancSet.html">高级设置</A></LI>';}	
    menu_code += '</UL></LI>';
	
	if(first=="osd"){menu_code +='<LI><A class="nav-top-item current" href="OutputP1MainOsd.html"> OSD设置</A>';	}
    else {menu_code += '<LI><A class="nav-top-item" href="OutputP1MainOsd.html"> OSD设置</A>';}	
    menu_code += '<UL>';
	
	if(second=="OutputP1MainOsd"){menu_code += '<LI><A href="OutputP1MainOsd.html" class="current">主码流</A></LI>';}
	else{menu_code += '<LI><A href="OutputP1MainOsd.html">主码流</A></LI>';}
	if(second=="OutputP1Second1Osd"){menu_code += '<LI><A href="OutputP1Second1Osd.html" class="current">次码流1</A></LI>';}
	else{menu_code += '<LI><A href="OutputP1Second1Osd.html">次码流1</A></LI>';}
	if(second=="OutputP1Second2Osd"){menu_code += '<LI><A href="OutputP1Second2Osd.html" class="current">次码流2</A></LI>';}
	else{menu_code += '<LI><A href="OutputP1Second2Osd.html">次码流2</A></LI>';}
	if(second=="OutputP1Second3Osd"){menu_code += '<LI><A href="OutputP1Second3Osd.html" class="current">次码流3</A></LI>';}
	else{menu_code += '<LI><A href="OutputP1Second3Osd.html">次码流3</A></LI>';}
    if(second=="Uplogo"){menu_code += '<LI><A href="Uplogo.html" class="current">LOGO上传</A></LI>';}
	else{menu_code += '<LI><A href="Uplogo.html">LOGO上传</A></LI>';}
	menu_code += '</UL></LI>';
	
	if(first=="system"){menu_code +='<LI><A class="nav-top-item current" href="SetNet.html">系统设置</A>';	}
    else {menu_code += '<LI><A class="nav-top-item" href="SetNet.html">系统设置</A>';}	
      menu_code += '<UL>';
	
	if(second=="SetNet"){menu_code += '<LI><A href="SetNet.html" class="current" >网络设置</A></LI>';}
	else{menu_code += '<LI><A href="SetNet.html" >网络设置</A></LI>';}
	
	if(second=="WifiSet"){menu_code += '<LI id="wifi"><A href="WifiSet.html"  class="current">WIFI设置</A></LI>';}
	else{menu_code += '<LI id="wifi"><A href="WifiSet.html">WIFI设置</A></LI>';}
	
	if(second=="g4Set"){menu_code += '<LI id="g4"><A href="g4Set.html"  class="current">4G设置</A></LI>';}
	else{menu_code += '<LI id="g4"><A href="g4Set.html">4G设置</A></LI>';}
	
	if(second=="SetPassword"){menu_code += '<LI><A href="SetPassword.html"  class="current">密码设置</A></LI>';}
	else{menu_code += '<LI><A href="SetPassword.html">密码设置</A></LI>';}
	
	if(second=="Remserial"){menu_code += '<LI><A href="Remserial.html"  class="current">串口透传</A></LI>';}
	else{menu_code += '<LI><A href="Remserial.html">串口透传</A></LI>';}
	
	if(second=="SystemUpdate"){menu_code += '<LI><A href="SystemUpdate.html"  class="current">更新和备份</A></LI>';}
	else{menu_code += '<LI><A href="SystemUpdate.html">更新和备份</A></LI>';}
	
	if(second=="Reboot"){menu_code += '<LI><A href="Reboot.html"  class="current">重启设备</A></LI>';}
	else{menu_code += '<LI><A href="Reboot.html">重启设备</A></LI>';}
	
	if(second=="Restart"){menu_code += '<LI><A href="Restart.html"  class="current">定时重启</A></LI>';}
	else{menu_code += '<LI><A href="Restart.html">定时重启</A></LI>';}
	
	if(second=="Reset"){menu_code += '<LI><A href="Reset.html"  class="current">恢复出厂设置</A></LI>';}
	else{menu_code += '<LI><A href="Reset.html">恢复出厂设置</A></LI>';}
	
	menu_code += '</UL></LI>';
	menu_code += '</UL>';
	$("#mainnav_div").replaceWith(menu_code);
	
}

//只有该文件调用，生成英文菜单
function get_menu_eng(first, second)
{
	var menu_code = '<UL id="main-nav">';
	 menu_code += '<LI>';
	if(first=='index'){menu_code += '<A class="nav-top-item no-submenu current" href="indexE.html">Status</A>';}
    else{menu_code += '<A class="nav-top-item no-submenu" href="indexE.html">Status</A>';}
    menu_code += '</LI>';
	
	if(first=="encode"){menu_code +='<LI><A class="nav-top-item current" href="OutputP1MainE.html"> Encoder</A>';}
    else {menu_code += '<LI><A class="nav-top-item" href="OutputP1MainE.html"> Encoder</A>';}	
	menu_code += '<UL>';
	
	if(second=="OutputP1Main"){menu_code += '<LI><A href="OutputP1MainE.html" class="current">Main stream</A></LI>';}
	else{menu_code += '<LI><A href="OutputP1MainE.html">Main stream</A></LI>';}	
	 if(second=="OutputP1Second1"){menu_code += '<LI><A href="OutputP1Second1E.html" class="current">Substream1</A></LI>';}
	else{menu_code += '<LI><A href="OutputP1Second1E.html">Substream1</A></LI>';}	
	if(second=="OutputP1Second2"){menu_code += '<LI><A href="OutputP1Second2E.html" class="current">Substream2</A></LI>';}
	else{menu_code += '<LI><A href="OutputP1Second2E.html">Substream2</A></LI>';}
	if(second=="OutputP1Second3"){menu_code += '<LI><A href="OutputP1Second3E.html" class="current">Substream3</A></LI>';}
	else{menu_code += '<LI><A href="OutputP1Second3E.html">Substream3</A></LI>';}
	if(second=="AudioEncodSet"){menu_code += '<LI><A href="AudioEncodSetE.html" class="current">Audio</A></LI>';}
	else{menu_code += '<LI><A href="AudioEncodSetE.html">Audio</A></LI>';}
	if(second=="AdvancSet"){menu_code += '<LI><A href="AdvancSetE.html" class="current">Advanced</A></LI>';}
	else{menu_code += '<LI><A href="AdvancSetE.html">Advanced</A></LI>';}	
    menu_code += '</UL></LI>';
	
	if(first=="osd"){menu_code +='<LI><A class="nav-top-item current" href="OutputP1MainOsdE.html"> OSD</A>';	}
    else {menu_code += '<LI><A class="nav-top-item" href="OutputP1MainOsdE.html"> OSD</A>';}	
    menu_code += '<UL>';
	
	if(second=="OutputP1MainOsd"){menu_code += '<LI><A href="OutputP1MainOsdE.html" class="current">Main stream</A></LI>';}
	else{menu_code += '<LI><A href="OutputP1MainOsdE.html">Main stream</A></LI>';}
	if(second=="OutputP1Second1Osd"){menu_code += '<LI><A href="OutputP1Second1OsdE.html" class="current">Substream1</A></LI>';}
	else{menu_code += '<LI><A href="OutputP1Second1OsdE.html">Substream1</A></LI>';}
	if(second=="OutputP1Second2Osd"){menu_code += '<LI><A href="OutputP1Second2OsdE.html" class="current">Substream2</A></LI>';}
	else{menu_code += '<LI><A href="OutputP1Second2OsdE.html">Substream2</A></LI>';}
	if(second=="OutputP1Second3Osd"){menu_code += '<LI><A href="OutputP1Second3OsdE.html" class="current">Substream3</A></LI>';}
	else{menu_code += '<LI><A href="OutputP1Second3OsdE.html">Substream3</A></LI>';}
    if(second=="Uplogo"){menu_code += '<LI><A href="UplogoE.html" class="current">LOGO Upload</A></LI>';}
	else{menu_code += '<LI><A href="UplogoE.html">LOGO Upload</A></LI>';}
	menu_code += '</UL></LI>';
	
	if(first=="system"){menu_code +='<LI><A class="nav-top-item current" href="SetNetE.html">System</A>';	}
    else {menu_code += '<LI><A class="nav-top-item" href="SetNetE.html">System</A>';}	
      menu_code += '<UL>';
	
	if(second=="SetNet"){menu_code += '<LI><A href="SetNetE.html" class="current" >Network</A></LI>';}
	else{menu_code += '<LI><A href="SetNetE.html" >Network</A></LI>';}
	
	if(second=="WifiSet"){menu_code += '<LI id="wifi"><A href="WifiSetE.html"  class="current">WIFI</A></LI>';}
	else{menu_code += '<LI id="wifi"><A href="WifiSetE.html">WIFI</A></LI>';}
	
	if(second=="g4Set"){menu_code += '<LI id="g4"><A href="g4SetE.html"  class="current">4G</A></LI>';}
	else{menu_code += '<LI id="g4"><A href="g4SetE.html">4G</A></LI>';}
	
	if(second=="SetPassword"){menu_code += '<LI><A href="SetPasswordE.html"  class="current">Password</A></LI>';}
	else{menu_code += '<LI><A href="SetPasswordE.html">Password</A></LI>';}
	
	if(second=="Remserial"){menu_code += '<LI><A href="RemserialE.html"  class="current">Serial to TCP</A></LI>';}
	else{menu_code += '<LI><A href="RemserialE.html">Serial to TCP</A></LI>';}
	
	if(second=="SystemUpdate"){menu_code += '<LI><A href="SystemUpdateE.html"  class="current">Upgrade and Backup</A></LI>';}
	else{menu_code += '<LI><A href="SystemUpdateE.html">Upgrade and Backup</A></LI>';}
	
	if(second=="Reboot"){menu_code += '<LI><A href="RebootE.html"  class="current">Reboot</A></LI>';}
	else{menu_code += '<LI><A href="RebootE.html">Reboot</A></LI>';}
	
	if(second=="Restart"){menu_code += '<LI><A href="RestartE.html"  class="current">Schedule Reboot</A></LI>';}
	else{menu_code += '<LI><A href="RestartE.html">Schedule Reboot</A></LI>';}
	
	/*if(second=="Reset"){menu_code += '<LI><A href="LogoutE.html" class="current">Log Out</A></LI>';}
	else{menu_code += '<LI><A href="LogoutE.html">Log Out</A></LI>';}*/
	
	if(second=="Reset"){menu_code += '<LI><A href="ResetE.html" class="current">Factory Reset</A></LI>';}
	else{menu_code += '<LI><A href="ResetE.html">Factory Reset</A></LI>';}
	
	menu_code += '</UL></LI>';
	menu_code += '</UL>';
	$("#mainnav_div").replaceWith(menu_code);
}

