<?php if (!defined('IN_CONTEXT')) die('access violation error!'); ?>
<div id="adminToolbar">
    <ul id="admintoolbar_nav">
<?php foreach ($admin_entries as $section => $entries) { ?>
    	<li><a href="###" class="section"><?php _e($section); ?></a>
            <div class="adminToolbar_downmenu">
            <?php foreach ($entries as $menu_entry) { ?>
                <?php if ($menu_entry[0] == '0') { ?>
                    <a href="#" title="" onclick="show_iframe_win('index.php?<?php echo Html::uriquery($menu_entry[1], $menu_entry[2]); ?>', '<?php _e($menu_entry[3]); ?>', 720, 520);return false;"><?php _e($menu_entry[3]); ?></a>
                <?php } else if ($menu_entry[0] == '1') { ?>
                    <a href="<?php echo $menu_entry[1]; ?>" target="_blank" title=""><?php _e($menu_entry[2]); ?></a>
                <?php } ?>
            <?php } ?>
            </div>
        </li>
<?php } ?>
    </ul>
    <div class="admintoolbar_right">
    	&raquo; <a href="javascript:save_layout();"><?php _e('Save Layout'); ?></a>&nbsp;
        &raquo; <a href="index.php?<?php echo $_SERVER['QUERY_STRING']?$_SERVER['QUERY_STRING'].'&amp;':''; ?>_v=preview" target="_blank" title=""><?php _e('Preview'); ?></a>
        &raquo; <a href="index.php?<?php echo Html::xuriquery('mod_auth', 'dologout'); ?>" title="<?php _e('Logout') ?>"><?php _e('Logout') ?></a>
    </div>
</div>

<script type="text/javascript" language="javascript">
<!--
    function save_layout() {
        var pos_form = document.forms["SAVE_POS"];
        save_position(pos_form, on_save_pos_success, on_save_pos_failure);
    }
    
    function on_save_pos_success(response) {
        var o_result = _eval_json(response);
        if (!o_result) {
            return on_failure(response);
        }
        
        if (o_result.result == "OK") {
            alert("<?php _e('Layout saved!'); ?>");
            return true;
        } else {
            return on_failure(response);
        }
    }

    function on_save_pos_failure(response) {
        alert("<?php _e('Request failed!'); ?>");
        return false;
    }
    
    function delayHide(jq_obj) {
        setTimeout(
            function() {
                jq_obj.children("div").hide("normal");
            },
            200
        );
    }
    
    function addHoverHide() {
        $("#admintoolbar_nav li").each(
            function() {
                $(this).hover(
	                function(){
	                    $(this).children("div").show("normal");
	                },
	                function(){
	                    delayHide($(this));
	                }
                );
            }
        );
    }
    addHoverHide();
//-->
</script>
