<?
$page = "admin_faq.php";
include "admin_header.php";
if(isset($_POST['task'])) { $task = $_POST['task']; } elseif(isset($_GET['task'])) { $task = $_GET['task']; } else { $task = "main"; }



if($task == "add_cat") {
if(isset($_POST['o_post'])) { $o_url = $_POST['o_post']; } else { $o_url = ""; }
echo $head;
echo "
<h2>$admin_faq1</h2>
$admin_faq2<br><br>
<table cellspacing='0' cellpadding='1'>
<tr>
<form action='admin_faq.php' method='POST'>
<td valign='bottom'>
<b>$admin_faq3</b><br>
<input type='text' class='text' name='new_category' maxlength='30' size='30'>
<input type='submit' class='button' value='$admin_faq4' style='margin-bottom: 2px;'>
<input type='hidden' name='task' value='add_cat_do'>
<input type='hidden' name='o_post' value='$o_url'>
</td>
</form>
<form action='admin_faq.php' method='POST'>
<td valign='bottom'>
<input type='submit' class='button' value='$admin_faq5' style='margin-bottom: 3px;'>
<input type='hidden' name='task' value='cancel'>
<input type='hidden' name='o_post' value='$o_url'>
</td>
</form>
</tr>
</table>
";
echo $foot;
exit;
}


if($task == "add_cat_do") {
if(isset($_POST['o_post'])) { $o_url = $_POST['o_post']; } else { $o_url = ""; }
$new_category = str_replace("'", "&#39;", $_POST['new_category']);
  if(str_replace(" ", "", $new_category) == "") {
  echo $head;
  echo "<b>$admin_faq6</b><br>$admin_faq7";
  echo $foot;
  exit;
  }
  if(mysql_num_rows(mysql_query("SELECT * FROM bhost_faqcat WHERE category='$new_category'")) != 0) {
  echo $head;
  echo "<b>$admin_faq6</b><br>$admin_faq8";
  echo $foot;
  exit;
  }
$max = mysql_fetch_assoc(mysql_query("SELECT max(c_order) as c_order FROM bhost_faqcat"));
$max = 1 + $max[c_order];
mysql_query("INSERT INTO bhost_faqcat (category, c_order) VALUES ('$new_category', '$max')");
header("Location: admin_faq.php?o=$o_url");
exit;
}


