/* getJS_menu_tpl.js
 * Get javascript for drop-down menus according to browser.
 *  - MSIE handles pixel calculation from top/side of page 
 *     different than other browsers.
 *  - We're defaulting to the most common (MSIE browsers)
 *      and changing to different template if it's another OS/browser.
 *  - Write the javascript src code directly into the header of the html page.
 *  - Write the javascript src according to the level of subdirectory
 *     is the calling page, (rather than leading slash '/lib/js/blah.js')
 *     so that this can be used on a standalone machine without webserver.
 *  08 mar 2005 - modfied for javascript location; firefox.
 *  01 jan 2005 - tightened up, and added better logic
 *                in case browser not named!
 *  13 dec 2003 - wrote for presscluboftibet.
 */

  // All our templates begin with this name:
  var js_basename = 'menu_tpl';
  // Our templates are located in:
  var js_menu_dir = '/lib/js/menu/'; 

  // Get the location of the calling page.
  var a_pathparts = location.href.split('/');
  var updots = '';

// alert(a_pathparts.length);

  if (a_pathparts.length == '4') {
    updots = '../';
  } else if (a_pathparts.length == '5') {
    updots = '../';
  } else if (a_pathparts.length == '6') {
    updots = '../../';
  } else if (a_pathparts.length == '7') {
    updots = '../../../';
  }

  // These are the variables available to determine browser/OS:
  // navigator.appName      - name, os, version, and extra stuff.
  // navigator.appVersion   - version, sometimes extra stuff.
  // navigator.userAgent    - browser name.

  // determine OS and browser, and set up template filename:
  if ( navigator.appVersion.indexOf("MSIE") > 0 ) {
    jsname = js_basename + '.js';
  } else if ( navigator.userAgent.indexOf("Firefox") > 0 ) {
    jsname = js_basename + '-firefox.js';
  } else if ( navigator.appVersion.indexOf("X11") > 0 ) {
    jsname = js_basename + '-linux.js';
  } else {
    jsname = js_basename + '.js';
  }

  // Now write the call to the template in the browser:
  document.write('<script language="javascript" type="text/javascript" ' +
    'src="' + updots + js_menu_dir + jsname + '"></script>');

// -- EOF 

