<?
include("global.php3");
include($G_dir_includes . "db_function.php3");
include($G_dir_includes . "art_function.php3");
include($G_dir_language . $G_def_f_lang . ".php3");
include($G_dir_theme . $G_def_theme . "/themes.php3");
//
pg_header($G_pg_logo, $G_pg_banner, $G_pg_link, $G_pg_text);
$tmenu=get_1stmenu();
$smenu=get_2ndmenu();

if (!isset($c)) {
   $c= $G_def_cat;
   if (isset($a)) {
      $sql="SELECT catalog_id FROM db_content WHERE content_id='$a'";
      $result = db_exec($G_db_base,$sql);
	  $catalogsets = mysql_fetch_array($result);
      $catalogid = $catalogsets['catalog_id'];
      $sql="SELECT catalog_id FROM db_catalog where catalog_id='$catalogid' and approve='Y'";
      $result = db_exec($G_db_base,$sql);
      if (mysql_num_rows($result)) {      
          $calalogid = mysql_fetch_array($result);
          $c = $calalogid['catalog_id'];
	  } else {
          $c= $G_def_cat;	  
	  }
   }
}
pg_menu($tmenu,$smenu,$c);
include("sidefunction.php3");
pg_content_s();
//
function change_value($style,$content) {
   global $G_url_image;
   $cdt = explode(" ",$content['create_date']);
   $mdt = explode(" ",$content['modify_date']);
   $style = ereg_replace ("#CREATEDATE#", $cdt[0],$style);
   $style = ereg_replace ("#MODIFTYDATE#", $mdt[0],$style);
   $style = ereg_replace ("#CREATETIME#", $cdt[1],$style);
   $style = ereg_replace ("#MODIFTTIME#", $mdt[1],$style);
   $style = ereg_replace ("#CREATEDATETIME#", $content['create_date'],$style);
   $style = ereg_replace ("#MODIFTYDATETIME#", $content['modify_date'],$style);
   $style = ereg_replace ("#SECTIONSNAME#", $content['catalog_txt'],$style);
   $style = ereg_replace ("#SECTIONLNAME#", $content['catalog_title'],$style);
   $style = ereg_replace ("#ARTICLEID#", $content['content_id'],$style);
   $style = ereg_replace ("#SECTIONID#", $content['catalog_id'],$style);
   for ($i=1;$i<=10;$i++) {
      $f = sprintf('%02d', $i);
      $t = "txt_".$f;
      $tt = "p_txt_".$f;
      if ($content[$tt]=="Y") {
         $style = ereg_replace ("#TEXT$f#", $content[$t],$style);
      } else {
         $style = ereg_replace ("#TEXT$f#", nl2br($content[$t]),$style);
      }
      $s = "img_".$f;
      if ($content[$s]=="") {
         $style = ereg_replace ("#MEDIA$f#", $G_url_image."/bk.gif",$style);
      } else {
         $style = ereg_replace ("#MEDIA$f#", $G_url_image."/".$content[$s],$style);
      }
      $z = "zim_".$f;
      $zz = "img_".$f;
      if ($content[$z]=="") {
         $style = ereg_replace ("#RELATE$f#", $G_url_image."/".$content[$zz],$style);
      } else {
         $style = ereg_replace ("#RELATE$f#", $G_url_image."/".$content[$z],$style);
      }
   }
   return $style;
}
//
if (!isset($a)) { // No Articel ID so try to create index view
   $sql="SELECT db_content.*, db_catalog.catalog_txt,db_catalog.catalog_title
         FROM db_catalog, db_content
         WHERE (db_content.catalog_id=db_catalog.catalog_id) and (db_content.catalog_id='$c') and (db_content.approve='Y') limit 0,2";
   $dbresult=db_exec($G_db_base,$sql);
   if (mysql_num_rows($dbresult)==1) {
      // Only one Articel found so display it with style for article
      $content=mysql_fetch_array($dbresult);
      $sql = "select * from db_style where style_id='".$content['style_id']."'";
      $stresult = db_exec($G_db_base,$sql);
      $styleset = mysql_fetch_array($stresult);
      $prestr = $styleset['style_details'];
      $outstr=explode("\n",$prestr);
      // Process Display Style
      for ($i=0;$i<count($outstr);$i++) {
         if ((strstr($outstr[$i],"<!--|PAYPAL_ADD_CART_BTN|-->"))) {
            $spos = strpos($outstr[$i],"<!--|PAYPAL_ADD_CART_BTN|-->");
		    $epos = 28;
		    $newstr = dsp_paypal_add_cart_btn($content);
		    $outstr[$i] = ereg_replace("<!--\|PAYPAL_ADD_CART_BTN\|-->",$newstr,$outstr[$i]);
	 }      
         if ((strstr($outstr[$i],"<!--|PAYPAL_VIEW_CART_BTN|-->"))) {
            $spos = strpos($outstr[$i],"<!--|PAYPAL_VIEW_CART_BTN|-->");
		    $epos = 29;
		    $newstr = dsp_paypal_view_cart_btn();
		    $outstr[$i] = ereg_replace("<!--\|PAYPAL_VIEW_CART_BTN\|-->",$newstr,$outstr[$i]);
	 }     
         if ((strstr($outstr[$i],"<!--|TITLEBAR|"))&&(strstr($outstr[$i],"|-->"))) {
            $spos = strpos($outstr[$i],"<!--|TITLEBAR|");
            $epos = strpos($outstr[$i],"|-->");
            $opts = substr($outstr[$i],$spos+14,$epos-($spos+14));
            $newstr = dsp_titlebar($opts);
            $opts = ereg_replace ("\(","\\(",$opts);
            $opts = ereg_replace ("\)","\\)",$opts);
            $outstr[$i] = ereg_replace("<!--\|TITLEBAR\|".$opts."\|-->",$newstr,$outstr[$i]);
         }
         if (strstr($outstr[$i],"<!--|GOSECTION|-->")) {
            $newstr = dsp_gosection();
            $outstr[$i] = ereg_replace("<!--\|GOSECTION\|-->",$newstr,$outstr[$i]);
         }
         if ((strstr($outstr[$i],"<!--|BOXOPEN|"))&&(strstr($outstr[$i],"|-->"))) {
            $spos = strpos($outstr[$i],"<!--|BOXOPEN|");
            $epos = strpos($outstr[$i],"|-->");
            $opts = substr($outstr[$i],$spos+13,$epos-($spos+13));
            $newstr = dsp_boxopen($opts);
            $outstr[$i] = ereg_replace("<!--\|BOXOPEN\|".$opts."\|-->",$newstr,$outstr[$i]);
         }
         if (strstr($outstr[$i],"<!--|BOXCLOSE|-->")) {
            $newstr = dsp_boxclose();
            $outstr[$i] = ereg_replace("<!--\|BOXCLOSE\|-->",$newstr,$outstr[$i]);
         }
      } // end for Process Display Style
      // Change value tag with values in record
      for ($i=0;$i<count($outstr);$i++) {
         $stylecontent = $outstr[$i];
         $output = change_value($stylecontent,$content);
         echo $output;
      }
   } else {  // Articel Count > 1 start
      $recflag = mysql_num_rows($dbresult);
      // More Then One Article found so use catalog index style to display
      $sql = "Select * from db_catalog where catalog_id='$c'";  // Get Section Default Style
      $result = db_exec($G_db_base,$sql);
      $res = mysql_fetch_array($result);
      $sql = "select * from db_style where style_id='".$res['style_id']."'"; // Get idx Style Detail
      $result = db_exec($G_db_base,$sql);
      $styset = mysql_fetch_array($result);
      if ($styset['style_details']!="") { // HTML Style present so process it
         $outstr=explode("\n",$styset['style_details']);
         $headerstart=-999;
         $headerstop=-999;
         $bodystart=-999;
         $bodystop=-999;
         $listperpage=-999;
         $listperrow=-999;
         $getchild=-999;
         $orderby_field=-999;
         $orderby_da=-999;
         for ($i=0;$i<count($outstr);$i++) { // Replace MACRO with sutable code define in style
            if ((strstr($outstr[$i],"<!--|TITLEBAR|"))&&(strstr($outstr[$i],"|-->"))) {
               $spos = strpos($outstr[$i],"<!--|TITLEBAR|");
               $epos = strpos($outstr[$i],"|-->");
               $opts = substr($outstr[$i],$spos+14,$epos-($spos+14));
               $newstr = dsp_titlebar($opts);
               $opts = ereg_replace ("\(","\\(",$opts);
               $opts = ereg_replace ("\)","\\)",$opts);
               $outstr[$i] = ereg_replace("<!--\|TITLEBAR\|".$opts."\|-->",$newstr,$outstr[$i]);
               //echo "Find Titlebar : $opts<hr>";
               //echo htmlspecialchars($outstr[$i])."<hr>";
            }
            if (strstr($outstr[$i],"<!--|GOSECTION|-->")) {
               $newstr = dsp_gosection();
               $outstr[$i] = ereg_replace("<!--\|GOSECTION\|-->",$newstr,$outstr[$i]);
               // echo "Find gosection<hr>";
               // echo htmlspecialchars($outstr[$i])."<hr>";
            }
            if ((strstr($outstr[$i],"<!--|BOXOPEN|"))&&(strstr($outstr[$i],"|-->"))) {
               $spos = strpos($outstr[$i],"<!--|BOXOPEN|");
               $epos = strpos($outstr[$i],"|-->");
               $opts = substr($outstr[$i],$spos+13,$epos-($spos+13));
               $newstr = dsp_boxopen($opts);
               $outstr[$i] = ereg_replace("<!--\|BOXOPEN\|".$opts."\|-->",$newstr,$outstr[$i]);
               // echo "Find BoxOpen : $opts<hr>";
               // echo htmlspecialchars($outstr[$i])."<hr>";
            }
            if (strstr($outstr[$i],"<!--|BOXCLOSE|-->")) {
               $newstr = dsp_boxclose();
               $outstr[$i] = ereg_replace("<!--\|BOXCLOSE\|-->",$newstr,$outstr[$i]);
	       // echo "Find BoxClose<hr>";
               // echo htmlspecialchars($outstr[$i])."<hr>";
            }
            // Index Page Function
            //goarticle
            if (strstr($outstr[$i],"<!--|GOARTICLE|-->")) {
               $newstr = dsp_goarticle($c);
               $outstr[$i] = ereg_replace("<!--\|GOARTICLE\|-->",$newstr,$outstr[$i]);
               // echo "Find GoArticle<hr>";
               // echo htmlspecialchars($outstr[$i])."<hr>";
            }
            //headerstart
            if (strstr($outstr[$i],"<!--|HEADERSTART|-->")) {
               $headerstart=$i;
               $outstr[$i] = ereg_replace("<!--\|HEADERSTART\|-->","",$outstr[$i]);
               // echo "Find HeaderStart at line $headerstart<hr>";
               // echo htmlspecialchars($outstr[$i])."<hr>";
            }
            //headerstop
            if (strstr($outstr[$i],"<!--|HEADERSTOP|-->")) {
               $headerstop=$i;
               $outstr[$i] = ereg_replace("<!--\|HEADERSTOP\|-->","",$outstr[$i]);
               // echo "Find HeaderStop at line $headerstop<hr>";
               // echo htmlspecialchars($outstr[$i])."<hr>";
            }
            //bodystart
            if (strstr($outstr[$i],"<!--|BODYSTART|-->")) {
               $bodystart=$i;
               $outstr[$i] = ereg_replace("<!--\|BODYSTART\|-->","",$outstr[$i]);
               // echo "Find BodyStart at line $bodystart<hr>";
               // echo htmlspecialchars($outstr[$i])."<hr>";
            }
            //bodystop
            if (strstr($outstr[$i],"<!--|BODYSTOP|-->")) {
               $bodystop=$i;
               $outstr[$i] = ereg_replace("<!--\|BODYSTOP\|-->","",$outstr[$i]);
               // echo "Find BodyStop at line $bodystop<hr>";
               // echo htmlspecialchars($outstr[$i])."<hr>";
            }
            //listperpage|99
            if ((strstr($outstr[$i],"<!--|LISTPERPAGE|"))&&(strstr($outstr[$i],"|-->"))) {
               $spos = strpos($outstr[$i],"<!--|LISTPERPAGE|");
               $epos = strpos($outstr[$i],"|-->");
               $listperpage = substr($outstr[$i],$spos+17,$epos-($spos+17));
               $outstr[$i] = ereg_replace("<!--\|LISTPERPAGE\|".$listperpage."\|-->","",$outstr[$i]);
               // echo "Find ListPerPage : $listperpage<hr>";
               // echo htmlspecialchars($outstr[$i])."<hr>";
            }
            //listperrow|99
            if ((strstr($outstr[$i],"<!--|LISTPERROW|"))&&(strstr($outstr[$i],"|-->"))) {
               $spos = strpos($outstr[$i],"<!--|LISTPERROW|");
               $epos = strpos($outstr[$i],"|-->");
               $listperrow = substr($outstr[$i],$spos+16,$epos-($spos+16));
               $outstr[$i] = ereg_replace("<!--\|LISTPERROW\|".$listperrow."\|-->","",$outstr[$i]);
               // echo "Find ListPerRow : $listperrow<hr>";
               // echo htmlspecialchars($outstr[$i])."<hr>";
            }
            //getchild|99
            if ((strstr($outstr[$i],"<!--|GETCHILD|"))&&(strstr($outstr[$i],"|-->"))) {
               $spos = strpos($outstr[$i],"<!--|GETCHILD|");
               $epos = strpos($outstr[$i],"|-->");
               $getchild = substr($outstr[$i],$spos+14,$epos-($spos+14));
               $outstr[$i] = ereg_replace("<!--\|GETCHILD\|".$getchild."\|-->","",$outstr[$i]);
               // echo "Find GetChild : $getclild<hr>";
               // echo htmlspecialchars($outstr[$i])."<hr>";
            }
            //orderby|nn|da
            if ((strstr($outstr[$i],"<!--|ORDERBY|"))&&(strstr($outstr[$i],"|-->"))) {
               $spos = strpos($outstr[$i],"<!--|ORDERBY|");
               $epos = strpos($outstr[$i],"|-->");
               $opts = substr($outstr[$i],$spos+13,$epos-($spos+13));
               $preout = explode("|",$opts);
               $orderby_field = $preout[0];
               $orderby_da = $preout[1];
               $outstr[$i] = ereg_replace("<!--\|ORDERBY\|".$orderby_field."\|".$orderby_da."\|-->","",$outstr[$i]);
               // echo "Find OrderBy : $orderby_field -> $orderby_da<hr>";
               // echo htmlspecialchars($outstr[$i])."<hr>";
            }
         }  // end loop process style file
         if (($getchild==-999)&&($recflag==0)) {  // No record in Selft and not get child
            include("construction.php3");
            pg_footer($G_pg_footer);
            exit;
         }
         // if ($headerstart!=-999) {
         // }
         // if ($headerstop!=-999) {
         // }
         // if ($bodystart!=-999) {
         // }
         // if ($bodystop!=-999) {
         // }
         if ($listperpage==-999) {
            $listperpage=10;
         }
         // if ($listperrow==-999) {
            // $listperrow=1;
         // }
         // if ($getchild!=-999) {
         // }
         if ($orderby_field==-999) {
            $orderby_field="create_date";
         } else {
            // Check Field Name
            if ($orderby_field=="TEXT01") $orderby_field="txt_01";
            if ($orderby_field=="TEXT02") $orderby_field="txt_02";
            if ($orderby_field=="TEXT03") $orderby_field="txt_03";
            if ($orderby_field=="TEXT04") $orderby_field="txt_04";
            if ($orderby_field=="TEXT05") $orderby_field="txt_05";
            if ($orderby_field=="TEXT06") $orderby_field="txt_06";
            if ($orderby_field=="TEXT07") $orderby_field="txt_07";
            if ($orderby_field=="TEXT08") $orderby_field="txt_08";
            if ($orderby_field=="TEXT09") $orderby_field="txt_09";
            if ($orderby_field=="TEXT10") $orderby_field="txt_10";
            if ($orderby_field=="CREATEDATETIME") $orderby_field="create_date";
            if ($orderby_field=="MODIFYDATETIME") $orderby_field="modify_date";
         }
         if ($orderby_da==-999) {
            $forderby_da="desc";
         } else if ($orderby_da=="D") {
            $forderby_da="desc";
         } else if ($orderby_da=="A") {
            $forderby_da="asc";
         } else {
            $forderby_da="desc";
         }
         //
         if (!isset($s)) {
            $e=$listperpage+1;
            $s=0;
         } else {
            $e=$s+$listperpage+1;
         }
         if ($getchild==-999) { // Index not get child so get content list
            $sql="SELECT db_content.*, db_catalog.catalog_txt,db_catalog.catalog_title
            FROM db_catalog, db_content
            WHERE (db_content.catalog_id=db_catalog.catalog_id) and (db_content.catalog_id='$c') and (db_content.approve='Y')
            order by $orderby_field $forderby_da limit $s, $e";
            //echo $sql."<BR>";
            //echo $orderby_da."<BR>";
            $rawdata=db_exec($G_db_base,$sql);
            while ( $aa = mysql_fetch_array($rawdata)) {
               $contentresult[] = $aa;
            }
            $ttlselect = mysql_num_rows($rawdata);
         } else { // Index is define as get child
            //
            // Get child and put into array
            //
            $ttlselect=0;
            // echo "list child found<br>";
            $sql = "select * from db_catalog where parent_id='$c' and approve='Y' order by short_idx";
            // echo "$sql<br>";
            $ccat = db_exec($G_db_base,$sql);
            while ( $ccatraw = mysql_fetch_array($ccat)) {
               $ccatset[]=$ccatraw;
               // echo $ccatraw['catalog_txt']."<br>";
            }
            for ($i=0;$i<count($ccatset);$i++) {
               $sql="SELECT db_content.*, db_catalog.catalog_txt,db_catalog.catalog_title
                     FROM db_catalog, db_content
                     WHERE (db_content.catalog_id=db_catalog.catalog_id) and (db_content.catalog_id='".$ccatset[$i]['catalog_id']."') and (db_content.approve='Y')
                     order by $orderby_field $forderby_da limit 0, $getchild";
               // echo "$sql<br>";
               $dat=db_exec($G_db_base,$sql);
               $ttlselect=$ttlselect+mysql_num_rows($dat);
               while ( $conraw=mysql_fetch_array($dat)) {
                  $contentresult[] = $conraw;
               }
            }
            $listperpage = $ttlselect;
         }
         $ptop=false;
         $pheader=true;
         $pcontent=false;
         $pbottom=true;
         $pnetviagation = true;
         $rowcount = -1;
         $headercount = 0;
         for ($xx=0;$xx<$listperpage;$xx++) {
            $content=$contentresult[$xx];
            if ($ptop==false) {
               // echo "\n<!--Begin Top-->\n";
	       $headercount=$headercount+1;
               for ($i=0;$i<$bodystart;$i++) { // Print Header
                  $stylecontent = $outstr[$i];
                  $output  = change_value($stylecontent,$content);
                  echo $output;
                  $ptop=true;
               }
               // echo "\n<!--End Top-->\n";
            }
            if ($listperrow!=-999) { // If lisperrow <> -999 then start print row table
               if ($rowcount==-1) {
                  // echo "\n<!--Row Star|$listperrow|-->\n";
                  echo "<table width=\"100%\" border=\"0\">";
                  echo "<tr><td align=\"center\" valign=\"top\">";
                  $rowcount=1;
               } else if ($rowcount==$listperrow) {
                  // echo "\n<!--Row New Line-->\n";
                  echo "</td></tr><tr><td align=\"center\" valign=\"top\">";
                  $rowcount=1;
               } else {
                  // echo "\n<!--Row New Record-->\n";
                  echo "</td><td align=\"center\" valign=\"top\">";
                  $rowcount++;
               }
            }
            if ($pheader==false) {
               // echo "\n<!--Begin Header-->";
	       if (($rowcount>=1)&&($headercount>0)) { // Section change force end table for row
	          echo "</td></tr></table>";
	          // echo "\n<!-- Section Change close table -->\n";
	          $rowcount=-9; 
	          $headercount=1;
	       } else {
                  $headercount=$headercount+1;
	       }
               for ($i=$headerstart;$i<$headerstop;$i++) {
                  $stylecontent = $outstr[$i];
                  $output  = change_value($stylecontent,$content);
                  echo $output;
               }
               echo "\n<!--End Header-->";
               $pheader=true;
            }
            if (($listperrow!=-999)&&($rowcount==-9)) {// If lisperrow <> -999 then means need print rows
	        // echo "\n<!--Row Start after section change|$listperrow|-->\n";
		echo "<table width=\"100%\" border=\"0\">";
		echo "<tr><td align=\"center\" valign=\"top\">";
		$rowcount=1;
            }			
            if ($pcontent==false) {
               // echo "\n<!--Begin Content-->\n";
               for ($i=$bodystart;$i<$bodystop;$i++) {
                  $stylecontent = $outstr[$i];
                  $output  = change_value($stylecontent,$content);
                  echo $output;
                  if (($xx==$listperpage-1)||($xx==count($contentresult)-1)) { // Last Record so enable print footer
                     $pbottom=false;
                  } else { // Not end so detimate next record secction
                     $nextcontent = $contentresult[$xx+1];
                     if ($content['catalog_id']!=$nextcontent['catalog_id']) {
                        $pheader=false;
                     }
                  }
               }
               // echo "\n<!--End Content-->\n";
            }
            if ($pbottom==false) {
               if ($listperrow!=-999) {
                  echo "</td></tr></table>";
               }
               // echo "\n<!--Begin Bottom-->\n";
               for ($i=$bodystop;$i<count($outstr);$i++) {
                  $stylecontent = $outstr[$i];
                  $output  = change_value($stylecontent,$content);
                  echo $output;
               }
               // echo "\n<!--End Bottom-->\n";
               $pnetviagation = false;
            }
            if ($pnetviagation ==false) {
               if (($ttlselect>$listperpage)||($s>0)) {
                  // echo "\n<!--Begin Netvigation Bar-->\n";
                  pg_btn_netgation($s,$e,$listperpage,$ttlselect,$c);
                  // echo "\n<!--End Netvigation Bar-->\n";
               }
               break;
            }
         } // Loop contentresult $xx
      } else {
         // Display index form PHP program
         if ($recflag==0) {  // No record in Self and not get child
            include("construction.php3");
            pg_footer($G_pg_footer);
            exit;
         } else {
            include ($G_dir_style.$styset['style_file']);
         }
      }
   } // End articel count for select display index or display article
} else if ($a!="") { // Articel ID found the display articel now
   // Display Article by article id
   $sql="SELECT db_content.*, db_catalog.catalog_txt,db_catalog.catalog_title
         FROM db_catalog, db_content
         WHERE (db_content.catalog_id=db_catalog.catalog_id) and (db_content.content_id='$a') and (db_content.approve='Y')";

   //$sql = "select * from db_content where content_id='$a' and approve='Y'";
   $result = db_exec($G_db_base,$sql);
   if (mysql_num_rows($result)==0) { // Can't find the article or articel not approve
      include("construction.php3");
      pg_footer($G_pg_footer);
      exit;  
   }
   $content=mysql_fetch_array($result);
   $sql = "select * from db_style where style_id='".$content['style_id']."'";
   $result = db_exec($G_db_base,$sql);
   $styset = mysql_fetch_array($result);
   $prestr = $styset['style_details'];
   $outstr = explode("\n",$prestr);
   for ($i=0;$i<count($outstr);$i++) {
      if ((strstr($outstr[$i],"<!--|PAYPAL_ADD_CART_BTN|-->"))) {
         $spos = strpos($outstr[$i],"<!--|PAYPAL_ADD_CART_BTN|-->");
         $epos = 28;
	 $newstr = dsp_paypal_add_cart_btn($content);
	 $outstr[$i] = ereg_replace("<!--\|PAYPAL_ADD_CART_BTN\|-->",$newstr,$outstr[$i]);
      }      
      if ((strstr($outstr[$i],"<!--|PAYPAL_VIEW_CART_BTN|-->"))) {
         $spos = strpos($outstr[$i],"<!--|PAYPAL_VIEW_CART_BTN|-->");
         $epos = 29;
         $newstr = dsp_paypal_view_cart_btn();
         $outstr[$i] = ereg_replace("<!--\|PAYPAL_VIEW_CART_BTN\|-->",$newstr,$outstr[$i]);
      }               
      if ((strstr($outstr[$i],"<!--|TITLEBAR|"))&&(strstr($outstr[$i],"|-->"))) {
         $spos = strpos($outstr[$i],"<!--|TITLEBAR|");
         $epos = strpos($outstr[$i],"|-->");
         $opts = substr($outstr[$i],$spos+14,$epos-($spos+14));
         $newstr = dsp_titlebar($opts);
         // echo "Find Title Bar :".htmlspecialchars($opts)."<hr>";
         $opts = ereg_replace ("\(","\\(",$opts);
         $opts = ereg_replace ("\)","\\)",$opts);
         // echo "Find Title Bar :".htmlspecialchars($opts)."<hr>";
         $outstr[$i] = ereg_replace("<!--\|TITLEBAR\|".$opts."\|-->",$newstr,$outstr[$i]);
      }
      if (strstr($outstr[$i],"<!--|GOSECTION|-->")) {
         $newstr = dsp_gosection();
         $outstr[$i] = ereg_replace("<!--\|GOSECTION\|-->",$newstr,$outstr[$i]);
      }
      if ((strstr($outstr[$i],"<!--|BOXOPEN|"))&&(strstr($outstr[$i],"|-->"))) {
         $spos = strpos($outstr[$i],"<!--|BOXOPEN|");
         $epos = strpos($outstr[$i],"|-->");
         $opts = substr($outstr[$i],$spos+13,$epos-($spos+13));
         $newstr = dsp_boxopen($opts);
         // echo htmlspecialchars($newstr)."<hr>";
         // echo "Find BoxOpen : $opts-->$i<hr>";
         $outstr[$i] = ereg_replace("<!--\|BOXOPEN\|".$opts."\|-->",$newstr,$outstr[$i]);
         // echo "Result:".htmlspecialchars($outstr[$i])."<hr>";
      }
      if (strstr($outstr[$i],"<!--|BOXCLOSE|-->")) {
         $newstr = dsp_boxclose();
         // echo "Find BoxClose-->$i<hr>";
         $outstr[$i] = ereg_replace("<!--\|BOXCLOSE\|-->",$newstr,$outstr[$i]);
         // echo "Result:".htmlspecialchars($outstr[$i])."<hr>";
      }
   }
   // echo "\n<!--Articel Print Start-->\n";
   for ($i=0;$i<count($outstr);$i++) {
      $stylecontent = $outstr[$i];
      $output = change_value($stylecontent,$content);
      // echo "\n\n<!--Seq=$i-->\n\n";
      echo $output;
   }
   // echo "\n<!--Articel Print End-->\n";
} else {
   include("construction.php3"); // Shouldn't fall into this unkmow error!
}
pg_footer($G_pg_footer);
?>