if($task == "mod_cat") {
if(isset($_GET['o'])) { $o_url = $_GET['o']; } else { $o_url = ""; }
if(!isset($_GET['fc_id'])) { exit; }
if(mysql_num_rows(mysql_query("SELECT * FROM bhost_faqcat WHERE fc_id='$_GET[fc_id]'")) != 1) { exit; }
$faqcat_info = mysql_fetch_assoc(mysql_query("SELECT * FROM bhost_faqcat WHERE fc_id='$_GET[fc_id]'"));
echo $head;
echo "
<h2>$admin_faq9</h2>
$admin_faq10<br><br>
<table cellspacing='0' cellpadding='1'>
<tr>
<form action='admin_faq.php' method='POST'>
<td>
<input type='hidden' name='task' value='mod_cat_do'>
<input type='hidden' name='fc_id' value='$faqcat_info[fc_id]'>
<input type='hidden' name='o_post' value='$o_url'>
<input type='text' name='mod_category' value='$faqcat_info[category]' maxlength='30' size='30'>
<input type='submit' class='button' value='$admin_faq11' style='margin-bottom: 2px;'>
</td>
</form>
<form action='admin_faq.php' method='POST'>
<td>
<input type='hidden' name='task' value='del_cat'>
<input type='hidden' name='fc_id' value='$faqcat_info[fc_id]'>
<input type='hidden' name='o_post' value='$o_url'>
<input type='submit' class='button' value='$admin_faq12' style='margin-bottom: 3px;'>
</td>
</form>
<form action='admin_faq.php' method='POST'>
<td>
<input type='hidden' name='task' value='cancel'>
<input type='hidden' name='o_post' value='$o_url'>
<input type='submit' class='button' value='$admin_faq5' style='margin-bottom: 3px;'>
</td>
</form>
</tr>
</table>
";

$faq = mysql_query("SELECT * FROM bhost_faq WHERE fc_id='$faqcat_info[fc_id]' ORDER BY q_order");
$questions = mysql_num_rows($faq);

if($questions > 0) {
echo "
<br>

<table cellspacing='0' cellpadding='1'>
<tr>
<form action='admin_faq.php?o=$o_url' method='POST'>
<td>

<table cellpadding='3' cellspacing='0'>
";
$max = mysql_fetch_assoc(mysql_query("SELECT max(q_order) as q_order FROM bhost_faq WHERE fc_id='$faqcat_info[fc_id]'"));
$old_faq_q_id = 0;

while($faq_info = mysql_fetch_assoc($faq)) {
echo "
<tr>";



// ECHO ARROW COLUMN
if($old_faq_q_id == 0 OR $faq_info[q_order] == $max[q_order]) { 
echo "<td colspan='2'"; 
 if($old_faq_q_id == 0) {
 echo " align='right'";
 }
echo ">"; 
} else { 
echo "<td>"; 
} 

if($old_faq_q_id != 0) { echo "<a href='admin_faq.php?task=quest_order_do&fc_id=$faqcat_info[fc_id]&q_id=$old_faq_q_id&o=$o_url'><img src='../images/faq_up.gif' border='0'></a></td>"; }

if($old_faq_q_id != 0) { 
 if($faq_info[q_order] != $max[q_order]) { echo "<td>"; } 
}

if($faq_info[q_order] != $max[q_order]) { echo "<a href='admin_faq.php?task=quest_order_do&fc_id=$faqcat_info[fc_id]&q_id=$faq_info[q_id]&o=$o_url'><img src='../images/faq_down.gif' border='0'></a></td>"; }

echo "<td>&nbsp;&nbsp;$faq_info[question]</td>";
echo "</tr>
";
$old_faq_q_id = $faq_info[q_id];
}


echo "
</table>
<br>

<input type='hidden' name='task' value='main'>
<input type='submit' class='button' value='$admin_faq13'>
</td>
</form>
</tr>
</table>
";
}

echo $foot;
exit;
}


if($task == "mod_cat_do") {
if(isset($_POST['o_post'])) { $o_url = $_POST['o_post']; } else { $o_url = ""; }
$fc_id = $_POST['fc_id'];
$mod_category = str_replace("'", "&#39;", $_POST['mod_category']);
  if(str_replace(" ", "", $mod_category) == "") {
  echo $head;
  echo "<b>$admin_faq6</b><br>$admin_faq7";
  echo $foot;
  exit;
  }
  if(mysql_num_rows(mysql_query("SELECT * FROM bhost_faqcat WHERE category='$mod_category' AND fc_id <> '$fc_id'")) != 0) {
  echo $head;
  echo "<b>$admin_faq6</b><br>$admin_faq8";
  echo $foot;
  exit;
  }
mysql_query("UPDATE bhost_faqcat SET category='$mod_category' WHERE fc_id='$fc_id'");
header("Location: admin_faq.php?o=$o_url");
exit;
}


if($task == "del_cat") {
if(isset($_POST['o_post'])) { $o_url = $_POST['o_post']; } else { $o_url = ""; }
$faqcat_info = mysql_fetch_assoc(mysql_query("SELECT * FROM bhost_faqcat WHERE fc_id='$_POST[fc_id]'"));
echo $head;
echo "
<h2>$admin_faq14</h2>
$admin_faq15 \"<b>$faqcat_info[category]</b>\"?<br>
<b>$admin_faq16</b><br><br>
<table cellspacing='0' cellpadding='1'>
<tr>
<form action='admin_faq.php' method='POST'>
<td>
<input type='hidden' name='task' value='del_cat_do'>
<input type='hidden' name='o_post' value='$o_url'>
<input type='hidden' name='fc_id' value='$faqcat_info[fc_id]'>
<input type='submit' class='button' value='$admin_faq12'>
</td>
</form>
<form action='admin_faq.php' method='POST'>
<td>
<input type='hidden' name='task' value='cancel'>
<input type='hidden' name='o_post' value='$o_url'>
<input type='submit' class='button' value='$admin_faq5'>
</td>
</form>
</tr>
</table>
";
echo $foot;
exit;

}


