var submenu    = new Array();
var lastActive = 99;
var menuobj;
		
submenu[0] = '<a href="/accommodation-newzealand/hotels-new-zealand.php" style="margin-right:20px;">Hotels</a> <a href="/accommodation-newzealand/new-zealand-motel.php" style="margin-right:20px;">Motels (Self-Contained)</a> <a href="/accommodation-newzealand/new-zealand-bed-breakfast.php" style="margin-right:20px;">Bed &amp; Breakfast</a> <a href="/accommodation-newzealand/new-zealand-camping-grounds.php" style="margin-right:20px;">Holiday Parks</a> <a href="/accommodation-newzealand/backpackers-new-zealand.php" style="margin-right:20px;">Backpackers</a> <a href="/accommodation-newzealand/new-zealand-deluxe-accommodation.php" style="margin-right:20px;">Deluxe Accommodation</a> <a href="/accommodation-newzealand/new-zealand-apartments.php" style="margin-right:20px;">Apartments</a> <a href="/accommodation-newzealand/new-zealand-baches-holiday-homes.php">Baches &amp; Holiday Homes</a>';
submenu[1] = '<a href="/what-to-see-newzealand/activities.php" style="margin-right:20px;">Activities/Adventure</a> <a href="/what-to-see-newzealand/attractions.php" style="margin-right:20px;">Attractions</a> <a href="/what-to-see-newzealand/arts_crafts.php" style="margin-right:20px;">Arts &amp; Crafts</a> <a href="/what-to-see-newzealand/dining.php" style="margin-right:20px;">Dining</a> <a href="/what-to-see-newzealand/events.php" style="margin-right:20px;">Events</a> <a href="/what-to-see-newzealand/nightlife.php" style="margin-right:20px;">Nightlife</a> <a href="/what-to-see-newzealand/shopping.php" style="margin-right:20px;">Shopping</a> <a href="/what-to-see-newzealand/tours.php" style="margin-right:20px;">Tours</a> <a href="/what-to-see-newzealand/information.php">Information &amp; Services</a>';
submenu[2] = '<a href="/transport-and-rentals-newzealand/land.php" style="margin-right:20px;margin-left:372px;">Land</a> <a href="/transport-and-rentals-newzealand/water.php" style="margin-right:20px;">Water</a> <a href="/transport-and-rentals-newzealand/air.php">Air</a>';
submenu[3] = '<a href="/about-newzealand/editorial.php?pagename=adventure" style="margin-right:20px;">Adventure</a> <a href="/about-newzealand/editorial.php?pagename=farming" style="margin-right:20px;">Farming</a> <a href="/about-newzealand/editorial.php?pagename=fishing" style="margin-right:20px;">Fishing</a> <a href="/about-newzealand/editorial.php?pagename=food" style="margin-right:20px;">Food &amp; Wine</a> <a href="/about-newzealand/editorial.php?pagename=history" style="margin-right:20px;">History &amp; Culture</a> <a href="/about-newzealand/editorial.php?pagename=regional-information" style="margin-right:20px;">Regional Information</a> <a href="/about-newzealand/editorial.php?pagename=sport" style="margin-right:20px;">Sport</a> <a href="/about-newzealand/editorial.php?pagename=transport" style="margin-right:20px;">Transport</a> <a href="/about-newzealand/editorial.php?pagename=visitorinfo" style="margin-right:20px;">Traveller Information</a> <a href="/about-newzealand/">more...</a>';
submenu[4] = '';
submenu[5] = '';
submenu[6] = '';
submenu[7] = '<a href="http://www.aa.co.nz" target="_blank" style="margin-right:20px;margin-left:496px;color:#000;">aa.co.nz</a> <a href="http://www.aa.co.nz/membership/" target="_blank" style="margin-right:20px;color:#000;">Membership</a> <a href="http://www.aa.co.nz/motoring/" target="_blank" style="margin-right:20px;color:#000;">Motoring</a> <a href="http://www.aa.co.nz/insurance/" target="_blank" style="margin-right:20px;color:#000;">Insurance</a> <a style="margin-right:20px;color:#000;" target="_blank" href="http://www.aa.co.nz/finance/">Finance</a>  <a href="https://www.ctisales.co.nz/login.aspx?ID=113463&User=WEBAA" target="_blank" style="color:#000;">Travel Insurance</a>';

//submenu[10] = '<a href="#">Home</a> &gt; <a href="#">Accommodation</a>';
submenu[10] = '';

function initTopNav() {
	
	menuobj = document.getElementById("navCrumb");
	
}

