
BrookhavenNav = function()
{


  /**
   *  These are the "links" that will displayed on each page.  They will be
   *  displayed in the order of the array below.  Element 0 of each sub-
   *  array is the link text, element 1 is the url
   */
  this.nodes =
  [
    ['HOME','/'],
    ['LISTEN','/listen.html'],
    ['SCHEDULE','/schedule.html'],
    ['EVENTS','/events.html'],
    ['ABOUT US','/about.html'],
    ['CONTACT US','/contact.html'],
    ['LOCATION','/location.html'],
    ['MINISTRIES','/ministries.html'],
    ['OUR PASTORS','/pastors.html']//,
    //['MISSIONS','/blank.html'],
    //['RESOURCES','/blank.html']
  ];


  /**
   *  Call this method to cause the links on the left to be created.
   */
  this.buildNav = function()
  {
    var navDiv = $('#navBarDiv');
    var node;

    while (this.hasNextNode())
    {
      // node is a 2 element array [0] is link text [1] is the relative url
      node = this.getNextNode();

      navDiv.append('<a href="'+this.getBaseUrl()+node[1]+'">'+node[0]+'</a><br/>');
    }
    this.appendSpecialNodes(navDiv);
  }

  this.appendSpecialNodes = function(navDiv)
  {
    //navDiv.append('<a href="'+this.getBaseUrl()+'/discoverChrist.html">DISCOVER CHRIST</a><br/>');
    navDiv.append('<a href="http://www.thecommon.org" target="_blank">THE COMMON</a>')
  }
  /**
   *  Sets the Base url which should be used to access pages the nodes link to.
   * this need only be set if the current page is below the root of the site
   */
  this.setBaseUrl = function(baseUrl)
  {
    this.baseUrl = baseUrl;
  }

  /**
   *  Returns the base url the nav object believes it should use for nav links
   *
   * @returns a string
   */
  this.getBaseUrl = function()
  {
    return this.baseUrl;
  }

  /**
   *  returns the next node in the navigation node set
   *
   * @returns a two dimintion array, first element in the link text, second
   *          element is the link location
   */
  this.getNextNode = function()
  {
    var nextNode = [];

    if (this.hasNextNode())
    {
      nextNode = this.nodes[this.currentNode];
      this.currentNode++;
    }
    else
    {
      throw "Attept to access next navigation node failed.  There are no more"
       +" nodes.";
    }

    return nextNode;
  }

  /**
   *  Returns true if there are more nodes in the navigation node set.
   *
   *  @returns a boolean
   */
  this.hasNextNode = function()
  {
    return (this.nodes.length > this.currentNode);
  }

  /**
   *  Resets the current node so that the "nextNode" is the first node.
   */
  this.resetNodeLocation = function()
  {
    this.currentNode = 0;
  }


  /**
   *  Private object attributes
   */
  /**
   * an integer which indicates curent location in interation through the nodes
   * array
   */
  this.currentNode = 0; 
  /**
   * a string indicating the current base URL for the website this need only be
   * set if the current page is below the root of the site
   */
  this.baseUrl = ''; // private
}

