﻿/*****************************/
/* SSA FRAMEWORK             */
/* created by: Eric Brown    */
/* last modified: 04/07/11   */
/*****************************/

/*******************************/
/*   SHUTDOWN DIALOG VARIABLE  */
/*******************************/
var shutdown = false; // set to true if you want the dialog to appear

/*****************************/
/*   CONFIGURE NAMESPACES    */
/*****************************/
/* JavaScript Framework 
---------------------------------------------*/
var jsFramework = {
    cdn: "http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js",
    docs: "http://jquery.com",
    version: "1.5.2"
}

/* JavaScript UI Framework 
---------------------------------------------*/
var jsUI = {
    cdn: "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js",
    cdnTheme: "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/smoothness/jquery-ui.css",
    docs: "http://jqueryui.com",
    version: "1.8.11"
}

/* JavaScript Plugins
---------------------------------------------*/
var jsPlugins = {
    file: "jquery.plugins.js",
    location: "/js/min/",
    version: "1.0"
}

/***********************************/
/*   CONFIGURE WIDGET NAMESPACES   */
/***********************************/

/* SSA Drop Down Boxes Fix 
---------------------------------------------*/
var ssaDropDown = {
    file: "drop-down.js",
    location: "/js/min/drop-down/",
    version: "1.5"    
}

/* SSA Disclaimer Dialog Box 
---------------------------------------------*/
var ssaDisclaimer = {
    file: "disclaimer.js",
    location: "/js/min/dialog/",
    version: "1.0"
}

/* SSA Shutdown Dialog Box 
---------------------------------------------*/
var ssaShutdown = {
    file: "shutdown.js",
    location: "/js/min/dialog/",
    version: "1.0"
}

/* SSA Menu Bar 
---------------------------------------------*/
var ssaMenuBar = {
    file: "menu.js",
    location: "/js/min/menu/",
    version: "1.5"
}

/* SSA News Slider 
---------------------------------------------*/
var ssaNewsSlider = {
    file: "newsslider.js",
    location: "/js/min/newsslider/",
    pluginfile: "jquery.cycle.min.js",
    pluginlocation: "/js/min/newsslider/plugins/",
    version: "1.5.1"
}

/* SSA Plugins 
---------------------------------------------*/
var ssaPlugins = {
    file: "plugins.js",
    location: "/js/min/ssa/",
    version: "1.0"
}


/*********************************/
/*   SSA CONFIG FUNCTIONS        */
/*********************************/
/* ADD-IN FEATURES IF JQUERY IS AVAILABLE
---------------------------------------------------------*/
if (typeof jQuery != "undefined") {

    /* SET A FLAG FOR OLDER VERSIONS OF IE
    ---------------------------------------------------------*/
    var msIEOld = false;

    if ($.browser.msie && $.browser.version < "7") {
        msIEOld = true;
    }
    else {
        $("html").addClass("modern");    
    }

    /* ESTABLISH SCRIPTS AND STYLES ARRAYS
    ---------------------------------------------------------*/
    var scripts = [];
    var styles = [];

    /* LOAD SCRIPTS ONLY WHEN THE DOM IS READY
       {REMOVE WHEN INITIATING <SCRIPT> CAN BE PUT AT BOTTOM}
    -------------------------------------------------------------*/
    $(function () {

        /*   RUN MODULES ONLY IN MODERN BROWSERS
        ---------------------------------------------------------*/
        if (msIEOld !== true) {

            /*   ESTABLISH WIDGETS BASED ON IDs/CLASSes
            ---------------------------------------------------------*/
            var $disclaimer = $("a.disclaimer").length;
            var $newsSlider = $("#news-slider").length;
            var $select = $("select.nav-select").length;
            var $shutdown = $("body.shutdown").length;

            /* PLUG-INS
            ---------------------------------------------------------*/
            scripts.push(jsPlugins.location + jsPlugins.file);
            scripts.push(ssaPlugins.location + ssaPlugins.file);

            /* NEWS SLIDER
            ----------------------------------------------------------*/
            if ($newsSlider > 0) {
                scripts.push(ssaNewsSlider.pluginlocation + ssaNewsSlider.pluginfile);
                scripts.push(ssaNewsSlider.location + ssaNewsSlider.file);
            }

            /* JQUERY UI 
            ---------------------------------------------------------*/
            styles.push(jsUI.cdnTheme);
            scripts.push(jsUI.cdn);

            /* DISCLAIMER DIALOG BOX
            ----------------------------------------------------------*/
            if ($disclaimer > 0) {
                scripts.push(ssaDisclaimer.location + ssaDisclaimer.file);
            }

            /* DROP DOWN (<SELECT>) ACCESSIBILITY FIX
            ----------------------------------------------------------*/
            if ($select > 0) {
                scripts.push(ssaDropDown.location + ssaDropDown.file);
            }

            /* MENU BAR
            ----------------------------------------------------------*/
            scripts.push(ssaMenuBar.location + ssaMenuBar.file);

            /* SHUTDOWN DIALOG BOX
            ----------------------------------------------------------*/
            if ($shutdown > 0 || shutdown === true) {
                scripts.push(ssaShutdown.location + ssaShutdown.file);
            }

            /* ENHANCE PAGE FUNCTION  
            ----------------------------------------------------------*/
            enhance({
                appendToggleLink: false,
                loadStyles: styles,
                loadScripts: scripts
            });

            /* ADD-IN INTERNET EXPLORER CSS
            ----------------------------------------------------------*/
            enhance({
                appendToggleLink: false,
                loadStyles: [{ href: '/css/min/ie.css', iecondition: 'lte IE 7'}]
            });
        }
    });
}
