jQuery(document).ready(function()
{	
	function wConsole(o, prop)
	{
		if (!jQuery("#consoleAct").is(':checked')) return;
		var p={};
		jQuery.extend(p,prop);
		var txt = "<b>"+o.find(".n:first").html()+"::  </b>";
		for (var property in p)
		{
			var pr = p [property];
			txt+= "<br>" + property + " = " + pr ;
		}
		txt+="<br><hr>";
		jQuery("#mb_console").append(txt);
	}

	jQuery(".containerPlus").buildContainers
	({
		containment:"document",
		elementsPath:"/img/framework/",
		onResize:function(o)
		{
			wConsole
			(o,{
				resized:true,
				width: o.outerWidth(),
				height: o.outerHeight()
			});
		},
		onClose:function(o)
		{			
			wConsole
			(o,{
				closed: o.mb_getState("closed")
			});
			
			// Takes care of the showing of the main menu after closing the dialog
			if(jQuery('#main_menu').exists())
			{
				var visible = 0;
				jQuery('.containerPlus').each(function(d,dialog)
				{
					if(jQuery(this).is(':visible'))
					{
						visible ++;
					}
				});
				
				if(getTinyMceActivated() && visible == 1)
				{
					hideFade('fade');
				}
				else if(visible == 1)showMainMenu();
			}
		},
		onCollapse:function(o)
		{
			wConsole
			(o,{
				collapse: o.mb_getState("collapsed")
			});
		},
		onIconize:function(o)
		{
			wConsole
			(o,{
				iconized: o.mb_getState("iconized")
			});
		},
		onDrag:function(o)
		{
			wConsole
			(o,{
				top: o.offset().top,
				left: o.offset().left
			});
		}
	});	
	jQuery('#main_dialog').mb_close();
	jQuery('#edit_dialog').mb_close();
});