if($task == "del_cat_do") {
if(isset($_POST['o_post'])) { $o_url = $_POST['o_post']; } else { $o_url = ""; }
$fc_id = $_POST['fc_id'];
mysql_query("DELETE FROM bhost_faqcat WHERE fc_id='$fc_id'");
mysql_query("DELETE FROM bhost_faq WHERE fc_id='$fc_id'");
header("Location: admin_faq.php?o=$o_url");
exit;
}









if($task == "cat_order") {
if(isset($_GET['o'])) { $o_url = $_GET['o']; } else { $o_url = ""; }
echo $head;
echo "
<h2>$admin_faq17</h2>
$admin_faq18<br><br>
<table cellspacing='0' cellpadding='1'>
<tr>
<form action='admin_faq.php?o=$o_url' method='POST'>
<td>
";

$faqcat = mysql_query("SELECT * FROM bhost_faqcat ORDER BY c_order");
$number_of_kittens = mysql_num_rows($faqcat);

if($number_of_kittens > 0) {

echo "<table cellpadding='3' cellspacing='0'>";
$max = mysql_fetch_assoc(mysql_query("SELECT max(c_order) as c_order FROM bhost_faqcat"));
$old_faqcat_fc_id = 0;

while($faqcat_info = mysql_fetch_assoc($faqcat)) {
echo "
<tr>";

// ECHO ARROW COLUMN
if($old_faqcat_fc_id == 0 OR $faqcat_info[c_order] == $max[c_order]) { 
echo "<td colspan='2'"; 
 if($old_faqcat_fc_id == 0) {
 echo " align='right'";
 }
echo ">"; 
} else { 
echo "<td>"; 
} 

if($old_faqcat_fc_id != 0) { echo "<a href='admin_faq.php?task=cat_order_do&fc_id=$old_faqcat_fc_id&o=$o_url'><img src='../images/faq_up.gif' border='0'></a></td>"; }

if($old_faqcat_fc_id != 0) { 
 if($faqcat_info[c_order] != $max[c_order]) { echo "<td>"; } 
}

if($faqcat_info[c_order] != $max[c_order]) { echo "<a href='admin_faq.php?task=cat_order_do&fc_id=$faqcat_info[fc_id]&o=$o_url'><img src='../images/faq_down.gif' border='0'></a></td>"; }

echo "<td>&nbsp;&nbsp;<b>$faqcat_info[category]</b></td>";
echo "</tr>
";

$old_faqcat_fc_id = $faqcat_info[fc_id];
}
echo "
</table>

<br>
<input type='hidden' name='task' value='main'>
<input type='submit' class='button' value='$admin_faq13'>
</td>
</form>
</tr>
</table>
";
} else {
echo "
$admin_faq19
</td></tr></table>
";
}
echo $foot;
exit();
}







if($task == "cat_order_do") {
$fc_id = $_GET['fc_id'];
if(isset($_GET['o'])) { $o_url = $_GET['o']; } else { $o_url = ""; }
$old_faqcat_info = mysql_fetch_assoc(mysql_query("SELECT * FROM bhost_faqcat WHERE fc_id='$fc_id'"));

$max = mysql_fetch_assoc(mysql_query("SELECT max(c_order) as c_order FROM bhost_faqcat"));
if($old_faqcat_info[c_order] == $max[c_order]) { exit(); }

$new = mysql_fetch_assoc(mysql_query("SELECT c_order FROM bhost_faqcat WHERE c_order > '$old_faqcat_info[c_order]' ORDER BY c_order LIMIT 1"));
$new_faqcat_info = mysql_fetch_assoc(mysql_query("SELECT * FROM bhost_faqcat WHERE c_order='$new[c_order]'"));

mysql_query("UPDATE bhost_faqcat SET c_order='$old_faqcat_info[c_order]' WHERE fc_id='$new_faqcat_info[fc_id]'");
mysql_query("UPDATE bhost_faqcat SET c_order='$new_faqcat_info[c_order]' WHERE fc_id='$fc_id'");
header("Location: admin_faq.php?task=cat_order&o=$o_url");
exit();
}


