function close_notification()
{
    $.cookie('notification_state', 'closed');
    $('#membersNotification').slideUp(400);
}
function checkForNewContent(){
    $.ajax({
        url:'/ajax/notification',
        type: "POST",
        data: 'notification_content='+$.cookie('notification_content'),
        success: function(cont){
            if(cont.length > 0){
                if(cont == "CLOSE"){
                    close_notification();
                }else{
                    $('#membersNotification #notificationContent').html('<h1>Members Notification</h1>'+cont);
                    if($.cookie('notification_state') == 'closed')
                    {
                        $.cookie('notification_state', null);
                        $.cookie('notification_content', cont);
                        $('#membersNotification').slideDown(400);
                    }
                }
            }
        }
    });
}
$(document).ready(function(){
    if( $.cookie('notification_content')){
        checkForNewContent();
    }
    else
        {
            $.cookie('notification_content', $('#membersNotification #notificationContent').html(), {expires: 1});
        }
    setInterval("checkForNewContent()", 10000);
    var cookieContent = $.cookie('notification_state');
    $('#membersNotification #notifiactionClose').click(function(){
            close_notification();
        });
    if(cookieContent)
    {
        $('#membersNotification').hide();
    }
});

