<?
include "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 $header;
echo "
<b>Create FAQ Category</b><br>
Please provide a title for your new FAQ category.<br><br>
<table cellspacing='0' cellpadding='1'>
<tr>
<form action='faq.php' method='POST' onsubmit='return add_cat(this)'>
<td valign='bottom'>
Category Name<br>
<input type='text' name='new_category' maxlength='30' size='30'>
<input type='submit' class='button' value='Create Category' 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='faq.php' method='POST'>
<td valign='bottom'>
<input type='submit' class='button' value='Cancel' 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 $footer;
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']);
  $cat_nospace = str_replace(" ", "", $new_category);
  if($cat_nospace == "") {
  echo $header;
  echo "<b>An Error Has Occurred</b><br>You have entered a blank category name.<br>Use your browser's back button to try again.";
  echo $footer;
  exit;
  }
$max = mysql_fetch_assoc(mysql_query("SELECT max(c_order) as c_order FROM ims_faqcat"));
$max = 1 + $max[c_order];
mysql_query("INSERT INTO ims_faqcat (category, c_order) VALUES ('$new_category', '$max')");
header("Location: faq.php?o=$o_url");
exit;
}


if($task == "mod_cat") {
if(isset($_GET['o'])) { $o_url = $_GET['o']; } else { $o_url = ""; }
if(!isset($_GET['c_id'])) { exit; }
if(mysql_num_rows(mysql_query("SELECT * FROM ims_faqcat WHERE c_id='$_GET[c_id]'")) != 1) { exit; }
$faqcat_info = mysql_fetch_assoc(mysql_query("SELECT * FROM ims_faqcat WHERE c_id='$_GET[c_id]'"));
echo $header;
echo "
<b>Modify FAQ Category</b><br>
Use this area to change the name or question order of this FAQ category.<br><br>
<table cellspacing='0' cellpadding='1'>
<tr>
<form action='faq.php' method='POST' onsubmit='return mod_cat(this)'>
<td>
<input type='hidden' name='task' value='mod_cat_do'>
<input type='hidden' name='c_id' value='$faqcat_info[c_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='Modify Category' style='margin-bottom: 2px;'>
</td>
</form>
<form action='faq.php' method='POST'>
<td>
<input type='hidden' name='task' value='del_cat'>
<input type='hidden' name='c_id' value='$faqcat_info[c_id]'>
<input type='hidden' name='o_post' value='$o_url'>
<input type='submit' class='button' value='Delete' style='margin-bottom: 3px;'>
</td>
</form>
<form action='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='Cancel' style='margin-bottom: 3px;'>
</td>
</form>
</tr>
</table>
";

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

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

<table cellspacing='0' cellpadding='1'>
<tr>
<form action='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 ims_faq WHERE c_id='$faqcat_info[c_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='faq.php?task=quest_order_do&c_id=$faqcat_info[c_id]&q_id=$old_faq_q_id&o=$o_url'><img src='../icons/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='faq.php?task=quest_order_do&c_id=$faqcat_info[c_id]&q_id=$faq_info[q_id]&o=$o_url'><img src='../icons/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='Back to FAQ'>
</td>
</form>
</tr>
</table>
";
}

echo $footer;
exit;
}


if($task == "mod_cat_do") {
if(isset($_POST['o_post'])) { $o_url = $_POST['o_post']; } else { $o_url = ""; }
$mod_category = str_replace("'", "&#39;", $_POST['mod_category']);
$c_id = $_POST['c_id'];
mysql_query("UPDATE ims_faqcat SET category='$mod_category' WHERE c_id='$c_id'");
header("Location: 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 ims_faqcat WHERE c_id='$_POST[c_id]'"));
echo $header;
echo "
<b>Delete FAQ Category</b>
<br>Are you sure you want to delete the category \"<b>$faqcat_info[category]</b>\"?<br>
<b>WARNING: All questions within this category will be deleted!</b><br><br>
<table cellspacing='0' cellpadding='1'>
<tr>
<form action='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='c_id' value='$faqcat_info[c_id]'>
<input type='submit' class='button' value='Delete'>
</td>
</form>
<form action='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='Cancel'>
</td>
</form>
</tr>
</table>
";
echo $footer;
exit;

}


if($task == "del_cat_do") {
if(isset($_POST['o_post'])) { $o_url = $_POST['o_post']; } else { $o_url = ""; }
$c_id = $_POST['c_id'];
mysql_query("DELETE FROM ims_faqcat WHERE c_id='$c_id'");
mysql_query("DELETE FROM ims_faq WHERE c_id='$c_id'");
header("Location: faq.php?o=$o_url");
exit;
}









