currentSection = '';
currentPage = '';
popUp = '';
menuList=new Array();
imagePath = '';
rootDir = '';

topnavHeight = '26';
subnavHeight = '18';

atextarea = "";

/*  
	AddMenu Syntax:
	
	AddMenu(menuname, gifname, href, width);
	(if gifname ='' a spacer will be inserted)
	
	AddMenuItem(menuname, gifname, href, popupfunctioname);
	(if gifname ='' a spacer will be inserted with a width of href)
*/

AddMenu('','','',240);

AddMenu('team','team','team/default.html','177');
AddMenuItem('team','','50','');
AddMenuItem('team','whatsit','team/whatabout/default.html','');
AddMenuItem('team','whythe','team/whywest/default.html','');
AddMenuItem('team','guides','team/guides/default.html','');
AddMenuItem('team','localevents','team/local/default.html','');
AddMenuItem('team','registration','team/registration.html','');
AddMenuItem('team','feedback','team/feedback.html','');
AddMenuItem('team','logoutteam','logout.html','');
AddMenuItem('team','','1','');

AddMenu('adventure','adventure','adventure/atv/default.html','177');
AddMenuItem('adventure','','50','');
AddMenuItem('adventure','atv','adventure/atv/default.html','');
AddMenuItem('adventure','bike','adventure/bike/default.html','');
AddMenuItem('adventure','jeep','adventure/jeep/default.html','');
AddMenuItem('adventure','rafting','adventure/rafting/default.html','');
AddMenuItem('adventure','rappelling','adventure/rappell/default.html','');
AddMenuItem('adventure','westernhorse','adventure/westernhorse/default.html','');
AddMenuItem('adventure','logoutadventure','logout.html','');
AddMenuItem('adventure','','1','');

AddMenu('american','american','american/default.html','175');
AddMenuItem('american','','50','');
AddMenuItem('american','knots','american/default.html','knots()');
AddMenuItem('american','stars','american/default.html','stars()');
AddMenuItem('american','rapids','american/default.html','rapids()');
AddMenuItem('american','nature','american/nature/default.html','');
AddMenuItem('american','campfire','american/campfire/default.html','');
AddMenuItem('american','logoutwest','logout.html','');
AddMenuItem('american','','1','');



function SetBaseDir(whichdir){
	rootDir = whichdir;
	imagePath = rootDir + 'asset/local/topnav/';
}

function AddMenu(mname, mgif, mhref, mwidth){
	menuList[menuList.length] = new aMenu(mname, mgif, mhref, mwidth);
}

function AddMenuItem(mname,itext,ihref, mpopup){
	whichMenu = 0;
	for (lcv=0; lcv < menuList.length; lcv++){
		if (menuList[lcv].name == mname) {
			whichMenu = lcv;
			break;			
		}	
	}
	nextItem = menuList[whichMenu].textItems.length;
	menuList[whichMenu].textItems[nextItem] = itext;
	menuList[whichMenu].hrefItems[nextItem] = ihref;
	menuList[whichMenu].imgItems[nextItem] = new Image();
	menuList[whichMenu].popupItems[nextItem] = mpopup;
}
	
function aMenu(mname, mgif, mhref, mwidth){
	this.name=mname;
	this.gif=mgif;
	this.href=mhref;
	this.width=mwidth;
	this.imgsrc = new Image();
	//alert(this.name + '..' + this.navtext + '..' + this.navwidth+ '..' + this.loc);
	this.textItems = new Array();
	this.hrefItems = new Array();
	this.imgItems = new Array();
	this.popupItems = new Array();
}

function navpreLoadImages(){
	if (document.images)  {
		for (lcv=0; lcv < menuList.length; lcv++){
			mname = menuList[lcv].name;
			mwidth = menuList[lcv].width;
			mgif = menuList[lcv].gif;
			menuList[lcv].imgsrc.src = imagePath + mgif + '.gif';
			
			for (ilcv=0; ilcv < menuList[lcv].textItems.length; ilcv++){
				itemText = menuList[lcv].textItems[ilcv];
				menuList[lcv].imgItems[ilcv].src = imagePath + itemText + '.gif';
			}
		}
	}
}

