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

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

$PARAM_OID_PREFIX="2";
define(MAX_SHOW_ROW_NUM,4);

define(UNKNOWN_TYPE,-1);
define(LEAF_TYPE,0);
define(SCALAR_TABLE_TYPE,1);
define(COLUMN_TABLE_TYPE,2);
define(ENTRY_TYPE,3);

$type_label=array(-1=>"unknown",0=>"LEAF_TYPE",1=>"SCALAR_TABLE_TYPE",2=>"COLUMN_TABLE_TYPE",3=>"ENTRY_TYPE");

//access
define(ACCESS_TABLE_NAME,0);
define(ACCESS_ENTRY,21);
define(ACCESS_READ_WRITE,19);
define(ACCESS_READ_ONLY,18);
define(ACCESS_INDEX_CREATE_SPE,48);

//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);

//style
define(SHOW_HIDE,0);
define(SHOW_SELECT,1);
define(SHOW_TEXTBOX,2);
define(SHOW_LABEL,3);

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

//nest table element
define(TABLE_ENTRY,0);
define(TABLE_ENTRIES,1);
define(TABLE_CREATE,2);

//sysTypeNo
define(SYSTYPENO_MSC,320);
define(SYSTYPENO_SMSC,350);
define(SYSTYPENO_SMPP,260);
define(SYSTYPENO_OPPS,375);
define(SYSTYPENO_PPS,360);
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_IUUPGW,389);
function showTable($oids)
{
	global $paraConfTable,$paraTable,$keyId,$objects;
	
	$objects[$keyId]["oid"]=$oids;
	$oidLevel=getLevel($oids);
	//echo "oidLevel=$oidLevel<br>";
	$sql="select * from $paraConfTable where $oidLevel 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($pubConn,$sql);
	$num=@mysqli_num_rows($res);
	$tmpKeyId=$keyId;
	if($num != 0)
	{
		$row=@mysqli_fetch_array($res);
		$objects[$keyId]["name_1"]=$row[name_1];
		$objects[$keyId]["name_2"]=$row[name_2];
		//if(!strstr($objects[$keyId]["name_1"],"Table") && !strstr($objects[$keyId]["name_1"],"Entry"))
			$objects[$keyId]["nest_num"]=$num-1;
		$objects[$keyId]["type"]=-1;	
		$objects[$keyId]["maxAccess"]=$row[maxAccess]+0;
		$objects[$keyId]["desc_1"]=$row[desc_1];
		$objects[$keyId]["valueType"]=$row[valueType]+0;
		$objects[$keyId]["setTemplate_1"]=$row[setTemplate_1];
		$objects[$keyId]["note_1"]=$row[note_1];
		$objects[$keyId]["style"]=$row[operType]+0;
		if(strstr($objects[$keyId]["name_1"],"Entry"))
			$objects[$keyId]["type"]=ENTRY_TYPE;
		
			
	}
	//nest
	if($num > 1)
	{
		$keyId++;
		
		$isTableExsit=0;
		$isEntryExsit=0;
		do
		{
			if(strstr($row[name_1],"Table"))
				$isTableExsit=1;
			if(strstr($row[name_1],"Entry"))
				$isEntryExsit=1;
			$nextOids="";
			for($i=1;$i<=10;$i++)
			{
				$level="level_".$i;
				if(($row[$level]+0) > 0)
					$nextOids.=".{$row[$level]}";
			}
			$nextOids=substr($nextOids,1);
			if($nextOids != $oids)
			{
				showTable($nextOids);
				//echo "<br>$nextOids<br>";
			}
		}while($row=@mysqli_fetch_array($res));
		
		if($isTableExsit && $isEntryExsit)
		{
			$objects[$tmpKeyId]["type"]=COLUMN_TABLE_TYPE;
		}
		else if($isTableExsit == 0 && $isEntryExsit == 0)
		{
			$objects[$tmpKeyId]["type"]=SCALAR_TABLE_TYPE;
		}
		
	}
	else
	{
		$objects[$keyId]["type"]=LEAF_TYPE;
		$keyId++;
	}
}


