var HTML_Dialogs_Open = new Array();


function HTML_Dialog_Open(name, url)
{
	if (name == '_blank') {
		window.open(url, name);
		return;
	}
	
	if (HTML_Dialogs[name]) {
		var features = '';
		var pageWidth = 480;
		var pageHeight = 340;
		if (document.body && document.body.clientWidth) {
   			pageWidth = document.body.clientWidth;
   			pageHeight = document.body.clientHeight;
		} else if (window.innerWidth) {
			pageWidth = window.innerWidth;
			pageHeight = window.innerHeight;
		}
		var topPos = (pageHeight - HTML_Dialogs[name]['Height']) / 2;
		var leftPos = (pageWidth - HTML_Dialogs[name]['Width']) / 2;
		features += 'width='+HTML_Dialogs[name]['Width'];
		features += ',height='+HTML_Dialogs[name]['Height'];
		if (HTML_Dialogs[name]['Top']) features += ',top='+HTML_Dialogs[name]['Top']; else features += ',top='+topPos;
		if (HTML_Dialogs[name]['Left']) features += ',left='+HTML_Dialogs[name]['Left']; else features += ',left='+leftPos;
		if (HTML_Dialogs[name]['ToolBar']) features += ',toolbar=1'; else features += ',toolbar=0';
		if (HTML_Dialogs[name]['LocationBar']) features += ',location=1'; else features += ',location=0';
		if (HTML_Dialogs[name]['Directories']) features += ',directories=1'; else features += ',directories=0';
		if (HTML_Dialogs[name]['Status']) features += ',status=1'; else	features += ',status=0';
		if (HTML_Dialogs[name]['ScrollBars']) features += ',scrollbars=1'; else	features += ',scrollbars=0';
		if (HTML_Dialogs[name]['Resizable']) features += ',resizable=1'; else features += ',resizable=0';
		if (HTML_Dialogs[name]['MenuBar']) features += ',menubar=1'; else features += ',menubar=0';
		if (HTML_Dialogs[name]['Dialog']) HTML_Dialogs_Open[name] = window.open(url, name, features);
		else window.open(url, name, features);
	}
}

function HTML_Dialog_CloseAll()
{
	for (dialog in HTML_Dialogs_Open) HTML_Dialogs_Open[dialog].close();
}
