

/* Loaded for the main site, used for page manipulation
 * globally and for all templates
 */
if ( ! Blue.Site.Main ) { 
    Blue.Site.Main = function() {
        this.type = function() { return 'Site'; };

        this.processFilters = function() { };
    }
    Blue.Site.Main.prototype = new Blue.Site();
}

/* Loaded for the admin site, used for page manipulation. */
Blue.Site.Admin = function() {
    this.type = function() { return 'Admin'; };

    this.processFilters = function() {

        // No turbo button
        Blue.doOnload( function() {
            $('div#wphead-info div#user_info p span.turbo-nag').hide()
            $('#content_toolbar2').show();
        } );

        $('div#profile-page form#your-profile').find('h3').each( function() {
            if (
                $(this).text() == "Contact Info"
                || $(this).text() == "Personal Options"
            ) 
                $(this).hide().next().hide();
        } );

        $('div#profile-page form#your-profile table.form-table tbody tr th').find('label').each( function() {
            if ( $(this).text() == "Biographical Info" ) 
                $(this).parent().hide().next().hide();
        } );

        $('div.wp-submenu ul li').find('a').each( function() {
            if ( $(this).text() == "Post Tags" )
                $(this).parent().hide();
        } );

        // Move the comment widget to the left
        $('#dashboard_recent_comments').attr( 'style', '' );

        // Change footer text
        $('#footer-left')
            .html('')
            .html(
                "Thank you for choosing " + 
                "<a href=\"http://bluecorral.com\">Blue Corral</a>"
            )
            .show();
        ;

        // Disable tools, but only if they're the last thing on 
        // the list.  Furthermore, this is a good determination
        // of whether or not you are working with admin or 
        // administrator, where the first side of the condition
        // is admin.
        if ( ! $('#menu-tools').hasClass('menu-top-last') ) {
            $('#menu-tools').show();
            $('#menu-comments').show();
        }
        else {
            $('#menu-users').addClass('menu-top-last');
            $('#menu-pages').addClass('menu-top-last');
        }

        // Enable customized meta-screen
        //
        // Update the link
        $('#contextual-help-link-wrap a').text('Blue Corral Help');
        $('#contextual-help-wrap').html("Loading ...");
        $('#contextual-help-link-wrap').show();

        // Invoke the help bar
        $.ajax(
            {
                url     : '/bc-api/get_content.php?type=sbs_admin_help',
                cache   : false,
                success : function( content ) {
                    var c = ( content )
                        ? content
                        : 'There was an error displaying the help menu.';

                    $('#contextual-help-wrap')
                        .html('')
                        .html(content);

                    $('div#sbs_help_picslider-wrap').cycle(
                        {
                            fx      : 'scrollRight',
                            speed   : 300, 
                            next    : '#sbs_help_picslider-wrap_next', 
                            prev    : '#sbs_help_picslider-wrap_prev', 
                            timeout : 0 
                        }
                    );
                },

                error : function()  { 
                    $('#contextual-help-wrap')
                        .html('')
                        .html('There was an error displaying the help menu.');
                }
            }
        );


        // Update the notification section
        $.ajax(
            {
                url     : '/bc-api/get_content.php?type=sbs_admin_notification',
                cache   : false,
                success : function( content ) {
                    var c = ( content )
                        ? content
                        : 'There are currently no notifications.';

                    $('#bluecorral_notifications')
                        .html('')
                        .html(content);
                },

                error : function()  { 
                    $('#bluecorral_notifications')
                        .html('')
                        .html('There are currently no notifications');
                }
            }
        );
    };

};
Blue.Site.Admin.prototype = new Blue.Site();

$(document).ready( function() { 

    document.oncontextmenu = function(){};

    var site = new Blue.Site();
    var me   = site.getSite();

    me.addFooterContent();
    me.processFilters();
} );