function createTopNav(whichSection){
	//navpreLoadImages();
	currentSection = whichSection;;
	topnavdivtag = '';
	topnavdivtag=topnavdivtag+'<TABLE WIDTH=770 BORDER=0 CELLPADDING=0 CELLSPACING=0>\n';
	topnavdivtag=topnavdivtag+'<tr>\n';
	topnavdivtag=topnavdivtag+'<td>\n';
	//topnavdivtag=topnavdivtag+'<DIV id=navbar style="Z-INDEX: 2; LEFT: 0px; VISIBILITY: visible; POSITION: absolute; TOP: 0px; HEIGHT:'+ topnavHeight + 'px">\n';
	topnavdivtag=topnavdivtag+'<table WIDTH=770 BORDER=0 CELLPADDING=0 CELLSPACING=0>\n';
	topnavdivtag=topnavdivtag+'<tr>\n';
	for (lcv=0; lcv < menuList.length; lcv++){
		mname = menuList[lcv].name;
		mwidth = menuList[lcv].width;
		mgif = menuList[lcv].gif;
		mhref = menuList[lcv].href;
		if (mhref != '#') {
			mhref = rootDir + mhref;
		}
		if (mname == '') { 
			topnavdivtag=topnavdivtag+'<td align=right bgcolor="#1F1F1F"><img src="'+imagePath+'spacer.gif" width="' + mwidth +'" height="'+ topnavHeight + '" border="0"></td>\n';
		} else {
			topnavdivtag=topnavdivtag+'<td align=right><a href="'+ mhref +'" onmouseover="navOver(\'' + mname +'\', \' \');" onmouseout="navOut(\'' + mname +'\');"><img src="'+imagePath + mgif +'i.gif" width="' + mwidth +'" height="'+ topnavHeight + '" name="' + mname +'" border="0"></a></td>\n';
		}
	}
	topnavdivtag=topnavdivtag+'</tr>\n';
	topnavdivtag=topnavdivtag+'</table>\n';
	/*
	topnavdivtag=topnavdivtag+'</div>\n';
	topnavdivtag=topnavdivtag+'</td>\n';
	topnavdivtag=topnavdivtag+'</tr>\n';
	topnavdivtag=topnavdivtag+'<tr>\n';
	topnavdivtag=topnavdivtag+'<td height='+ subnavHeight + '>&nbsp;\n';
	topnavdivtag=topnavdivtag+'</td>\n';
	topnavdivtag=topnavdivtag+'</tr>\n';
	*/
	topnavdivtag=topnavdivtag+'</TABLE>\n';
	atextarea = topnavdivtag;

	document.write(topnavdivtag);
	
	createSubNav();

	loadAmbient();
	
}


function loadAmbient(){
	qstring = parent.frames['audio'].document.location.href;
	//alert(qstring);
	if (qstring.lastIndexOf("/") > 0) {
		qstring = qstring.substr(qstring.lastIndexOf("/")+1);
	} else {
		qstring = '';
	}
	if (qstring != 'ambient_audio.html') {
		parent.frames['audio'].document.location = rootDir + 'asset/global/ambientaudio.html';
	}
}


function loadSilence(){
	qstring = parent.frames['audio'].document.location.href;
	//alert(qstring);
	if (qstring.lastIndexOf("/") > 0) {
		qstring = qstring.substr(qstring.lastIndexOf("/")+1);
	} else {
		qstring = '';
	}
	if (qstring != 'silence.html') {
		parent.frames['audio'].document.location = rootDir + 'asset/global/silence.html';
	}
}

