$(document).ready(function() {
  $("#notify").ajaxComplete( function() {
    var data = $.cookie('notification'); 
    $.cookie('notification', null, {path: '/'});
    if(data != null) {
      data = jQuery.parseJSON(unescape(data));
      if(data !== null) {
        for(var i = 0; i < data.length; i++) {
          $("#notify").append('<li class="'+data[i].status+'" style="display:none">'+data[i].message+'</li>');
        }
        $("#notify > li").show(600);
      }
    }
  });
  $("#notify > li").live('click', function() {
      $(this).hide(300, function() {
        $(this).remove();
      });
  });
  $("#notify > li").live('mouseover mouseout', function(event) {
    if(event.type == 'mouseover') {
      $(this).stop(true, true).animate({opacity: 0.5});
    } else {
      $(this).stop(true, true).animate({opacity: 1});
    }
  });
});