if($task == "quest_order_do") {
$fc_id = $_GET['fc_id'];
$q_id = $_GET['q_id'];
if(isset($_GET['o'])) { $o_url = $_GET['o']; } else { $o_url = ""; }

$old_faq_info = mysql_fetch_assoc(mysql_query("SELECT * FROM bhost_faq WHERE q_id='$q_id' AND fc_id='$fc_id'"));
$max = mysql_fetch_assoc(mysql_query("SELECT max(q_order) as q_order FROM bhost_faq WHERE fc_id='$fc_id'"));
if($old_faq_info[q_order] == $max[q_order]) { exit(); }

$new = mysql_fetch_assoc(mysql_query("SELECT q_order FROM bhost_faq WHERE q_order > '$old_faq_info[q_order]' AND fc_id='$fc_id' ORDER BY q_order LIMIT 1"));
$new_faq_info = mysql_fetch_assoc(mysql_query("SELECT * FROM bhost_faq WHERE q_order='$new[q_order]' AND fc_id='$fc_id'"));

mysql_query("UPDATE bhost_faq SET q_order='$old_faq_info[q_order]' WHERE q_id='$new_faq_info[q_id]'");
mysql_query("UPDATE bhost_faq SET q_order='$new_faq_info[q_order]' WHERE q_id='$q_id'");

header("Location: admin_faq.php?task=mod_cat&fc_id=$fc_id&o=$o_url");
exit();
}





if($task == "add_quest") {
if(isset($_POST['o_post'])) { $o_url = $_POST['o_post']; } else { $o_url = ""; }
echo $head;
echo "
<h2>$admin_faq20</h2>
$admin_faq21<br><br>
<form action='admin_faq.php' method='POST'>
$admin_faq22<br>
<select name='new_category'>
<option></option>";
$faqcat = mysql_query("SELECT * FROM bhost_faqcat ORDER BY c_order");
while($faqcat_info = mysql_fetch_assoc($faqcat)) {
echo "<option value='$faqcat_info[fc_id]'>$faqcat_info[category]</option>";
}
echo "
</select><br><br>
$admin_faq23<br>
<input type='text' name='new_question' maxlength='100' size='60'><br><br>
$admin_faq24<br>
<textarea name='new_answer' rows='15' cols='60'></textarea><br>
<table cellspacing='0' cellpadding='1'>
<tr>
<td>
<input type='hidden' name='task' value='add_quest_do'>
<input type='hidden' name='o_post' value='$o_url'>
<input type='submit' class='button' value='$admin_faq25'>
</td>
</form>
<form action='admin_faq.php' method='POST'>
<td>
<input type='hidden' name='task' value='cancel'>
<input type='hidden' name='o_post' value='$o_url'>
<input type='submit' class='button' value='$admin_faq5'>
</td>
</form>
</tr>
</table>
";
echo $foot;
exit;
}


