var oTaskBar;
var aTasks = new Array();
var taskBarButtonIndex=1;

function taskBarInit(idDiv)
{
	oWindowContainerMain.attachEvent("onClose", onCloseWindow)
	oWindowContainerMain.attachEvent("onFocus", onFocusWindow)
	oTaskBar = new dhtmlXToolbarObject(idDiv, "dhx_skyblue");
	oTaskBar.setIconsPath("css/imgs/");
	oTaskBar.attachEvent("onStateChange", onStateChange_taskBar);
}

function addWindow(name, x, y, width, height, text, icon)
{
	if(oTaskBar!==undefined)
	{
		oTaskBar.addButtonTwoState(name, taskBarButtonIndex, text, icon, icon);
	}
	oWindow = oWindowContainerMain.createWindow(name, x, y, width, height);
	oWindow.setIcon(icon);
	oWindow.setText(text);
	return oWindow;
}

function onStateChange_taskBar(id, state)
{
	oWindowContainerMain.window(id).bringToTop();
	oTaskBar.forEachItem(function(id)
		{
			oTaskBar.setItemState(id, false);
		}
	);
	oTaskBar.setItemState(id, true);
}

function onCloseWindow(oWindow)
{
	oTaskBar.removeItem(oWindow.idd);
	return true;
}

function onFocusWindow(oWindow)
{
	onStateChange_taskBar(oWindow.idd, true);
}
