/*
'NAME:				openwindow.js
'VERSION:			1.0
'VERSIONED:			2005-07-13
'APPLICATION:			First Report
'LANGUAGE:			JavaScript
'FOR:				First Report Ltd
'CREATED:			2005-07-13
'COPYRIGHT			yMonda Ltd 2005
'AUTHOR:			j.Osmond yMonda Ltd
'RETURN CODE:			js
'DEPENDS ON:
'DEPENDENTS:
' ***************************************************************
' DESCRIPTION and NOTES
Open window or modal dialog
' ***************************************************************
'REVISION HISTORY
2005-07-13 WHC tested scrollbars
2005-08-10 JO changed rule, if pass in width then center it to screen
'*/

function OW(strName,iW,iH,TOP,LEFT,R,S,SC,T,TB,URL,TYPE,dArg){
  if(iW!=''){
    TOP=TOP?TOP:(screen.availHeight - iH) / 2 ;
    LEFT=LEFT?LEFT:(screen.availWidth - iW) / 2 ;
  }
  //TOP=TOP?TOP:(screen.availHeight - iH) / 2 ;
  //LEFT=LEFT?LEFT:(screen.availWidth - iW) / 2 ;
  if ((TYPE=="modal" || TYPE=="modalIframe") && (navigator.userAgent.indexOf('MSIE')>0) ){
    var sF=""
    var _rv
    sF+=T?'unadorned:'+T+';':'';
    sF+=TB?'help:'+TB+';':'';
    sF+=S?'status:'+S+';':'';
    sF+=SC?'scroll:'+SC+';':'';
    sF+=R?'resizable:'+R+';':'';
    sF+=iW?'dialogWidth:'+iW+'px;':'';
    sF+=iH?'dialogHeight:'+iH+'px;':'';
    sF+=TOP?'dialogTop:'+TOP+'px;':'';
    sF+=LEFT?'dialogLeft:'+LEFT+'px;':'';
    if (TYPE=="modal") //Modal Dialog - Returns value, unable to post form
      _rv=window.showModalDialog(URL+"&r="+Math.round(Math.random()*1000000),dArg?dArg:"",sF);
    else  { //Modal Dialog - Able to post form back to itself
      var da=new Object()
      da.w=iW;
      da.h=iH;
      da.url=URL;
      _rv=window.showModalDialog("ModalIframe.asp?r="+Math.round(Math.random()*1000000),da,sF);
    }
    if ("undefined" != typeof(_rv) )
      return _rv;
    }else{
      var sF=""
      sF+=iW?'width='+iW+',':'';
      sF+=iH?'height='+iH+',':'';
      sF+=R?'resizable='+R+',':'';
      sF+=S?'status='+S+',':'';
      sF+=SC?'scrollbars='+SC+',':'';
      sF+=T?'titlebar='+T+',':'';
      sF+=TB?'toolbar='+TB+',':'';
      sF+=TB?'menubar='+TB+',':'';
      sF+=TB?'location='+TB+',':'';
      sF+=TOP?'top='+TOP+',':'';
      sF+=LEFT?'left='+LEFT+',':'';
      //alert(sF);
      var HMW=window.open(URL?URL:'about:blank',strName?strName:'',sF);
      //var HMW=window.open(URL?URL:'about:blank',strName?strName:'', "'width=400,height=150,scrollbars=yes'");
      if ( (document.window != null) && (!HMW.opener) )
        HMW.opener=document.window;
        HMW.focus();
     }
}

function helppopup(page,width,height) {
	window.open(page,"Help","top=10,left=10,scrollbars=yes,resizable=yes,width=" + width + ",height=" + height);
}
