<script language="Javascript">
function MouseOverColor(obj)
{
	obj.bgColor="#ddddff";
}

function MouseOutColor(obj)
{
	obj.bgColor="white";
}


function correctPNG()  
{ 
	for(var i=0; i<document.images.length; i++) 
	{ 
	  var img = document.images[i] 
	  var imgName = img.src.toUpperCase() 
	  if (imgName.substring(imgName.length-3, imgName.length) == "PNG") 
	  { 
	   var imgID = (img.id) ? "id='" + img.id + "' " : "" 
	   var imgClass = (img.className) ? "class='" + img.className + "' " : "" 
	   var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' " 
	   var imgStyle = "display:inline-block;" + img.style.CSSText  
	   if (img.align == "left") imgStyle = "float:left;" + imgStyle 
	   if (img.align == "right") imgStyle = "float:right;" + imgStyle 
	   if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle   
	   var strNewHTML = "<span " + imgID + imgClass + imgTitle 
	   + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";" 
	  + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" 
	   + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"  
	   img.outerHTML = strNewHTML 
	   i = i-1 
	  } 
	} 
} 
window.attachEvent("onload", correctPNG); 

</script>

<?php
//sysTypeNo
define(SYSTYPENO_MSC,320);
define(SYSTYPENO_SMSC,350);
define(SYSTYPENO_SMPP,260);
define(SYSTYPENO_OPPS,375);
define(SYSTYPENO_PPS,360);
define(SYSTYPENO_MME,361);
define(SYSTYPENO_SPGW,362);
define(SYSTYPENO_IMS,363);
define(SYSTYPENO_RCS,364);
define(SYSTYPENO_UDM,365);
define(SYSTYPENO_AUSF,366);
define(SYSTYPENO_MTP3,222);
define(SYSTYPENO_SCCP,223);
define(SYSTYPENO_AAS,311);
define(SYSTYPENO_VSS,390);
define(SYSTYPENO_VLR,325);
define(SYSTYPENO_HLR,330);
define(SYSTYPENO_AUC,340);
define(SYSTYPENO_SMEG,355);
define(SYSTYPENO_EIR,380);
define(SYSTYPENO_MRFC,385);
define(SYSTYPENO_PALIM,378);
define(SYSTYPENO_RLS,379);
define(SYSTYPENO_MHC,386);
define(SYSTYPENO_MNP,370);
define(SYSTYPENO_GRS,387);
define(SYSTYPENO_TMG,391);
define(SYSTYPENO_AMRMG,392);
define(SYSTYPENO_GbC,393);
define(SYSTYPENO_MCA,394);
define(SYSTYPENO_RCM,395);
define(SYSTYPENO_MTP3,222);
define(SYSTYPENO_XAPP,225);
//define(SYSTYPENO_IUUPGW,389);

//create method       
define(MANUAL_CREATE,0);
define(AUTO_CREATE,1);

//value type
define(VALUE_NONE,0);
define(VALUE_STRING,2);
define(VALUE_INT,3);
define(VALUE_IP,5);
define(VALUE_TIMESTAMP,8);
define(VALUE_OPAQUE,9);

/*
check the status of the system
*/
function CheckSystemStatus($sysTypeNo,$sysNo,$subSysNo)
{



	global $strUninstalled,$pubConn;
	$sysConfTable = 'sysConf';
	$sysInfoTable = 'sysInfo';
	//echo "ss=$sysNo,$subSysNo";
	if(($sysNo == '99') || ($subSysNo == '99'))
	{
		if($sysNo == '99')
		{
			$sysIdSql ="SELECT sysTypeName,$sysInfoTable.sysTypeNo,sysNo,subSysNo,sysAlias  
					FROM $sysInfoTable,$sysConfTable 
					WHERE $sysInfoTable.sysTypeNo=$sysConfTable.sysTypeNo 
					AND $sysInfoTable.sysTypeNo = '$sysTypeNo'
					";
		
		}
		else
		{
			$sysIdSql ="SELECT sysTypeName,$sysInfoTable.sysTypeNo,sysNo,subSysNo,sysAlias  
					FROM $sysInfoTable,$sysConfTable 
					WHERE $sysInfoTable.sysTypeNo=$sysConfTable.sysTypeNo 
					AND $sysInfoTable.sysTypeNo = '$sysTypeNo'
					AND sysNo = '$sysNo'
					";
		}
		if($DEBUG)echo "sysIdSql(1) = $sysIdSql<br>";
		$result = mysqli_query($pubConn,$sysIdSql);
		echo mysqli_error($pubConn);
		$rowsNum=mysqli_num_rows($result);
		$rows=mysqli_fetch_array($result);
		$sysTypeName=$rows[sysTypeName];
		if($rowsNum < 1)
		{
			echo "&nbsp;</td></tr></table>$strUninstalled<br>";
			exit();
		}
	}
	else
	{
		$sysIdSql ="SELECT sysTypeName,$sysInfoTable.sysTypeNo,sysNo,subSysNo,sysAlias  
				FROM $sysInfoTable,$sysConfTable 
				WHERE $sysInfoTable.sysTypeNo=$sysConfTable.sysTypeNo 
				AND $sysInfoTable.sysTypeNo = '$sysTypeNo'
				AND sysNo = '$sysNo'
				AND subSysNo = '$subSysNo'
				";
		if($DEBUG) echo "sysIdSql(2) = $sysIdSql<br>";
		$result = mysqli_query($pubConn,$sysIdSql);
		echo mysqli_error($pubConn);
		$rowsNum=mysqli_num_rows($result);
		$rows=mysqli_fetch_array($result);
		$sysTypeName=$rows[sysTypeName];
		if($rowsNum < 1)
		{
			echo "&nbsp;</td></tr></table>$strUninstalled<br>";
			exit();
		}
	}	
}

