var DefaultThemeName = 'Glass';

function navigate(s, e) {
    var src = e.item.name + '/';
    var frame = $('iframe')[0];
    if (frame != null) {
        var container = $('#div_Content').parent();
        var div = $('#div_Content').clone();
        $('#div_Content').remove();
        $(container).append(div);
        $('iframe')[0].src = src;
        $('#rpContent_frmContent').load(onFrameLoad);
        $('#rpContent_hdnContentSrc').val(src);

        $('div#HeaderLeft').text($(e.htmlElement).text().trim());
        $('div#HeaderRight').text(e.item.name);
        showLoadingPanel();
    }
}

function resizeFrame() {
    var frame = $('iframe')[0];
    if (frame != null) {
        if (frame.contentWindow != null) {
            var frameBody = frame.contentWindow.document.body;
            var height = frameBody.scrollHeight;
            //height = $(frameBody).height();
            if (height < 600)
                height = 600;
            frame.style.height = (height + 50) + 'px';
            hideLoadingPanel();
        }
    }
}

function initFrame() {
    var frame = $('iframe')[0];
    if (frame != null) {
        var height = screen.availHeight - $('iframe').position().top - 200;
        frame.style.height = (height) + 'px';
    }
}

function showLoadingPanel() {
    try { panelLoading.Show(); } catch (ex) { }
}

function hideLoadingPanel() {
    try { panelLoading.Hide(); } catch (ex) { }
    
}

function onShowUpLoginFromClick(s, e) {
    popup_Login.Show();
}

function getThemeName() {
    var theme = $.cookie('KionTheme');
    if (theme == null)
        theme = DefaultThemeName;
    return theme;
}

function setThemeName(name) {
    $.cookie('KionTheme', name, { expires: 10 });
}

function onFrameLoad() {
    hideLoadingPanel();
    resizeFrame();
}
