<!--<div class="menubg">
    <ul id="menu">
        <li><a style="cursor: pointer;">Masters</a>
            <ul>
                <li><a href="index.php?page=survey_master">Surveys</a></li>
                <li><a href="index.php?page=lab_mapping">Lab Mapping</a></li>
                <li><a href="index.php?page=reimbusmnt_mapping">Reimbursement</a></li>
                <li><a href="index.php?page=app_settings">Application Settings</a></li>
            </ul>
        </li>
        <li><a style="cursor: pointer;">Recruitment</a>
            <ul>
                <li><a href="index.php?page=recuirtment">Registration</a></li>
                <li><a href="index.php?page=locator_info">Locator Information</a></li>
            </ul>
        </li>
        <li><a style="cursor: pointer;">Lab</a>
            <ul>
                <li><a href="index.php?page=lab_master">Lab Sample Collection</a></li>
            </ul>
        </li>
        <li><a style="cursor: pointer;">Reimbursment</a>
            <ul>
                <li><a href="index.php?page=reimbusmnt_master">Reimbursement</a></li>
                <li><a href="index.php?page=incentive_master">Incentive</a></li>
            </ul>
        </li>
        <li><a style="cursor: pointer;">Reports</a>
            <ul>
                <li><a href="#">Lab Chart</a></li>
                <li><a href="#">RDStat Import</a></li>
            </ul>
        </li>
        <li><a style="cursor: pointer;">Administrator</a>
            <ul>
                <li><a href="index.php?page=settings">Settings</a></li>
            </ul>
        </li>
        <li><a style="cursor: pointer;">User Management</a>
            <ul>
                <li><a href="index.php?page=main_menu">Main Menu</a></li>
                <li><a href="index.php?page=sub_menu">Sub Menu</a></li>
                <li><a href="index.php?page=usr_mngmnt">User Management</a></li>
            </ul>
        </li>
    	<li>
        	<div style="width: 250px;">&nbsp;&nbsp;</div>
        </li>
    	<li><a href="index.php?page=logout">Logout</a></li>
    </ul>
</div>-->
<?php
    include_once("includes/config.php");
    include_once("includes/common_functions.php");
    
    $common = new General_Functions();
    $query = "SELECT min_mnu_desc, sub_mnu_name, sub_mnu_desc FROM custom_menu_access 
                    INNER JOIN custom_main_menu ON (custom_main_menu.min_mnu_id = mnu_acs_mnu_id_fk AND custom_main_menu.status = '1')
                    INNER JOIN custom_sub_menu ON (custom_sub_menu.sub_mnu_id = mnu_acs_sub_mnu_id_fk AND custom_sub_menu.status = '1')
            WHERE mnu_acs_usr_id_fk = '".USR."' AND mnu_acs_usr_status = 1 ORDER BY mnu_acs_mnu_id_fk ASC, sub_mnu_preference ASC";
    $common->sql->query($query, SQL_ALL, SQL_ASSOC);
    $ex_records = $common->sql->record;
    $ex_cnt = count($ex_records);

    for($i=0; $i<$ex_cnt; $i++)
    {
        $ex_min_dsc[] = $ex_records[$i]['min_mnu_desc'];
        $ex_sub_nme[$ex_records[$i]['min_mnu_desc']][] = $ex_records[$i]['sub_mnu_name'];
        $ex_sub_dsc[$ex_records[$i]['min_mnu_desc']][] = $ex_records[$i]['sub_mnu_desc'];
    }

    if($ex_cnt > 0)
        $ex_min_dsc = array_unique($ex_min_dsc);
?>
<div class="menubg">
    <ul id="menu">
        <?php
            $j = 0;
            foreach($ex_min_dsc as $key => $val)
            {
                echo '<li><a style="cursor:pointer;">'.$val.'&nbsp;&nbsp;</a>
                    <ul class="sub_menu">';
                    for($i=0; $i<count($ex_sub_nme[$val]); $i++)
                    {
                        echo '<li><a href="index.php?page='.$ex_sub_nme[$val][$i].'">'.$ex_sub_dsc[$val][$i].'</a></li>';
                        // echo '<li><a href="'.WWW_DOC_ROOT.'index/page/'.$ex_sub_nme[$val][$i].'">'.$ex_sub_dsc[$val][$i].'</a></li>';
                        // echo '<li><a href="'.$ex_sub_nme[$val][$i].'.html">'.$ex_sub_dsc[$val][$i].'</a></li>';
                    }
                    $j++;
                    echo '</ul>
                </li>';
            }
        ?>
    	<li style="float: right;"><a href="index.php?page=logout">Logout</a></li>
    	<li style="float: right;"><a href="index.php?page=chng_pwd">Change Password</a></li>
    	<!--<li style="float: right;"><a href="logout.html">Logout</a></li>-->
    </ul>
</div>
<script>
	/*function getUrlVars() {
		var vars = {};
		var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
			vars[key] = value;
		});
		return vars;
	}
	var first = getUrlVars();
	var second = getUrlVars()["page"];
	 
	alert(first);
	alert(second);
	
	var sPath = window.location.pathname;
	var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
	//alert(sPage);
	
	$(document).ready( function() {
		$("#menu li a").each(function(i) {
			//alert($(this).attr("href"));
		});
	});*/
</script>