function adjustTableName($name)
{
	$len=strlen($name);
	$result="";
	
	if($name[0]>='a' && $name[0]<='z')
		$result.=chr(ord($name[0])-32);	

	if($len <= 4)
	{
		for($i = 1; $i < $len; $i++)
		{
			$result.=$name[$i];
		}
	}
	else
	for($i=1;$i<$len;$i++)
	{	
		if($i != 1)
			if($name[$i]>='A' && $name[$i]<='Z' && $name[$i-1]>='a' && $name[$i-1]<='z')
				$result.=" ";
			
		if($name[$i]>='A' && $name[$i]<='Z' && $name[$i+1]>='a' && $name[$i+1]<='z' && $name[$i-1]>='A' && $name[$i-1]<='Z')
				$result.=" ";
		
				
		$result.=$name[$i];	
		
		if(($name[$i]<'0' || $name[$i]>'9')&& ($name[$i+1]>='0' && $name[$i+1]<='9'))
			$result.=" ";

		if(($name[$i]>='0' && $name[$i]<='9')&& ($name[$i+1]<'0' || $name[$i+1]>'9'))
				$result.=" ";

	}
	
	$result=str_replace("Table","",$result);
	$result=str_replace("Entry","",$result);
	
	return $result;
}
function getOIDByRow($row)
{
	$oid="";
	for($i=1;$i<=10;$i++)
	{
		$level="level_".$i;
		if($row[$level] == 0)
		{
			break;
		}
		else
		{
			$oid.=$row[$level].".";
		}
	}
	$oid=substr($oid,0,strlen($oid)-1);
	return $oid;
}
function GetOIDByName($sysTypeNo,$name)
{
	global $objDbConn;

	$database="OBJ_".$sysTypeNo.".paramConf";
	$sql="select * from $database where name_2 like '%$name%' ";

	$res=@mysqli_query($objDbConn,$sql);
	$row=@mysqli_fetch_array($res);
	
	$oids="";
	for($i=1;$i<=10;$i++)
	{
		$tmpN="level_".$i;
		$tmpV=$row[$tmpN]+0;
		if($tmpV == 0)
			break;
			
		$oids.=$tmpV.".";
		
	}

	if($i>1)
		$oids=substr($oids,0,strlen($oids)-1);
	
	return $oids;
}
function getShowNameOfTable($name,$keyId)
{
	global $objects;
	
	if($keyId != -1 && strstr($objects[$keyId]['desc_1'],"Name:"))
	{
		$new_name=explode("Name:",$objects[$keyId]['desc_1']);
		return str_replace(";","",$new_name[sizeof($new_name)-1]);
	}
	
	$len=strlen($name);
	$result="";
	
	if($name[0]>='a' && $name[0]<='z')
		$result.=chr(ord($name[0])-32);	
	for($i=1;$i<$len;$i++)
	{	
		if($i != 1)
			if($name[$i]>='A' && $name[$i]<='Z' && $name[$i-1]>='a' && $name[$i-1]<='z')
				$result.=" ";
			
		if($name[$i]>='A' && $name[$i]<='Z' && $name[$i+1]>='a' && $name[$i+1]<='z' && $name[$i-1]>='A' && $name[$i-1]<='Z')
			$result.=" ";
				
		$result.=$name[$i];	
		
		if(($name[$i]<'0' || $name[$i]>'9')&& ($name[$i+1]>='0' && $name[$i+1]<='9'))
			$result.=" ";
		if(($name[$i]>='0' && $name[$i]<='9')&& ($name[$i+1]<'0' || $name[$i+1]>'9'))
			$result.=" ";
	}
	
	$result=str_replace("Table","",$result);
	$result=str_replace("Entry","",$result);
	
	return $result;
}
function getShowNameOfField($name,$keyId)
{
	global $objects;
	
	if($keyId != -1 && strstr($objects[$keyId]['desc_1'],"Name:"))
	{
		$new_name=explode("Name:",$objects[$keyId]['desc_1']);
		return str_replace(";","",$new_name[sizeof($new_name)-1]);
	}
	
	$len=strlen($name);
	$result="";
	
	for($j=0;$j<$len;$j++)
	{
		if($name[$j]>='A' && $name[$j]<='Z')
			break;
	}
	for($i=$j;$i<$len;$i++)
	{
		if($name[$i]>='A' && $name[$i]<='Z' && $name[$i-1]>='a' && $name[$i-1]<='z')
			$result.=" ";
			
		if($name[$i]>='A' && $name[$i]<='Z' && $name[$i+1]>='a' && $name[$i+1]<='z' && $name[$i-1]>='A' && $name[$i-1]<='Z')
			$result.=" ";
				
		$result.=$name[$i];	
		
		if(($name[$i]<'0' || $name[$i]>'9')&& ($name[$i+1]>='0' && $name[$i+1]<='9'))
			$result.=" ";
		if(($name[$i]>='0' && $name[$i]<='9')&& ($name[$i+1]<'0' || $name[$i+1]>'9'))
			$result.=" ";
	}
	
	return $result;
}
function translateValueToOpt($operType,$valueType,$template,$value)
{
	if(($operType == SHOW_LABEL || $operType == SHOW_SELECT) && $valueType == VALUE_INT)
	{
		if(trim($template) == "")
				return $value;
			$options=explode(";",$template);
			for($ii=0;$ii<sizeof($options);$ii++)
			{
				$tmp=explode("=",$options[$ii]);
				$val=$tmp[0];
				$opt=$tmp[1];
				if($value == $opt)
					return $val;
			}
	}
	return $value;
}
/*
	tableName: the name of the table, rountingSelection for example. case-ignored
	$type: TABLE_ENTRY, TABLE_ENTRIES, TABLE_CREATE
*/
define(TABLE_ENTRY,0);
define(TABLE_ENTRIES,1);
define(TABLE_CREATE,2);
function findRelationOid($tableName,$type,$sysTypeNo)
{
		global $objDbConn;

	$tableName=strtolower($tableName);
	$dbtable="OBJ_".$sysTypeNo.".paramConf";
	if($type == TABLE_ENTRY)
		$likestr=$tableName."Entry";
	else if($type == TABLE_ENTRIES)
		$likestr=$tableName."Entries";
	else if($type == TABLE_CREATE)
		$likestr="CreateEntry".$tableName;
		
	$sql="select * from $dbtable where name_2 like '%$likestr%' ";
	//echo "<br>$sql<br>";
	$res=@mysqli_query($objDbConn,$sql);
	$num=mysqli_num_rows($res);
	if($num == 0)
		return "";
	$row=@mysqli_fetch_array($res);
	$findOid="";
	for($i=1;$i<=10;$i++)
	{
		if($row["level_".$i] == '0')
			break;
		$findOid.=$row["level_".$i].".";
	}
	$findOid=substr($findOid,0,strlen($findOid)-1);
	//PrintInfo("tableName=$tableName,dbtable=$dbtable,oid=$findOid");
	return $findOid;
}
?>

<?php
$glo_id=0;
function GetGlobalID()
{
	global $glo_id;
	$tmp=$glo_id;
	$glo_id++;
	return $tmp;
}