function createSubNav(){
	for (lcv=0; lcv < menuList.length; lcv++){
		subnavdivtag = '';
		mname = menuList[lcv].name;
		if (mname == '') { 
			continue;
		}
		//alert(mname + '...' +  currentSection);
		if (mname != currentSection) {
			continue;
		}
		
		mloc = menuList[lcv].loc;
		numItems = menuList[lcv].textItems.length;
		subnavdivtag=subnavdivtag+'<table WIDTH=770 BORDER=0 CELLPADDING=0 CELLSPACING=0>\n';
		subnavdivtag=subnavdivtag+'<tr>\n';
		subnavdivtag=subnavdivtag+'<td width="100%" align="right">\n';
		subnav = "";
		atextarea = "";
		
		for (ilcv=0; ilcv < numItems; ilcv++){
			itemText = menuList[lcv].textItems[ilcv];
			itemHref = menuList[lcv].hrefItems[ilcv];
			popupWin = menuList[lcv].popupItems[ilcv];
			if (itemText == '') { 
				subnav = subnav + '<img src="'+imagePath+'spacer.gif" width="' + itemHref +'" height="'+ subnavHeight + '" border="0">';
			} else {
				if (itemHref != '#') {
					itemHref = rootDir + itemHref;
					if (popupWin != '') {
						itemHref = itemHref + '?popup=' + popupWin
					}
				}
				subnav = subnav + '<a href="' + itemHref +'" onmouseover="subnavOver(\'' + mname +'\',\'' + itemText +'\', \'\')" onmouseout="subnavOut(\'' + mname +'\',\'' + itemText +'\')">';
				subnav = subnav + '<img src="' + imagePath + itemText + 'i.gif" name="' + itemText + '" border=0>';
				subnav = subnav + '</a>';
				subnav = subnav + '<a href="' + itemHref +'" onmouseover="subnavOver(\'' + mname +'\',\'\', \'\')" onmouseout="subnavOut(\'' + mname +'\',\'\')">';
				subnav = subnav + '<img src="' + imagePath + 'spacer.gif" width="10" height="' + subnavHeight + '" border="0">';
				subnav = subnav + '</a>';
			}
		}
		
		subnavdivtag=subnavdivtag + subnav;
		//alert(subnav);
		subnavdivtag=subnavdivtag+'</td>\n';
		subnavdivtag=subnavdivtag+'</tr>\n';
		subnavdivtag=subnavdivtag+'</table>\n';
		document.write(subnavdivtag);
		
	}
}

function createSubNavDivs(){
	for (lcv=0; lcv < menuList.length; lcv++){
		subnavdivtag = '';
		mname = menuList[lcv].name;
		if (mname == '') { 
			continue;
		}
		mloc = menuList[lcv].loc;
		numItems = menuList[lcv].textItems.length;
		
		subnavdivtag=subnavdivtag+'<!-- start ' + mname + ' subnav -->\n';
		subnavdivtag=subnavdivtag+'<DIV id=' + mname + '_subnavbar style="Z-INDEX: 3; LEFT: 0px; VISIBILITY: hidden; POSITION: absolute; TOP: '+ topnavHeight + 'px; HEIGHT:'+ subnavHeight + 'px">\n';
		subnavdivtag=subnavdivtag+'<table WIDTH=770 BORDER=0 CELLPADDING=0 CELLSPACING=0>\n';
		subnavdivtag=subnavdivtag+'<tr>\n';
		subnavdivtag=subnavdivtag+'<td width="100%" align="right">\n';
		subnav = "";
		for (ilcv=0; ilcv < numItems; ilcv++){
			itemText = menuList[lcv].textItems[ilcv];
			itemHref = menuList[lcv].hrefItems[ilcv];
			popupWin = menuList[lcv].popupItems[ilcv];
			if (itemText == '') { 
				subnav = subnav + '<a href="' + itemHref +'" onmouseover="showCurrentTopNav();" onmouseout="subnavOut(\'' + mname +'\',\'\')"><img src="'+imagePath+'spacer.gif" width="' + itemHref +'" height="'+ subnavHeight + '" border="0"></a>';
			} else {
				if (itemHref != '#') {
					itemHref = rootDir + itemHref;
					if (popupWin != '') {
						itemHref = itemHref + '?popup=' + popupWin
					}
				}
				subnav = subnav + '<a href="' + itemHref +'" onmouseover="subnavOver(\'' + mname +'\',\'' + itemText +'\', \'\')" onmouseout="subnavOut(\'' + mname +'\',\'' + itemText +'\')"><img src="'+imagePath+itemText +'i.gif" name="' + itemText +'" border="0"></a>';
				subnav = subnav + '<a href="' + itemHref +'" onmouseover="subnavOver(\'' + mname +'\',\'\', \'\')" onmouseout="subnavOut(\'' + mname +'\',\'\')"><img src="'+imagePath+'spacer.gif" width="10" height="'+ subnavHeight + '" border="0"></a>';
			}
		}
		//alert(subnav);
		subnavdivtag=subnavdivtag+subnav;
		subnavdivtag=subnavdivtag+'</td>\n';
		subnavdivtag=subnavdivtag+'</tr>\n';
		subnavdivtag=subnavdivtag+'</table>\n';
		subnavdivtag=subnavdivtag+'</div>\n';
		subnavdivtag=subnavdivtag+'<!--end ' + mname + ' subnav-->\n';
		document.write(subnavdivtag);
		
	}
}


