var counties = {
  PersistentlyVisibleBranch: function(key, persist)
  {
    //this.key = key;
    //this.persist = persist;
    persBranches.push(this);
    persBranchKeys.push(key);
  },

  initBranches: function()
  {
    persBranches = new Array();
    persBranchKeys = new Array();

    counties.PersistentlyVisibleBranch('smith', false);
    counties.PersistentlyVisibleBranch('rains', false);
    counties.PersistentlyVisibleBranch('vanzandtAndKaufman', false);
  },

  hasPersistence: function()
  {
    for(i=0; i<persBranches.length; i++)
    {
      if(persBranches[i].persist)
        return true;
    }

    return false;
  },

  getPersistentBranchObj: function(key)
  {
    var branch = null;
    for(i=0; i<persBranches.length; i++)
    {
      if(persBranches[i].key == key)
        branch = persBranches[i];
    }
    return branch;
  },

  getBranchId: function(key)
  {
    if(key == 'cherokee')
      return "cherokeeDetails";
    if(key == 'gregg')
      return "greggAndUpshurDetails";
    if(key == 'harrison')
      return "harrisonAndPanolaDetails";
    if(key == 'marion')
      return "marionDetails";
    if(key == 'panola')
      return "panolaDetails";
    if(key == 'rains')
      return "rainsDetails";
    if(key == 'rusk')
      return "ruskDetails";
    if(key == 'upshur')
      return "upshurDetails";
    if(key == 'vanzandtAndKaufman')
      return "vanzandtAndKaufmanDetails";
    if(key == 'Kaufman')
      return "KaufmanDetails";
    if(key == 'wood')
      return "woodDetails";
    if(key == 'smith')
      return "smithDetails";

    alert(key + " not found.");
  },

  getBranchDiv: function(key)
  {
    var branch = null;
    return $(this.getBranchId(key));
  },

  togglePersistence: function(key)
  {
    return;

    for(i=0; i<persBranches.length; i++)
    {
      var div = this.getBranchDiv(persBranchKeys[i]);

      if(persBranchKeys[i] == key)
      {
        if(persBranches[i].persist)
        {
          persBranches[i].persist = false;
          div.className = "texthidden";
        }
        else
        {
          persBranches[i].persist = true;
          div.className = "shown";
        }
      }
      else
      {
        persBranches[i].persist = false;
        div.className = "texthidden";
      }
    }
  },
  hideBranch2: function(key)
  {
    //Only hide the DIV if the user has not clicked on it to make it persist...
    //if(this.getPersistentBranchObj(key).persist) return;

    var branch = this.getBranchDiv(key);
    var id = this.getBranchId(key);

    if(branch != null)
    {
      //window.setTimeout('new Effect.SwitchOff(\'' + id + '\', {duration:.9});', 500);
      //window.setTimeout('$(\'' + id + '\').className=\'texthidden\';', 1000);
      branch.className = "texthidden";
    }
  }, 

  hideBranch: function(key)
  {
   
  },

  showBranch: function(key)
  {


counties.hideBranch2('panola');
counties.hideBranch2('harrison');
counties.hideBranch2('marion');
counties.hideBranch2('rusk');
counties.hideBranch2('cherokee');
counties.hideBranch2('smith');
counties.hideBranch2('gregg');
counties.hideBranch2('upshur');
counties.hideBranch2('wood');
counties.hideBranch2('rains');
counties.hideBranch2('vanzandtAndKaufman');
counties.hideBranch2('Kaufman');

    	
    //Only show a different DIV if none are persistent....
    if(this.hasPersistence()) return;

    var branch = this.getBranchDiv(key);
    var id = this.getBranchId(key);

    if(branch != null)
    {
      //window.setTimeout('$(\'' + id + '\').className=\'shown\';', 500);
      //window.setTimeout('$(\'' + id + '\').className=\'shown\';new Effect.Appear(\'' + id + '\', {duration:.9});', 500);
      branch.className = "shown";
    }
  }
}