if($task == "cat_order") {
if(isset($_GET['o'])) { $o_url = $_GET['o']; } else { $o_url = ""; }
echo $header;
echo "
<b>FAQ Category Order</b>
<br>Use this area to change the order of your FAQ categories.<br><br>
<table cellspacing='0' cellpadding='1'>
<tr>
<form action='faq.php?o=$o_url' method='POST'>
<td>
";

$faqcat = mysql_query("SELECT * FROM ims_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 ims_faqcat"));
$old_faqcat_c_id = 0;

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

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

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

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

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

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

$old_faqcat_c_id = $faqcat_info[c_id];
}
echo "
</table>

<br>
<input type='hidden' name='task' value='main'>
<input type='submit' class='button' value='Back to FAQ'>
</td>
</form>
</tr>
</table>
";
} else {
echo "
Note: There are no categories in your FAQ. <a href='faq.php'>Click here</a> to go back and create one.
</td></tr></table>
";
}
echo $footer;
exit();
}







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

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

$new = mysql_fetch_assoc(mysql_query("SELECT c_order FROM ims_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 ims_faqcat WHERE c_order='$new[c_order]'"));

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


if($task == "quest_order_do") {
$c_id = $_GET['c_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 ims_faq WHERE q_id='$q_id' AND c_id='$c_id'"));
$max = mysql_fetch_assoc(mysql_query("SELECT max(q_order) as q_order FROM ims_faq WHERE c_id='$c_id'"));
if($old_faq_info[q_order] == $max[q_order]) { exit(); }

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

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

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





if($task == "add_quest") {
if(isset($_POST['o_post'])) { $o_url = $_POST['o_post']; } else { $o_url = ""; }
echo $header;
echo "
<b>Add FAQ Question</b><br>
Enter a new FAQ question and answer below. HTML is allowed.<br>
<form action='faq.php' method='POST' onsubmit='return add_quest(this)'>
Category:<br>
<select name='new_category'>
<option></option>";
$faqcat = mysql_query("SELECT * FROM ims_faqcat");
while($faqcat_info = mysql_fetch_assoc($faqcat)) {
echo "<option value='$faqcat_info[c_id]'>$faqcat_info[category]</option>";
}
echo "
</select><br><br>
Question:<br>
<input type='text' name='new_question' maxlength='100' size='60'><br><br>
Answer:<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='Add Question'>
</td>
</form>
<form action='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='Cancel'>
</td>
</form>
</tr>
</table>
";
echo $footer;
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']);
  $quest_nospace = str_replace(" ", "", $new_question);
  if($quest_nospace == "") {
  echo $header;
  echo "<b>An Error Has Occurred</b><br>You have entered a blank question title.<br>Use your browser's back button to try again.";
  echo $footer;
  exit;
  }
$new_answer = $_POST['new_answer'];
$max = mysql_fetch_assoc(mysql_query("SELECT max(q_order) as q_order FROM ims_faq WHERE c_id='$new_category'"));
$max = 1 + $max[q_order];
mysql_query("INSERT INTO ims_faq (c_id, question, answer, q_order) VALUES ('$new_category', '$new_question', '$new_answer', '$max')");
header("Location: 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 ims_faq WHERE q_id='$_GET[q_id]'")) != 1) { exit(); }
$faq_info = mysql_fetch_assoc(mysql_query("SELECT * FROM ims_faq WHERE q_id='$_GET[q_id]'"));
echo $header;
echo "
<b>Modify FAQ Question</b><br>
Modify this FAQ question below. HTML is allowed.<br><br>
<form action='faq.php' method='POST' onsubmit='return mod_quest(this)'>
Category<br>
<select name='mod_category'>
<option></option>";
$faqcat = mysql_query("SELECT * FROM ims_faqcat");
while($faqcat_info = mysql_fetch_assoc($faqcat)) {
echo "<option value='$faqcat_info[c_id]'"; if($faqcat_info[c_id] == $faq_info[c_id]) { echo " SELECTED"; } echo ">$faqcat_info[category]</option>";
}
echo "
</select><br><br>
Question<br>
<input type='text' name='mod_question' value='$faq_info[question]' maxlength='100' size='60'><br><br>
Answer<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='Modify Question'>
</td>
</form>
<form action='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='Delete'>
</td>
</form>
<form action='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='Cancel'>
</td>
</form>
</tr>
</table>
";
echo $footer;
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'];
$question_info = mysql_fetch_assoc(mysql_query("SELECT * FROM ims_faq WHERE q_id='$q_id'"));
if($mod_category != $question_info[c_id]) {
$max = mysql_fetch_assoc(mysql_query("SELECT max(q_order) as q_order FROM ims_faq WHERE c_id='$mod_category'"));
$q_order = 1 + $max[q_order];
} else {
$q_order = $question_info[q_order];
}
mysql_query("UPDATE ims_faq SET c_id='$mod_category', question='$mod_question', answer='$mod_answer', q_order='$q_order' WHERE q_id='$q_id'");
header("Location: 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 ims_faq WHERE q_id='$_POST[q_id]'"));
echo $header;
echo "
<b>Delete FAQ Question</b>
<br>Are you sure you want to delete the question \"<b>$faq_info[question]</b>\"?<br><br>
<table cellspacing='0' cellpadding='1'>
<tr>
<form action='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='Delete'>
</td>
</form>
<form action='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='Cancel'>
</td>
</form>
</tr>
</table>
";
echo $footer;
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 ims_faq WHERE q_id='$q_id'");
header("Location: faq.php?o=$o_url");
exit;
}







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








