////////////////////////////////////////////////////////////////////////////////
// navmenu.js : navbar configuration script : v2.0 : (C)2003 YBS              //
////////////////////////////////////////////////////////////////////////////////

// these assignments come from GenCode which modifies this file
// whenever the User changes one of the UI controls that influence
// the placement or contents of, or the images used in, the NavMenu...

var navPlace=0;
var navAbout=1;
var navContact=1;
var navMenu='';


////////////////////////////////////////////////////////////////////////////////
function extractFilename (instr) {
  lastSlash=instr.lastIndexOf ('/', instr.length-1)
  outstr=instr.substring (lastSlash+1, instr.length)
  return (outstr);
}



// note: we could also try this instead of using a function
// var thisPage = document.location.href.substring(document.location.href.lastIndexOf('/'),document.location.href.length);

////////////////////////////////////////////////////////////////////////////////
function setNavMenu () {

  // changed 20020828 for the deactivated.html page

  // this really needs to be just the filename!!
  var thisPage=extractFilename( document.location.href );

  // added this to fix problem initially visiting "http://www.mystore.com/"
  if (thisPage == '') {
    thisPage='index.html';
  }
  
  // modified 20031104
  // dynamic imagePath so cart.pl can use navmenu.js
  // (see the references to imagePath below)
  // cart.pl must output some element with id="incart" for this to work
  var imagePath='';
  if (document.getElementById('incart')) {
    imagePath = "../images/"; 
  } else {
    imagePath = "images/";
  }
  
  // add Home button if not on index.html
  // trailing &nbsp; added 11-09-02
  if ((thisPage!='index.html') && (thisPage!='deactivated.html')) {
    navMenu=navMenu+'<a href="index.html"><img border="0" src="'+imagePath+homeFN+'"></a>&nbsp;';
  }

  // add Index button if not on cindex.html
  // trailing &nbsp; added 11-09-02
  if ((thisPage!='cindex.html') && (thisPage!='deactivated.html')) {
    navMenu=navMenu+'<a href="cindex.html"><img border="0" src="'+imagePath+indexFN+'"></a>&nbsp;';
  }

  // add the Shopping Cart and Checkout buttons
  // ScriptURL is defined in core.js
  if (thisPage!='deactivated.html') {
    // trailing &nbsp; added 11-09-02
    navMenu=navMenu+'<a href="'+ScriptURL+'?OP=VC"><img border="0" src="'+imagePath+shopcartFN+'"></a>&nbsp;';
    navMenu=navMenu+'<a href="'+ScriptURL+'?OP=C1"><img border="0" src="'+imagePath+checkoutFN+'"></a>';
  }

  // add the About button if not on about.html, and About button is used
  // leading &nbsp; added 11-09-02
  if ((thisPage!='about.html') && (navAbout==1)) {
    navMenu=navMenu+'&nbsp;<a href="about.html"><img border="0" src="'+imagePath+aboutFN+'"></a>';
  }

  // add the Contact Us button if not on contact.html, and Contact Us button is used
  // leading &nbsp; added 11-09-02
  if ((thisPage!='contact.html') && (navContact==1)) {
    navMenu=navMenu+'&nbsp;<a href="contact.html"><img border="0" src="'+imagePath+contactFN+'"></a>';
  }

  // done making the html, now, figure out where to put it...
  // changed 20021008-20021031 to handle Netscape 4.x
  if ((navPlace==0) || (navPlace==2)) {
    if (ie4 || ie5 || ns6) {
      document.getElementById('headnav').innerHTML=navMenu;
    } else if (ns4) {
      // insert navmenu wrapped in a table for centering
      document.headnavlayer.document.open();
      document.headnavlayer.document.write('<table width="100%"><tr><td width="100%" align="center">'+navMenu+'</td></tr></table>');
      document.headnavlayer.document.close();
      document.headnavlayer.left = document.headnspacer.x;
      document.headnavlayer.top = document.headnspacer.y;
    }
  }

  if ((navPlace==1) || (navPlace==2)) {
    if (ie4 || ie5 || ns6) {
      document.getElementById('footnav').innerHTML=navMenu;
    } else if (ns4) {
      // insert navmenu wrapped in a table for centering
      document.footnavlayer.document.open();
      document.footnavlayer.document.write('<table width="100%"><tr><td width="100%" align="center">'+navMenu+'</td></tr></table>');
      document.footnavlayer.document.close();
      document.footnavlayer.left = document.footnspacer.x;
      document.footnavlayer.top = document.footnspacer.y;
    }
  }

  return;
}
