
// Functions: duplicated in utils.js
var util = [];
util.Redir = function (url) {
    $('#TableInner').fadeTo(100, 0.5);
    //TODO Show loader;
    window.location.assign(url);
};

// Replacing;  window.open(url, title','title=no,scrollbars=yes,resizable=yes,width="+width+",height="+height+"')
util.Popin = function (url, htmltitle, width, height) {
    var container = $('#dInner').append('<div></div>');
    var popin = $(container).dialog({
        autoOpen: false,
        resizable: true,
        minWidth: width,
        minHeight: height,
        modal: true,
        title: htmltitle
    });

    popin.dialog('open');
    return popin;
}

window.util = util; // Setting util globally

// Starting jQuery NUI POC setup
$(document).ready(function () {

    var $tableMain = $('#TableHeading').addClass('ui-corner-all');
    var $menu = $('#menuActions'); // Should we:.hide();

    if ($menu.length > 0) { // If any menu, it's a full page, restyle it
        $tableMain.find('table').eq(2); //.hide();
        var l_logout = $('#_ctl2_LinkLogout');
        $menu.find('a').closest('table').not('[id]').click(function (event) {
            var btn = $(this).find('a.MenuLink').eq(0);
            util.Redir(btn.attr('href'));
            return false;
        });
        $menu.find('a').closest('table').not('[id]').hover(
                function () {
                    $(this).addClass('ui-state-hover');
                },
                function () {
                    $(this).removeClass('ui-state-hover');
                });

        $('#dOuter').css('height', ($tableMain.height() + 600));
        // DEBUG: console.log($('#dOuter').height()); // DEBUG
    }
});


