
var AdminLoadingImage;

function InitAdmin() {
    // Admin Events

    onLogIn.subscribe(
        function(type, args) {
            try {
                if (!args[0].IsStartUp) {
                    ADRefreshContent();
                    ADRefreshNavigation();
                }
            } catch (e) { logE("Admin - onLogIn.subscribe", e); }
        }
    );

        onLogOut.subscribe(
        function(type, args) {
            try {
                if (!args[0].IsStartUp) {
                    ADRefreshContent();
                    ADRefreshNavigation();
                }
            } catch (e) { logE("Admin - onLogOut.subscribe", e); }
        }
    );

        // *************************************
        // Startup Handlers - called from Master
        // *************************************


        onPageResize.subscribe(
            function(type, args) {
                    try {
                        ADAdjustContentLayout();
                    } catch (e) { logE("Admin - onPageResize.subscribe", e); }
                }
        );

        onRefreshContent.subscribe(
        function(type, args) {
                    ADRefreshContent();
                }
        );
        onRefreshNavigation.subscribe(
        function(type, args) {
                    ADRefreshNavigation();
                }
        );

}

// *************************************
// Event Handlers
// *************************************



 function AdminContentControlRequestStart(sender, eventArgs){
    AdminLoadingImage.show();
 }
 function AdminContentControlResponseEnd(sender, eventArgs){
    AdminLoadingImage.hide();
 }



 function ADAdjustContentLayout() {
     $j("#main").height(contentHeight);
     $j("#leftColumn").height(contentHeight);
     $j("#TreePanel").height(contentHeight);
     $j("#splitter").height(contentHeight);
     $j("#rightColumn").height(contentHeight);
     $j("#rightColumn").width($j("#main").outerWidth() - SplitterWidth - leftColumnWidth);
    //xHeight('ctl00_ctl00_ContentPlaceHolder_CPhPPanel', contentHeight - xHeight(ContentToolBarPanel));
    $j(sVars.AD_ContentToolBarPanelID).height( contentHeight - $j(sVars.AD_ContentToolBarPanelID).outerHeight());
}


// *****************************
// Other Called from Master Code
// *****************************

function  ADRefreshContent(){
    try {
        $find(sVars.ContentControlID).ajaxRequest("REFRESH");
    } catch (e){logE("Admin - RefreshContent",e);}
}

function ADRefreshNavigation() {
    try {
        AD.NavigationTree.refresh();
    } catch (e) { logE("Admin - RefreshNavigation", e); }
}