function GetTabConf($sysTypeNo)
{
	global $pubConn,$OMC_server;
	$objDb='OBJ_'.$sysTypeNo;

$objDbConn = mysqli_connect($OMC_server[0]['host'],$OMC_server[0]['user'],$OMC_server[0]['password'],$objDb);	
	$sql="select * from OBJ_{$sysTypeNo}.paramConf where maxAccess=0 and name_2 <> 'parameter' order by level_1,level_2,level_3,level_4,level_5,level_6,level_7,level_8,level_9,level_10 ";

	//PPS do not need show fileOperation in the paramater
	//if($sysTypeNo == 360)
	//	$sql="select * from OBJ_{$sysTypeNo}.paramConf where maxAccess=0 and name_2 <> 'parameter' and name_2 <> 'fileOperation' order by level_1,level_2,level_3,level_4,level_5,level_6,level_7,level_8,level_9,level_10 ";
	$res=@mysqli_query($objDbConn,$sql);

	//$num=@mysqli_num_rows($res);
			echo mysqli_error($objDbConn);

		if ($res)
	{
		$num=@mysqli_num_rows($res);

	}
	else 
	{
		exit();
	}
	for($i=0;$i<$num;$i++)
	{
		$row=@mysqli_fetch_array($res);
		$tabConf[$i][Name]=adjustTableName($row[name_2]);
		$tabConf[$i][OID]=getOIDByRow($row);
		
		$checkoid=$tabConf[$i][OID].".1.1.0";
		$checkwhere=getLevelWhere($checkoid);
		$checksql="select desc_2 from OBJ_{$sysTypeNo}.paramConf where $checkwhere";
		$checkres=@mysqli_query($objDbConn,$checksql);
		$checknum=@mysqli_num_rows($checkres);
		if($checknum == 1)
		{
			$checkrow=@mysqli_fetch_array($checkres);
			$desc=$checkrow[desc_2];
			if(strstr($desc,"Name:"))
			{
				$new_name=explode("Name:",$desc);
				$tabConf[$i][Name]=str_replace(";","",$new_name[sizeof($new_name)-1]);
			}
		}
		
	}
	if($num == 0)
		return 0;
	return $tabConf;
}
function GetSystemStatus($sysTypeNo,$sysNo,$subSysNo=0)
{
	$due_date	= date("Y-m-d H:i:s",mktime(date("H"),date("i"),date("s")-60,date("m"),date("d"),date("Y")));
	$ove_date	= date("Y-m-d H:i:s",mktime(date("H"),date("i"),date("s")+60,date("m"),date("d"),date("Y")));
	
	$sql="select * from OMC_PUB.sysInfo where sysTypeNo=$sysTypeNo and sysNo=$sysNo and subSysNo=$subSysNo ";	
	$res=@mysqli_query($pubConn,$sql);
	$num=mysqli_num_rows($res);
	if($num == 0)
		return 0;
	
	$row=@mysqli_fetch_array($res);
	$baseStat=$row[baseStat]+0;
	if($baseStat == 0)
		return 0;
		
	$updateTime=$row[updateTime];
	if($updateTime < $due_date || $updateTime > $ove_date)
		return 0;
		
	return 1;
}
function GetSubTabConf($sysTypeNo,$tabOid)
{
	$where=getLevelWhere($tabOid);


	global $objDbConn;
	$where=getLevelWhere($tabOid);
	$sql="select * from OBJ_{$sysTypeNo}.paramConf where (maxAccess=0 and name_2 <> 'parameter' and $where) or (maxAccess=21 and name_2 like '%Entry' and $where) order by level_1,level_2,level_3,level_4,level_5,level_6,level_7,level_8,level_9,level_10  ";

	$res=@mysqli_query($objDbConn,$sql);
	$num=@mysqli_num_rows($res);
	//echo"num=$sql<br>";
	

	$subTabConf[SubMenuCount]=0;
	$subTabConf[ItemCount]=0;
	$subTabConf[ScalarParamCount]=0;
	$subTabConf[ScalarParamDisplayCount]=0;
	$subTabConf[ColumnTableCount]=0;
	$subTabConf[ButtonCount]=0;
	$subTabConf[ScalarSetParamCount]=0;
	for($i=0;$i<$num;$i++)
	{
		$row=@mysqli_fetch_array($res);
		$desc=$row[desc_2];
		$maxAccess=$row[maxAccess];
		$name=$row[name_2];
		
		if($maxAccess == 0)
		{
			$subTabConf[RawName]=$name;
			$subTabConf[ShowName]=adjustTableName($name);
			$where=getLevelWhere(getOIDByRow($row));
			$pos=1;
			while($row["level_".$pos] != 0)
				$pos++;
			$pos++;
			$sql="select * from OBJ_{$sysTypeNo}.paramConf where $where and level_{$pos}=0 and maxAccess >= 18 and maxAccess <= 19 order by level_1,level_2,level_3,level_4,level_5,level_6,level_7,level_8,level_9,level_10 ";
			//echo "$sql<br>";
			$param_res=@mysqli_query($objDbConn,$sql);
			$subTabConf[ScalarParamCount]=@mysqli_num_rows($param_res);
			for($j=0;$j<$subTabConf[ScalarParamCount];$j++)
			{
				$param_row=@mysqli_fetch_array($param_res);
				
				$subTabConf[ScalarParam][$j][ValueType]=$param_row[valueType];
				$subTabConf[ScalarParam][$j][OID]=getOIDByRow($param_row);
				$subTabConf[ScalarParam][$j][MaxAccess]=$param_row[maxAccess];
				$subTabConf[ScalarParam][$j][RawName]=$param_row[name_2];
				$subTabConf[ScalarParam][$j][Tip]=$param_row[note_2];
				$subTabConf[ScalarParam][$j][Tip]=str_replace("'","\'",$subTabConf[ScalarParam][$j][Tip]);
				if(strstr($param_row[desc_2],"Name:"))
				{
					$new_name=explode("Name:",$param_row[desc_2]);
					$subTabConf[ScalarParam][$j][ShowName]=str_replace(";","",$new_name[sizeof($new_name)-1]);
				}
				else
				{
					$subTabConf[ScalarParam][$j][ShowName]=adjustTableName($subTabConf[ScalarParam][$j][RawName]);
				}
				
				if(strstr($param_row[desc_2],"Hidden Parameter"))
				{
					$subTabConf[ScalarParam][$j][MaxAccess]=999;
				}
				else
				{
					if(stristr($param_row[name_2],"command"))
					{
						$subTabConf[ScalarParam][$j][MaxAccess]=999;
						
						$template=trim($param_row[setTemplate_2]);
						$options=explode(";",$template);
						for($ii=0;$ii<sizeof($options);$ii++)
						{
							$tmp=explode("=",$options[$ii]);
							$val=$tmp[0];
							$opt=$tmp[1];
							//echo "$val - $opt<br>";
							$showName=getShowNameOfTable($val,-1);
							$subTabConf[Button][$subTabConf[ButtonCount]][OID]=$subTabConf[ScalarParam][$j][OID];
							$subTabConf[Button][$subTabConf[ButtonCount]][ShowName]=getShowNameOfTable($val,-1);
							$subTabConf[Button][$subTabConf[ButtonCount]][Value]=$opt;
							$subTabConf[ButtonCount]++;
						}
						
					}
					else
					{
						$subTabConf[ScalarParam][$j][GetFlag]=1;
						$subTabConf[ScalarParamDisplayCount]++;
					}
					
					
					if($subTabConf[ScalarParam][$j][MaxAccess] == 19)
					{
						$subTabConf[ScalarParam][$j][SetFlag]=1;
						$subTabConf[ScalarSetParamCount]++;
					}
				}
			}
		}
		else
		{
			//echo "THIS IS $i ".$maxAccess;
			$subTabConf[ColumnTable][$subTabConf[ColumnTableCount]][SubMenuFlag]=0;
			$subTabConf[ColumnTable][$subTabConf[ColumnTableCount]][RawName]=$name;
			$subTabConf[ColumnTable][$subTabConf[ColumnTableCount]][OID]=getOIDByRow($row);
			if(strstr($desc,"Name:"))
			{
				$new_name=explode("Name:",$desc);
				$subTabConf[ColumnTable][$subTabConf[ColumnTableCount]][ShowName]=str_replace(";","",$new_name[sizeof($new_name)-1]);
			}
			else
			{
				$subTabConf[ColumnTable][$subTabConf[ColumnTableCount]][ShowName]=adjustTableName($subTabConf[ColumnTable][$subTabConf[ColumnTableCount]][RawName]);
			}
			
			if(strstr($row[desc_2],"level:2"))
			{
				$subTabConf[ColumnTable][$subTabConf[ColumnTableCount]][TableLevel]=2;
			}
			else if(strstr($row[desc_2],"level:3"))
			{
				$subTabConf[ColumnTable][$subTabConf[ColumnTableCount]][TableLevel]=3;
			}
			else
			{
				$subTabConf[ColumnTable][$subTabConf[ColumnTableCount]][TableLevel]=1;
				$subTabConf[ColumnTable][$subTabConf[ColumnTableCount]][SubMenuFlag]=1;
				$subTabConf[SubMenuCount]++;
			}
			$subTabConf[ColumnTableCount]++;
		}
		
		$subTabConf[ItemCount]++;
	}
	return $subTabConf;
}

function GetSingleParameterInfo($sysId,$oid)
{
	global $OMC_server;
	$sysIdArr=explode('_',$sysId);
	$sysTypeNo=$sysIdArr[0];
	$objDbConn = mysqli_connect($OMC_server[0]['host'],$OMC_server[0]['user'],$OMC_server[0]['password'],'OBJ_'.$sysTypeNo);	

	$where=getLevelWhere($oid);
	
	$sql="select * from OBJ_{$sysTypeNo}.paramConf where {$where}; ";
	$res=@mysqli_query($objDbConn,$sql);
	$num=@mysqli_num_rows($res);
	if($num == 0)
	{
		echo "can not find this parameter $oid<br>";
		return;
	}
	$row=@mysqli_fetch_array($res);
	$singleParameterInfo[ShowName]=getShowNameOfField($row[name_2],-1);
	
	if(strstr($row[desc_2],"Name:"))
	{
		$new_name=explode("Name:",$row[desc_2]);
		$singleParameterInfo[ShowName]=str_replace(";","",$new_name[sizeof($new_name)-1]);
	}
	
	$singleParameterInfo[Description]=str_replace("'","\'",$row[note_2]);
	return $singleParameterInfo;
}

