/*!
 * Alert helper JS
 * Copyright (c) 2014 Intense Visions, Inc.
 */
/* global jQuery */

(function($) {
	'use stict';

	function intenseSetAlertCookie(cname, cvalue, exdays) {
		var d = new Date();
		d.setTime(d.getTime() + (exdays*24*60*60*1000));
		var expires = "expires="+d.toUTCString();
		document.cookie = cname + "=" + cvalue + "; " + expires;
	}

	$(document).ready(function() {
		$('.intense.alert .intense.close').click(function() {
			var $closeButton = $(this);
			var $alert = $closeButton.parent();
			var memory = $closeButton.data('memory');

			if (null !== memory && '' !== memory) {				
				intenseSetAlertCookie( 'intense-alert-' + $alert.attr('id'), 1, memory );
			}
		});
	});
})(jQuery);