jQuery(document).ready(function() {
	jQuery.fn.ThickBoxCookied = function(parameters) {// 'this' is a jQuery object at this point - with all the jQuery functions
		defaults = {
			name_of_cookie_prefix: 'show_box_',
			name_of_cookie_id: '',
			expiration_cookie: 7,
			tbox_height: 400,
			tbox_width: 600,
			show_box_only_ones: ''
		};
	  	return this.each(function() {// return so we don't break the chain now we are inside of a jQuery function, the DOM element is the context so 'this' has changed to become a DOM element.
			jQuery.extend(defaults, parameters);
	    	html_elem = this;


			//MUST BE AN ID, NOT CLASS
			if((jQuery(html_elem)).is('*'))
			{
					var id_of_elem = jQuery(html_elem).attr('id');
					var show_box = (id_of_elem + "_" + defaults.name_of_cookie_prefix + defaults.name_of_cookie_id).toLowerCase();
					var ShowOnes = jQuery.trim(defaults.show_box_only_ones.toLowerCase());
					if (ShowOnes == "true")
					{
						ShowOnes = "yes";
					}

					if(ShowOnes != "yes")
					{
						jQuery.cookie(show_box, null);
					}
					//alert($.cookie(show_box));
		        	if(jQuery.cookie(show_box) != 'no')
		        	{
			            tb_show("Popup", "?TB_inline=true&inlineId=" + id_of_elem + "&height="+defaults.tbox_height+"&width="+defaults.tbox_width+"&modal=true");
		        	}
					if(ShowOnes == 'yes')
					{
			        	if(jQuery.cookie(show_box) != 'no')
			        	{
							jQuery.cookie(show_box, 'no', {expires: defaults.expiration_cookie});
						}
					}
			}
	  	});
	};



});