<?php
/*********************************************************      
 程序说明：         
	功能说明：显示OMC的Top menu
	调用关系：调用: header.inc     
              被调用:      
	变量说明：
	返回值：无
	作者：Cui Ticun    
      
修改注释：      
NO.1      
姓名：
时间：
修改说明：      
*********************************************************/  
require("../../inc/header.inc");

$DEBUG=0;
$pubDb = 'OMC_PUB';
$menuTable='sysMenuConf';

$myPrivilege = $userInfo['privilege'];
$max_layer=5;
if($selectedLanguage == 'eng'){
	$menuName	= 'name_2';
	$menuRemark	= 'remark_2';
}else{
	$menuName	= 'name_1';
	$menuRemark	= 'remark_1';
}
global $OmcTypeNo;

//menuTypeNo level_1 level_2 level_3 level_4 level_5 name_1 name_2 link_1 link_2 privilege remark_1 remark_2 
$menuSql = "SELECT level_1,$menuName,httpLink,$menuRemark 
			FROM $menuTable 
			WHERE menuTypeNo = '$OmcTypeNo' AND privilege <= '$myPrivilege' AND privilege >= '0'
			AND level_2 = '0' AND level_3 = '0' AND level_4 = '0' AND level_5 = '0'
			ORDER BY level_1
			";
if($DEBUG)
    echo "<br>menuSql = $menuSql";
