var menupic = new Array('16','17','18','19','10','11','12','13','5','6');
if (location.href.indexOf('lindblad.waves') == -1)
{
	var whichtop = new Array(94,94,94,94,69,69,69,69,31,31);
}
else
{
	var whichtop = new Array(114,114,114,114,89,89,89,89,51,51);
}
var pushleft = new Array(-15,3,2,2,3,3,3,3,3,3);
var leftedge = (document.body.clientWidth - 914) / 2;
if (leftedge < 0) {leftedge = 0;}

var mnumber = new Array();
var hiddens = new Array();
var closing = new Array();
var mparent = new Array();
for (i=0; i<=0; i++)
{
	mnumber[i] = 0;
	hiddens[i] = new Array();
	closing[i] = new Array();
	mparent[i] = new Array();
}

closing2 = new Array();
closing3 = new Array();

function displayMenu(type,which)
{
	clearTimeout(closing[type][which]);
	if (type == 0)
	{
		eval("document.template_" + menupic[which] + "pic.src = templateon_" + menupic[which] + ".src");
	}
	if (eval("document.getElementById('menu" + type + "_" + which + "').style.visibility == 'hidden'"))
	{
		eval("document.getElementById('menu" + type + "_" + which + "').style.visibility = 'visible'");
		document.getElementById('menu' + type + '_' + which).style.overflowX = 'hidden';
		document.getElementById('menu' + type + '_' + which).style.overflowY = 'auto';
	}
	for (i=0; i<hiddens[type].length; i++)
	{
		if (i != which) {hideMenu(type,i);}
	}
	hiddens[type][which] = false;

	if (type > 0)
	{
		ptype = type - 1;
		displayMenu(ptype,mparent[type][which]);
	}
}

function delayHide(type,which)
{
	clearTimeout(closing[type][which]);
	closing[type][which] = setTimeout('hideMenu(' + type + ',' + which + ')',100);
	if (type > 0)
	{
		ptype = type - 1;
		delayHide(ptype,mparent[type][which]);
	}
}

function hideAll(type)
{
	for (i=0; i<hiddens[type].length; i++)
	{
		hideMenu(type,i);
	}
	if (type > 0)
	{
		ptype = type - 1;
		hideAll(ptype);
	}
}

function hideMenu(type,which)
{
	clearTimeout(closing[type][which]);
	document.getElementById('menu' + type + '_' + which).style.overflowX = 'hidden';
	document.getElementById('menu' + type + '_' + which).style.overflowY = 'hidden';
	eval("document.getElementById('menu" + type + "_" + which + "').style.visibility = 'hidden'");
	hiddens[type][which] = true;

	if (type == 0)
	{
		eval("document.template_" + menupic[which] + "pic.src = template_" + menupic[which] + ".src");
	}
}

function clickMenu2(which,menuID)
{
	clearTimeout(closing2[menuID]);
	if (document.getElementById(which).style.visibility == 'visible')
	{
		hideMenu2(which);
	}
	else
	{
		displayMenu2(which,menuID);
	}
}

function displayMenu2(which,menuID)
{
	clearTimeout(closing2[menuID]);
	document.getElementById(which).style.visibility = 'visible';
	document.getElementById(which).style.overflowX = 'hidden';
	document.getElementById(which).style.overflowY = 'auto';
}

function delayHide2(which,menuID)
{
	closing2[menuID] = setTimeout('hideMenu2(\'' + which + '\')',100);
}

function hideMenu2(which)
{
	document.getElementById(which).style.overflowX = 'hidden';
	document.getElementById(which).style.overflowY = 'hidden';
	document.getElementById(which).style.visibility = 'hidden';
}

function displayMenu3(which,menuID)
{
	clearTimeout(closing3[menuID]);
	document.getElementById(which).style.visibility = 'visible';
}

function delayHide3(which,menuID)
{
	closing3[menuID] = setTimeout('hideMenu3(\'' + which + '\')',100);
}

function hideMenu3(which)
{
	document.getElementById(which).style.visibility = 'hidden';
}

function highlightMenuItem(whichmenu,whichitem)
{
	for (i=0; i<micount[whichmenu]; i++)
	{
		thiscolor = (i == whichitem) ? '#000000' : '#999999';
		document.getElementById('menuitem_' + whichmenu + '_' + i).style.color = thiscolor;
	}
}

function unhighlightMenuItems(whichmenu)
{
	for (i=0; i<micount[whichmenu]; i++)
	{
		document.getElementById('menuitem_' + whichmenu + '_' + i).style.color = '#666666';
	}
}

var arrowcount = 0;

