/*  Copyright © 2001, 2002 OGMA Consulting Corp. */

function openWindow(URL, width, height, WindowName, Navigation, addDisplayType, unSafe) {

  var sessionID = getValueByName("sessionID");

  var w, h;

  if (unSafe) {
    URL = makeSafeHTMLIntoSafeURL(URL)
  }
  // Anatoli added Special for progress screen
  if (URL.indexOf('??') > -1) {     
	index = URL.indexOf('??');
	len = URL.length - index - 2;
     	hiddenMessage = URL.substring(index+2, URL.length+1);
	// cut off a hidden message
	URL = URL.substring(0,index);
        pattern = /\s*;\s*/;
	// Get all fields hidden
	parameterList = hiddenMessage.split(pattern);
	sendMessage = '^||^sendMessage=';
	for(i = 0; i<parameterList.length; i++){
	    param = parameterList[i];
	    disid = param.substring(5);
	    ready = false;
	    if(getValueByName('hcwithdraw'+disid)!='N'){
	       ready = true;
	    }
	    if(ready){
		    sendMessage = sendMessage + parameterList[i] +'param'+getValueByName(parameterList[i])+'token';	    	  	
	   } 
	}
	URL = URL + sendMessage;
  }	

 if ((Navigation == 'Document')||(Navigation == 'AlbertaDocument'))
    w = "width=" + (screen.availWidth - 10) + ",left=0,";
  else if ((Navigation == 'Maint') || (Navigation == 'external'))
    w = "width=" + width + ",left=0,";
  else if (width == "")
    w = "";
  else
    w = "width="  + width  + ",left=80,";

if ((Navigation == 'Document')||(Navigation == 'AlbertaDocument'))
    h = "height=" + (screen.availHeight - 50) + ",top=0,";
  else if ((Navigation == 'Maint') || (Navigation == 'external'))
    h = "height=" + height + ",top=0,";
  else if (height == "")
    h = "";
  else
    h = "height=" + height + ",top=40,";

  if (addDisplayType) {
    var displayType = getValueByName("DisplayType");
    URL = (URL + '&sessionID=' + sessionID + '&DisplayType=' + displayType);
    WindowName = "_" + sessionID + displayType;
  } else {
    WindowName = '_' + sessionID + WindowName;
  }

  if (Navigation == 'few') {
    var formWindow = window.open(URL, WindowName, w + h + 'toolbar=no,location=no,menubar=no,status=yes,scrollbars=yes')
  } else if (Navigation == 'all') {
    var formWindow = window.open(URL, WindowName, w + h + "resizable,toolbar,menubar,status,scrollbars");
  } else if (Navigation == 'Document') {
    var formWindow = window.open(URL, WindowName, w + h + "resizable,status,scrollbars");
    if (formWindow.name != WindowName) {
    	formWindow.name = WindowName;
		}
  } else if (Navigation == 'external') {
    var formWindow = window.open(URL, WindowName, w + h + "resizable,status,scrollbars");// status added 09/01/03 for BCBid
     if (URL.substring(0,8)== 'showPMCO'){
	formWindow = window.open('/pmcoe/pmcoe.dll?sessionID='+sessionID, WindowName, w + h + "maximized,status,scrollbars");
    }
  } else if (Navigation == 'none') {
    var formWindow = window.open(URL, WindowName, w + h + "resizable=no,status,scrollbars=no");// status added 09/01/03 for BCBid
   } else if (Navigation == 'AlbertaDocument') {
      var formWindow = window.open(URL, WindowName, w + h + "resizable,menubar=yes,status,scrollbars");
      if (formWindow.name != WindowName) {
      	formWindow.name = WindowName;
     }
   }		
  else { // some
    var formWindow = window.open(URL, WindowName, w + h + "resizable,status,scrollbars");// status added 09/01/03 for BCBid
  }

}