function showParamInReadOnly($keyId,$sysId)
{
	global $objects;
	
	
	$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";
	
	$oid=$objects[$keyId]['oid'];
	$oidwhere=getLevelWhere($oid);
	$sql="select initValue from $paraTable where $oidwhere and instanceNo='0000' ";
	
	if($sysTypeNo == 260 && $sysNo != 99 && $subSysNo != 99)
		$sql.="and subSysNo='$subSysNo' ";
	
	$res=@mysqli_query($pubConn,$sql);
	$num=@mysqli_num_rows($res);
	if($num != 0)
	{
		$row=@mysqli_fetch_array($res);
		$returnvalue=$row[initValue];
		if(($objects[$keyId]["style"] == SHOW_LABEL || $objects[$keyId]["style"] == SHOW_SELECT )&& $objects[$keyId]["valueType"] == VALUE_INT)
		{
			if(trim($objects[$keyId]["setTemplate_1"]) == "")
				return $returnvalue;
			$options=explode(";",$objects[$keyId]["setTemplate_1"]);
			for($ii=0;$ii<sizeof($options);$ii++)
			{
				$tmp=explode("=",$options[$ii]);
				$val=$tmp[0];
				$opt=$tmp[1];
				if($returnvalue == $opt)
					return $val;
			}
		}
	}
	else
	{
		$returnvalue="--";
	}
	
	//discard the postfix E of the opaque
	if($objects[$keyId]["valueType"] == 9)
	{
		$split=explode("[unit]",$objects[$keyId]["setTemplate_1"]);
		$len=sizeof($split);
		//only one unit
		//if($len == 2)
		{
			$split2=explode("keepHex-low-",$objects[$keyId]["setTemplate_1"]);
			$repl=substr($split2[1],0,1);
			$returnvalue=str_replace($repl," ",$returnvalue);
		}
	}
	
	if(trim($returnvalue) == "")
		$returnvalue="--";
	return $returnvalue;
}

function getLevel($objIdStr)
{
	$levelArr=explode('.',$objIdStr);
	for($j=0;$j<sizeof($levelArr);$j++){
		$levelNo=$j+1;
		${"level_$levelNo"}=$levelArr[$j];
		if($Debug) echo "<BR>levelArr[$j]={$levelArr[$j]}";
		if($j == 0){
			$levelWhere ="level_$levelNo='${"level_$levelNo"}'";
		}else{
			$levelWhere .=" AND level_$levelNo='${"level_$levelNo"}'";
		}
	}
	$levelNo+=2;
	if($levelNo<=10)
		$levelWhere.=" AND level_$levelNo=0 ";
	return($levelWhere);
}

function getParamValue($sysId,$oid,$instanceNo)
{
	$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($sysTypeNo == 260 && $sysNo != 99 && $subSysNo != 99)
		$sql.="and subSysNo='$subSysNo' ";


	$res=@mysqli_query($pubConn,$sql);
	$num=mysqli_num_rows($res);
	if($num == 0)
		return "--";
		
	$row=@mysqli_fetch_array($res);
	$originalValue=$row[initValue];
	
	return $originalValue;
}

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($keyId,$value)
{
	global $objects;
	
	$operType=$objects[$keyId]['style'];
	$valueType=$objects[$keyId]['valueType'];
	$template=$objects[$keyId]['setTemplate_1'];
	
	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;
}

function getTableNameByOid($sysId,$oid)
{
	$sysIdArr=explode('_',$sysId);
	$sysTypeNo=$sysIdArr[0];
	$sysNo=$sysIdArr[1];
	$subSysNo=$sysIdArr[2];
	$objDb='OBJ_'.$sysTypeNo;
	$paraConfTable=$objDb.'.paramConf';
	
	$oidWhere=getLevelWhere($oid);
	$sql="select name_1 from $paraConfTable where $oidWhere ";
	$res=@mysqli_query($pubConn,$sql);
	$num=mysqli_num_rows($res);
	if($num == 0)
		return "--";
	
	$row=@mysqli_fetch_array($res);
	return $row[name_1];
}

function checkTableNest($sysId,$table_oid)
{
	$sysIdArr=explode('_',$sysId);
	$sysTypeNo=$sysIdArr[0];
	$sysNo=$sysIdArr[1];
	$subSysNo=$sysIdArr[2];
	$objDb='OBJ_'.$sysTypeNo;
	$paraConfTable=$objDb.'.paramConf';
	
	$tmpwhere=getLevelWhere($table_oid);
	
	$sql="select * from $paraConfTable where $tmpwhere and name_1 like '%CreateEntry%' ";
	//echo "$sql<hr>";
	$res=@mysqli_query($pubConn,$sql);
	$num=mysqli_num_rows($res);
	if($num > 0)
		return 1;
	else
		return 0;
}

