var url = "";

function menu(i,p,n,c,h,o)
{
  this.id = i;
  this.parent = p;
  this.name = n;
  this.cname = c;
  if (h.indexOf("contents.asp") == -1)
  {
    if ((h != '#') && (h.indexOf('http') == -1) )
      this.href = url + h; 
    else
      this.href = h; 
  }
  else
    this.href = h; 

  this.opt = o;
  return(this);
} var wasopen;

var menus = new Array();

menus[0] = new menu(29,-28,'Crew Reception','MenuItem','/images/crewrecpt.htm','c','75','15');
menus[1] = new menu(30,-28,'10th July 2005','MenuItem','/images/10july.htm','c','75','15');
menus[2] = new menu(1,0,'WELCOME','MenuItem','/welcome.htm','c','75','15');
menus[3] = new menu(15,0,'SIR MATTHEW PINSENT','MenuItem','/matthew pinsent.htm','c','75','15');
menus[4] = new menu(3,0,'TRAINING','MenuItem','/training.htm','c','75','15');
menus[5] = new menu(4,0,'REGATTA','MenuItem','/regatta.htm','c','75','15');
menus[6] = new menu(18,0,'IMAGES','MenuItem','/images.htm','c','75','15');
menus[7] = new menu(22,0,'NOTICE BOARD','MenuItem','/noticeboard.htm','c','75','15');
menus[8] = new menu(24,0,'COMMENTS','MenuItem','/comments.htm','c','75','15');
menus[9] = new menu(5,0,'NEWS','MenuItem','/news.htm','c','75','15');
menus[10] = new menu(6,0,'CONTACT US','MenuItem','/contact_us.htm','c','75','15');
menus[11] = new menu(7,3,'VENUES','MenuItem','/training/venues.htm','c','75','15');
menus[12] = new menu(8,3,'SCHEDULES','MenuItem','/training/schedules.htm','c','75','15');
menus[13] = new menu(9,3,'DIRECTIONS','MenuItem','/training/directions.htm','c','75','15');
menus[14] = new menu(14,4,'VENUE','MenuItem','/regatta/venue.htm','c','75','15');
menus[15] = new menu(20,4,'HOTELS','MenuItem','/hotels.htm','c','75','15');
menus[16] = new menu(13,4,'DIRECTIONS','MenuItem','/regatta/directions.htm','c','75','15');
menus[17] = new menu(27,18,'MEDAL CREWS','MenuItem','/images/winners.htm','c','75','15');
menus[18] = new menu(31,18,'2nd JULY 2006','MenuItem','/images/2July06.htm','c','75','15');
menus[19] = new menu(23,18,'DOCKLANDS','MenuItem','/images/docklands.htm','c','75','15');
menus[20] = new menu(25,18,'DORNEY LAKE','MenuItem','/images/dorneylake.htm','c','75','15');
menus[21] = new menu(28,18,'2005 IMAGES','MenuItem','/images/crewrecpt.htm','c','75','15');
menus[22] = new menu(36,28,'10th July 2005','MenuItem','/images/crewrecpt/10july.htm','c','75','15');



var opened = '';
var toopen = 0;

function DrawMenuItems(l)
{
var html='';;
var i,j;
var f;


  f = 0;
  if (l == 0)
    html += "<table border=0 class=\"menu-table\">";
  else
    html += "<table border=0 class=\"submenu-table\">";
  GetSlash();
  for (i = 0; i < menus.length; i ++)
    {
    if (menus[i].parent == l)
      {
      f = 1;
      html += "<tr>";
      if (menus[i].parent == 0)
        html += "<td class=\"menu-td\">";
      else
        html += "<td class=\"submenu-td\">";
        
      if (menus[i].opt == 'n')
        html += "<a target='newbrowser' class='" + menus[i].cname + CurrentPage(menus[i].href) + "' href='" + GetSlash() + menus[i].href + "'>" + menus[i].name + "</a>";
      else
        html += "<a class='" + menus[i].cname + CurrentPage(menus[i].href) + "' href='" + GetSlash() + menus[i].href + "'>" + menus[i].name + "</a>";
        
      if (opened.indexOf('|' + menus[i].id + '|') != -1) html += DrawMenuItems(menus[i].id);
      html += "</td>";
      html += "</tr>";
      }
    }
  html += "</table>";
  if (f == 0)
    return("");
  else
    return(html);
}

