Drupal.behaviors.gg_notices = function (context) {
    $('.user-notices .msg-close a:not(.gg-notices-processed)', context)
    .click( function () { 
      ajaxNoticeDismiss(this, this.href); 
      return false;
    }).addClass('gg-notices-processed').before('<div class="status"></div>');
}


function ajaxNoticeDismiss(el, url) {
  $(el).parent().children('.status').show();
  $.ajax({
  	url: url,
	type: 'GET',
	data: { async : 'true' },
	dataType: 'json',
	timeout: 4000, //set very high to prevent time outs for users with high latency connections
	success: function (json) {
	  noticeDismissSuccess(el, json);
	},
    error: function(json){
      $(el).parent().children('.status').hide();
    }
  });
}

function noticeDismissSuccess(el,json) {
    $(el).parents('li').fadeOut('fast',function() {$(this).remove();});
}