/*
	tableName: the name of the table, rountingSelection for example. case-ignored
	$type: TABLE_ENTRY, TABLE_ENTRIES, TABLE_CREATE
*/
function findRelationOid($tableName,$type,$sysTypeNo)
{
	$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_1 like '%$likestr%' ";
	//echo "<br>$sql<br>";
	$res=@mysqli_query($pubConn,$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;
}

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 showTitle($page,$tableOid,$instanceNo,$sysId,$sysTypeNo,$module_name,$table_type=1)
{
	if($page == "edit")
	{
		$tableName=getTableNameByOid($sysId,$tableOid);
		$tmp=explode("Entry",$tableName);
		$titleTableName=$tmp[0];
		//printInfo("show_table instanceNo=".$instanceNo.",tableOid=".$tableOid.",$tableName");
		$level=getTableLevel($tableOid,$sysTypeNo);
		$titlelevel=$level;
		$titleTableOid=$tableOid;
		$titleInstanceNo=$instanceNo;
		echo "<p><a href=\"param_show_down.php?tableOid=2&sysId=$sysId&instanceNo=0000&table_type=0\">";
		echo "<b>$module_name</b></a>";
		while(1)
		{
			//get table name
			$tableName=getTableNameByOid($sysId,$titleTableOid);
			//check whether it have the new name
			$clevel=getLevelWhere($titleTableOid);
			$dbtable="OBJ_".$sysTypeNo.".paramConf";
			$oidsplit=explode(".",$titleTableOid);
			$oidsize=sizeof($oidsplit)+1;
			$zerowhere=" level_$oidsize=0 ";
			$checksql="select * from $dbtable where $clevel and $zerowhere and desc_1 like '%Name:%' ";
			$checkres=@mysqli_query($pubConn,$checksql);
			$checknum=mysqli_num_rows($checkres);
			if($checknum == 1)
			{
				$checkrow=@mysqli_fetch_array($checkres);
				$new_name=explode("Name:",$checkrow[desc_1]);
				$title_new_name[$level]=str_replace(";","",$new_name[sizeof($new_name)-1]);
			}
			else
				$title_new_name[$level]="none";
			
			$tableName=str_replace("Entry","",$tableName);
			//echo "tableOid=$titleTableOid,tableName=$tableName instanceNo=$titleInstanceNo";
			//echo "<a href=\"param_show_table.php?sysId=$sysId&table_type=1&tableOid=$titleTableOid&instanceNo=$titleInstanceNo\">$tableName</a>";
			$title_oid[$level]=$titleTableOid;
			$title_name[$level]=$tableName;
			$title_instanceNo[$level]=$titleInstanceNo;
			
			$titleTableOid=findRelationOid($tableName,TABLE_ENTRIES,$sysTypeNo);
			if($titleTableOid == "")
				break;
			
			$ttmp=explode(".",$titleTableOid);
			$sizet=sizeof($ttmp)-1;
			$titleTableOid="";
			for($ti=0;$ti<$sizet;$ti++)
			{
				$titleTableOid.="{$ttmp[$ti]}.";
			}
			$titleTableOid=substr($titleTableOid,0,strlen($titleTableOid)-1);
			
			$ttmp=explode(".",$titleInstanceNo);
			$sizet=sizeof($ttmp);
			if($sizet == 1)
				$titleInstanceNo="0000";
			else
			{
				$titleInstanceNo="";
				for($ti=0;$ti<$sizet-1;$ti++)
				{
					$titleInstanceNo.="{$ttmp[$ti]}.";
				}
				$titleInstanceNo=substr($titleInstanceNo,0,strlen($titleInstanceNo)-1);
			}
			$level--;
		}
		for($index=1;$index<=$titlelevel;$index++)
		{
			if($index == 1)
				$thisinstance="0000";
			else
				$thisinstance=$title_instanceNo[$index-1];
			echo "> ";
			echo "<a href=\"param_show_table.php?sysId=$sysId&table_type=1&tableOid={$title_oid[$index]}&instanceNo={$thisinstance}\">";
			$showName=getShowNameOfTable($title_name[$index],-1);
			
			if($title_new_name[$index] != "none")
				$showName=$title_new_name[$index];
				
			echo "<b>{$showName}</b></a>";
			$thisinstance=$title_instanceNo[$index];
			$ttmp=explode(".",$thisinstance);
			$instanceShow=$ttmp[sizeof($ttmp)-1]+0;
			if($index == $titlelevel)
				echo " <b>$instanceShow</b> ";
			else
			{
				echo "<a href=\"param_edit.php?sysId=$sysId&table_type=1&tableOid={$title_oid[$index]}&instanceNo={$thisinstance}\";>";
				echo " <b>$instanceShow</b> ";
				echo "</a>";
			}
		}
		echo "<br>";
	}
	else if($page == "show")
	{
		$tableName=getTableNameByOid($sysId,$tableOid);
		$tmp=explode("Entry",$tableName);
		$titleTableName=$tmp[0];
		//printInfo("show_table instanceNo=".$instanceNo.",tableOid=".$tableOid.",$tableName");
		$level=getTableLevel($tableOid,$sysTypeNo);
		$titlelevel=$level;
		$titleTableOid=$tableOid;
		$titleInstanceNo=$instanceNo;
		echo "<p><a href=\"param_show_down.php?tableOid=2&sysId=$sysId&instanceNo=0000&table_type=0\">";
		echo "<b>$module_name</b></a>";
		while(1)
		{
			//get table name
			$tableName=getTableNameByOid($sysId,$titleTableOid);
			//check whether it have the new name
			$clevel=getLevelWhere($titleTableOid);
			$dbtable="OBJ_".$sysTypeNo.".paramConf";
			$oidsplit=explode(".",$titleTableOid);
			$oidsize=sizeof($oidsplit)+1;
			$zerowhere=" level_$oidsize=0 ";
			$checksql="select * from $dbtable where $clevel and $zerowhere and desc_1 like '%Name:%' ";
			$checkres=@mysqli_query($pubConn,$checksql);
			$checknum=mysqli_num_rows($checkres);
			if($checknum == 1)
			{
				$checkrow=@mysqli_fetch_array($checkres);
				$new_name=explode("Name:",$checkrow[desc_1]);
				$title_new_name[$level]=str_replace(";","",$new_name[sizeof($new_name)-1]);
			}
			else
				$title_new_name[$level]="none";
			
			$tableName=str_replace("Entry","",$tableName);
			//echo "tableOid=$titleTableOid,tableName=$tableName instanceNo=$titleInstanceNo";
			//echo "<a href=\"param_show_table.php?sysId=$sysId&table_type=1&tableOid=$titleTableOid&instanceNo=$titleInstanceNo\">$tableName</a>";
			$title_oid[$level]=$titleTableOid;
			$title_name[$level]=$tableName;
			$title_instanceNo[$level]=$titleInstanceNo;
			
			$titleTableOid=findRelationOid($tableName,TABLE_ENTRIES,$sysTypeNo);
			if($titleTableOid == "")
				break;
			
			$ttmp=explode(".",$titleTableOid);
			$sizet=sizeof($ttmp)-1;
			$titleTableOid="";
			for($ti=0;$ti<$sizet;$ti++)
			{
				$titleTableOid.="{$ttmp[$ti]}.";
			}
			$titleTableOid=substr($titleTableOid,0,strlen($titleTableOid)-1);
			
			$ttmp=explode(".",$titleInstanceNo);
			$sizet=sizeof($ttmp);
			if($sizet == 1)
				$titleInstanceNo="0000";
			else
			{
				$titleInstanceNo="";
				for($ti=0;$ti<$sizet-1;$ti++)
				{
					$titleInstanceNo.="{$ttmp[$ti]}.";
				}
				$titleInstanceNo=substr($titleInstanceNo,0,strlen($titleInstanceNo)-1);
			}
			$level--;
		}
		for($index=1;$index<=$titlelevel;$index++)
		{
			echo "> ";
			echo "<a href=\"param_show_table.php?sysId=$sysId&table_type=1&tableOid={$title_oid[$index]}&instanceNo={$title_instanceNo[$index]}\">";
			$showName=getShowNameOfTable($title_name[$index],-1);
			
			if($title_new_name[$index] != "none")
				$showName=$title_new_name[$index];
				
			echo "<b>{$showName}</b></a>";
			if($index == $titlelevel)
			{
				$instanceShow="";
			}
			else
			{
				$thisinstance=$title_instanceNo[$index+1];
				$ttmp=explode(".",$thisinstance);
				$instanceShow=$ttmp[sizeof($ttmp)-1]+0;
			}
			echo "<a href=\"param_edit.php?sysId=$sysId&table_type=1&tableOid={$title_oid[$index]}&instanceNo={$thisinstance}\";>";
			echo " <b>$instanceShow</b> ";
			echo "</a>";
		}
	}
}

function GetOIDByName($sysTypeNo,$name)
{
	$database="OBJ_".$sysTypeNo.".paramConf";
	$sql="select * from $database where name_2 like '%$name%' ";
	$res=@mysqli_query($pubConn,$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;
}

/*
	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)
{
	$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($pubConn,$sql);
	$row=@mysqli_fetch_array($res);
	$value=$row[readValue]+0;
	
	return $value;
}

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 PrintInfo($info)
{
	$command="echo '$info' >> /tmp/omcdebug.txt ";
	system($command);
}
?>