if($task == "add_quest_do") {
if(isset($_POST['o_post'])) { $o_url = $_POST['o_post']; } else { $o_url = ""; }
$new_category = $_POST['new_category'];
$new_question = str_replace("'", "&#39;", $_POST['new_question']);
$new_answer = $_POST['new_answer'];
  if(str_replace(" ", "", $new_category) == "") {
  echo $head;
  echo "<b>$admin_faq6</b><br>$admin_faq26";
  echo $foot;
  exit;
  }
  if(str_replace(" ", "", $new_question) == "") {
  echo $head;
  echo "<b>$admin_faq6</b><br>$admin_faq27";
  echo $foot;
  exit;
  }
  if(str_replace(" ", "", $new_answer) == "") {
  echo $head;
  echo "<b>$admin_faq6</b><br>$admin_faq28";
  echo $foot;
  exit;
  }
$max = mysql_fetch_assoc(mysql_query("SELECT max(q_order) as q_order FROM bhost_faq WHERE fc_id='$new_category'"));
$max = 1 + $max[q_order];
mysql_query("INSERT INTO bhost_faq (fc_id, question, answer, q_order) VALUES ('$new_category', '$new_question', '$new_answer', '$max')");
header("Location: admin_faq.php?o=$o_url");
exit;
}



if($task == "mod_quest") {
if(isset($_GET['o'])) { $o_url = $_GET['o']; } else { $o_url = ""; }
if(!isset($_GET['q_id'])) { exit; }
if(mysql_num_rows(mysql_query("SELECT * FROM bhost_faq WHERE q_id='$_GET[q_id]'")) != 1) { exit(); }
$faq_info = mysql_fetch_assoc(mysql_query("SELECT * FROM bhost_faq WHERE q_id='$_GET[q_id]'"));
echo $head;
echo "
<h2>$admin_faq29</h2>
$admin_faq30<br>
<form action='admin_faq.php' method='POST'>
$admin_faq22<br>
<select name='mod_category'>
<option></option>";
$faqcat = mysql_query("SELECT * FROM bhost_faqcat ORDER BY c_order");
while($faqcat_info = mysql_fetch_assoc($faqcat)) {
echo "<option value='$faqcat_info[fc_id]'"; if($faqcat_info[fc_id] == $faq_info[fc_id]) { echo " SELECTED"; } echo ">$faqcat_info[category]</option>";
}
echo "
</select><br><br>
$admin_faq23<br>
<input type='text' name='mod_question' value='$faq_info[question]' maxlength='100' size='60'><br><br>
$admin_faq24<br>
<textarea name='mod_answer' rows='15' cols='60'>$faq_info[answer]</textarea><br>
<table cellspacing='0' cellpadding='1'>
<tr>
<td>
<input type='hidden' name='q_id' value='$faq_info[q_id]'>
<input type='hidden' name='task' value='mod_quest_do'>
<input type='hidden' name='o_post' value='$o_url'>
<input type='submit' class='button' value='$admin_faq31'>
</td>
</form>
<form action='admin_faq.php' method='POST'>
<td>
<input type='hidden' name='q_id' value='$faq_info[q_id]'>
<input type='hidden' name='task' value='del_quest'>
<input type='hidden' name='o_post' value='$o_url'>
<input type='submit' class='button' value='$admin_faq12'>
</td>
</form>
<form action='admin_faq.php' method='POST'>
<td>
<input type='hidden' name='task' value='cancel'>
<input type='hidden' name='o_post' value='$o_url'>
<input type='submit' class='button' value='$admin_faq5'>
</td>
</form>
</tr>
</table>
";
echo $foot;
exit;
}


if($task == "mod_quest_do") {
if(isset($_POST['o_post'])) { $o_url = $_POST['o_post']; } else { $o_url = ""; }
$q_id = $_POST['q_id'];
$mod_category = $_POST['mod_category'];
$mod_question = str_replace("'", "&#39;", $_POST['mod_question']);
$mod_answer = $_POST['mod_answer'];
  if(str_replace(" ", "", $mod_category) == "") {
  echo $head;
  echo "<b>$admin_faq6</b><br>$admin_faq26";
  echo $foot;
  exit;
  }
  if(str_replace(" ", "", $mod_question) == "") {
  echo $head;
  echo "<b>$admin_faq6</b><br>$admin_faq27";
  echo $foot;
  exit;
  }
  if(str_replace(" ", "", $mod_answer) == "") {
  echo $head;
  echo "<b>$admin_faq6</b><br>$admin_faq28";
  echo $foot;
  exit;
  }
$question_info = mysql_fetch_assoc(mysql_query("SELECT * FROM bhost_faq WHERE q_id='$q_id'"));
if($mod_category != $question_info[fc_id]) {
$max = mysql_fetch_assoc(mysql_query("SELECT max(q_order) as q_order FROM bhost_faq WHERE fc_id='$mod_category'"));
$q_order = 1 + $max[q_order];
} else {
$q_order = $question_info[q_order];
}
mysql_query("UPDATE bhost_faq SET fc_id='$mod_category', question='$mod_question', answer='$mod_answer', q_order='$q_order' WHERE q_id='$q_id'");
header("Location: admin_faq.php?o=$o_url");
exit;
}