function setTopNav() {
	currentSection = arguments[0];
	currentPage =  arguments[1];
	if (arguments.length > 2){
		popUp = arguments[2];
	}
	if (currentSection != '') {
		eval('document.'+currentSection+'.src="'+imagePath+currentSection+'o.gif"');
	}
	if (currentPage != '') {
		eval('document.'+currentPage+'.src="'+imagePath+currentPage+'a.gif"');
	}
	window.status=' ';
	if (popUp != '') {
		eval(popUp)
	}
	
	

	return true;
}


function navOver(whichone, statusMsg) {
	if (whichone != currentSection) {
		eval('document.'+whichone+'.src="'+imagePath+whichone+'a.gif"');
		window.status=statusMsg;
	}
	return true;
}
			
function navOut(whichone) {
	if (whichone != currentSection) {
		eval('document.'+whichone+'.src="'+imagePath+whichone+'i.gif"');
		window.status=' ';
	}
	return true;
}

function subnavOver(whichnav, whichone, statusMsg) {
	if (whichnav != currentSection){
		//resetTopNav();
		eval('document.'+whichnav+'.src="'+imagePath+whichnav+'a.gif"');
	}
	if (whichone != ''){
		if (whichone != currentPage) {
			eval('document.'+whichone+'.src="'+imagePath+whichone+'a.gif"');
			window.status=statusMsg;
		}
	}
	return true;
}
			
function subnavOut(whichnav, whichone) {
	if (whichnav != currentSection){
		//resetTopNav();
		eval('document.'+whichnav+'.src="'+imagePath+whichnav+'i.gif"');
	}
	if (whichone != ''){
		if (whichone != currentPage) {
			eval('document.'+whichone+'.src="'+imagePath+whichone+'i.gif"');
			window.status=' ';
		}
	}
	return true;
}


function showSubNav1(whichone){
	  var elm;
	  var styleObj;
	  
	  hideAllSubNav();	
	  elm = document.getElementById(whichone+'_subnavbar');
	  if (!elm) {
		alert(whichone + ' was not found!');
	  } else {
		styleObj = new xbStyle(elm);
		styleObj.setVisibility('visible');
	  }
}

function hideAllSubNav1(){
	var elm;
	var styleObj;	

	for (lcv=0; lcv < menuList.length; lcv++){
		mname = menuList[lcv].name;
		if (mname != ''){
			whichone =mname+'_subnavbar';
			elm = document.getElementById(whichone);
			if (!elm) {
				alert(whichone + ' was not found!');
			} else {
				styleObj = new xbStyle(elm);
				styleObj.setVisibility('hidden');
			}
		}
	}
}
function showSubNav(whichone){
	var ie = (document.all) ? 1:0;
	
	if (ie) {
		hideAllSubNav();
		subnavdiv = eval('document.all.'+whichone+'_subnavbar');
		subnavdiv.style.visibility = 'visible'; 
	}else {
		hideAllSubNav();
		subnavdiv = eval('document.layers.'+whichone+'_subnavbar');
		subnavdiv.visibility = 'visible'; 
	}
}

function hideAllSubNav(){
	var ie = (document.all) ? 1:0;

	for (lcv=0; lcv < menuList.length; lcv++){
		mname = menuList[lcv].name;
		if (mname != ''){
			if (ie) {
				eval('document.all.'+mname+'_subnavbar.style.visibility = "hidden"');
			} else {
				eval('document.layers.'+mname+'_subnavbar.visibility = "hidden"');
			}
		}
	}
}

function loadPopUp(){
	qstring = location.href;
	if (qstring.lastIndexOf("?") > 0) {
		qstring = qstring.substr(qstring.lastIndexOf("?")+1);
	} else {
		qstring = '';
	}
	if (qstring != '' ) {
		//alert(qstring);
		tbargs = qstring.split('&');
		for (l=0; l < tbargs.length; l++){
			temp = tbargs[l].split('=');
			switch (temp[0]){
				case 'popup':
					popupFunction = temp[1];
					//alert(popupFunction);
					if (popupFunction != '' ){
						eval(popupFunction);
					}
					break;
				default:
					//don't do a thing
			}
		}
	}
}


