/* Copyright (c) 2003-2007 PeopleCube. All Rights Reserved */

var helpBase = "/UserOLH/webevent_view_help.htm#";
var adminHelpBase = "/AdminOLH/webevent_view_help.htm#";
var helper = new Object();

/*
   'helper' is an associative array - to create a new entry for a command,
   simply create a new line with an object property with the same name 
   as the WebEvent command.  Set the helper object's new property to a
   string naming the appropriate help file.  Example, for the WebEvent command
   'foo' and it's help file 'bar.htm'  one would enter:

   helper.foo = "bar.htm";

   Warning: all command property names must be unique.

   Note: be kind to others and insert your new entry to maintain
   alphabetical order.  Thanks!

   Meanwhile, the following should be inserted into the Perl template where you
   want the Local Help button to appear:

   <script language='javascript1.2'>makeHelpButton("[% base_url %]", "[% cmd %]")</script>

   The bases_url must always entered as shown.  The 'cmd' argument need only be a
   unique name that maps to a 'helper' object property.

   If the 'cmd' argument does NOT match any helper object property, then no
   help button is generated.

   Generally, we use the current WebEvent command as that unique name (hence "[% cmd %]")
   but it's OK to be creative.  Sometimes a given template may have multiple modes and
   therefore may need multiple help files.  If the templates mode can be distinguished,
   it is quite appropriate to make that distinction in the 'cmd' argument.  Ex.: let's
   say that in addition to [% cmd %], we have another Perl template variable [% subcmd %]
   so we concatenate them to the 'cmd' argument (with an underscore separator) thusly:
   "[% cmd %]_[% subcmd %]".  Further, let's say [% cmd %] returns 'brown' and [% subcmd %]
   returns 'doggy'.  With this known, we might create a helper object property like this:

      helper.brown_doggy = "hlp_about_brown_dogs.htm";


*/

helper.approve                = "hlp_approving_events.htm";
helper.contacts               = "hlp_about_contacts.htm";
helper.editcontact_add        = "hlp_adding_contacts.htm";
helper.editcontact_edit       = "hlp_modifying_contacts.htm";
helper.edittask_add           = "hlp_adding_tasks.htm";
helper.edittask_edit          = "hlp_modifying_tasks.htm";
helper.exportcal              = "hlp_export_cal.htm";
helper.exportcontacts         = "hlp_exporting_contacts.htm";
helper.newevent0              = "hlp_add_event_basic.htm";
helper.newevent1              = "hlp_add_event_style.htm";
helper.newevent2              = "hlp_add_event_emails.htm";
helper.opt_cal                = "hlp_opt_cal.htm";
helper.opt_download           = "hlp_sync_install.htm";
helper.opt_group              = "hlp_opt_group.htm";
helper.opt_session            = "hlp_opt_session.htm";
helper.opt_site_auth          = "hlp_opt_site_auth.htm";
helper.opt_site_cal           = "hlp_opt_site_cal.htm";
helper.opt_site_custom        = "hlp_opt_site_custom.htm";
helper.opt_site_global        = "hlp_opt_site_global.htm";
helper.opt_site_setup_cats    = "hlp_opt_site_setup_cats.htm";
helper.opt_site_setup_fields  = "hlp_opt_site_setup_fields.htm";
helper.opt_site_setup_license = "hlp_opt_site_setup_license.htm";
helper.opt_sub_report         = "hlp_opt_sub_report.htm";
helper.opt_user               = "hlp_opt_user.htm";
helper.search                 = "hlp_searching_eventw.htm";
helper.set_favs               = "hlp_adding_multi_calendars.htm";
helper.set_todays             = "hlp_adding_multi_calendars.htm";
helper.subscribe              = "hlp_subscribing.htm";
helper.tasklist               = "hlp_about_tasks.htm";
helper.timescan               = "hlp_scanning_for_times.htm";

var hw;

function openHelpWindow(baseURL, cmd, admin)
{
  if (admin)
    hw = window.open(baseURL+adminHelpBase+helper[cmd], '_help');
  else
    hw = window.open(baseURL+helpBase+helper[cmd], '_help');
  hw.focus();
}


function makeHelpButton(baseURL, cmd, admin)
{
  if (helper[cmd])
  {
    document.write("<input type='button' value='Help' accesskey='h' ");
    if (admin)
      document.write("onClick='openHelpWindow(\""+baseURL+"\", \""+cmd+"\", \""+admin+"\")'>\n");
    else
      document.write("onClick='openHelpWindow(\""+baseURL+"\", \""+cmd+"\")'>\n");
//    "onClick='window.open(\""+baseURL+helpBase+helper[cmd]+"\", \"_help\")'>\n"+
  }
/* if there's no entry for the command, then no button is created. */
/* Un-comment the following else statement fro testing purposes 
  else
  {
    document.write(""+
    "<input type='button' value='Test' "+
    "onClick='alert(\"No matching helper object property.\")'>\n"+
    "");
  }
*/
}