if($task == "del_quest") {
if(isset($_POST['o_post'])) { $o_url = $_POST['o_post']; } else { $o_url = ""; }
$faq_info = mysql_fetch_assoc(mysql_query("SELECT * FROM bhost_faq WHERE q_id='$_POST[q_id]'"));
echo $head;
echo "
<h2>$admin_faq32</h2>
$admin_faq33 \"<b>$faq_info[question]</b>\"?<br><br>
<table cellspacing='0' cellpadding='1'>
<tr>
<form action='admin_faq.php' method='POST'>
<td>
<input type='hidden' name='task' value='del_quest_do'>
<input type='hidden' name='q_id' value='$faq_info[q_id]'>
<input type='hidden' name='o_post' value='$o_url'>
<input type='submit' class='button' value='$admin_faq12'>
</td>
</form>
<form action='admin_faq.php' method='POST'>
<td>
<input type='hidden' name='task' value='cancel'>
<input type='hidden' name='o_post' value='$o_url'>
<input type='submit' class='button' value='$admin_faq5'>
</td>
</form>
</tr>
</table>
";
echo $foot;
exit;
}


if($task == "del_quest_do") {
if(isset($_POST['o_post'])) { $o_url = $_POST['o_post']; } else { $o_url = ""; }
$q_id = $_POST['q_id'];
mysql_query("DELETE FROM bhost_faq WHERE q_id='$q_id'");
header("Location: admin_faq.php?o=$o_url");
exit;
}







if($task == "cancel") {
if(isset($_POST['o_post'])) { $o_url = $_POST['o_post']; } else { $o_url = ""; }
header("Location: admin_faq.php?o=$o_url");
}








if($task == "faq_onoff") {
$faq_on = $_POST['faq_on'];
mysql_query("UPDATE bhost_admin SET faq_on='$faq_on'");
$task = "main";
}








