(function($){
	var props = {
		$active: null,
		next: []
	}
	
	var fn = {
		ready: function()
		{
			$('.CcMessageBox').each(fn.init);
		},
		init: function(i)
		{
			var $this = $(this);
			$this.find('input.dismiss, .close').click(fn.dismiss);
			$this.find('input.goto').click(fn.goto);
			
			if (i == 0) fn.show($this);
			else props.next.push($this);
		},
		show: function($elm)
		{
			$elm.show();
			props.$active = $elm;
		},
		dismiss: function()
		{
			props.$active.remove();
			if (props.next.length > 0)
			{
				fn.show(props.next.pop());
			}
		},
		goto: function()
		{
			location.href = $(this).attr('title');
		}
	}
	
	$(document).ready(fn.ready);
})(jQuery);
