/* header.js */

/*
This header defines parameters used by footer.js.
On all pages except the index it also shows the logo at the top,
and this logo is a link back to the index page.

Insert this header at the top of any HTML page just after <body>, thus:
  <script src="header.js"></script>
For pages in the "people" subdirectory it must point one level up, thus:
  <script src="../header.js"></script>
DO NOT use a root slash: not "/header.js". This works on the live website only, but
we want it to work on any back-up copy on a hard disk, in some arbitrary directory.
*/


/* language parameter -- see footnote (1) */
var lang;        /* 'en', 'fr', 'bg', etc. */

/* Are we in the main index directory, or one level down in "people"? */
/* (temporary Jan. 2008: check for "sitemap" too) */
var rootdir;
if (location.pathname.indexOf('people/') > -1
 || location.pathname.indexOf('people\\') > -1)   /* for IE */
  rootdir = '../';	/* look one level up */
else if (location.pathname.indexOf('sitemap/') > -1
 || location.pathname.indexOf('sitemap\\') > -1)
  rootdir = '../';
else
  rootdir = '';

/* Work out from the parameters what the correct front page is. */
var indexname = rootdir + 'index';
if (lang == 'es')
  indexname = indexname + 'Spanish';
else if (lang == 'bg')
  indexname = indexname + 'Bulgarian';
else if (lang == 'zh')
  indexname = indexname + 'Chinese';
else if (lang == 'ja')
  indexname = indexname + 'Japanese';
else if (lang == 'ms')
  indexname = indexname + 'Bahasa';
  /* 'ms' is ISO code for Malay; Indonesian is 'id' but as they're the
     same language we treat them both as just Bahasa */
indexname = indexname + '.html';


var logoname = rootdir + 'logoTop.jpg';


/* Every page except the English index has the upper left logo linking back to the
   index for the appropriate language. */
if (location.pathname.indexOf('index.html') == -1) {
    document.write('<div class="header">');
    document.write('<a href="' + indexname + '">');
    document.write('<img src="' + logoname + '" ');
    document.write(' width="211" height="100" alt="EKonomics LLC" border="0" />');
    document.write('</a>');
    document.write('</div>');
}




/* FOOTNOTES
(1) I want to be able to add new parameters without worrying about the fact that
they're not defined in older pages. Older pages can use the default value, e.g.
  if (lang = 'fr')
    ShowSomePage('French');
  else
    ShowSomePage('English');
This way we can declare "var lang='fr';" somewhere in the French page. By redeclaring
"var lang" in this header, we ensure it exists so the code runs -- even if the English
page doesn't mention it. Redeclaring variables like this is safe: it preserves any
assigned values they might have had -- so it doesn't reset 'fr' to undefined.

*/