/*  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)
  }
 // alert(URL);
//  if (URL.substring(0,19)== 'showDisplayDocument')
//  {
//	alert('Got it all!');
//	URL='https://air.test.gov.bc.ca/open.dll/'+URL  
//  }
  if (Navigation == 'Document')
    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')
    h = "height=" + (screen.availHeight - 50) + ",top=0,";
  else if ((Navigation == 'Maint') || (Navigation == 'external'))
    h = "height=" + height + ",top=0,";
  else if(Navigation == 'ONVERIFY')  
  {
       
	var userId = getUserId();
	var apipass = getapipass();
	var urla  = getURLA();
	URL = urla+'userid='+userId+'&apipass='+apipass+'&pin='+WindowName+'&template_id=1524&number='+URL;
	 h = "height=" + height + ",top=0,";
	 w = "width=" + width + ",left=0,";
	 WindowName = 'Validation'
	 $(document).ready(function(){
	$.getJSON(URL +'&callback=?',
		function(dd){
			if (dd.res==1) alert('Call is queued');
		
		
		});
	});	
        return 1;
  }
  else if (height == "")
    h = "";
  else
    h = "height=" + height + ",top=80,";
  
  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
  } 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 == 'ONVERIFY') {
	return window.open(URL, WindowName, w + h + "resizable=no,status,scrollbars=no");// status added 09/01/03 for BCBid
  } else { // some
    var formWindow = window.open(URL, WindowName, w + h + "resizable,status,scrollbars");// status added 09/01/03 for BCBid
  }

}