function createMenu(type,mtop,mleft,labellist,linklist)
{
	ptype = type - 1;
	ctype = type + 1;
	var labels = labellist.split('|');
	var links = linklist.split('|');

	mleft = document.getElementById('template_'+menupic[mnumber[type]]+'div').offsetLeft + pushleft[mnumber[type]];
	mtop = whichtop[mnumber[type]];

	document.write('<DIV id="menu'+type+'_'+mnumber[type]+'" style="top:'+mtop+'px; left:' + mleft + 'px; VISIBILITY:hidden; OVERFLOW:visible; POSITION:absolute; Z-INDEX:3;" onMouseOver = "displayMenu('+type+','+mnumber[type]+')" onMouseOut = "delayHide('+type+','+mnumber[type]+')">');

	if (labellist != '')
	{
		usebg = '#c5c3bd';
		document.write('<table border="0" cellpadding="0" cellspacing="1" bgcolor="#ffffff">');
		document.write('<tr><td bgcolor="#f2f2f2" style="background-image: url(\'https://www.expeditions.com/images/menubg.gif\'); background-repeat: repeat-x; background-position: left top;">');
		document.write('<table border="0" cellpadding="0" cellspacing="0">');
		for (i=0; i<labels.length; i++)
		{
			var linkinfo = links[i].split('^');
			if (linkinfo[1])
			{
				mparent[ctype][linkinfo[1]] = mnumber[type];
				if (ie || n6)
				{
					document.write('<tr><td height="20"><a class="menu1" onMouseOver="displayMenu('+ctype+','+linkinfo[1]+')" onMouseOut="delayHide('+ctype+','+linkinfo[1]+')" href="'+linkinfo[0]+'">&nbsp;&nbsp;'+labels[i]+'&nbsp;&nbsp;</a></td></tr>');
				}
			}
			else
			{
				document.write('<tr><td height="20"><a id="menuitem_' + mnumber[type] + '_' + i + '" class="menu1" onMouseOver="highlightMenuItem(' + mnumber[type] + ',' + i + ')" onMouseOut="unhighlightMenuItems(' + mnumber[type] + ')" href="' + linkinfo[0] + '">&nbsp;&nbsp;' + labels[i] + '&nbsp;&nbsp;</a></td></tr>');
			}
			arrowcount++;
		}
		document.write('</table></td></tr></table>');
		micount[mnumber[type]] = labels.length;
	}
	document.writeln('</DIV>');
	hiddens[type][mnumber[type]] = true;
	closing[type][mnumber[type]] = 0;
	mnumber[type]++;
}

function createMenu2(type,mtop,mleft,labellist,linklist)
{
	ptype = type - 1;
	ctype = type + 1;
	var labels = labellist.split('|');
	var links = linklist.split('|');

	mleft = document.getElementById('template_'+menupic[mnumber[type]]+'div').offsetLeft + pushleft[mnumber[type]];
	mtop = whichtop[mnumber[type]];

	document.write('<DIV id="menu'+type+'_'+mnumber[type]+'" style="top:'+mtop+'px; left:' + mleft + 'px; VISIBILITY:hidden; OVERFLOW:visible; POSITION:absolute; Z-INDEX:3;" onMouseOver = "displayMenu('+type+','+mnumber[type]+')" onMouseOut = "delayHide('+type+','+mnumber[type]+')">');

	if (labellist != '')
	{
		usebg = '#c5c3bd';
		document.write('<table border="0" cellpadding="0" cellspacing="1" bgcolor="#ffffff">');
		document.write('<tr><td bgcolor="#f2f2f2" style="padding-left:25px; padding-right:25px; padding-top:15px; padding-bottom:15px; background-image: url(\'https://www.expeditions.com/images/menubg.gif\'); background-repeat: repeat-x; background-position: left bottom;">');
		document.write('<table border="0" cellpadding="0" cellspacing="0">');
		document.write('<tr><td valign="top" style="padding-right:20px;"><table border="0" cellpadding="0" cellspacing="0">');

		colcheck = parseInt((labels.length + 1) / 3);
		if ((labels.length + 1) % 3 != 0)
		{
			colcheck++;
		}

		for (i=0; i<labels.length; i++)
		{
			if ((i > 0) && (i % colcheck == 0))
			{
				document.write('</table></td><td valign="top" style="padding-right:20px;"><table border="0" cellpadding="0" cellspacing="0">');
			}

			var linkinfo = links[i].split('^');
			if (linkinfo[1])
			{
				mparent[ctype][linkinfo[1]] = mnumber[type];
				if (ie || n6)
				{
					document.write('<tr><td height="20"><a class="' + (linkinfo[0].substr(linkinfo[0].length-3, 3) == '333' ? 'menu2' : 'menu1') + '" onMouseOver="displayMenu('+ctype+','+linkinfo[1]+')" onMouseOut="delayHide('+ctype+','+linkinfo[1]+')" href="'+linkinfo[0]+'">&nbsp;&nbsp;'+labels[i]+'&nbsp;&nbsp;</a></td></tr>');
				}
			}
			else
			{
				document.write('<tr><td height="20"><a id="menuitem_' + mnumber[type] + '_' + i + '" class="' + (linkinfo[0].substr(linkinfo[0].length-3, 3) == '333' ? 'menu2' : 'menu1') + '" onMouseOver="highlightMenuItem(' + mnumber[type] + ',' + i + ')" onMouseOut="unhighlightMenuItems(' + mnumber[type] + ')" href="' + linkinfo[0] + '">&nbsp;&nbsp;' + labels[i] + '&nbsp;&nbsp;</a></td></tr>');
			}
			arrowcount++;
		}
		document.write('</table></td></tr>');
		document.write('<tr><td colspan="3" align="right"><a class="itinblue" href="/Expeditions14.asp">BROWSE ALL</a></td></tr>');
		document.write('</table>');
		document.write('</td></tr>');
		document.write('</table>');
		micount[mnumber[type]] = labels.length;
	}
	document.writeln('</DIV>');
	hiddens[type][mnumber[type]] = true;
	closing[type][mnumber[type]] = 0;
	mnumber[type]++;
}

function centerMenus()
{
	for (i=0; i<mnumber[0]; i++)
	{
		mleft = document.getElementById('template_'+menupic[i]+'div').offsetLeft + pushleft[i];
		document.getElementById('menu0_'+i).style.left = mleft;
	}
}

