// A list of onload handlers:
var onloadHandlers = Array();

function addOnloadHandler(handler) {
	if (handler != null) {
		onloadHandlers.add(handler);
	}
};

// Define the window onload handler:
$(window).on("load", function() {
	// Add the popup windows:
	new PopupWindow("popup", null, null, "800px", "500px", "Popup", 50).makeDraggable().makeResizable().hide();
	Debugger.setTarget(new PopupWindow("debug", null, null, "500px", "300px", "<font color='#dd0000'>The debugger</font>", false).makeDraggable().makeResizable().body).hide();
	
	// Replace all widget holders with actual widgets:
	Widget.replaceAll(document.getElementsByName("widget"));
	
	// Call each onload handler:
	for (var i = 0; i < onloadHandlers.length; i++) {
		onloadHandlers[i]();
	}
});


function showHide(div){
	var dis = document.getElementById(div).style.display;
	if (dis == 'none'){
		document.getElementById(div).style.display = 'block';
	}
	else {
		document.getElementById(div).style.display = 'none';
	}
}

function hardShow(div){
	t=setTimeout('doOpen(\''+div+'\')', 50);
}

function doOpen(div){
var dis = document.getElementById(div).style.display;

	if(dis==null)
		var t=setTimeout('doOpen(\''+div+'\')', 500);

	document.getElementById(div).style.display = 'block';
}