function GetSingleTableInfo($singleTabConf,$sysTypeNo)
{

	global $pubConn,$objDbConn;
		//echo $singleTabConf[OID];
	$where=getLevelWhere($singleTabConf[OID]);
	$sql="select * from OBJ_{$sysTypeNo}.paramConf where $where order by level_1,level_2,level_3,level_4,level_5,level_6,level_7,level_8,level_9,level_10 ";
	//echo "sql=$sql<br>";
	$res=@mysqli_query($objDbConn,$sql);
	$num=@mysqli_num_rows($res);
	//echo "num=$num";
	$singleTabInfo[ColumnParamCount]=0;
	$singleTabInfo[ColumnParamSetCount]=0;               
	$singleTabInfo[ButtonCount]=0;
	$singleTabInfo[TableLevel]=$singleTabConf[TableLevel];
	for($i=0;$i<$num;$i++)
	{
		$row=@mysqli_fetch_array($res);
		$name=$row[name_2];
		$desc=$row[desc_2];
		if(strstr($name,"Entry") && !strstr($name,"Create"))
		{
			$singleTabInfo[TableEntryOID]=getOIDByRow($row);
		}
		else
		{
			if(strstr($name,"Index"))
			{
				$singleTabInfo[TableIndexPos]=$singleTabInfo[ColumnParamCount];
				if($singleTabInfo[TableLevel] == 1)
				{
					if($row[maxAccess] == 48)
					{
						$singleTabInfo[CreateOID]=getOIDByRow($row);
					}
				}
				else
				{
					$tableName=str_replace("Entry","",$singleTabConf[RawName]);
					$singleTabInfo[CreateOID]=findRelationOid($tableName,TABLE_CREATE,$sysTypeNo);
					//find the field need update when create
					$singleTabInfo[CreateUpdateOID]=findRelationOid($tableName,TABLE_ENTRIES,$sysTypeNo);
				}
			}
			else if(strstr($name,"RowStatus"))
			{
				$singleTabInfo[TableDeletePos]=$singleTabInfo[ColumnParamCount];
				if(strstr($desc,"Key Parameter"))
				{
					$singleTabInfo[DeleteOID]=getOIDByRow($row);
					if($singleTabInfo[TableLevel] != 1)
					{
						$tableName=str_replace("Entry","",$singleTabConf[RawName]);
						//find the field need update when delete
						$singleTabInfo[DeleteUpdateOID]=findRelationOid($tableName,TABLE_ENTRIES,$sysTypeNo);
					}
				}
			}
			else if(strstr($name,"Entries"))
			{
				$singleTabInfo[ColumnParam][$singleTabInfo[ColumnParamCount]][EntriesFlag]=1;
				//find the sub table entry oid
				$len=strlen($name);
				for($tpi=0;$tpi<$len;$tpi++)
				{
					if(!($name[$tpi] >= 'a' && $name[$tpi] <= 'z'))
						break;
				}
				$tableName=substr($name,$tpi);
				$singleTabInfo[ColumnParam][$singleTabInfo[ColumnParamCount]][NestEntryOID]=findRelationOid($table,TABLE_ENTRY,$sysTypeNo);
			}
			
			if(strstr($desc,"Key Parameter"))
				$singleTabInfo[ColumnParam][$singleTabInfo[ColumnParamCount]][KeyFlag]=1;
			else
				$singleTabInfo[ColumnParam][$singleTabInfo[ColumnParamCount]][KeyFlag]=0;
			
			$singleTabInfo[ColumnParam][$singleTabInfo[ColumnParamCount]][RawName]=$name;
			if(strstr($desc,"Name:"))
			{
				$new_name=explode("Name:",$desc);
				$singleTabInfo[ColumnParam][$singleTabInfo[ColumnParamCount]][ShowName]=str_replace(";","",$new_name[sizeof($new_name)-1]);
			}
			else
			{
				$singleTabInfo[ColumnParam][$singleTabInfo[ColumnParamCount]][ShowName]=getShowNameOfField($name,-1);
			}
			$singleTabInfo[ColumnParam][$singleTabInfo[ColumnParamCount]][MaxAccess]=$row[maxAccess];
			if($row[maxAccess] == 19)
				$singleTabInfo[ColumnParamSetCount]++;
			$singleTabInfo[ColumnParam][$singleTabInfo[ColumnParamCount]][OperType]=$row[operType];
			$singleTabInfo[ColumnParam][$singleTabInfo[ColumnParamCount]][ValueType]=$row[valueType];
			$singleTabInfo[ColumnParam][$singleTabInfo[ColumnParamCount]][OID]=getOIDByRow($row);
			$tmpsp=explode(".",$singleTabInfo[ColumnParam][$singleTabInfo[ColumnParamCount]][OID]);
			$singleTabInfo[ColumnParam][$singleTabInfo[ColumnParamCount]][LastOID]=$tmpsp[count($tmpsp)-1];
			$singleTabInfo[ColumnParam][$singleTabInfo[ColumnParamCount]][Description]=$row[desc_2];
			$singleTabInfo[ColumnParam][$singleTabInfo[ColumnParamCount]][Tip]=str_replace("'","\'",$row[note_2]);
			$singleTabInfo[ColumnParam][$singleTabInfo[ColumnParamCount]][Template]=$row[setTemplate_2];
			
			//get command Button
			if(stristr($name,"command"))
			{

				$template=trim($row[setTemplate_2]);
				$options=explode(";",$template);
				for($ii=0;$ii<sizeof($options);$ii++)
				{
					$tmp=explode("=",$options[$ii]);
					$val=$tmp[0];
					$opt=$tmp[1];
					//echo "$val - $opt<br>";
					$showName=getShowNameOfTable($val,-1);
					$singleTabInfo[Button][$singleTabInfo[ButtonCount]][OID]=$singleTabInfo[ColumnParam][$singleTabInfo[ColumnParamCount]][OID];
					$singleTabInfo[Button][$singleTabInfo[ButtonCount]][ShowName]=getShowNameOfTable($val,-1);
					$singleTabInfo[Button][$singleTabInfo[ButtonCount]][Value]=$opt;
					$singleTabInfo[ButtonCount]++;
				}
				
			}
			
			$singleTabInfo[ColumnParamCount]++;		
		}
	}
	
	return $singleTabInfo;
}
function getTableLevel($tableOid,$sysTypeNo)
{
	$tableWhere=getLevelWhere($tableOid);
	$database="OBJ_".$sysTypeNo.".paramConf";
	$sql="select desc_1 from $database where $tableWhere ";
	$res=@mysqli_query($pubConn,$sql);
	$row=@mysqli_fetch_array($res);
	$desc_1=$row[desc_1];
	$tmp=explode("level:",$desc_1);
	$level=$tmp[1]+0;
	return $level;
}