if($task == "faq_onoff") {
$faq_on = $_POST['faq_on'];
mysql_query("UPDATE ims_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 c_id FROM ims_faqcat");
$all = "0";
while($faq_cat_info = mysql_fetch_assoc($faq_cat)) {
$all .= ",".$faq_cat_info[c_id];
}

echo $header;

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

if($faqinfo[faq_on] == "yes") {
echo "
<b>FAQ (Frequently Asked Questions) Manager</b><br>
Use this page to manage your support FAQ, which users access via their support area within their accounts.
To view, modify, or delete an object, please click its title.
";
} else {
echo "
<b>FAQ (Frequently Asked Questions) Manager</b><br>
The FAQ page is where you can provide your users with answers to frequently
asked questions, thereby reducing the need for email support.
If you turn this feature on, a categorized FAQ page will become available in
your users' support area.
";
}

echo "
<br><br>

<table width='320' cellpadding='0' cellspacing='0' style='background: #FFFFFF; border: 1px solid #AAAAAA;'>
<form action='faq.php' method='POST'>
<tr>
<td style='padding: 6px;'>
<table cellpadding='0' cellspacing='0' width='100%'>
<tr><td valign='top'>
<b>Turn the FAQ feature on or off?</b><br>
<table cellpadding='0' cellspacing='0' style='margin-top: 2px;'>
<tr><td>
<input type='radio' name='faq_on' value='yes'"; if($faqinfo[faq_on] == "yes") { echo " CHECKED"; } echo "></td><td style='padding-bottom: 2px;'>&nbsp;<b>ON</b></td><td>&nbsp;&nbsp;
<input type='radio' name='faq_on' value='no'"; if($faqinfo[faq_on] == "no") { echo " CHECKED"; } echo "></td><td style='padding-bottom: 2px;'>&nbsp;<b>OFF</b></td>
</tr></table>
</td>
<td>
<input type='submit' class='button' value='Update'>
</td></tr></table>
</td>
</tr>
<input type='hidden' name='task' value='faq_onoff'>
</form>
</table>
";

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

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

echo "
<br>

<table cellspacing='0' cellpadding='1'>
<tr>
<form action='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='Add Category'>
</td>
</form>
<form action='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='Add Question'"; if($number_of_kittens == 0) { echo " DISABLED"; } echo ">
</td>
</form>
</tr>
</table>

<br>

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

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

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

if($number_of_kittens == 0) {
echo "Note: You do not have any categories to manage. Click the \"Add Category\" button above to create one.";
}

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

if(in_array($faqcat_info[c_id], $open)) {
  $new_open = "";
  $a = 0;
  for($c=0;$c<count($open);$c++) {
    if($open[$c] != $faqcat_info[c_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='faq.php?o=$o'><img src='../icons/cat_open.gif' border='0'></a></td>
<td valign='bottom'>
<strong><a href='faq.php?task=mod_cat&c_id=$faqcat_info[c_id]&o=$o_url' class='admin_menu'>$faqcat_info[category]</a></strong>
</td>
</tr>
</table>
";

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

$questions1 = mysql_query("SELECT q_id, c_id, question FROM ims_faq WHERE c_id='$faqcat_info[c_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='../icons/question"; if($count == $total_questions) { echo "_last"; } echo ".gif' border='0'></td>
<td valign='bottom'>
<a href='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[c_id];
echo "
<table cellpadding='0' cellspacing='0'>
<tr>
<td width='38' NOWRAP><a href='faq.php?o=$o'><img src='../icons/cat_closed.gif' border='0'></a></td>
<td valign='bottom'>
<strong><a href='faq.php?task=mod_cat&c_id=$faqcat_info[c_id]&o=$o_url' class='admin_menu'>$faqcat_info[category]</a></strong>
</td>
</tr>
</table>
";
}}
}

echo $footer;

}

?>