/*
 * jQuery WG CookiedAction plug-in 1.0
 * Copyright (c) 2009 Roberto Lee (webgenerator.nl)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * Date: 2010-01-17
 * Rev: 2
 *
 *
 * REQUIREMENTS:
 *
 *
 * jquery.cookie.js
 *
 *
 *
 */
(function($){
     $.fn.extend({
         WG_CookiedAction: function(options) {
				var defaults = {
					name_of_cookie_prefix: 'show_box_',
					name_of_cookie_id: '',
					expiration_cookie: 7,
					show_box_type: '', //'','once','always'
					callback_action: function(){}
				};
				var options = $.extend(defaults, options);

				var show_type = jQuery.trim(options.show_box_type);
				var name_cookie = (options.name_of_cookie_prefix + options.name_of_cookie_id);

				if(options.show_box_type == '')
				{
					jQuery.cookie(name_cookie, null); //Delete cookie when if never to show
				}
				else
				{
					var show_box = jQuery.cookie(name_cookie);
		        	if((show_box != 'no') || (show_type == 'always'))
						options.callback_action.call();

					if((show_type == 'once') && (show_box != 'no'))
						jQuery.cookie(name_cookie, 'no', {expires: options.expiration_cookie}); //set cookie not to show next time
				}
         }
    });
})(jQuery);