//browser detection
function detectBrowser()
{
  var oldOnError = window.onerror;
  var element = null;
  
  window.onerror = defaultOnError;

  navigator.OS    = '';
  navigator.version  = 0;
  navigator.org    = '';
  navigator.family  = '';

  var platform;
  if (typeof(window.navigator.platform) != 'undefined')
  {
    platform = window.navigator.platform.toLowerCase();
    if (platform.indexOf('win') != -1)
      navigator.OS = 'win';
    else if (platform.indexOf('mac') != -1)
      navigator.OS = 'mac';
    else if (platform.indexOf('unix') != -1 || platform.indexOf('linux') != -1 || platform.indexOf('sun') != -1)
      navigator.OS = 'nix';
  }

  var i = 0;
  var ua = window.navigator.userAgent.toLowerCase();
  
  if (ua.indexOf('opera') != -1)
  {
    i = ua.indexOf('opera');
    navigator.family  = 'opera';
    navigator.org    = 'opera';
    navigator.version  = parseFloat('0' + ua.substr(i+6), 10);
  }
  else if ((i = ua.indexOf('msie')) != -1)
  {
    navigator.org    = 'microsoft';
    navigator.version  = parseFloat('0' + ua.substr(i+5), 10);
    
    if (navigator.version < 4)
      navigator.family = 'ie3';
    else
      navigator.family = 'ie4'
  }
  else if (typeof(window.controllers) != 'undefined' && typeof(window.locationbar) != 'undefined')
  {
    i = ua.lastIndexOf('/')
    navigator.version = parseFloat('0' + ua.substr(i+1), 10);
    navigator.family = 'gecko';

    if (ua.indexOf('netscape') != -1)
      navigator.org = 'netscape';
    else if (ua.indexOf('compuserve') != -1)
      navigator.org = 'compuserve';
    else
      navigator.org = 'mozilla';
  }
  else if ((ua.indexOf('mozilla') !=-1) && (ua.indexOf('spoofer')==-1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('opera')==-1)&& (ua.indexOf('webtv')==-1) && (ua.indexOf('hotjava')==-1))
  {
      var is_major = parseFloat(navigator.appVersion);
    
    if (is_major < 4)
      navigator.version = is_major;
    else
    {
      i = ua.lastIndexOf('/')
      navigator.version = parseFloat('0' + ua.substr(i+1), 10);
    }
    navigator.org = 'netscape';
    navigator.family = 'nn' + parseInt(navigator.appVersion);
  }
  else if ((i = ua.indexOf('aol')) != -1 )
  {
    // aol
    navigator.family  = 'aol';
    navigator.org    = 'aol';
    navigator.version  = parseFloat('0' + ua.substr(i+4), 10);
  }

  navigator.DOMCORE1  = (typeof(document.getElementsByTagName) != 'undefined' && typeof(document.createElement) != 'undefined');
  navigator.DOMCORE2  = (navigator.DOMCORE1 && typeof(document.getElementById) != 'undefined' && typeof(document.createElementNS) != 'undefined');
  navigator.DOMHTML  = (navigator.DOMCORE1 && typeof(document.getElementById) != 'undefined');
  navigator.DOMCSS1  = ( (navigator.family == 'gecko') || (navigator.family == 'ie4') );

  navigator.DOMCSS2   = false;
  if (navigator.DOMCORE1)
  {
    element = document.createElement('p');
    navigator.DOMCSS2 = (typeof(element.style) == 'object');
  }

  navigator.DOMEVENTS  = (typeof(document.createEvent) != 'undefined');

  window.onerror = oldOnError;
}


// Handy functions
function noop() {}
function noerror() { return true; }

function defaultOnError(msg, url, line)
{
  // customize this for your site
  if (top.location.href.indexOf('/evangelism/lib/js/errors/') == -1)
    top.location = '/evangelism/lib/js/errors/index.html?msg=' + escape(msg) + '&url=' + escape(url) + '&line=' + escape(line);
}


function browserDetail(){
	var i;
	var properties = new Array();
	properties[properties.length] = 'family';
	properties[properties.length] = 'version';
	properties[properties.length] = 'OS';
	properties[properties.length] = 'org';
	properties[properties.length] = 'DOMCORE1'
	properties[properties.length] = 'DOMCORE2';
	properties[properties.length] = 'DOMHTML';
	properties[properties.length] = 'DOMCSS1';
	properties[properties.length] = 'DOMCSS2';
	properties[properties.length] = 'DOMEVENTS';
	
	document.write('<table border="1">');
	document.write('<tr><td><b>Sniffer Variable</b></td><td><b>Value<\/b><\/td><\/tr>');
	document.write('<tr><td>navigator.userAgent<\/td><td>' + navigator.userAgent  + '<\/td><\/tr>');
	
	for (i = 0; i < properties.length; i++)
	document.write('<tr><td>navigator.' + properties[i] + '<\/td><td>' + navigator[properties[i]]  + '<\/td><\/tr>');
	document.write('<\/table>');
}

//-->