function HasChildren(x)
{
var i;

  for (i = 0; i < menus.length; i ++)
    if (menus[i].parent = x) return(true);
    
  return (false);
}

function GetParentSubscript(x)
{
var i;

  for (i = 0; i < menus.length; i ++)
    if (menus[i].id == x) return(i);
    
  return(-1);
}

function strtolower(s)
{
var t;

  t = s;
  
  while (t.indexOf(" ") != -1)
    t = t.replace(" ", "_");
  
  return(t.toLowerCase());
}

function DrawMenu(l)
{
var m = MM_findObj("menux");
var pos;
var apos;
var i;
var url='nowhere';

  
  if (l != 0)
    {
    var p;
    p = l;
    
    if (opened.indexOf('|' + l + '|') == -1)
      opened = '|' + l + '|';
    else
      opened = '';
    
    while (GetParentSubscript(p) != -1)
      {
      j = GetParentSubscript(p);
      opened = '|' + menus[j].parent + '|' + opened;
      p = menus[j].parent;
      }
    }
  else 
    {
    opened = '';
    }
  
  m.innerHTML = DrawMenuItems(0);
}

function GetSlash(){
	
	var number_slashes = 0;
	var return_Slashes = "";
	var sPath = window.location.pathname;
	var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);

	if (sPage != "contents.asp"){
		number_slashes = sPath.split("/");
		for( i = 0; i < (number_slashes.length - 3); i++){
			return_Slashes = return_Slashes + "../";
		}
	}
return return_Slashes;
}

function CurrentPage(link_url){
var sURL = window.location.href;
var sPath = window.location.pathname;
var matching = "";
	var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
	if (sPage == "contents.asp"){
		if (getParameter ( link_url, "p" ) == getParameter ( sURL, "p" )){
			matching = "on";
		}
		else{
			matching = "";
		}
	}
	else{
		
		if (sPath == link_url){
			matching = "on";
		}
		else{
			matching = "";
		}
	}
return matching;
}


function getParameter ( queryString, parameterName ) {
	// Add "=" to the parameter name (i.e. parameterName=value)
	var parameterName = parameterName + "=";
	if ( queryString.length > 0 ) {
	// Find the beginning of the string
		begin = queryString.indexOf ( parameterName );
		// If the parameter name is not found, skip it, otherwise return the value
		if ( begin != -1 ) {
			// Add the length (integer) to the beginning
			begin += parameterName.length;
			// Multiple parameters are separated by the "&" sign
			end = queryString.indexOf ( "&" , begin );
			if ( end == -1 ) {
				end = queryString.length
			}
		// Return the string
		return unescape ( queryString.substring ( begin, end ) );
	}
	// Return "null" if no parameter has been found
	return "null";
	}
}



toopen = 0;
pos = document.location.href;
i = pos.indexOf('www');
if (i > 0) pos = pos.substring(i, pos.length);
i = pos.indexOf('/');
if (i > 0) pos = pos.substring(i, pos.length);

if (pos.indexOf('contents.asp') > 0)
  {
  i = pos.indexOf('contents.asp');
  pos = pos.substring(i, pos.length);
  }

for (i = menus.length - 1; i > -1 ; i --) 
  {
  
  if (pos.indexOf(strtolower(menus[i].href)) >= 0)
    {
    toopen = menus[i].id;
    break;
    }
  } 

DrawMenu(toopen);

