function openWindow(url, name, left, top, width, height, status, scroll, resizable, maximized, center, modeless) {
	if (modeless)
		return (window.showModelessDialog(url, name, "dialogHeight: " + (maximized ? (screen.availHeight - 28) : height) + "px;	dialogWidth: " + (maximized	?	(screen.availWidth - 12) : width)	+	"px; dialogTop:	" + (center ? parseInt((screen.availHeight - height - 28) / 2) : top) + "; dialogLeft: " + (center ? parseInt((screen.availWidth - width - 12) / 2) : left) + "; center: " + (center ? "yes" : "no") + "; help: no; resizable: " + (resizable ? "yes" : "no") + "; scroll: " + (scroll ? "yes" : "yes") + "; status: " + (status ? "yes" : "no") + ";"));
	else
		return (window.open(url, name, "channelmode=no, directories=no, location=no, width=" + (maximized	?	(screen.availWidth - 12) : width) + ", height="	+	(maximized ? (screen.availHeight - 28) : height) + ",	top="	+	(center ? parseInt((screen.availHeight - height - 28) / 2) : top) + ", left=" + (center ? parseInt((screen.availWidth - width - 12) / 2) : left) + ",	status=" + (status ? "yes" : "no") + ",	scrollbars=" + (scroll ? "yes" : "yes") + ",	resizable="	+	(resizable ? "yes" : "no")));
}

// Método criado para substituir a openWindow em alguns casos onde as janelas
// não estão do tamanho correto ou não estão exibindo a barra de rolagem.
// Ele também impede que o usuário torne ativa a janela anterior.

var activeWindow = null;

function openModalMaximizedWindow(url, name, left, top, width, height, status, scroll, resizable, maximized, center, modeless) {

    scroll  = true;
	left	= 0;
	top		= 0;
	width	=  (screen.availWidth - 10);
	height	=  (screen.availHeight - 28);
	if (modeless)
		activeWindow = window.showModelessDialog(url, name, "dialogHeight: " + height + "px;	dialogWidth: " + width	+	"px; dialogTop:	" + top + "; dialogLeft: " + left + "; center: " + (center ? "yes" : "no") + "; help: no; resizable: " + (resizable ? "yes" : "no") + "; scroll: " + (scroll ? "yes" : "yes") + "; status: " + (status ? "yes" : "no") + ";");
	else
		activeWindow = window.open(url, name, "channelmode=no, directories=no, location=no, width=" + width + ", height=" + height + ", top=" + top + ", left=" + left + ", status=" + (status ? "yes" : "no") + ",	scrollbars=" + (scroll ? "yes" : "yes") + ",	resizable="	+	(resizable ? "yes" : "no"));
	window.onfocus = function window_onFocus() { if ((activeWindow != null) && (!activeWindow.closed)) activeWindow.focus(); };
	window.onactivate = function window_onActivate() { if ((activeWindow != null) && (!activeWindow.closed)) activeWindow.focus(); };
	return (activeWindow);
}


function showMessage(message, type) {
	return showCustomMessage(message, 2, "OK;;");
}

function showConfirmMessage(message) {
	return showCustomMessage(message, 1, "Sim;true;|N\xE3o;false;");
}

function showWebEmail(message) {
	return showCustomWebEmail(message, 1, "Sim;true;|N\xE3o;false;");
}

function showOptionMessage(options) {
	var objectSize  = evalObject("divString");
	var pathName    = window.location.pathname;
	var optionArray = options.split("|");
	var i           = 0;
	if (objectSize == null) {
		document.body.insertAdjacentHTML("afterBegin", "<DIV id=\"divString\" style=\"position: absolute; visibility: hidden; display: inline; top: 0px; left: 0px; z-index: -1; font-family: Tahoma; font-size: 11px;\"></DIV>");
		objectSize = evalObject("divString");
	}
	objectSize.innerHTML = "";
	for (; i < optionArray.length; i++)
		objectSize.innerHTML += optionArray[i] + "<BR>";
	pathName = pathName.substring(0, pathName.indexOf('/', 1));
	return (window.showModalDialog(pathName + "/Script/Window/OptionMessage.aspx", options, "dialogHeight: " + (objectSize.offsetHeight + 111) + "px; dialogWidth: " + Math.max((objectSize.offsetWidth + 76), 204) + "px; center: yes; help: no; resizable: no; scroll: no; status: no; unadorned: no;"));
}

function showExitProcessMessage(sender) {
	var opcao = showCustomMessage("Deseja Finalizar este Processo?", 1, "Sim;0;|N\xE3o;../../Default.aspx;|Cancelar;3;");

	// Verifica se deve habilitar o "CausesValidation"
	if (opcao == 0)
		sender.onclick = function btnOnClick() { if (typeof(Page_ClientValidate) == 'function') Page_ClientValidate(); };
	else
		sender.onclick = null;
		
	return (opcao == 0);
}

function showTransitionWindow() {
	var popupWindow     = window.createPopup();
	var popupWindowBody = popupWindow.document.body;
	var pathName    = window.location.pathname;
	pathName = pathName.substring(0, pathName.indexOf('/', 1));
	popupWindowBody.style.border          = "#A0A0A0 2px solid";
	popupWindowBody.style.backgroundColor = "#FFFFFF";
	popupWindowBody.innerHTML = "<table border='0' cellpadding='3' cellspacing='2' style='width: 100%; height: 100%' align='center'><tr><td style='text-align: center; font-family: Verdana; font-size: 12px; font-weight: 700; vertical-align: middle; background-color: #E0E0E0;'><img src='" + pathName + "/img/Ampulheta.gif' style='vertical-align: middle'>&nbsp;Processando...</td></tr></table>"
	popupWindow.show((window.document.body.clientLeft + (window.document.body.clientWidth - 180) / 2), (window.document.body.clientTop + (window.document.body.clientHeight - 80) / 2), 180, 80, document.body);
}

function popup_centralizado(pagina,largura,altura, rolagem) {

//pega a resolução do visitante
w = screen.width;
h = screen.height;

//divide a resolução por 2, obtendo o centro do monitor
meio_w = w/2;
meio_h = h/2;

//diminui o valor da metade da resolução pelo tamanho da janela, fazendo com q ela fique centralizada
altura2 = altura/2;
largura2 = largura/2;
meio1 = meio_h-altura2;
meio2 = meio_w-largura2;

//abre a nova janela, já com a sua devida posição
window.open(pagina,'','height=' + altura + ', width=' + largura + ', top='+meio1+', left='+meio2+', scrollbars='+ rolagem +',resizable=no'); 
}