var menutxt="";

menutxt+="@0 home.htm Home";
menutxt+="@0 history.htm History of the Society";
menutxt+="@1 history_early_years.htm The Early Years";
menutxt+="@1 history_first_century.htm The First 100 Years";
menutxt+="@1 history_centenary.htm Centenary Celebrations";
menutxt+="@0 committee.htm The Committee";
menutxt+="@0 patron.htm Our Patron";
menutxt+="@0 previous_productions.htm Previous Productions";
menutxt+="@1 previous_1903_to_1950.htm 1903 to 1950";
menutxt+="@1 previous_1951_to_2000.htm 1951 to 2000";
menutxt+="@2 previous_1957.htm 1957";
menutxt+="@2 previous_1987.htm 1987";
menutxt+="@2 previous_1992.htm 1992";
menutxt+="@2 previous_1997.htm 1997";
menutxt+="@1 previous_2001_to_2005.htm 2001 to 2005";
menutxt+="@2 2001_pirates_of_penzance.htm The Pirates of<BR>Penzance";
menutxt+="@2 2001_south_pacific.htm South Pacific";
menutxt+="@2 2002_card.htm The Card";
menutxt+="@2 2002_gigi.htm Gigi";
menutxt+="@2 2003_hms_pinafore.htm HMS Pinafore";
menutxt+="@2 2003_crazy_for_you.htm Crazy For You";
menutxt+="@2 2004_mikado.htm The Mikado";
menutxt+="@2 2004_best_little_whorehouse.htm The Best Little<BR>Whorehouse in Texas";
menutxt+="@2 2005_kiss_me_kate.htm Kiss Me Kate";
menutxt+="@2 2005_a_funny_thing_happened.htm A Funny Thing<BR>Happened on the Way<BR>to the Forum";
menutxt+="@0 recent_productions.htm Recent Productions";
menutxt+="@1 2006_rodgers_and_hart.htm Rodgers & Hart";
menutxt+="@1 2006_yeomen_of_the_guard.htm The Yeomen of the<BR>Guard";
menutxt+="@1 2007_annie_get_your_gun.htm Annie Get Your Gun";
menutxt+="@1 2008_iolanthe.htm Iolanthe";
menutxt+="@1 2008_42nd_street.htm 42nd Street";
menutxt+="@1 2008_merry_widow.htm The Merry Widow";
menutxt+="@2 roy_hudd.htm Roy Hudd Drops In";
menutxt+="@1 2009_mame.htm Mame";
menutxt+="@1 2009_thoroughly_modern_millie.htm Thoroughly Modern<BR>Millie";
menutxt+="@1 2009_pirates_of_penzance.htm The Pirates of<BR>Penzance";
menutxt+="@1 2010_bitter_sweet.htm Bitter Sweet";
menutxt+="@0 future_productions.htm Future Productions";
menutxt+="@1 2010_carousel.htm Carousel";
menutxt+="@1 2011_beauty_and_the_beast.htm Disney's Beauty and<BR>The Beast";
menutxt+="@1 2011_patience.htm Patience";
menutxt+="@0 join.htm Join the Society";
menutxt+="@0 friends.htm Become a Friend";
menutxt+="@0 alan_holt_award.htm Alan Holt Award";
menutxt+="@0 links.htm Links";
menutxt+="@0 members.php Members' Page";
menutxt+="@1 rehearsals.php Rehearsal Schedule";
menutxt+="@1 directors.php Directors' Notes";
menutxt+="@1 downloads.php Downloads";
//menutxt+="@1 ticket_sales.php Ticket Sales";
menutxt+="@1 newswatch.php News Watch";
menutxt+="@0 brian_donnan.htm Brian Donnan";

var menu=menutxt.split("@");

var docurl=document.URL.replace(/\\/g,"/");
var referer=docurl.split("/");
var reqpage=referer[referer.length-1].split("#")[0];

var lev=new Array(200),url=new Array(200),link=new Array(200),pclass=new Array(200),vis=new Array(200);
var mask,n,i,r,j,reqn,reqlev;

mask=/(\d) ([\w\.]*) (.*)/;
n=0;
while (menu[n+1])
{
  n++;
  lev[n]=menu[n].match(mask)[1];
  url[n]=menu[n].match(mask)[2];
  link[n]=menu[n].match(mask)[3];
  link[n]=link[n].replace(/<BR>/,"<br />");
  pclass[n]='<p class="leftnav">'
  if (lev[n]>0)
  {
    pclass[n]=pclass[n].replace(/leftnav/,"leftnav-");
    for (i=1;i<=lev[n];i++)
    {
      pclass[n]=pclass[n].replace(/-/,"-sub");
    }
  }
  vis[n]=false;
  if (url[n]==reqpage)
  {
    reqn=n;
    reqlev=lev[n];
  }
}

r=reqlev;
for (i=reqn;i>=1;i--)
{
  if ((url[i]==reqpage)||(lev[i]<r))
  {
    pclass[i]=pclass[i].replace(/">/,'-on">');
    r=lev[i];
  }
}

r=reqlev;
for (i=reqn;i>=1;i--)
{
  if ((r-lev[i]==0)||(r-lev[i]==1))
  {
    r=lev[i];
    vis[i]=true;
  }
}
j=reqn+1;
while (lev[j]>reqlev)
{
  if (lev[j]-reqlev==1)
  {
    vis[j]=true;
  }
  j++;
}
r=reqlev;
for (i=j;i<=n;i++)
{
  if (r-lev[i]>= 0)
  {
    r=lev[i];
    vis[i]=true;
  }
}

for (i=1;i<=n;i++)
{
  if (vis[i])
  {
    document.write(pclass[i]+'<a href="'+url[i]+'">'+link[i]+'</a></p>');
  }
}