function showNavigateTitle($table_id,$sub_table_id,$table_level,$sysId,$columnTable,$instanceNo,$type)
{
	
	global $pubConn,$objDbConn;
	if(0)
	{
		echo "table_id=$table_id,sub_table_id=$sub_table_id,table_level=$table_level,instanceNo=$instanceNo,type=$type<br>";
		echo "This tableName={$columnTable[$sub_table_id][Name]}<br>";
	}
	
	if(0)
	{
		echo "<pre>";
		print_r($columnTable);
		echo "</pre>";
	}
	$sysIdArr=explode('_',$sysId);
	$sysTypeNo=$sysIdArr[0];
	$table_count=count($columnTable);
	if($table_level == 1)
	{
		if($type == "show")
		{

			echo "<b>{$columnTable[$sub_table_id][ShowName]}</b>";
		}
		else if($type == "edit")
		{
			echo "<b><a href=\"param_show_table.php?table_id=$table_id&sub_table_id=$sub_table_id&sysId=$sysId&table_level=1&instanceNo=0000\">";
			echo "{$columnTable[$sub_table_id][ShowName]}";
			echo "</a></b>";
			
			echo "&nbsp;";
			
			echo "<b>";
			echo ($instanceNo+0);
			echo "</b>";
		}
		else
		{
			echo "<b><a href=\"param_show_table.php?table_id=$table_id&sub_table_id=$sub_table_id&sysId=$sysId&table_level=1&instanceNo=0000\">";
			echo "{$columnTable[$sub_table_id][ShowName]}";
			echo "</a></b>";
		}
	}
	else if($table_level == 2)
	{
		//get last table sub_table_id
		//echo "sub_table_id=$sub_table_id,{$columnTable[$sub_table_id][Name]}<br>";
		$tableName=str_replace(" ","",$columnTable[$sub_table_id][Name]);
		$oid=trim(findRelationOid($tableName,TABLE_ENTRIES,$sysTypeNo));
		$lastdotpos=strrpos($oid,".");
		$newoid=substr($oid,0,$lastdotpos);
		$where=getLevelWhere($newoid);
		$sql="select name_2 from OBJ_{$sysTypeNo}.paramConf where $where AND name_2 like '%Entry' ";
		//echo ":sql=$sql";
		$res=@mysqli_query($objDbConn,$sql);
				$num=@mysqli_num_rows($res);
		//echo "num222=$sql<br>";
		$row=@mysqli_fetch_array($res);
		// 		echo "<pre>";
		// print_r($row);
		// echo "</pre>";
		$newname=str_replace("Entry","",$row[name_2]);
			//echo "name_2=$newname<br>";

		for($i=0;$i<$table_count;$i++)
		{
			//echo "$newname+{$columnTable[$i][Name]}<br>";
			if(strcasecmp($newname,str_replace(" ","",$columnTable[$i][Name])) == 0)
			{
				$l1_sub_table_id=$i;
				break;
			}
		}
		
		if($type == "show")
		{	
			
			echo "<b><a href=\"param_show_table.php?sysId=$sysId&table_id=$table_id&sub_table_id=$l1_sub_table_id&table_level=1&instanceNo=0000\">";
			echo "{$columnTable[$l1_sub_table_id][ShowName]}";
			echo "</a></b>";
			
			echo "&nbsp;";
			
			echo "<b><a href=\"param_edit.php?sysId=$sysId&table_id=$table_id&sub_table_id=$l1_sub_table_id&table_level=1&instanceNo=$instanceNo\">";
			echo ($instanceNo+0);
			echo "</a></b>";
			
			echo "&nbsp;>&nbsp;";
			echo "<b>{$columnTable[$sub_table_id][ShowName]}</b>";
		}
		else if($type == "edit")
		{
			echo "<b><a href=\"param_show_table.php?sysId=$sysId&table_id=$table_id&sub_table_id=$l1_sub_table_id&table_level=1&instanceNo=0000\">";
			echo "{$columnTable[$l1_sub_table_id][ShowName]}";
			echo "</a></b>";
			
			echo "&nbsp;";
			
			$tmp=explode(".",$instanceNo);
			echo "<b><a href=\"param_edit.php?sysId=$sysId&table_id=$table_id&sub_table_id=$l1_sub_table_id&table_level=1&instanceNo={$tmp[0]}\">";
			echo ($tmp[0]+0);
			echo "</a></b>";
			
			echo "&nbsp;>&nbsp;";
			echo "<b><a href=\"param_show_table.php?sysId=$sysId&table_id=$table_id&sub_table_id=$sub_table_id&table_level=2&instanceNo={$tmp[0]}\">";
			echo "{$columnTable[$sub_table_id][ShowName]}";
			echo "</a></b>";
			
			echo "&nbsp;";
			
			echo "<b>";
			echo ($tmp[1]+0);
			echo "</b>";
		}
		else
		{
			echo "<b><a href=\"param_show_table.php?sysId=$sysId&table_id=$table_id&sub_table_id=$l1_sub_table_id&table_level=1&instanceNo=0000\">";
			echo "{$columnTable[$l1_sub_table_id][ShowName]}";
			echo "</a></b>";
			
			echo "&nbsp;";
			
			$tmp=explode(".",$instanceNo);
			echo "<b><a href=\"param_edit.php?sysId=$sysId&table_id=$table_id&sub_table_id=$l1_sub_table_id&table_level=1&instanceNo={$tmp[0]}\">";
			echo ($tmp[0]+0);
			echo "</a></b>";
			
			echo "&nbsp;>&nbsp;";
			echo "<b><a href=\"param_show_table.php?sysId=$sysId&table_id=$table_id&sub_table_id=$sub_table_id&table_level=2&instanceNo={$tmp[0]}\">";
			echo "{$columnTable[$sub_table_id][ShowName]}";
			echo "</a></b>";
		}
	}
	else if($table_level == 3)
	{
		//get last table sub_table_id
		$tableName=str_replace(" ","",$columnTable[$sub_table_id][Name]);
		$oid=trim(findRelationOid($tableName,TABLE_ENTRIES,$sysTypeNo));
		$lastdotpos=strrpos($oid,".");
		$newoid=substr($oid,0,$lastdotpos);
		$where=getLevelWhere($newoid);
		$sql="select name_2 from OBJ_{$sysTypeNo}.paramConf where $where ";
		$res=@mysqli_query($objDbConn,$sql);
		$row=@mysqli_fetch_array($res);
		$newname=str_replace("Entry","",$row[name_2]);
		for($i=0;$i<$table_count;$i++)
		{
			if(strcasecmp($newname,str_replace(" ","",$columnTable[$i][Name])) == 0)
			{
				$l1_sub_table_id=$i;
				break;
			}
		}
		
		//get last table sub_table_id
		$tableName=str_replace(" ","",$newname);
		$oid=trim(findRelationOid($tableName,TABLE_ENTRIES,$sysTypeNo));
		$lastdotpos=strrpos($oid,".");
		$newoid=substr($oid,0,$lastdotpos);
		$where=getLevelWhere($newoid);
		$sql="select name_2 from OBJ_{$sysTypeNo}.paramConf where $where ";
		$res=@mysqli_query($objDbConn,$sql);
		$row=@mysqli_fetch_array($res);
		$newname=str_replace("Entry","",$row[name_2]);
		for($i=0;$i<$table_count;$i++)
		{
			if(strcasecmp($newname,str_replace(" ","",$columnTable[$i][Name])) == 0)
			{
				$l2_sub_table_id=$i;
				break;
			}
		}
		
		if($type == "show")
		{
			echo "<b><a href=\"param_show_table.php?sysId=$sysId&table_id=$table_id&sub_table_id=$l2_sub_table_id&table_level=1&instanceNo=0000\">";
			echo "{$columnTable[$l2_sub_table_id][ShowName]}";
			echo "</a></b>";
			
			echo "&nbsp;";
			
			$tmp=explode(".",$instanceNo);
			echo "<b><a href=\"param_edit.php?sysId=$sysId&table_id=$table_id&sub_table_id=$l2_sub_table_id&table_level=1&instanceNo={$tmp[0]}\">";
			echo ($tmp[0]+0);
			echo "</a></b>";
			
			echo "&nbsp;>&nbsp;";
			
			echo "<b><a href=\"param_show_table.php?sysId=$sysId&table_id=$table_id&sub_table_id=$l1_sub_table_id&table_level=2&instanceNo={$tmp[0]}\">";
			echo "{$columnTable[$l1_sub_table_id][ShowName]}";
			echo "</a></b>";
			
			echo "&nbsp;";
			
			echo "<b><a href=\"param_edit.php?sysId=$sysId&table_id=$table_id&sub_table_id=$l1_sub_table_id&table_level=2&instanceNo={$instanceNo}\">";
			echo ($tmp[1]+0);
			echo "</a></b>";
			
			echo "&nbsp;>&nbsp;";
			
			echo "<b>";
			echo "{$columnTable[$sub_table_id][ShowName]}";
			echo "</b>";
		}
		else if($type == "edit")
		{
			echo "<b><a href=\"param_show_table.php?sysId=$sysId&table_id=$table_id&sub_table_id=$l2_sub_table_id&table_level=1&instanceNo=0000\">";
			echo "{$columnTable[$l2_sub_table_id][ShowName]}";
			echo "</a></b>";
			
			echo "&nbsp;";
			
			$tmp=explode(".",$instanceNo);
			echo "<b><a href=\"param_edit.php?sysId=$sysId&table_id=$table_id&sub_table_id=$l2_sub_table_id&table_level=1&instanceNo={$tmp[0]}\">";
			echo ($tmp[0]+0);
			echo "</a></b>";
			
			echo "&nbsp;>&nbsp;";
			
			echo "<b><a href=\"param_show_table.php?sysId=$sysId&table_id=$table_id&sub_table_id=$l1_sub_table_id&table_level=2&instanceNo={$tmp[0]}\">";
			echo "{$columnTable[$l1_sub_table_id][ShowName]}";
			echo "</a></b>";
			
			echo "&nbsp;";
			
			echo "<b><a href=\"param_edit.php?sysId=$sysId&table_id=$table_id&sub_table_id=$l1_sub_table_id&table_level=2&instanceNo={$tmp[0]}.{$tmp[1]}\">";
			echo ($tmp[1]+0);
			echo "</a></b>";
			
			echo "&nbsp;>&nbsp;";
			
			echo "<b><a href=\"param_show_table.php?sysId=$sysId&table_id=$table_id&sub_table_id=$sub_table_id&table_level=3&instanceNo={$tmp[0]}.{$tmp[1]}\">";
			echo "{$columnTable[$sub_table_id][ShowName]}";
			echo "</a></b>";
			
			echo "&nbsp;";
			
			echo "<b>";
			echo ($tmp[2]+0);
			echo "</b>";
		}
		else
		{
			echo "<b><a href=\"param_show_table.php?sysId=$sysId&table_id=$table_id&sub_table_id=$l2_sub_table_id&table_level=1&instanceNo=0000\">";
			echo "{$columnTable[$l2_sub_table_id][ShowName]}";
			echo "</a></b>";
			
			echo "&nbsp;";
			
			$tmp=explode(".",$instanceNo);
			echo "<b><a href=\"param_edit.php?sysId=$sysId&table_id=$table_id&sub_table_id=$l2_sub_table_id&table_level=1&instanceNo={$tmp[0]}\">";
			echo ($tmp[0]+0);
			echo "</a></b>";
			
			echo "&nbsp;>&nbsp;";
			
			echo "<b><a href=\"param_show_table.php?sysId=$sysId&table_id=$table_id&sub_table_id=$l1_sub_table_id&table_level=2&instanceNo={$tmp[0]}\">";
			echo "{$columnTable[$l1_sub_table_id][ShowName]}";
			echo "</a></b>";
			
			echo "&nbsp;";
			
			echo "<b><a href=\"param_edit.php?sysId=$sysId&table_id=$table_id&sub_table_id=$l1_sub_table_id&table_level=2&instanceNo={$tmp[0]}.{$tmp[1]}\">";
			echo ($tmp[1]+0);
			echo "</a></b>";
			
			echo "&nbsp;>&nbsp;";
			
			echo "<b><a href=\"param_show_table.php?sysId=$sysId&table_id=$table_id&sub_table_id=$sub_table_id&table_level=3&instanceNo={$tmp[0]}.{$tmp[1]}\">";
			echo "{$columnTable[$sub_table_id][ShowName]}";
			echo "</a></b>";
		}
	}
	
	//echo "l1_sub_table_id=$l1_sub_table_id,l2_sub_table_id=$l2_sub_table_id<br>";
	
	
}

