// Variaveis Globais
 var winModalWindow;

function ShowWindow(pagina,width,height) {
	var x = ((window.screen.width / 2) - (width / 2));
	var y = ((window.screen.height / 2) - (height / 2));
	
	if(width == 0 || width == ""){
		width = 400	
	}

	if(height == 0 || height == ""){
		height = 400	
	}

// IE browser or ShowModalDialog capable browser
  if (window.showModalDialog) {
      rv = window.showModalDialog( pagina ,null,"dialogWidth=" + width + "px;dialogHeight=" + height + "px;center:yes;help:no");
      // Return Value from child window here, may be null, zip or false or ??? 
	  document.bgColor = rv; // we hope for a color here in this example.
     }

 // Non IE or Non ShowModalDialog capable browser
  else {
    window.top.captureEvents (Event.CLICK|Event.FOCUS);
    window.top.onclick=IgnoreEvents;
    window.top.onfocus=HandleFocus;
    winModalWindow = window.open ( pagina ,"ModalChild","dependent=yes,width=" + width + ",height=" + height + ", left=" + x + ",top=" + y + ", scrollbars=yes,resizable=no");
    winModalWindow.focus();
   }

} // end of function ShowWindow

// ==============================================================
// Non IE or Non ShowModalDialog capable browser FUNCTIONS

function IgnoreEvents(e) {
  return false;
  } // end of function IgnoreEvents
  
function HandleFocus() {

  if (winModalWindow) {
    if (!winModalWindow.closed) {
        winModalWindow.focus();
       }
	else {
      window.top.releaseEvents (Event.CLICK|Event.FOCUS);
      window.top.onclick = "";
     }
  }
  return false;
} // end of function HandleFocus

// END of non IE or non ShowModalDialog capable browser FUNCTIONS
// ==============================================================
