var emailBo = '<A HREF="mailto:bo@fatbirder.com" STYLE="text-decoration:none">bo@fatbirder.com</A>';

var geoHREF = '/links_geo/';
var linksHREF = '/links/';
var mainHREF = '/';

//var ns6 = document.getElementById && !document.all;
//isIE = (document.all ? true : false);
//isDOM = (document.getElementById ? true : false);

// overly simplistic test for IE
isIE = (document.all ? true : false);
// both IE5 and NS6 are DOM-compliant (well, sort of...)
isDOM = (document.getElementById ? true : false);

function toggleVisible(divname) {
 divstyle = getDivStyle(divname);
 if (divstyle.visibility == 'visible' || divstyle.visibility == 'show') {
   divstyle.visibility = 'hidden';
 } else {
   divstyle.visibility = 'visible';
 }
}

function getDivStyle(divname) {
 var style;
 if (isDOM) { style = document.getElementById(divname).style; }
 else { style = isIE ? document.all[divname].style
                     : document.layers[divname]; } // NS4
 return style;
}

var menulist = new Array(new Array(	new Array('mnu_world','#',235,181),
				new Array(	new Array('Africa',geoHREF+'africa/',''),
						new Array('Antartica',geoHREF+'antartica/',''),
						new Array('Asia',geoHREF+'asia/',''),
						new Array('Australasia',geoHREF+'australasia/',''),
						new Array('Europe',geoHREF+'europe/',''),
						new Array('Middle East',geoHREF+'middle_east/',''),
						new Array('North America',geoHREF+'america_north/',''),
						new Array('Central America',geoHREF+'america_central/',''),
						new Array('South America',geoHREF+'america_south/',''))),
		  new Array(	new Array('mnu_uk','#',235,181),
				new Array(	new Array('England',geoHREF+'europe/england.html',''),
						new Array('Northern Ireland',geoHREF+'europe/northern_ireland.html',''),
						new Array('Scotland',geoHREF+'europe/scotland.html',''),
						new Array('Wales',geoHREF+'europe/wales.html',''),
						new Array('Isle of Man',geoHREF+'europe/england_isle_of_man.html',''),
						new Array('Channel Islands',geoHREF+'europe/england_channel_islands.html',''))),
		  new Array(	new Array('mnu_fun','#',235,181),
				new Array(
						new Array('Birding Facts',linksHREF+'fun/facts.html',''),
						new Array('Birding Hints and Tips',linksHREF+'fun/hints_and_tips.html',''),
						new Array('Bird Jokes and Humour',linksHREF+'fun/bird_humour.html',''),
						new Array('Birding Blogs',linksHREF+'signpost_and_discussion/blogs.html',''),
						new Array('Birding Stories & Urban Myths',linksHREF+'fun/urban_myths.html',''),
						new Array('Big Days and Bird Racing',linksHREF+'listing_and_racing/big_days_and_bird_racing.html',''),
						new Array('Big Sits',linksHREF+'listing_and_racing/big_sits.html',''),
						new Array('Listing',linksHREF+'listing_and_racing/listing.html',''),
						new Array('Miscellany',linksHREF+'fun/misc.html',''),
						new Array('Pet Birds',linksHREF+'petbirds/petbirds.html',''),
						new Array('Twitching',linksHREF+'listing_and_racing/twitching.html',''),
						new Array('Quizzes',linksHREF+'fun/quizzes.html',''),
						new Array('Stamps Featuring Birds',linksHREF+'fun/stamps.html',''),
						new Array('Webring - Fatbirder',mainHREF+'webring/',''),
						new Array('Webring - Others',linksHREF+'signpost_and_discussion/webrings.html',''))),
		  new Array(	new Array('mnu_signpost','#',235,181),
				new Array(	new Array('Birdlines & postings',linksHREF+'signpost_and_discussion/birdlines.html',''),
						new Array('Birds and Angling',linksHREF+'signpost_and_discussion/birds_and_angling.html',''),
						new Array('Birds and Gardening',linksHREF+'signpost_and_discussion/birds_and_gardening.html',''),
						new Array('Disabled birding',linksHREF+'signpost_and_discussion/disabled_birding.html',''),
						new Array('Mailing lists & Discussion forums',linksHREF+'signpost_and_discussion/mailing_lists.html',''),
						new Array('Mega links pages',linksHREF+'signpost_and_discussion/mega_links_pages.html',''),
						new Array('Fatbirder Top 10 birding sites',linksHREF+'fun/top_ten.html',''))),
		  new Array(	new Array('mnu_travel','#',235,181),
				new Array(	new Array('Trip Reports',linksHREF+'trip_reports/',''),
						new Array('Fatbirder Trip Reports','http://www.anytimetours.co.uk',''),
						new Array('Holiday Companies',linksHREF+'travel/holiday_companies.html',''),
						new Array('Pelagics',linksHREF+'travel/pelagics.html',''),
						new Array('Weather and Tides',linksHREF+'ornithology/weather_and_tides.html',''))),
		  new Array(	new Array('mnu_library','#',235,181),
				new Array(	new Array('Bookstores',linksHREF+'commerce/books_bookshops.html',''),
						new Array('Book Publishers',linksHREF+'commerce/books_publishers.html',''),
						new Array('Fieldguide Indexes',linksHREF+'commerce/fieldguide_indexes.html',''),
						new Array('Magazines',linksHREF+'commerce/books_magazines.html',''),
						new Array('Online Books',linksHREF+'commerce/books.html',''),
						new Array('Videos, CDs & Software',linksHREF+'commerce/tapes.html',''))),
		  new Array(	new Array('mnu_birdfamilies','#',235,181),
				new Array(	
						new Array('Extinct & Threatened Species',linksHREF+'ornithology/threatened_and_extinct_species.html',''),
						new Array('Non-Passerines',mainHREF+'species_and_families/non_passerines/',''),
						new Array('Passerines',mainHREF+'species_and_families/passerines/',''),
						new Array('Identification',linksHREF+'ornithology/identification.html',''),
						new Array('Names and Taxonomy',linksHREF+'ornithology/names_and_taxonomy.html',''))),
		  new Array(	new Array('mnu_ornithology','#',235,181),
				new Array(
						new Array('Banding and Ringing',linksHREF+'ornithology/banding_and_ringing.html',''),
						new Array('Birders and Ornithologists',linksHREF+'ornithology/birders_and_ornithologists.html',''),
						new Array('Conservation',linksHREF+'ornithology/conservation.html',''),
						new Array('Migration',linksHREF+'ornithology/migration.html',''),
						new Array('Bird Behaviour Study',linksHREF+'ornithology/study_and_behaviour.html',''),
						new Array('Ornithology Courses',linksHREF+'ornithology/courses.html',''),
						new Array('Fairs, Festivals & Conferences',linksHREF+'ornithology/bird_fairs.html',''),
						new Array('Birding Organisations',linksHREF+'ornithology/birding_organisations.html',''),
						new Array('Museums and Universities',linksHREF+'ornithology/museums.html',''))),
		  new Array(	new Array('mnu_sightsounds','#',235,181),
				new Array(	new Array('Bird Art and Artists',linksHREF+'images_and_sound/art_and_artists.html',''),
						new Array('Bird Song',linksHREF+'images_and_sound/bird_song.html',''),
						new Array('Digiscoping',linksHREF+'images_and_sound/digiscoping.html',''),
						new Array('Photographs and Photographers',linksHREF+'images_and_sound/photos.html',''),
						new Array('Podcasts',linksHREF+'images_and_sound/podcasts.html',''),
						new Array('Webcams',linksHREF+'images_and_sound/webcams.html',''))),
		  new Array(	new Array('mnu_equipment','#',235,181),
				new Array(	new Array('Optics - Retail',linksHREF+'commerce/optics.html',''),
						new Array('Optics - Manufacturers',linksHREF+'commerce/optics_manufacturers.html',''),
						new Array('Optics - Tripods',linksHREF+'commerce/optics_tripods.html',''),
						new Array('Other Birding Related Equipment',linksHREF+'commerce/other.html',''),
						new Array('Outdoor clothing',linksHREF+'commerce/outdoor_clothing.html',''),
						new Array('Backyard Supplies - Food',linksHREF+'commerce/bird_food.html',''),
						new Array('Backyard Supplies - Other',linksHREF+'commerce/other_supplies.html',''))))


