var dlg = null;

function FecharPopUp()
{
	if( dlg && !dlg.closed)
	{
		dlg.close();
		dlg = null;
	}
}

function dlg_show(width, height, url ) {
	dlg_show2(width, height, url, true);
}

function dlg_show2(width, height, url, scroll) {
	var left = (screen.width - width) / 2;
	var top = (screen.height - height) / 2;
	
	var strConfig = 'height='+ height +',';
	strConfig    += 'width='+ width +',';
	strConfig    += 'edge=Raised,';
	strConfig    += 'center=yes,';
	strConfig    += 'left='+left+'px,';
	strConfig    += 'top='+top+'px,';
	strConfig    += 'help=no,';	
	strConfig    += 'resizable=no,';
	strConfig    += 'status=yes,';
	strConfig    += 'location=yes,';
	if (scroll)
		strConfig    += 'scrollbars=yes';
	else
		strConfig    += 'scrollbars=no';
	dlg_custom_show(strConfig, url, true);
}

function dlg_custom_show(config, url, closeOnBlur) {
	if (closeOnBlur)
		dlg = window.open(url, '_blank', config);
	else
		window.open(url, '_blank', config);
}

function dlg_showWindow(tag) {
	dlg_showWindowFromUrl(tag.getAttribute('href'));
}

function dlg_showWindow(tag, scroll) {
	dlg_showWindowFromUrl(tag.getAttribute('href'), scroll);
}

function dlg_showWindowFromUrl(url) {
	dlg_showWindowFromUrl(url, false);
}

function dlg_showWindowFromUrl(url, scroll) {
	var strConfig = 'menubar=no,location=yes';
	strConfig    += ',resizable=yes';
	strConfig    += ',status=yes';
	
	if (scroll)
		strConfig    += ',scrollbars=yes';
	else
		strConfig    += ',scrollbars=no';

	window.open(url, '', strConfig);
}

function dlg_help(url)
{
	var width = 550;
	var height = 500;
	var left = (screen.width - width) - 20;
	var top = (screen.height - height) / 2;

	var strConfig = 'menubar=no';
	var strConfig = 'height='+ height +',';
	strConfig    += 'width='+ width +',';
	strConfig    += 'edge=Raised,';
	strConfig    += 'left='+left+'px,';
	strConfig    += 'top='+top+'px,';
	strConfig    += 'resizable=yes,';
	strConfig    += 'scrollbars=yes,';	
	strConfig    += 'location=yes,';
	strConfig    += 'status=yes';
	window.open(url, '', strConfig);
}