<?PHP
/************************************************************************/
/* NPDS V : Net Portal Dynamic System .                                 */
/* ===========================                                          */
/*                                                                      */
/* Original Copyright (c) 2001 by Francisco Burzi (fburzi@ncc.org.ve)   */
/* http://phpnuke.org                                                   */
/*                                                                      */
/* This version name NPDS Copyright (c) 2001-2005 by Philippe Brunier   */
/*                                                                      */
/* ======================                                               */
/* Based on Automated FAQ                                               */
/* Copyright (c) 2001 by                                                */
/*    Richard Tirtadji AKA King Richard (rtirtadji@hotmail.com)         */
/*    Hutdik Hermawan AKA hotFix (hutdik76@hotmail.com)                 */
/* http://www.phpnuke.web.id                                            */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/
if (!function_exists("Mysql_Connexion")) {include ("mainfile.php");}

function ShowFaq($id_cat, $categories) {
    global $sitename;
    echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\"><tr><td class=\"HEADER\">\n";
    echo "$sitename ".translate("FAQ (Frequently Ask Question)");
    echo "</td></tr></table>\n";
    echo "<form name=\"search\" onSubmit=\"return findInPage(this.string.value);\">";
    echo"<a name=\"top\"></a>".translate("Category:")." <a href=\"faq.php\" class=\"NOIR\">".translate("Main")."</a> -> ".StripSlashes($categories);
    echo "
    <SCRIPT type=\"text/javascript\" language=\"JavaScript\">
    var NS4 = (document.layers);
    var IE4 = (document.all);
    var win = window;
    var n = 0;

    function findInPage(str) {
       var txt, i, found;
       if (str == \"\")
          return false;

       if (NS4) {
          if (!win.find(str))
             while(win.find(str, false, true))
                n++;
          else
             n++;

          if (n == 0)
             alert(\"".translate("No matches found to your query")."\");
       }

       if (IE4) {
          txt = win.document.body.createTextRange();
          for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) {
             txt.moveStart(\"character\", 1);
             txt.moveEnd(\"textedit\");
          }

          if (found) {
             txt.moveStart(\"character\", -1);
             txt.findText(str);
             txt.select(); //lwf
             txt.scrollIntoView();
             n++;
          } else {
             if (n > 0) {
                n = 0;
                findInPage(str);
             } else
                alert(\"".translate("No matches found to your query")."\");
          }
       }
       return false;
    }
    </script>";
    echo "<br /><br /><p align=\"center\">
    <input class=\"TEXTBOX_STANDARD\" name=\"string\" type=\"text\" size=\"30\" onChange=\"n=0;\">&nbsp;&nbsp;
    <input type=\"submit\" class=\"BOUTON_STANDARD\" value=\"".translate("Search in")." ".translate("the page")."\">
    </p></form>
    <table width=\"100%\" cellspacing=\"0\" cellpadding=\"2\" border=\"0\">
    <tr><td class=\"ONGL\">".translate("Question")."</td></tr>";
    $result = mysql_query("select id, id_cat, question, answer from faqanswer where id_cat='$id_cat'");
    while (list($id, $id_cat, $question, $answer) = mysql_fetch_row($result)) {
        $rowcolor = tablos();
        echo"<tr $rowcolor><td><a href=\"#$id\" class=\"NOIR\">".aff_langue($question)."</a></td></tr>";
    }
    echo "</table>
    <br />";
}

function ShowFaqAll($id_cat) {
    echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\"><tr><td class=\"HEADER\">\n";
    echo translate("Answer");
    echo "</td></tr></table>\n";
    echo "<br /><table width=\"100%\" cellspacing=\"0\" cellpadding=\"2\" border=\"0\">";
    $result = mysql_query("select id, id_cat, question, answer from faqanswer where id_cat='$id_cat'");
    while(list($id, $id_cat, $question, $answer) = mysql_fetch_row($result)) {
        $rowcolor = tablos();
        echo"<tr $rowcolor><td><a name=\"$id\"></a><span class=\"TITRE\"><b>&nbsp;".aff_langue($question)."&nbsp;</b></span><p align=\"justify\">";
        $answer=aff_code(aff_langue($answer));
        echo meta_lang($answer);
        echo "</p><hr noshade class=\"ONGL\"><a href=\"#top\" class=\"NOIR\">".translate("Back to Top")."</a><br /><br /></td></tr>";
    }
    echo"</table><br /><br /><div align=\"center\"><b>[ <a href=\"faq.php\" class=\"NOIR\">".translate("Back to FAQ Index")."</a> ]</b></div>";
}

 if (!$myfaq) {
    include ("header.php");
    // Include cache manager
    if ($SuperCache) {
       $cache_obj = new cacheManager();
       $cache_obj->startCachingPage();
    }
    if (($cache_obj->genereting_output==1) or ($cache_obj->genereting_output==-1) or (!$SuperCache)) {
       opentable();
       echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\"><tr><td class=\"HEADER\">\n";
       echo "$sitename ".translate("FAQ (Frequently Ask Question)");
       echo "</td></tr></table>\n";
       echo "<br /><table width=\"100%\" cellspacing=\"0\" cellpadding=\"2\" border=\"0\">
       <tr><td class=\"ONGL\">".translate("Categories")."</td></tr>";
       $result = mysql_query("select id_cat, categories from faqcategories ORDER BY id_cat ASC");
       while(list($id_cat, $categories) = mysql_fetch_row($result)) {
          $rowcolor=tablos();
          $catname = urlencode(aff_langue($categories));
          echo"<tr $rowcolor><td><a href=\"faq.php?id_cat=$id_cat&amp;myfaq=yes&amp;categories=$catname\" class=\"NOIR\">".aff_langue($categories)."</a></td></tr>";
       }
       echo"</table>";
       closetable();
    }
    if ($SuperCache) {
       $cache_obj->endCachingPage();
    }
    include ("footer.php");

 } else {
    $title="FAQ : ".removeHack(StripSlashes($categories));
    include("header.php");
    // Include cache manager
    if ($SuperCache) {
       $cache_obj = new cacheManager();
       $cache_obj->startCachingPage();
    }
    if (($cache_obj->genereting_output==1) or ($cache_obj->genereting_output==-1) or (!$SuperCache)) {
       opentable();
       ShowFaq($id_cat, removeHack($categories));
       ShowFaqAll($id_cat);
       CloseTable();
    }
    if ($SuperCache) {
       $cache_obj->endCachingPage();
    }
    include("footer.php");
 }
?>