//$menuResult = @mysqli_query($pubConn,$menuSql);
$menuResult = mysqli_query($pubConn,$menuSql);
echo mysqli_error($pubConn);
$menuRowsNum = mysqli_num_rows($menuResult);
?>
<style type="text/css">
<!--
body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt;BACKGROUND-IMAGE: url(../../images/background_top.gif);BACKGROUND-REPEAT: repeat-x;BACKGROUND-COLOR: #f0efef;OVERFLOW: hidden}
A:link    {text-decoration: none; color: #000000}
A:visited {text-decoration: none; color: #000000}
A:hover   {text-decoration: none; color: #FFFFFF}
-->
</style>
<base target="downMain">
<script LANGUAGE="JavaScript" type="text/javascript">
<!--
var nav=navigator.appName; //浏览器的名称
var ver=navigator.appVersion;//浏览器的版本
var IE4,NS4;
var bV=parseInt(navigator.appVersion);
if (ver.indexOf("MSIE") != -1){
	IE4=true;
	NS4=false;
}else{
	IE4=false;
	NS4=true;
}
var DOM=(!document.layers && !document.all && bV>=4) ? true : false; // A hack to guess if the browser supports the DOM
var capable = (NS4 || IE4 || DOM) ? true : false;

var colorOfMClick	= "#b5b5b5"; 
var colorGray		= "#A5A5A5";
var colorBlack		= "#000000";
var colorWhite		= "#FFFFFF";

function defaultClick(){
	updateAlarm();
	if(IE4){
		divColl = document.all.tags("DIV");
		divColl(0).style.background =colorOfMClick;
	}else if(NS4){
		document.layers[0].style.background = colorOfMClick;
	}
	
}
function beMOver(e)
{
	if(e.style.background != colorOfMClick){
		e.style.background=colorGray;
		e.style.color=colorWhite;
	}
}
function beMOut(e)
{	
	if(e.style.background != colorOfMClick){
		e.style.background="";
		e.style.color=colorBlack;
	}
}

function beMClick(e)
{
	if (!capable) return;
	if (IE4) {
		divColl = document.all.tags("DIV");
		for (i=0; i<divColl.length; i++){
			divColl(i).style.background ="";
			divColl(i).style.color =colorBlack;
		}
		e.style.background=colorOfMClick;
	} else if(NS4) {
		for (i=0; i<document.layers.length; i++) {
		  whichID = document.layers[i];
		  whichID.style.background = colorWhite;
		  whichID.style.color = colorBlack;
		}
		whichID.style.background = colorOfMClick;
	} else if(DOM) {
		return;
	}
}


document.write("<div id='EMS_TIP_WINDOW' style=\"z-index:1;display:none;position:absolute;border-color:#000000;border-style:solid;border-width:1px;\" ></div>");
	
function getEvent()
{  
	if(document.all)   
		return window.event; 	
	func=getEvent.caller; 	

	while(func!=null){  
		var arg0=func.arguments[0];
		if(arg0)
		{
			if((arg0.constructor==Event || arg0.constructor ==MouseEvent) || (typeof(arg0)=="object" && arg0.preventDefault && arg0.stopPropagation)) 
				return arg0;
              
		}
		func=func.caller;
	}
	return null;
}

var alarmNum1=0;
var alarmNum2=0;
var alarmNum3=0;
var alarmNum4=0;
var alarmNum5=0;
function showTipWindow(alarmlevel,tip)
{
	if(tip.length == 0)
		return;
	var pos_x;
	var pos_y;
	var event=getEvent();
	if (navigator.appName=='Microsoft Internet Explorer') 
	{
		pos_x=event.x;
		pos_y=event.y+document.body.scrollTop;
	}
	else if (navigator.appName=='Netscape') 
	{
		pos_x=event.pageX;
		pos_y=event.pageY;
	}

	document.getElementById("EMS_TIP_WINDOW").style.top=pos_y;
	document.getElementById("EMS_TIP_WINDOW").style.left=pos_x-80;
	document.getElementById("EMS_TIP_WINDOW").style.backgroundColor='#eeeeee';
	document.getElementById("EMS_TIP_WINDOW").style.display='';
	if(alarmlevel == 1)
		document.getElementById("EMS_TIP_WINDOW").innerHTML="Critical: "+alarmNum1;
	else if(alarmlevel == 2)
		document.getElementById("EMS_TIP_WINDOW").innerHTML="Major: "+alarmNum2;
	else if(alarmlevel == 3)
		document.getElementById("EMS_TIP_WINDOW").innerHTML="Minor: "+alarmNum3;
	else if(alarmlevel == 4)
		document.getElementById("EMS_TIP_WINDOW").innerHTML="Warning: "+alarmNum4;
	else if(alarmlevel == 5)
		document.getElementById("EMS_TIP_WINDOW").innerHTML="Indeterminate: "+alarmNum5;
}

function hideTipWindow()
{
	document.getElementById("EMS_TIP_WINDOW").style.display='none';
}

function updateAlarm()
{
	var fixurl="./updateAlarm.php";
	var browserr = navigator.appName;
	if(browserr == "Microsoft Internet Explorer")
	{
		request_oo = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{
		request_oo = new XMLHttpRequest();
	}
	request_oo.open("GET",fixurl,"false");

	request_oo.onreadystatechange=function()
	{ 
		checkAlarmState(); 
	}
	request_oo.send(null);
	setTimeout("updateAlarm()", 10000);
}

function checkAlarmState()
{
	//not
	if(request_oo.readyState == 3)
	{
		//alert("not finish");
	}
	if(request_oo.readyState == 4)
	{
		var response = request_oo.responseText;
		//alert(response);
		
		var alarmArr=response.split('_');
		
		//critical
		if(alarmArr[0] > 0)
		{
			document.getElementById('no_critical_alarm_id').style.display='none';
			document.getElementById('critical_alarm_id').style.display='';
			alarmNum1=alarmArr[0];
		}
		else
		{
			document.getElementById('no_critical_alarm_id').style.display='';
			document.getElementById('critical_alarm_id').style.display='none';
		}
		
		//major
		if(alarmArr[1] > 0)
		{
			document.getElementById('no_major_alarm_id').style.display='none';
			document.getElementById('major_alarm_id').style.display='';
			alarmNum2=alarmArr[1];
		}
		else
		{
			document.getElementById('no_major_alarm_id').style.display='';
			document.getElementById('major_alarm_id').style.display='none';
		}
		
		//minor
		if(alarmArr[2] > 0)
		{
			document.getElementById('no_minor_alarm_id').style.display='none';
			document.getElementById('minor_alarm_id').style.display='';
			alarmNum3=alarmArr[2];
		}
		else
		{
			document.getElementById('no_minor_alarm_id').style.display='';
			document.getElementById('minor_alarm_id').style.display='none';
		}
		
		//warning
		if(alarmArr[3] > 0)
		{
			document.getElementById('no_warn_alarm_id').style.display='none';
			document.getElementById('warn_alarm_id').style.display='';
			alarmNum4=alarmArr[3];
		}
		else
		{
			document.getElementById('no_warn_alarm_id').style.display='';
			document.getElementById('warn_alarm_id').style.display='none';
		}
		
		//undefine
		if(alarmArr[3] > 0)
		{
			document.getElementById('no_undefine_alarm_id').style.display='none';
			document.getElementById('undefine_alarm_id').style.display='';
			alarmNum5=alarmArr[4];
		}
		else
		{
			document.getElementById('no_undefine_alarm_id').style.display='';
			document.getElementById('undefine_alarm_id').style.display='none';
		}

		
	}
}
  
-->
</script>
<!---->
<body onload="javascript:defaultClick();">
<?php
	echo "<meta http-equiv=\"refresh\" content=\"600; url=$PHP_SELF\">";
?>
<table width="100%">
	<tr>
		
		<td width="153" valign="top" align="center" rowspan="2">
			<img  align="absbottom" border="0" src="../../images/alto_logo_40.gif" >
			&nbsp;
		
		</td>

		<td valign="middle">
			<table width=100 border="0" cellpadding="-1" cellspacing="-1" bordercolor="#FFFFFF" bordercolordark="#FFFFFF">
				<tr>
				<?php
				$menuID=0;
				if($selectedLanguage == 'chn'){
					$keepLenght=12;
				}else{
					$keepLenght=14;
				}

				while($menuRow=mysqli_fetch_array($menuResult)){
					$menuID++;
					echo "<font color=\"#0000FF\" >";
					echo "<td title=\"$menuRow[$menuRemark]\"  align=\"center\">"; 
					echo "<a href=\"../downIndex/downIndex.php?level_1=$menuRow[level_1]\">";
					echo "<div height=21 bgcolor=\"#000000\" ID=\"menu_$menuID\" onClick=\"beMClick(this)\" ";
					echo "onmouseover=\"javascript:beMOver(this)\" onmouseout=\"javascript:beMOut(this)\">";
					echo "<b>";
					$blankLen=ceil(($keepLenght - strlen($menuRow[$menuName])) / 2);
					//echo "<br>blankLen=$blankLen";
					$blankStr='';
					for($i=0;$i<$blankLen/3;$i++){
						$blankStr .= '&nbsp;';
					}
					echo "$blankStr$menuRow[$menuName]$blankStr";
					echo "</b>";
					echo "</div>";
					echo "</a>";
					echo "</td>";
					echo "</font>";
				}
				?>
				</tr>
			</table>
		</td>
		<td align="right">
			
			<a href="../../fault/alarmList/alarmList_index.php?selAlarmLevel=1&selSysTypeNo=all&noop=1" target="contents">
			<span id="critical_alarm_id" style="display:none;">
			<img id="critical_img_id" valign="middle" border="0" src="../../images/red_blink.gif" onMouseOver="javascript:showTipWindow('1','0');" onMouseOut="javascript:hideTipWindow();">
			</span>
			</a>
			
			<span id="no_critical_alarm_id">
			<img valign="middle" border="0" src="../../images/red_gray.gif">
			</span>
			
			
			<a href="../../fault/alarmList/alarmList_index.php?selAlarmLevel=2&selSysTypeNo=all&noop=1" target="contents">
			<span id="major_alarm_id" style="display:none;">
			<img id="major_img_id" valign="middle" border="0" src="../../images/orange_blink.gif" onMouseOver="javascript:showTipWindow('2','0');" onMouseOut="javascript:hideTipWindow();">
			</span>
			</a>
			
			<span id="no_major_alarm_id">
			<img valign="middle" border="0" src="../../images/orange_gray.gif">
			</span>
			
			
			<a href="../../fault/alarmList/alarmList_index.php?selAlarmLevel=3&selSysTypeNo=all&noop=1" target="contents">
			<span id="minor_alarm_id" style="display:none;">
			<img id="minor_img_id" valign="middle" border="0" src="../../images/yellow_blink.gif" onMouseOver="javascript:showTipWindow('3','0');" onMouseOut="javascript:hideTipWindow();">
			</span>
			</a>
			
			<span id="no_minor_alarm_id">
			<img valign="middle" border="0" src="../../images/yellow_gray.gif">
			</span>
			
			<a href="../../fault/alarmList/alarmList_index.php?selAlarmLevel=4&selSysTypeNo=all&noop=1" target="contents">
			<span id="warn_alarm_id" style="display:none;">
			<img id="warn_img_id" valign="middle" border="0" src="../../images/blue_blink.gif" onMouseOver="javascript:showTipWindow('4','0');" onMouseOut="javascript:hideTipWindow();">
			</span>
			</a>
			
			<span id="no_warn_alarm_id">
			<img valign="middle" border="0" src="../../images/blue_gray.gif">
			</span>
			
			
			<a href="../../fault/alarmList/alarmList_index.php?selAlarmLevel=5&selSysTypeNo=all&noop=1" target="contents">
			<span id="undefine_alarm_id" style="display:none;">
			<img id="undefine_img_id" valign="middle" border="0" src="../../images/lightblue_blink.gif" onMouseOver="javascript:showTipWindow('5','0');" onMouseOut="javascript:hideTipWindow();">
			</span>
			</a>
			
			<span id="no_undefine_alarm_id">
			<img valign="middle" border="0" src="../../images/lightblue_gray.gif">
			</span>

			&nbsp;&nbsp;
		</td>	
	</tr>

<!--	a<tr>
		<td ALIGN="right"  valign="middle">
			<a href="../../fault/alarmList/alarmList_index.php" ></a> 
			<IFRAME NAME="alarm_frame"  frameborder="0" border="0" width="650" height="25" SRC="../../fault/alarmList/alarmNumList.php"></IFRAME>
		</td>
	</tr>-->
</table>
</body>
</html>