function showit(which) {
	var thecontent = (which == -1) ? submenu[10] : submenu[which];
	
	menuobj.innerHTML = thecontent;
	
	if (lastActive != 99) {
	
		if (lastActive == 0) {
		
			document.getElementById("topnavAcc").style.backgroundPosition = "0px 0%";
		
		} else if (lastActive == 1) {
		
			document.getElementById("topnavWTSD").style.backgroundPosition = "0px 0%";
		
		} else if (lastActive == 2) {
		
			document.getElementById("topnavDrive").style.backgroundPosition = "0px 0%";
		
		} else if (lastActive == 3) {
		
			document.getElementById("topnavAbout").style.backgroundPosition = "0px 0%";
		
		} else if (lastActive == 4) {
		
			document.getElementById("topnavHome").style.backgroundPosition = "0px 0%";
		
		} else if (lastActive == 5) {
		
			document.getElementById("topnavDeals").style.backgroundPosition = "0px 0%";
		
		} else if (lastActive == 6) {
		
			document.getElementById("topnavMaps").style.backgroundPosition = "0px 0%";
		
		} else if (lastActive == 7) {
		
			document.getElementById("topnavServices").style.backgroundPosition = "0px 0%";
		
		}

		lastActive = 99;
	
	}

	if (which != -1) lastActive = which;
	
	if (which == 0) {
	
		menuobj.style.backgroundPosition = "0px -92px";
		document.getElementById("topnavAcc").style.backgroundPosition = "-134px 0%";
		
	} else if (which == 1) {
	
		menuobj.style.backgroundPosition = "0px -69px";
		document.getElementById("topnavWTSD").style.backgroundPosition = "-140px 0%";
	
	} else if (which == 2) {
	
		menuobj.style.backgroundPosition = "0px -46px";
		document.getElementById("topnavDrive").style.backgroundPosition = "-155px 0%";
		
	} else if (which == 3) {
	
		menuobj.style.backgroundPosition = "0px 0px";
		document.getElementById("topnavAbout").style.backgroundPosition = "-118px 0%";
		
	} else if (which == 4) {
	
		menuobj.style.backgroundPosition = "0px -23px";
		document.getElementById("topnavHome").style.backgroundPosition = "-91px 0%";
		
	} else if (which == 5) {
	
		menuobj.style.backgroundPosition = "0px -23px";
		document.getElementById("topnavDeals").style.backgroundPosition = "-112px 0%";
		
	} else if (which == 6) {
	
		menuobj.style.backgroundPosition = "0px -23px";
		document.getElementById("topnavMaps").style.backgroundPosition = "-95px 0%";
		
	} else if (which == 7) {
	
		menuobj.style.backgroundPosition = "0px -23px";
		document.getElementById("topnavServices").style.backgroundPosition = "-106px 0%";
	
	} else if (which == -1) {
	
		menuobj.style.backgroundPosition = "0px -115px";
	
	}
	
}

function resetit(e) { showit(-1) }

function contains_ns6(a, b) {
	while (b.parentNode)
	if ((b = b.parentNode) == a)
	return true;
	return false;
}

function attachKeyEvents() {
	
	var el = document.getElementById(txtCityId);
	
	if (el.addEventListener) {
		
		el.addEventListener ("keydown",processKeyDown,false);
		el.addEventListener ("keyup",processKeyUp,false);
		
	} else if (el.attachEvent) {
		
		el.attachEvent ("onkeydown",processKeyDown);
		el.attachEvent ("onkeyup",processKeyUp);
		
	} else {
		
		el.onkeydown = processKeyDown;
		el.onkeyup = processKeyUp;
		
	}
	
}

function setMultipleValues4(y, m, d) {
	
	document.searchaccom.checkinYear.value = y;
	document.searchaccom.checkinMonth.selectedIndex = m;
	
	for (var i=0; i<document.searchaccom.checkinDate.options.length; i++) {
		
		if (document.searchaccom.checkinDate.options[i].value == d) document.searchaccom.checkinDate.selectedIndex = i;
		
	}
	
}

function setMultipleValues5(y, m, d) {
	
	document.searchaccom.toYear.value = y;
	document.searchaccom.toMonth.selectedIndex = m;
	
	for (var i=0; i<document.searchaccom.toDate.options.length; i++) {
		
		if (document.searchaccom.toDate.options[i].value == d) document.searchaccom.toDate.selectedIndex = i;
		
	}
	
}

function getDateString(y_obj, m_obj, d_obj) {
	
	var y = y_obj.options[y_obj.selectedIndex].value;
	var m = m_obj.options[m_obj.selectedIndex].value;
	var d = d_obj.options[d_obj.selectedIndex].value;
	
	if (y == "" || m == "") return null;
	if (d == "") d = 1;
	
	return str = y + '-' + m + '-' + d;
	
}