function showMenu(object) {
  if (document.getElementById && document.getElementById(object) != null)
    node = document.getElementById(object).style.visibility='visible';
  else if (document.layers && document.layers[object] != null)
    document.layers[object].visibility = 'visible';
  else if (document.all)
    document.all[object].style.visibility = 'visible';
}


function hideMenu(object) {
  if (document.getElementById && document.getElementById(object) != null)
    node = document.getElementById(object).style.visibility='hidden';
  else if (document.layers && document.layers[object] != null)
    document.layers[object].visibility = 'hidden';
  else if (document.all)
    document.all[object].style.visibility = 'hidden';
}


function hideAll(){
  var a
  var v = (document.layers) ? ".visibility" : ".style.visibility";
  var arr = (document.layers) ? document.layers : (document.all) ? document.all.tags("DIV") : document.getElementsByTagName("DIV");
  for(var i=0;i<arr.length;i++){
    
    a=arr[i].id;
    if (a.substring(0,4) == "mnu_") {
    
    	eval("arr["+i+"]"+v+"='hidden'");
    }
  }
  if (document.layers != null) {
    document.layers['advert'].visibility = 'visible';
  }
  else if (document.all) {
    document.all['advert'].style.visibility = 'visible';
  }
}


function showJustMe(object) {
  if (document.layers && document.layers[object]) {
    hideAll();
    showMenu(object);
  }
  else if (document.all) {
    hideAll();
    showMenu(object);
  }
}


