	// Setup
	var parentObj;
	var parentID;
	var breakSwitch = -1;
	var images = new Array();
	var images_o = new Array();
	var showoff = new Array(0, 0);

	var isIE = (navigator.userAgent.indexOf('MSIE') > -1) ? 1 : 0;
	var isIE5 = (navigator.userAgent.indexOf('MSIE 5') > -1) ? 1 : 0;
	var isIE6 = (navigator.userAgent.indexOf('MSIE 6') > -1) ? 1 : 0;
	var isMoz = (navigator.userAgent.indexOf('Gecko') > -1) ? 1 : 0;
	var isOpera = (navigator.userAgent.indexOf('Opera') > -1) ? 1 : 0;

	var mouseout = (isMoz || isIE5) ? 'onmouseout="suboff_delay();"' : 'onmouseleave="suboff();"';
	var mouseout = (isOpera) ? 'onmouseout="suboff();"' : mouseout;

	document.write('<div id="showMenu" style="visibility: hidden; position: absolute;" onmouseover="subon();" '+mouseout+'></div>');

	// Functions
	function on (obj, id, mode){
		if (document.getElementById('menuim'+id)){ document.getElementById('menuim'+id).src='images/menus/menu'+id+'_o.png'; }
		if (mode || (typeof(menus) != 'undefined' && menus[0] && menus[0][id] && menus[0][id][1])){ obj.style.cursor=(isIE5) ? 'hand' : 'pointer'; }
		if (!mode){ document.getElementById('showMenu').style.visibility='hidden'; }

		if (!mode){
			obj.className='nav_m_on';
			if (check('navbl_'+id, 'm_on_buliml')){ document.getElementById('navbl_'+id).src=m_on_buliml; }
			if (check('navbr_'+id, 'm_on_bulimr')){ document.getElementById('navbr_'+id).src=m_on_bulimr; }
		} else {
			obj.className='nav_s_on';
			if (check('navbl_'+id, 's_on_buliml')){ document.getElementById('navbl_'+id).src=s_on_buliml; }
			if (check('navbr_'+id, 's_on_bulimr')){ document.getElementById('navbr_'+id).src=s_on_bulimr; }
		}

		// Show Sumenus
		if (typeof(menus) != 'undefined' && menus[id]){
			// Create
				parentObj = obj;
				parentID = id;

				var smode = (menushift[0] >= 0) ? 'left': 'right';
				var tmode = (menushift[1] >= 0) ? 'top' : 'bottom';

				if (menumode == 1 || menumode == 2){
					if (menushift[0] < 0){ showoff[0] = menushift[0]; menushift[0] = 0; }
					if (menushift[1] < 0){ showoff[1] = menushift[1]; menushift[1] = 0; }
				} else {
					if (menushift[0] < 0){ showoff[0] = -menushift[0]; menushift[0] = 0; }
					if (menushift[1] < 0){ showoff[1] = -menushift[1]; menushift[1] = 0; }
				}

				var menuCode = '<table class="nav_s" border="0" cellpadding="0" cellspacing="0" style="margin-'+smode+': '+menushift[0]+'px; margin-'+tmode+': '+menushift[1]+'px; '+submenustyle+'">';
				for (var i=0;i<menus[id].length;i++){
					menuCode += "<tr><td>"+makesub(menus[id][i][0], menus[id][i][1], menus[id][i][2])+"</td></tr>";
				}
				menuCode += "</table>";

			// Insert
				var showMenu = document.getElementById('showMenu');
				showMenu.innerHTML = menuCode;

			// Position
				switch (menumode){
					case 1:
						showMenu.style.top = findPosY(obj)+obj.clientHeight+showoff[1];
						showMenu.style.left = findPosX(obj)+showoff[0];
						break;
					case 2:
						showMenu.style.top = findPosY(obj)+showoff[1];
						showMenu.style.left = findPosX(obj)+obj.clientWidth+showoff[0];
						break;
					case -1:
						showMenu.style.top = findPosY(obj)-showMenu.clientHeight+showoff[1];
						showMenu.style.left = findPosX(obj)+showoff[0];
						break;
					case -2:
						showMenu.style.top = findPosY(obj)+showoff[1];
						showMenu.style.left = findPosX(obj)-showMenu.clientWidth+showoff[0];
						break;
				}

				showMenu.style.visibility='visible';
				breakSwitch = -1;
		}
	}

	function off (obj, id, mode){
		if (document.getElementById('menuim'+id)){ document.getElementById('menuim'+id).src=imgurl+'/menu'+id+'.png'; }
		document.getElementById('showMenu').style.visibility='hidden';

		if (!mode){
			obj.className='nav_m';
			if (check('navbl_'+id, 'm_buliml')){ document.getElementById('navbl_'+id).src=m_buliml; }
			if (check('navbr_'+id, 'm_bulimr')){ document.getElementById('navbr_'+id).src=m_bulimr; }
		} else {
			obj.className='nav_s';
			if (check('navbl_'+id, 's_buliml')){ document.getElementById('navbl_'+id).src=s_buliml; }
			if (check('navbr_'+id, 's_bulimr')){ document.getElementById('navbr_'+id).src=s_bulimr; }
		}
	}
	
	function go (obj, id, mode){
		if (menus[0][id] && menus[0][id][1]){ location.href=menus[0][id][1]; }
		if (menus[parentID]){
			for (var i=0;i<menus[parentID].length;i++){ if (menus[parentID][i][2] == id){ location.href=menus[parentID][i][1]; } }
		}
	}
	
	function subon (){
		if (parentObj.className != 'nav_m_on'){
			parentObj.className='nav_m_on';
			if (document.getElementById('menuim'+parentID)){ document.getElementById('menuim'+parentID).src=imgurl+'/menu'+parentID+'_o.png'; }
			if (check('navbl_'+parentID, 'm_on_buliml')){ document.getElementById('navbl_'+parentID).src=m_on_buliml; }
			if (check('navbr_'+parentID, 'm_on_bulimr')){ document.getElementById('navbr_'+parentID).src=m_on_bulimr; }
		}
		breakSwitch++;
		document.getElementById('showMenu').style.visibility='visible';
	}
	
	function suboff (){
		parentObj.className='nav_m';
		if (document.getElementById('menuim'+parentID)){ document.getElementById('menuim'+parentID).src='images/menus/menu'+parentID+'.png'; }
		if (check('navbl_'+parentID, 'm_on_buliml')){ document.getElementById('navbl_'+parentID).src=m_buliml; }
		if (check('navbr_'+parentID, 'm_on_bulimr')){ document.getElementById('navbr_'+parentID).src=m_bulimr; }
		document.getElementById('showMenu').style.visibility='hidden';
	}
	
	function suboff_delay (){
		setTimeout("if (breakSwitch){ breakSwitch--; } else { suboff(); window.status=breakSwitch; }", 20);
	}
	
	function check (obj, ivar){
		eval('var type = typeof('+ivar+');');
		if (document.getElementById(obj) && type != 'undefined'){ return true; }
		else { return false; }
	}
	
	function findPosX(obj){
		var curleft = 0;
		if (obj.offsetParent){
			while (obj.offsetParent){
				curleft += obj.offsetLeft
				obj = obj.offsetParent;
			}
		}
		else if (obj.x)
			curleft += obj.x;
		return curleft;
	}

	function findPosY(obj){
		var curtop = 0;
		if (obj.offsetParent){
			while (obj.offsetParent){
				curtop += obj.offsetTop
				obj = obj.offsetParent;
			}
		}
		else if (obj.y)
			curtop += obj.y;
		return curtop;
	}

	function loadImages (){
		for (var i=0;i<menus.length;i++){
			if (menus[i]){
				for (var j=0;j<menus[i].length;j++){
					if (menus[i][j] && menus[i][j][3]){
						var id = menus[i][j][2];
						images[id] = new Image();
						images_o[id] = new Image();
						images[id].src = imgurl+'/menu'+id+'.png';
						images_o[id].src = imgurl+'/menu'+id+'_o.png';
					}
				}
			}
		}
	}

	// Functions for Forms - Menu Data come after this
		var curform = '';
		var pi = 3.1415926535897932384626433832795;
		var e = 2.71828182845904523536028747135;

		function getv (n,o){
			if (o){ return document.forms[curform].elements[n]; }
			return (parseFloat(document.forms[curform].elements[n].value) || 0);
		}
		function dosum (){
			var o = 0;
			for (var i=0;i<arguments.length;i++){
				o += arguments[i];
			}
			return o;
		}
		function doround (v, n){
			if (isNaN(v) || v == 'Infinity'){ return v; }
			v = Math.round(v*Math.pow(10,n)) / Math.pow(10,n);

			if (n > 0){
				v += ((v+'').indexOf('.') == -1) ? '.' : '';
				var a = v.split('.');
				while (a[1].length < n){ a[1] += '0'; }
				v = a.join('.');
			}
			return v;
		}
		function domod (n1, n2){
			return n1 % n2;
		}
		function dodiv (n1, n2){
			return Math.floor(n1 / n2);
		}
		function dolookup (){
			var args = arguments;
			var indx = args[0];
		
			for (var i=1;i<args.length;i++){
				if (args[i].length == 2 && indx == args[i][0]){ return args[i][1]; }
				if (args[i].length == 3){
					var x = args[i][0];
					var y = args[i][1];
					if (indx >= Math.min(x, y) && indx < Math.max(x, y)){ return args[i][2]; }
				}
			}
			return indx;
		}
		function dofieldvals (){
			var args = arguments;
			var field = args[0];
			var result = 0;
			if (!field || field == 1) return;

			if (field.tagName && field.tagName == 'SELECT'){
				return args[field.selectedIndex+1];
			} else if ((!field.type && field[0].type == 'checkbox') || field.type == 'checkbox'){
				for (var i=0;i<field.length;i++){
					if (field[i] && field[i].checked) result += args[i+1];
				}
			}
			return result;
		}

	// Menus
	var menus = [];


	menus[0] = new Array();
	menus[0][1] = ['MTS', '/index.html', 1, 0];
	menus[0][2] = ['Melanesian Tours', '/index.html', 2, 0];
	menus[0][3] = ['Book Online', 'http://www.mtspng.com/scripts/mts.booking/booking.pl', 3, 0];
	menus[0][4] = ['Madang Resort', 'http://www.mtspng.com/scripts/mts.booking/booking.pl', 4, 0];
	menus[0][5] = ['Expeditions', '', 5, 0];
	menus[0][6] = ['Kalibobo Spirit', 'http://www.kalibobospirit.com', 6, 0];
	menus[0][7] = ['Resorts', '', 7, 0];
	menus[0][8] = ['Madang Resort', 'http://www.madangresort.com', 8, 0];
	menus[0][9] = ['Kalibobo Village', 'http://www.kalibobovillage.com', 9, 0];
	menus[0][10] = ['Diving', '', 10, 0];
	menus[0][11] = ['Nuigini Diving', 'http://www.niuginidive.com', 11, 0];
	menus[0][12] = ['Places to visit', '/index10.html', 12, 0];
	menus[0][13] = ['Places to Visit', '/index28.html', 13, 0];
	menus[0][14] = ['Specials', '', 14, 0];
	menus[0][15] = ['Packages', '/index27.html', 15, 0];
	menus[0][16] = ['Cruises', '/index29.html', 16, 0];
	menus[0][17] = ['Shipping Agent', '', 17, 0];
	menus[0][18] = ['Port Information', '/index31.html', 18, 0];
	menus[0][19] = ['Rates', '/index32.html', 19, 0];
	menus[0][20] = ['Melanesian Foundation', 'http://www.foundation.mtspng.com', 20, 0];
	menus[0][21] = ['Foundation', 'http://www.foundation.mtspng.com', 21, 0];
	menus[0][22] = ['Contact MTS', '', 22, 0];
	menus[0][23] = ['Contact Details', '/index21.html', 23, 0];

	loadImages();
