var isNN4, isIE4;
var userHasActiveX;
function checkClientMachine() {
   userHasActiveX = false;
   isNN4 = (navigator.appName == "Netscape") && (parseInt(navigator.appVersion.substring(0, 1)) >= 4);
   isIE4 = (navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion.substring(0, 1)) >= 4);
   if (!isIE4 && !isNN4)
      alert("Supported browser required.");
      
   // Check IE for ViewerX
   if (isIE4 && vbsHasActiveX()) 
     userHasActiveX = true;
   
   // Check NN for our Plug-In (NPAWSAxHost)
   else if (isNN4 && navigator.mimeTypes["NPAWSClientX/AWS"] != null)
     userHasActiveX = true;
}
function baseOpenAWSDatabase(aldFile,bUseActiveX) {
   var aspPage;
   if (userHasActiveX)
       bUseActiveX = true;
   if (isIE4) {
      aspPage = "/AlchemyWebServer/PtServer/PtAsp/PtOpenDatabase.asp";
      window.location.href = aspPage + "?DBPath=" + escape(aldFile)+  "&UseActiveX=" + bUseActiveX;
   } else if (isNN4) {
      aspPage = "/AlchemyWebServer/PtServer/PtAsp/PtPrepareDatabaseNN.asp?DBPath=" + escape(aldFile) + "&UseActiveX=" + bUseActiveX; 
      window.open(aspPage, "AWS_IMR", "status=yes,menubar=yes,resizable=yes", true);
   }
}
function baseOpenAWSGroup(groupName,bUseActiveX) {
   var aspPage;
   if (userHasActiveX)  
       bUseActiveX = true;
   if (isIE4) {
      aspPage = "/AlchemyWebServer/PtServer/PtAsp/PtOpenGroup.asp";
      window.location.href = aspPage + "?GroupName=" + escape(groupName) + "&UseActiveX=" + bUseActiveX;
   } else if (isNN4) {
      aspPage = "/AlchemyWebServer/PtServer/PtAsp/PtPrepareGroupNN.asp?GroupName=" + escape(groupName) + "&UseActiveX=" + bUseActiveX; ;
      window.open(aspPage, "AWS_IMR", "status=yes,menubar=yes,resizable=yes", true);
   }
}
function openAWSDatabase(aldFile) {
   baseOpenAWSDatabase(aldFile,false)
}
function openAWSGroup(groupName) {
   baseOpenAWSGroup(groupName,false)
}
function openAWSDatabaseActiveX(aldFile) {
   baseOpenAWSDatabase(aldFile,true)
}
function openAWSGroupActiveX(groupName) {
   baseOpenAWSGroup(groupName,true)
}
window.onload = checkClientMachine;
