/*
*   A minimized version of this file exists using the file name of inserting .min before .js
*   To minimized, use http://refresh-sf.com/yui/ and save output to the .min equivalent of this file.
*/
$(document).ready(function ()
{
    var liDaysUntilcma = getDaysTillSailMessage();
    if (liDaysUntilcma != "" && liDaysUntilcma != null)
    {
        $("#header-num-days").html(liDaysUntilcma);
        $("#header2010 .btm #subnav").addClass("dl");
        $("#header-days-left").show();
    }
    $("#dropdowns li, #subnav li").hover(function ()
    {
        if ($(this).find('.flyout').length > 0)
        {
            if (!($(this).hasClass('find') && $('.quick-search').not('#header2010 .quick-search').length > 0))
            {
                $(this).addClass('active');
                if ($.browser.msie && parseInt($.browser.version) == 6)
                {
                    $(this).find(".flyout").bgiframe();
                }
            }
        }
    }, function ()
    {
        var lbHasFocus = false;
        var lsActiveID = document.activeElement.id;
        $(this).find('select').each(function ()
        {
            if ($(this).attr('id') == lsActiveID)
            {
                lbHasFocus = true;
            }
        });

        if (!lbHasFocus)
        {
            $(this).removeClass('active');
        }
    });

    var lsUserAgent = navigator.userAgent.toLowerCase();
    if (lsUserAgent.indexOf('safari') != -1 && lsUserAgent.indexOf('chrome') == -1)
    {
        $('select.med').css('width', '210px').css('height', '38px').css('background', 'none').css('border', '1px solid');
    }

    /*
    if ($("#aspnetForm").attr('action') == "home.aspx" || location.href.length < 25 || (location.href.split('/').length < 5 && location.href.length < 25))
    {
        $('body').addClass('home');
    }
    */
});
jQuery.extend(jQuery.expr[':'], {
    focus: function (aoElement)
    {
        return aoElement == document.activeElement;
    }
});
function getDaysTillSailMessage()
{
    var lsReturn = "";
    var liMinutes = 1000 * 60;
    var liHours = liMinutes * 60;
    var liDays = liHours * 24;

    try
    {
        var lsSailDate = $.cookie("SailDate");
    }
    catch (aoXcp)
    {
    }

    if (lsSailDate != null && lsSailDate != "")
    {
        var loSailDate = Date.parse(lsSailDate);
        var lsParsedSailDate = Date.parse(Date());
        var lsLabel = " Days";
        liDays = parseInt(((loSailDate - lsParsedSailDate) / liDays));
        if (liDays == 1)
        {
            lsLabel = " Day";
        }

        lsReturn = liDays + lsLabel;
    }

    return lsReturn;
}