function WriteDIVs() {
  for (idx=0; idx<menulist.length; idx++) {
    generateDIVs(menulist[idx][0][0],idx,menulist[idx][0][2],menulist[idx][0][3]);
    if (idx > 0) {
    }
  }
}


function generateDIVs(jsLayerName,jsLayerNumber,jsExtWidth,jsIntWidth){
  // height of right vertical spacer = (number of items x 16 px) + 19 px
  LayerHeight = ((menulist[idx][1].length)*16)+19;
  document.writeln('<DIV ID="'+ jsLayerName +'">');
  document.writeln('<table border="0" cellspacing="0" cellpadding="0">');
  document.writeln('  <tr>');
  document.writeln('    <td colspan="5" onMouseOver="hideAll()"><img src="/images/gen_spacer.gif" width="' + jsExtWidth + '" height="20"></td>');
  document.writeln('  </tr>');
  document.writeln('  <tr>');
  document.writeln('    <td><img src="/images/gen_spacer.gif" width="20" height="7"></td>');
  document.writeln('    <td><img src="/images/gen_popup_top_left.gif" width="7" height="7"></td>');
  document.writeln('    <td background="/images/gen_popup_top.gif"><img src="/images/gen_spacer.gif" width="1" height="7"></td>');
  document.writeln('    <td><img src="/images/gen_popup_top_right.gif" width="7" height="7"></td>');
  document.writeln('    <td rowspan="3" onMouseOver="hideAll()"><img src="/images/gen_spacer.gif" width="20" height="' + LayerHeight +'"></td>');
  document.writeln('  </tr>');
  document.writeln('  <tr>');
  document.writeln('    <td width="20" valign="top" onMouseOver="showJustMe(\''+ jsLayerName +'\')"><img src="/images/gen_popup_arrow.gif" width="20" height="20"><br><img src="/images/gen_spacer.gif" width="20" height="' + (LayerHeight-34) +'"></td>');
  document.writeln('    <td width="7" background="/images/gen_popup_left.gif"><img src="/images/gen_spacer.gif" width="7" height="1"></td>');
  document.writeln('    <td bgcolor="#317B84" width="' + jsIntWidth +'" valign="top">');

    for (i=0; i<menulist[idx][1].length; i++) {
      document.writeln('<a href="'+ menulist[jsLayerNumber][1][i][1] +'" onMouseOver="');
      a = menulist[jsLayerNumber][1][i][0];
      for (i2=0; i2<menulist[idx][1].length; i2++) {
        b = menulist[jsLayerNumber][1][i2][0];
        c = menulist[jsLayerNumber][1][i2][2];
        if (b != a && c != '') {
          document.writeln('hideMenu(\''+ c +'\'),');
        }
        else if (c != '') {
          document.writeln('showMenu(\''+ c +'\'),');
        }
      }
    document.writeln('hideMenu(\'dummy\')" class="navigation">'+ menulist[jsLayerNumber][1][i][0] + '</a><br>');
    }

  document.writeln('    <td width="7" background="/images/gen_popup_right.gif" bgcolor="#317B84">&nbsp;</td>');
  document.writeln('  </tr>');
  document.writeln('  <tr>');
  document.writeln('    <td height="7" width="20"><img src="/images/gen_spacer.gif" width="20" height="7"></td>');
  document.writeln('    <td height="7" width="7"><img src="/images/gen_popup_bottom_left.gif" width="7" height="7"></td>');
  document.writeln('    <td height="7" background="/images/gen_popup_bottom.gif"><img src="/images/gen_spacer.gif" width="' + jsIntWidth +'" height="7"></td>');
  document.writeln('    <td><img src="/images/gen_popup_bottom_right.gif" width="7" height="7"></td>');
  document.writeln('  </tr>');
  document.writeln('  <tr>');
  document.writeln('    <td colspan="5" onMouseOver="hideAll()"><img src="/images/gen_spacer.gif" width="' + jsExtWidth + '" height="20"></td>');
  document.writeln('  </tr>');
  document.writeln('</table>');
  document.writeln('</DIV>');;
}

function openWindow(url) {
  popupWin = window.open(url, 'openWin', "width=400, height=250, scrollbars=yes, resizable=yes"); 
}
