<?php

include './core.php';


if(isset($_REQUEST['mode']) === false) {
	$catlist = $MySQL->fetch_complete( "SELECT categoryID, name FROM faq_categories WHERE name NOT LIKE 'HELP_%' ORDER BY `order`" );
	$Smarty->assign( 'catlist', $catlist );
}

if( isset( $_REQUEST['category'] ) )
	$cat = $MySQL->query_first( sprintf("SELECT categoryID, name FROM faq_categories WHERE categoryID=%d", intval( $_REQUEST['category'] )) );
else
	$cat = $catlist[0];
$Smarty->assign( 'cat', $cat );


$faqs = $MySQL->fetch_complete( "SELECT * FROM faqs WHERE categoryID=".$cat['categoryID']." ORDER BY `order`" );
$Smarty->assign( 'faqs', $faqs );


if(isset($_REQUEST['mode']) === true && $_REQUEST['mode'] == 'help') {
	$cat['name'] = str_replace('HELP_', '', $cat['name']);

	$Smarty->assign('page_title', $cat['name']);
	$Smarty->assign('page_title_long', $cat['name']);
	$Smarty->assign('page_title_site', $cat['name']);

	$page['content'] = $Smarty->fetch( 'faqs.tpl' );
	$Smarty->assign( 'page', $page );
	$Smarty->display( 'main_simple.tpl' );	
} else {
	$Smarty->assign('page_title', "FAQs");
	$Smarty->assign('page_title_long', "Frequently Asked Question");
	$Smarty->assign('page_title_site', "Frequently Asked Question");

	$page['content'] = $Smarty->fetch( 'faqs.tpl' );
	$Smarty->assign( 'page', $page );
	$Smarty->display( 'main.tpl' );
}


?>