﻿function SetPageDesignSize() {
    var defaultBackgroundWidth = 1097; /* make sure this width ties with the gradientbackgroundlayer width */
    var gradientLayerHeight = $("#masthead").outerHeight() + $("#canvas").outerHeight() + $("#footer").outerHeight() - 6;
    $("#gradientbackgroundlayer").height(gradientLayerHeight);

    var windowWidth = $(window).width();
    //alert(windowWidth);
    if (windowWidth < defaultBackgroundWidth) {
        $("#gradientbackgroundlayer").width(windowWidth);
        $("#mainbackgroundlayer").width(windowWidth);
    }
    else {
        $("#gradientbackgroundlayer").width(defaultBackgroundWidth);
        $("#mainbackgroundlayer").width(defaultBackgroundWidth);
    }
}

$(function() { //On Document ready

    $(window).resize(function() { SetPageDesignSize(); });

    // jquery dropdown menu functions						
    $('#jsddm > li').bind('mouseover', jsddm_open)
    $('#jsddm > li').bind('mouseout', jsddm_timer)
    document.onclick = jsddm_close;

    // jquery rollover code init;
    $(".ro").autoMouseOver({ outStr: ".", overStr: "_o." });

    // this is wires up the Site Search for Google search submit
    $('#sa').click(function() { $('#cse-search-box').submit(); });

    // this is for the dropdowns (About Us)
    $('#mastheadnav').supersubs({
        minWidth: 12,
        maxWidth: 27,
        extraWidth: 1
    }).superfish({ speed: 'fast' });

    // this is for the IE6 fixup
    $('body').supersleight();


    
    // Browser Check -> show a dialog if using IE 6 or earlier
    if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 7 && $.cookie('ie6') == null) {
        // set session cookie so this warning message only shows once per session
        $.cookie('ie6', 'true');

        var $browserCheckDialog = $('<div></div>');
        $browserCheckDialog
                        .load('/ie6.htm')
                        .dialog({
                            title: 'Browser Version Detection',
                            width: 600,
                            height: 300
                        });

        $browserCheckDialog.dialog('open');

        return false;
    }
    
    
});