<?php
if (!defined("IN_FUSION")) { die("Access Denied"); }

include_once LOCALE.LOCALESET."admin/main.php";
include_once ADMIN."template/locale/".LOCALESET."breadCrumb.locale.php";
require_once ADMIN."template/includes/breadCrumb.inc.php";

@list($title) = dbarraynum(dbquery("SELECT admin_title FROM ".DB_ADMIN." WHERE admin_link='".FUSION_SELF."'"));

add_to_title($locale['global_200'].$locale['global_123'].($title ? $locale['global_201'].$title : ""));

if(function_exists("add_to_footer")) {
    add_to_footer("<script language='javascript' type='text/javascript' src='".ADMIN."template/jquery/jquery.corner_tipsy.min.js'></script>");
    add_to_footer("<script language='javascript' type='text/javascript'>    
    $(document).ready(function() {
        $('.tip').tipsy({gravity: 'sw'});
        $('.tip_s').tipsy({gravity: 'nw'});
        $('.admin-body, .forum-corner, .forum_thread, .forum_post, .no-desc, .admin-main-panel-contener-bg, .response').corner('8px');
        $('.admin-message').corner('8px').fadeIn(1600).animate({opacity:0.01},4500).hide(800);
	    $('#bbcode_smileys_list_shout_message').corner('4px').css({opacity:0.7});
	    $('.error, .valid, .status').corner('8px').hide(1).fadeIn(1000);
        $('.textbox, .button, .bbcode').corner('4px');
        $('#column1, #column2, #column3, #column4, #messageBox').corner('4px');                       	                                                            
    });        
    </script>");
    add_to_footer("<script language='javascript' type='text/javascript'> var AID_LINK = '".$aidlink."', PATH_ADMIN = '".ADMIN."', LOCALE = { 'ac_ajax_01' : '".$locale['ac_ajax_01']."', 'ac_ajax_02' : '".$locale['ac_ajax_02']."' };  </script>");
    if(FUSION_SELF == "index.php")  {
        add_to_footer("<script language='javascript' type='text/javascript' src='".ADMIN."template/jquery/jquery.adminPanel.js'></script>");
    }         
} else {
    add_to_head("<script language='javascript' type='text/javascript' src='".ADMIN."template/jquery/jquery.corner_tipsy.min.js'></script>");
    add_to_head("<script language='javascript' type='text/javascript'>
    $(document).ready(function() {
        $('.tip').tipsy({gravity: 'sw'});
        $('.tip_s').tipsy({gravity: 'nw'});
        $('.admin-body, .forum-corner, .forum_thread, .forum_post, .no-desc, .admin-main-panel-contener-bg, .response').corner('8px');
        $('.admin-message').corner('8px').fadeIn(1600).animate({opacity:0.01},4500).hide(800);
	    $('#bbcode_smileys_list_shout_message').corner('4px').css({opacity:0.7});
	    $('.error, .valid, .status').corner('8px').hide(1).fadeIn(1000);
        $('.textbox, .button, .bbcode').corner('4px');
        $('#column1, #column2, #column3, #column4').corner('4px');
    });
    </script>");
    add_to_head("<script language='javascript' type='text/javascript'> var AID_LINK = '".$aidlink."', PATH_ADMIN = '".ADMIN."', LOCALE = { 'ac_ajax_01' : '".$locale['ac_ajax_01']."', 'ac_ajax_02' : '".$locale['ac_ajax_02']."' };  </script>");
    if(FUSION_SELF == "index.php")  {
        add_to_head("<script language='javascript' type='text/javascript' src='".ADMIN."template/jquery/jquery.adminPanel.js'></script>");
    }        
}

$pages = array(1 => false, 2 => false, 3 => false, 4 => false, 5 => false);
$index_link = false; $admin_nav_opts = ""; $current_page = 0;

if ((!isset($_GET['pagenum']) || !isnum($_GET['pagenum'])) && (FUSION_SELF != "index.php")) {
    $result = dbquery("SELECT admin_page FROM ".DB_ADMIN." WHERE admin_link='".FUSION_SELF."'");
    if(dbrows($result)) { $_GET['pagenum'] = dbresult($result,0); }        
}

echo "<div align='right' style='margin: 0 5px 5px 0;'>\n";
echo "<a href='".BASEDIR."index.php' class='side'>Home</a> | ";
echo "<a href='".ADMIN."index.php".$aidlink."' class='side'>".$locale['global_123']."</a>\n";
echo "</div>\n";

openside($locale['global_001']);
$result = dbquery("SELECT admin_title, admin_page, admin_rights, admin_link FROM ".DB_ADMIN." ORDER BY admin_page DESC, admin_title ASC");
$rows = dbrows($result);
if($rows != 0) {
    while ($data = dbarray($result)) {
        if ($data['admin_link'] != "reserved" && checkrights($data['admin_rights'])) {
            $pages[$data['admin_page']] .= preg_replace("/&(?!(#\d+|\w+);)/", "&amp;", $data['admin_title']);
    	}
    }    
}

echo "<ul id='admin-ul-nav'>\n";
for ($i = 1; $i <= 5; $i++) {
    $class = (isset($_GET['pagenum']) && $_GET['pagenum'] == $i ? "active " : "");
    if ($pages[$i]) {
        echo "<li align='center' width='20%' class='".$class.(isset($_GET['pagenum']) && $_GET['pagenum'] == $i ? "admin-ul-nav-active-".$i : "admin-ul-nav-".$i)."' id='nav_li_".$i."'>";
        echo "<a href='".ADMIN."index.php".$aidlink."&amp;pagenum=".$i."' class='admin_nav_link admin-link-".$i."' id='nav_link_".$i."'".(FUSION_SELF == "index.php" ? /*" onClick='return false;'"*/ "" : "").">".$locale['ac0'.$i]."</a>";
        echo "</li>\n";
    } else {
        echo "<li align='center' width='20%' class='access ".$class." admin-ul-nav-".$i."'>".$locale['ac0'.$i]."</li>\n";
    }
}
echo "</ul>\n";
closeside();

openside($userdata['user_name']);
$msg_count = dbcount("(message_id)", DB_MESSAGES, "message_to='".$userdata['user_id']."' AND message_read='0'AND message_folder='0'");

if ($msg_count) { 
    echo "<div class='status bold'>\n";
    echo "<img src='".ADMIN."template/images/loader.gif' alt='' /><br />\n";
    echo "<a href='".BASEDIR."messages.php' class='side tip' title='".sprintf($locale['global_125'], $msg_count).($msg_count == 1 ? $locale['global_126'] : $locale['global_127'])."'>".sprintf($locale['global_125'], $msg_count).($msg_count == 1 ? $locale['global_126'] : $locale['global_127'])."</a></div>"; 
}

echo "<ul id='admin-ul-nav'>\n";
echo "<li><a href='".BASEDIR."edit_profile.php' class='side' title='".$locale['global_120']."'>".$locale['global_120']."</a></li>\n";
echo "<li><a href='".BASEDIR."messages.php' class='side' title='".$locale['global_121']."'>".$locale['global_121']."</a></li>\n";
echo "<li><a href='".BASEDIR."members.php' class='side' title='".$locale['global_122']."'>".$locale['global_122']."</a></li>\n";
echo "<li><a href='".BASEDIR."setuser.php?logout=yes' class='side' title='".$locale['global_124']."'>".$locale['global_124']."</a></li>\n";
echo "</ul>\n";
closeside();

?>