function getParamValue($sysId,$oid,$instanceNo)
{
	global $objDbConn;
	$sysIdArr=explode('_',$sysId);
	$sysTypeNo=$sysIdArr[0];
	$sysNo=$sysIdArr[1];
	$subSysNo=$sysIdArr[2];
	$objDb='OBJ_'.$sysTypeNo;
	$paraConfTable=$objDb.'.paramConf';
	
	
	
	if(checkIndependSystem($sysTypeNo))//Plat
		$paraTable=$objDb.".param_".$sysNo;
	else
		$paraTable=$objDb.".param_99";
	$oidWhere=getLevelWhere($oid);	
		
	if(strstr($instanceNo,"."))
		$sql="select initValue from $paraTable where $oidWhere and instanceNo='$instanceNo' ";
	else
		$sql="select initValue from $paraTable where $oidWhere and instanceNo=$instanceNo ";

	if(checkPlatWhoHaveSubSysNo($sysTypeNo,$sysNo))
		$sql.="and subSysNo='$subSysNo' ";
		
	$res=@mysqli_query($objDbConn,$sql);
	$num=mysqli_num_rows($res);
	if($num == 0)
		return "--";
		
	$row=@mysqli_fetch_array($res);
	$originalValue=$row[initValue];
	
	return $originalValue;
}
function DeleteSubTableData($sysTypeNo,$instanceNo,$tableOid,$paraTable)
{	
	global $objDbConn;
	//echo "DeleteSubTableData($sysTypeNo,$instanceNo,$tableOid,$paraTable)<br>";
	$where=getLevelWhere($tableOid);
	$sql="delete from $paraTable where $where and instanceNo like '{$instanceNo}%'";
	@mysqli_query($objDbConn,$sql);
	//echo "$sql";
	$where=getLevelWhere($tableOid);
	$table="OBJ_{$sysTypeNo}.paramConf";
	$sql="select * from $table where name_2 like '%Entries' and $where ";
	$res=@mysqli_query($objDbConn,$sql);
	$num=mysqli_num_rows($res);
	for($i=0;$i<$num;$i++)
	{
		$row=@mysqli_fetch_array($res);
		$entriesName=$row[name_2];
		$len=strlen($entriesName);
		for($j=0;$j<$len;$j++)
		{
			if($entriesName[$j]<'a'||$entriesName[$j]>'z')
				break;
		}
		$entriesName=substr($entriesName,$j);
		$entriesName=str_replace("Entries","",$entriesName);
		$entryoid=findRelationOid($entriesName,TABLE_ENTRY,$sysTypeNo);
		
		DeleteSubTableData($sysTypeNo,$instanceNo,$entryoid,$paraTable);
	}
}
function GetAllRowData($singleTabInfo,$paraTable,$instanceNo,$sysId)
{
	global $pubConn,$objDbConn;
	if (isset($sysId))
	{

		$sysIdArr=explode('_',$sysId);
		$sysTypeNo=$sysIdArr[0];
		$sysNo=$sysIdArr[1];
		$subSysNo=$sysIdArr[2];
	//	echo "sysTypeNo=$subSysNo<br>";

	}
		// echo "<pre>";
		// print_r($singleTabInfo);
		// echo "</pre>";
		//echo "$singleTabInfo,$paraTable,$instanceNo";
	if($singleTabInfo[TableLevel] == 1)
		$instanceCond=" LENGTH(instanceNo)=4 ";
	else if($singleTabInfo[TableLevel] == 2)
		$instanceCond=" LENGTH(instanceNo)=9 and instanceNo like '{$instanceNo}.%' ";
	else if($singleTabInfo[TableLevel] == 3)
		$instanceCond=" LENGTH(instanceNo)=14 and instanceNo like '{$instanceNo}.%' ";
	
	$oidwhere=getLevelWhere($singleTabInfo[TableEntryOID]);
	
	$sql="select * from $paraTable where $oidwhere and {$instanceCond} ";
	//echo "checkPlatWhoHaveSubSysNo($sysTypeNo,$sysNo)";
	if(checkPlatWhoHaveSubSysNo($sysTypeNo,$sysNo))
	{
		$sql.=" AND subSysNo='$subSysNo' ";
	}	
		//echo "SSS=$sql<br>";

	$res=@mysqli_query($objDbConn,$sql);
	$num=@mysqli_num_rows($res);
	for($i=0;$i<$num;$i++)
	{
		$row=@mysqli_fetch_array($res);
		$oid=getOIDByRow($row);
		$fieldIndex=sizeof(explode(".",$oid));
		$fieldPos=$row["level_".$fieldIndex]+0;
		$instanceValue=substr($row[instanceNo],strlen($row[instanceNo])-4,4)+0;
		$showObject[$instanceValue][$fieldPos]=$row[initValue];
	}


	return $showObject;
}
define(GET_OID,0);
define(SCALAR_ITEM_OID,1);
function GetAllOIDArr($sysTypeNo,$get_type=0)
{
	global $objDbConn;
	$tabConf=GetTabConf($sysTypeNo);
	if(0)
	{
		echo "<pre>";
		print_r($tabConf);
		echo "</pre>";
	}
	$tab_id_count=sizeof($tabConf);
	for($table_id=0;$table_id<$tab_id_count;$table_id++)
	{
		$tableOid=$tabConf[$table_id][OID];
		//Get the sub oid of the table
		$oidwhere=getLevelWhere($tableOid);
		$size=sizeof(explode(".",$tableOid));
		$oidwhere.=" AND level_".($size+1).">0 ";
		$lastlevel="level_".($size+2);
		$sql="select * from OBJ_{$sysTypeNo}.paramConf where $oidwhere order by level_1,level_2,level_3,level_4,level_5,level_6,level_7,level_8,level_9,level_10 ";
		//echo "$sql<br>";
		$res=@mysqli_query($objDbConn,$sql);
		$num=@mysqli_num_rows($res);
		
		$scalarTableIndex=0;
		$columnTableIndex=0;
		$scalarItemIndex=0;
		for($i=0;$i<$num;$i++)
		{
			$row=@mysqli_fetch_array($res);
			if($row[$lastlevel] == 0)
			{
				//scalar table
				if($row[maxAccess] == ACCESS_TABLE_NAME && $row[operType] == 2)
				{
					$scalarTableIndex++;
				}
				//column table
				else if($row[maxAccess] == ACCESS_ENTRY && strstr($row[name_2],"Table"))
				{
					//only get the top two level table
					$tmpoid=getOIDByRow($row).".1";
					$tablelevel=getTableLevel($tmpoid,$sysTypeNo);
					if($tablelevel < 3)
						$oidArr[]=$tmpoid;	
					$columnTableIndex++;
				}
				//scalar item
				else
				{
					$scalarItemIndex++;
					if(stristr($row[name_2],"Command"))
						continue;
					if($row[maxAccess] == ACCESS_ENTRY)
						continue;
					if(strstr($row['desc_2'],"Hidden Parameter"))
						continue;
					$tmpss=getOIDByRow($row);
					$oidArr[]=$tmpss;
					$scalar_oids[]=$tmpss;
				}
			}
		}
	}
	
	if($get_type == SCALAR_ITEM_OID)
		return $scalar_oids;
	else
		return $oidArr;
}
/*
	This function is for the special issue of getting msc timeslot
	Get the timeslot parameter from plat which the Group ID specify in trunk
*/
function GetTrunkGroupID($tgno,$trunkno)
{
	global $OMC_server;
	$objDbConn = mysqli_connect($OMC_server[0]['host'],$OMC_server[0]['user'],$OMC_server[0]['password'], 'OBJ_'.$sysTypeNo);
	
	$trunk_table_oid=GetOIDByName(SYSTYPENO_MSC,"trunkEntry");
	
	$tgno_w=omc_keep_length($tgno,"0",4);
	$trunkno_w=omc_keep_length($trunkno,"0",4);
	$instance=$tgno_w.".".$trunkno_w;
	
	oidSysCommSend("320_99_99", 0, $trunk_table_oid, -1, $instance);
	
	$trunkGroupID_oid=GetOIDByName(SYSTYPENO_MSC,"trunkGroupID");
	$oidWhere=getLevelWhere($trunkGroupID_oid);
	
	$sql="select * from OBJ_320.param_99 where $oidWhere and instanceNo= '$instance' ";
	$res=@mysqli_query($objDbConn,$sql);
	$row=@mysqli_fetch_array($res);
	$value=$row[readValue]+0;
	
	return $value;
}
function BubbleOrder($showObject,$order,$ascFlag)
{

	//bubble order
	$objectCount=sizeof($showObject);
	if($objectCount == 0)
		return $showObject;
	$instance_list_num=0;
	foreach($showObject as $instance => $obj)
	{
		//echo "instance_list_num=$instance<br>";
		$instance_list[]=$instance;
		$instance_list_num++;


	}

	for($i=0;$i<$instance_list_num;$i++)
	{
		for($j=$i;$j<$instance_list_num;$j++)
		{
			$index1=$instance_list[$i];
			$index2=$instance_list[$j];
			if($ascFlag)
			{
				if($showObject[$index1][$order] > $showObject[$index2][$order])
				{
					//echo "$order index1=$index1,{$showObject[$index1][$order]},index2=$index2,{$showObject[$index2][$order]}<br>";
					$tmp=$showObject[$index1];
					$showObject[$index1]=$showObject[$index2];
					$showObject[$index2]=$tmp;
				}
			}
			else
			{
				if($showObject[$index1][$order] < $showObject[$index2][$order])
				{
					//echo "$order index1=$index1,{$showObject[$index1][$order]},index2=$index2,{$showObject[$index2][$order]}<br>";
					$tmp=$showObject[$index1];
					$showObject[$index1]=$showObject[$index2];
					$showObject[$index2]=$tmp;
				}
			}
		}
	}

	return $showObject;
}

