<?php
/**
 * Created by PhpStorm.
 * User: IOAN
 * Date: 9/1/2015
 * Time: 12:43 PM
 */
$show_faq = false;
$faq_friendly_url = mysql_real_escape_string(trim($_REQUEST['faq_friendly_url']));

$q = "SELECT * FROM faq_cat WHERE friendly_url='$faq_friendly_url';";
$r = @mysql_query($q);
if($r && mysql_num_rows($r) == 1) {
    $row = mysql_fetch_assoc($r);
    $faq = array_map('stripslashes', $row);
    $faq_id = intval($faq['faq_cat_id']);
    $faq_title = $faq['title_en'];
    $faq_description = $faq['description'];
    $webpage_title_en = $faq_title;
    $meta_description = $faq['meta_description'];
    $meta_keywords = $faq['meta_keywords'];

    $meta['description'] = $meta_description;


    $fq = array();
    $fa = array();
    $qq = "SELECT * FROM faq WHERE parent_id='$faq_id' AND active='yes' ORDER BY order_seq ASC;";
    $rq = @mysql_query($qq);
    if($rq && mysql_num_rows($rq) > 0) {
        $show_faq = true;
        while($rowq = mysql_fetch_assoc($rq)) {
            $fq [] = stripslashes($rowq['name']);
            $fa [] = stripslashes($rowq['answer']);
        }
    }

    $canonical_link = $protocol . $_SERVER['HTTP_HOST'] . '/faq/' . $faq_friendly_url . '.html';
}

if($show_faq) {

    $partial_url = "faq/" . $faq_friendly_url . '.html';
    $top_id = 'faq-' . $faq_id;
    ?>
    <article class="article cyprus">
        <header>
            <h1><?=$faq_title?></h1>
            <!--[/SocialShareButtons/]-->
        </header>
        <div class="article-body cyprus">
            <div class="well well-sm">
                <br>
                <ol class="no-padding" id="<?=$top_id;?>">
                    <?php
                    foreach($fq as $q_id=>$q) {
                        echo '<li><a href="'.$partial_url .'#a' . $q_id .'">' . $q . '</a></li>';
                    }
                    ?>
                </ol>
            </div>

            <?php
            foreach($fq as $q_id=>$q) {
                echo '<p><a id="a'.$q_id.'" name="a'.$q_id.'"></a><b>' . $q . '</b> (<a href="'.$partial_url .'#' . $top_id .'">top</a>)<br>'.$fa[$q_id].'</p>';
            }
            ?>
        </div>
    </article>
    <?php
}
else {
    $module_page = "404";
    $send404 = true;
}