if($task == "main") {

if(isset($_GET['o'])) { 
$o = $_GET['o']; 
$o_url = $o;
$open = explode(",", trim($o));
} else {
$open = Array("0");
}

$faq_cat = mysql_query("SELECT fc_id FROM bhost_faqcat");
$all = "0";
while($faq_cat_info = mysql_fetch_assoc($faq_cat)) {
$all .= ",".$faq_cat_info[fc_id];
}

echo $head;

$faqinfo = mysql_fetch_assoc(mysql_query("SELECT faq_on FROM bhost_admin"));

if($faqinfo[faq_on] == "1") {
echo "
<h2>$admin_faq34</h2>
$admin_faq35
";
} else {
echo "
<h2>$admin_faq34</h2>
$admin_faq36 
";
}

echo "
<br><br>

<table cellpadding='0' cellspacing='0'>
<form action='admin_faq.php' method='POST'>
<tr>
<td class='entry'>
 <table cellpadding='0' cellspacing='0'>
 <tr>
 <td><input type='checkbox' name='faq_on' value='1'"; if($faqinfo[faq_on] == "1") { echo " CHECKED"; } echo ">&nbsp;</td>
 <td>$admin_faq37 &nbsp;&nbsp;</td>
 <td><input type='submit' class='button' value='$admin_faq38'></td>
 </tr>
 </table>
</td>
</tr>
<input type='hidden' name='task' value='faq_onoff'>
</form>
</table>




";

if($faqinfo[faq_on] == "1") {

$catcount = 0;
$faqcat = mysql_query("SELECT * FROM bhost_faqcat ORDER BY c_order");
$number_of_kittens = mysql_num_rows($faqcat);

echo "
<br>

<table cellspacing='0' cellpadding='1'>
<tr>
<form action='admin_faq.php' method='POST'>
<td>
<input type='hidden' name='task' value='add_cat'>
<input type='hidden' name='o_post' value='$o_url'>
<input type='submit' class='button' value='$admin_faq39'>
</td>
</form>
<form action='admin_faq.php' method='POST'>
<td>
<input type='hidden' name='task' value='add_quest'>
<input type='hidden' name='o_post' value='$o_url'>
<input type='submit' class='button' value='$admin_faq40'"; if($number_of_kittens == 0) { echo " DISABLED"; } echo ">
</td>
</form>
</tr>
</table>

<br>

<table cellpadding='0' cellspacing='0'>
<tr>
<td width='20'><img src='../images/cat_top.gif'></td>
<td><strong><a href='admin_faq.php?task=cat_order&o=$o_url' class='admin_menu'>$admin_faq41</a></strong>";

if($number_of_kittens != 0) {
echo " - <a href='admin_faq.php?task=main&o=$all' style='text-decoration: none;'>[$admin_faq42]</a> - <a href='admin_faq.php' style='text-decoration: none;'>[$admin_faq43]</a>";
}

echo "
</td>
</tr>
</table>
";

if($number_of_kittens == 0) {
echo "
$admin_faq44
";
}

while($faqcat_info = mysql_fetch_assoc($faqcat)) {
$catcount++;

if(in_array($faqcat_info[fc_id], $open)) {
  $new_open = "";
  $a = 0;
  for($c=0;$c<count($open);$c++) {
    if($open[$c] != $faqcat_info[fc_id]) {
    $new_open[$a] = $open[$c];
    $a = $a+1;
    }
  }

$o = implode(",", $new_open);
echo "
<table cellpadding='0' cellspacing='0'>
<tr>
<td width='38' NOWRAP><a href='admin_faq.php?o=$o'><img src='../images/cat_open.gif' border='0'></a></td>
<td valign='bottom'>
<strong><a href='admin_faq.php?task=mod_cat&fc_id=$faqcat_info[fc_id]&o=$o_url' class='admin_menu'>$faqcat_info[category]</a></strong>
</td>
</tr>
</table>
";

if($catcount == mysql_num_rows($faqcat)) {
$leftimage = "<img src='../images/trans.gif'>";
} else {
$leftimage = "<img src='../images/space_left.gif'>";
}

$questions1 = mysql_query("SELECT q_id, fc_id, question FROM bhost_faq WHERE fc_id='$faqcat_info[fc_id]' ORDER BY q_order");
$total_questions = mysql_num_rows($questions1);
$count = 0;
while($question = mysql_fetch_assoc($questions1)) {
$count = $count + 1;
echo "
<table cellpadding='0' cellspacing='0'>
<tr>
<td width='56'>$leftimage<img src='../images/question"; if($count == $total_questions) { echo "_last"; } echo ".gif' border='0'></td>
<td valign='bottom'>
<a href='admin_faq.php?task=mod_quest&q_id=$question[q_id]&o=$o_url' class='admin_menu'>$question[question]</a>
</td>
</tr>
</table>
";
}
} else {
$o = implode(",", $open);
$o = $o.",".$faqcat_info[fc_id];
echo "
<table cellpadding='0' cellspacing='0'>
<tr>
<td width='38' NOWRAP><a href='admin_faq.php?o=$o'><img src='../images/cat_closed.gif' border='0'></a></td>
<td valign='bottom'>
<strong><a href='admin_faq.php?task=mod_cat&fc_id=$faqcat_info[fc_id]&o=$o_url' class='admin_menu'>$faqcat_info[category]</a></strong>
</td>
</tr>
</table>
";
}}
}

echo $foot;

}

?>