function InitTab($sysTypeNo)
{
	echo "\n<script language=\"JavaScript\">\n";
	echo "var tab_count=0;\n";
	echo "var tab_len=new Array();\n";
	echo "var tab_start=0;\n";
	echo "var tab_sel=0;\n";
	echo "function mouseovertab(itemid)\n";
	echo "{\n";
	echo "document.getElementById(itemid).style.color='#0000ff';\n";
	echo "}\n";
	
	echo "function mouseouttab(itemid)\n";
	echo "{\n";
	echo "document.getElementById(itemid).style.color='#000000';\n";
	echo "}\n";
	
	echo "function clicktab(itemid)\n";
	echo "{\n";
	echo "var sysId=document.selectform.system_id_select.value;\n";
	//echo "tab_sel=itemid;\n";
	//echo "alert(itemid);\n";
	echo "adjust_tab(itemid);\n";
	echo "parent.param_show_table.location.href='./param_show_table.php?table_id='+itemid+'&sysId='+sysId+'&instanceNo=0000&table_level=1';\n";
	
	echo "return;\n";
	echo "}\n";
	
	echo "function adjust_firefox()\n";
	echo "{\n";
	echo "var browserr=navigator.appName;\n";
	echo "if(browserr != 'Microsoft Internet Explorer')\n";
	echo "{\n";
	echo "for(i=0;i<tab_count;i++)\n";
	echo "{\n";
	echo "document.getElementById(i).style.top='41px';\n";
	echo "document.getElementById('ano_'+i).style.top='41px';\n";
	echo "}\n";
	echo "document.getElementById('left_id').style.top='41px';\n";
	echo "document.getElementById('right_id').style.top='41px';\n";
	echo "document.getElementById('left_id').style.height='28px';\n";
	echo "document.getElementById('right_id'),style.height='28px';\n";
	echo "}\n";
	echo "}\n";

	echo "function left_tab()\n";
	echo "{\n";
	echo "if(tab_start == 0)\n";
	echo "return;\n";
	echo "tab_start--;\n";
	echo "adjust_tab(tab_sel);\n";
	echo "}\n";
	
	echo "function right_tab()\n";
	echo "{\n";
	echo "if(tab_start == tab_count)\n";
	echo "return;\n";
	echo "tab_start++;\n";
	echo "adjust_tab(tab_sel);\n";
	echo "}\n";
	
	echo "function adjust_tab(itemid)\n";
	echo "{\n";	
	echo "var total_width=document.getElementById('img_up').width+10;\n";
	echo "var cur_width=0;\n";
	echo "var left_width;\n";
	echo "var hasRight=0;\n";
	
	echo "if(tab_sel != null)\n";
	echo "{\n";
	//echo "alert(document.getElementById(tab_sel));\n";
	echo "document.getElementById(tab_sel).style.zIndex=tab_sel;\n";
	echo "document.getElementById('ano_'+tab_sel).style.zIndex=tab_sel;\n";
	echo "}\n";
	
	echo "if(itemid == -1)\n";
	echo "itemid=tab_sel;\n";
	echo "tab_sel=itemid;\n";
	echo "document.getElementById(tab_sel).style.zIndex=1000;\n";
	echo "document.getElementById('ano_'+tab_sel).style.zIndex=1000;\n";
	echo "for(i=0;i<tab_count;i++)\n";
	echo "{\n";
	echo "document.getElementById(i).style.display='none';\n";
	echo "document.getElementById('ano_'+i).style.display='none';\n";
	echo "}\n";
	echo "if(tab_start>0)\n";
	echo "{\n";
	echo "document.getElementById('left_id').style.display='';\n";
	echo "left_width=20;\n";
	echo "}\n";
	echo "else\n";
	echo "{\n";
	echo "document.getElementById('left_id').style.display='none';\n";
	echo "left_width=0;\n";
	echo "}\n";
	echo "cur_width=left_width;\n";
	
	echo "for(i=tab_start;i<tab_count;i++)\n";
	echo "{\n";
	echo "if(cur_width + tab_len[i] > total_width+30)\n";
	echo "{\n";
	echo "hasRight=1;\n";
	echo "break;\n";
	echo "}\n";
	echo "cur_width+=tab_len[i];\n";
	echo "}\n";
	echo "if(tab_sel>=tab_start && tab_sel<i)\n";
	echo "{\n";
	echo "document.getElementById(tab_sel).style.display='none';\n";
	echo "document.getElementById('ano_'+tab_sel).style.display='';\n";
	echo "}\n";
	echo "cur_width=left_width;\n";
	echo "for(i=tab_start;i<tab_count;i++)\n";
	echo "{\n";
	echo "if(cur_width + tab_len[i] > total_width+30)\n";
	echo "break;\n";
	echo "document.getElementById(i).style.display='';\n";
	echo "if(i>tab_start)\n";
	echo "{\n";
	echo "document.getElementById(i).style.left=(cur_width-16*(i-tab_start))+'px';\n";
	echo "document.getElementById('ano_'+i).style.left=(cur_width-16*(i-tab_start))+'px';\n";
	echo "}\n";
	echo "else\n";
	echo "{\n";
	echo "document.getElementById(i).style.left=cur_width+'px';\n";
	echo "document.getElementById('ano_'+i).style.left=cur_width+'px';\n";
	echo "}\n";
	echo "cur_width+=tab_len[i];\n";
	echo "}\n";
	echo "if(hasRight == 1)\n";
	echo "{\n";
	echo "document.getElementById('right_id').style.display='';\n";
	echo "document.getElementById('right_id').style.left=(total_width-47)+'px';\n";
	echo "}\n";
	echo "else\n";
	echo "{\n";
	echo "document.getElementById('right_id').style.display='none';\n";
	echo "document.getElementById('right_id').style.left=(total_width-47)+'px';\n";
	echo "}\n";
	echo "}\n";
	
	echo "</script>\n";
}
$previous_left=20;
function AddTab($id,$value,$lable,$image_1,$image_2,$imageWidth,$imageHeight)
{
	global $previous_left;
	echo "<span ";
	echo "onmouseover=\"javascript:mouseovertab('$id');\" ";
	echo "onmouseout=\"javascript:mouseouttab('$id');\" ";
	echo "onclick=\"javascript:clicktab('$id');\" ";
	echo "id=\"$id\" ";
	$z=100+$id*5;
	$imagedir="./images/";
	
	$chrlen=strlen($lable)+1;
	$lable="&nbsp;".$lable;
	$imageheight=17;
	if($chrlen <= 4)
	{
		$imagefile1=$imagedir."tab_dark_4.gif";
		$imagefile2=$imagedir."tab_light_4.gif";
		$imagewidth=68;
	}
	else if($chrlen <= 10)
	{
		$imagefile1=$imagedir."tab_dark_8.gif";
		$imagefile2=$imagedir."tab_light_8.gif";
		$imagewidth=98;
	}
	else if($chrlen <= 16)
	{
		$imagefile1=$imagedir."tab_dark_12.gif";
		$imagefile2=$imagedir."tab_light_12.gif";
		$imagewidth=133;
	}
	else if($chrlen <= 22)
	{
		$imagefile1=$imagedir."tab_dark_16.gif";
		$imagefile2=$imagedir."tab_light_16.gif";
		$imagewidth=170;
	}
	else if($chrlen <= 28)
	{
		$imagefile1=$imagedir."tab_dark_20.gif";
		$imagefile2=$imagedir."tab_light_20.gif";
		$imagewidth=206;
	}
	else if($chrlen <= 34)
	{
		$imagefile1=$imagedir."tab_dark_24.gif";
		$imagefile2=$imagedir."tab_light_24.gif";
		$imagewidth=243;
	}
	else
	{
		$lable=substr($lable,0,34);
		$imagefile1=$imagedir."tab_dark_24.gif";
		$imagefile2=$imagedir."tab_light_24.gif";
		$imagewidth=243;
	}
	
	$left=$previous_left;

	echo "style=\"FILTER:chroma(color:#ffffff);z-index:{$z};";
	echo "background-repeat:no-repeat;";
	echo "position:absolute;top:36px;left:{$left}px;width:{$imagewidth}px;height:{$imageheight}px;";
	echo "background-image:url({$imagefile2});";
	echo "white-space:nowrap;cursor:hand;color:black;padding:4px;\">";
	echo "{$lable}</span>";
	
	echo "<span id=\"ano_{$id}\" ";
	$z=100+$id*5;
	$left=$previous_left;
	$previous_left=$previous_left+$imagewidth-16;
	echo "style=\"FILTER:chroma(color:#ffffff);z-index:{$z};";

	echo "background-repeat:no-repeat;";
	echo "display:none;";
	echo "position:absolute;top:36px;left:{$left}px;width:{$imagewidth}px;height:{$imageheight}px;";
	echo "background-image:url({$imagefile1});";
	echo "white-space:nowrap;cursor:hand;color:black;padding:4px;\">";
	echo "{$lable}</span>";
	
	echo "\n<script language=\"JavaScript\">\n";
	echo "tab_len[tab_count]=$imagewidth;\n";
	echo "tab_count++;\n";
	echo "</script>\n";
}

?>
