//Copyright 2000 Macromedia, Inc. All rights reserved.

function displayHelp(){
  var rootPath = dw.getConfigurationPath();
  var drivePath = rootPath.substring(0,rootPath.lastIndexOf("/")) + "/Help/";
  var separator = helpDoc.indexOf("/");
  var missingDoc = drivePath + helpDoc;

  if (separator != -1) {
    var helpBook = helpDoc.substring(0, separator+1);
    var idPath = drivePath + helpBook + "contextID.html";
    missingDoc = idPath;

    if (DWfile.exists(idPath)) {
      var idRoot  = dreamweaver.getDocumentDOM(idPath);
      var contextSetter  = idRoot.documentElement;
      var idURL = idRoot.URL;
      var bookURL = idURL.substring(0,(idURL.lastIndexOf("/")));
      var helpURL = bookURL.substring(0,(bookURL.lastIndexOf("/")+1));
      bookURL = bookURL + "/";

      contextSetter.innerHTML = '<' + 'head>\n<' + 'title>context setter<' + '/title>\n\n<' + 'script language="javascript">\nfunction setContext() {\n  parent.right.location="' + helpURL + helpDoc + '";\n}\n<' + '/script>\n<' + '/head>\n\n<' + 'body onLoad="setContext()" bgcolor="#ffffff">\n<' + 'noscript>\n<' + 'p>' + MM.HELP_errorNoJavaScript + '<' + '/p>\n<' + '/noscript>\n<' + '/body>';
  
      DWfile.write(idURL, contextSetter.outerHTML);
      dreamweaver.releaseDocument(idRoot);
      var helpFrameset = bookURL + 'ContextHelp.htm';
      dreamweaver.browseDocument(helpFrameset);
      missingDoc = "";
    }
  }
  if (missingDoc) { //help file not found
    alert(MM.HELP_errorFileNotFound + missingDoc);
  }
}
