﻿$(document).ready(function () {

    //hide the notices (so that we can animate them in ToggleNotices)
    HideNotices();

    //we check for notice cookie if no we don't show notices
    if (!$.cookie("CRMCWebNotice") && AnyNotices()) {  
        ToggleNotices();
    }

    //we 'flash' the notices
    $('#notices>p').fadeOut('fast').fadeIn('fast').fadeOut('slow').fadeIn('slow');

    //we allow users to hide the notices
    $('#noticeCloseButton').click(function () {
        //set notice cookie
        $.cookie("CRMCWebNotice", "set");
        ToggleNotices();
    });
});

//hide the notices and resize the page
function HideNotices() {

    //hide the notices
    $('#noticeContainer').hide();

    //we try to resize frames if we are on a document page
    window.parent.$('#headerfrm').height($('body').height());

    //this line makes IE behave (bad IE!!! no treat!)
    $('#nav>li:first').addClass("sfhover");
}

//opens/closes notice section
function ToggleNotices() {
    $('#noticeContainer').animate({ "height": "toggle" }, { duration: 1000 });

    //we try to resize frames if we are on a document page
    window.parent.$('#headerfrm').height($('body').height());

    //this line makes IE behave (bad IE!!! no treat!)
    $('#nav>li:first').addClass("sfhover");
}

function AnyNotices()
{
    return ($('#notices>p').size() > 0) ? true : false;
}
