var menu = new Array();
	menu[0] = new Array();
	menu[0]['id'] = 'about';
	menu[0]['vis'] = false;
	menu[0]['h'] = 0;
	menu[0]['nav'] = 'aboutnav';
	menu[0]['transit'] = false;
	menu[0]['tmp'] = 0;
	menu[0]['curr'] = 0;
	menu[0]['timer'] = '';
	menu[0]['class'] = '';
	menu[0]['act'] = false;
	menu[1] = new Array();
	menu[1]['id'] = 'modernism';
	menu[1]['vis'] = false;
	menu[1]['h'] = 0
	menu[1]['nav'] = 'modernismnav';
	menu[1]['transit'] = false;
	menu[1]['tmp'] = 0;
	menu[1]['timer'] = '';
	menu[1]['curr'] = 0;
	menu[1]['class'] = '';
	menu[1]['act'] = false;
	menu[2] = new Array();
	menu[2]['id'] = 'preservation';
	menu[2]['vis'] = false;
	menu[2]['h'] = 0;
	menu[2]['nav'] = 'preservationnav';
	menu[2]['transit'] = false;
	menu[2]['tmp'] = 0;
	menu[2]['timer'] = '';
	menu[2]['curr'] = 0;
	menu[2]['class'] = '';
	menu[2]['act'] = false;

var loaded = false;
var transit = false;
var closeTimer = '';
var currentMain = '';
var currentSub = '';

home_on = new Image();
home_on.src = 'images/nav/btn_home_on.gif';
home_off = new Image();
home_off.src = 'images/nav/btn_home_off.gif';
about_on = new Image();
about_on.src = 'images/nav/btn_about_on.gif';
about_off = new Image();
about_off.src = 'images/nav/btn_about_off.gif';
about_ex = new Image();
about_ex.src = 'images/nav/btn_about_ex.gif';
news_on = new Image();
news_on.src = 'images/nav/btn_news_on.gif';
news_off = new Image();
news_off.src = 'images/nav/btn_news_off.gif';
contact_on = new Image();
contact_on.src = 'images/nav/btn_contact_on.gif';
contact_off = new Image();
contact_off.src = 'images/nav/btn_contact_off.gif';
contact2_on = new Image();
contact2_on.src = 'images/nav/btn_contact2_on.gif';
contact2_off = new Image();
contact2_off.src = 'images/nav/btn_contact2_off.gif';
donate_on = new Image();
donate_on.src = 'images/nav/btn_donate_on.gif';
donate_off = new Image();
donate_off.src = 'images/nav/btn_donate_off.gif';
donate2_on = new Image();
donate2_on.src = 'images/nav/btn_donate2_on.gif';
donate2_off = new Image();
donate2_off.src = 'images/nav/btn_donate2_off.gif';
board_on = new Image();
board_on.src = 'images/nav/btn_board_on.gif';
board_off = new Image();
board_off.src = 'images/nav/btn_board_off.gif';
friends_on = new Image();
friends_on.src = 'images/nav/btn_friends_on.gif';
friends_off = new Image();
friends_off.src = 'images/nav/btn_friends_off.gif';
events_on = new Image();
events_on.src = 'images/nav/btn_events_on.gif';
events_off = new Image();
events_off.src = 'images/nav/btn_events_off.gif';
modernism_on = new Image();
modernism_on.src = 'images/nav/btn_modernism_on.gif';
modernism_off = new Image();
modernism_off.src = 'images/nav/btn_modernism_off.gif';
modernism_ex = new Image();
modernism_ex.src = 'images/nav/btn_modernism_ex.gif';
architects_on = new Image();
architects_on.src = 'images/nav/btn_architects_on.gif';
architects_off = new Image();
architects_off.src = 'images/nav/btn_architects_off.gif';
styles_on = new Image();
styles_on.src = 'images/nav/btn_styles_on.gif';
styles_off = new Image();
styles_off.src = 'images/nav/btn_styles_off.gif';
neighborhoods_on = new Image();
neighborhoods_on.src = 'images/nav/btn_neighborhoods_on.gif';
neighborhoods_off = new Image();
neighborhoods_off.src = 'images/nav/btn_neighborhoods_off.gif';
preservation_on = new Image();
preservation_on.src = 'images/nav/btn_preservation_on.gif';
preservation_off = new Image();
preservation_off.src = 'images/nav/btn_preservation_off.gif';
preservation_ex = new Image();
preservation_ex.src = 'images/nav/btn_preservation_ex.gif';
endangered_on = new Image();
endangered_on.src = 'images/nav/btn_endangered_on.gif';
endangered_off = new Image();
endangered_off.src = 'images/nav/btn_endangered_off.gif';
landmarks_on = new Image();
landmarks_on.src = 'images/nav/btn_landmarks_on.gif';
landmarks_off = new Image();
landmarks_off.src = 'images/nav/btn_landmarks_off.gif';
historic_on = new Image();
historic_on.src = 'images/nav/btn_historic_on.gif';
historic_off = new Image();
historic_off.src = 'images/nav/btn_historic_off.gif';
resources_on = new Image();
resources_on.src = 'images/nav/btn_resources_on.gif';
resources_off = new Image();
resources_off.src = 'images/nav/btn_resources_off.gif';
mailinglist2_off = new Image();
mailinglist2_off.src = 'images/nav/mailinglist_off.gif';
mailinglist2_on = new Image();
mailinglist2_on.src = 'images/nav/mailinglist_on.gif';

function init(section, subsection) {
	if (section && (!subsection || subsection =='') && !hasSub(section)) {
		currentMain = section;
		document.getElementById(section).onmouseover = null;
		document.getElementById(section).onmouseover = clearTimer;
		document.getElementById(section).onmouseout = null;
		document.getElementById(section).onmouseout = startTimer;
		document.getElementById(section).className = '';
		document.getElementById(section).className = 'active';
		document.getElementById(section).style.background = 'url(images/nav/btn_'+section+'_on.gif)';
	}
	for (i=0;i<menu.length;i++) {
		nodes = document.getElementById(menu[i]['nav']).getElementsByTagName('a');
		document.getElementById(menu[i]['nav']).style.height = 0 +'px';
		document.getElementById(menu[i]['nav']).style.overflow = 'hidden';
		loaded = true;
		for (j=0;j<nodes.length;j++) {
			menu[i]['h'] += 15;
		}
		if (menu[i]['id'] == section && (!subsection || subsection == '')) {
			menu[i]['act'] = true;
			currentMain = section;
			document.getElementById(section).onmouseover = null;
			document.getElementById(section).onmouseover = clearTimer;
			document.getElementById(section).onmouseout = null;
			document.getElementById(section).onmouseout = startTimer;
			document.getElementById(section).className = '';
			document.getElementById(section).className = 'active';
			document.getElementById(section).style.background = 'url(images/nav/btn_'+section+'_on.gif)';
			openNode(section);
		}
		else if (menu[i]['id'] == section && subsection) {
			menu[i]['act'] = true;
			currentMain = section;
			currentSub = subsection;
			document.getElementById(subsection).onmouseover = null;
			document.getElementById(subsection).onmouseover = clearTimer;
			document.getElementById(subsection).onmouseout = null;
			document.getElementById(subsection).onmouseout = startTimer;
			document.getElementById(subsection).className = '';
			document.getElementById(subsection).className = 'active';
			document.getElementById(section).onmouseover = null;
			document.getElementById(section).onmouseover = function() { document.getElementById(currentMain).style.background = 'url('+eval(currentMain +'_on.src')+')'; clearTimer(); }
			document.getElementById(section).onmouseout = null;
			document.getElementById(section).onmouseout = function() { document.getElementById(currentMain).style.background = 'url('+eval(currentMain +'_ex.src')+')'; document.getElementById(section).className = 'expanded'; startTimer(); }
			document.getElementById(section).className = '';
			document.getElementById(section).className = 'expanded';
			document.getElementById(section).style.background = 'url(images/nav/btn_'+section+'_ex.gif)';
			openNode(section);
		}
	}
}

function getIndex(section) {
	for (i=0;i<menu.length;i++) {
		if (menu[i]['id'] == section || menu[i]['nav'] == section) {
			return i;
			break;
		}
	}
	return false;
}

function hasSub(section) {
	for (i=0;i<menu.length;i++) {
		if (menu[i]['id'] == section) {
			return menu[i]['nav'];
			break;
		}
	}
	return false;
}

function openNode(node) {
	if (loaded) {
		nodeIndex = getIndex(node);
		menu[nodeIndex]['transit'] = true;
		menu[nodeIndex]['curr'] = parseInt(document.getElementById(menu[nodeIndex]['nav']).style.height);
		menu[nodeIndex]['tmp'] = menu[nodeIndex]['curr'] + 6;
		menu[nodeIndex]['class'] = 'expanded';
		if (menu[nodeIndex]['tmp'] < menu[nodeIndex]['h']) {
			document.getElementById(menu[nodeIndex]['nav']).style.height = menu[nodeIndex]['tmp'] +'px';
			document.getElementById(menu[nodeIndex]['nav']).style.display = 'block';
			menu[nodeIndex]['timer'] = window.setTimeout("openNode('"+node+"');", 10);
		}
		else if (menu[nodeIndex]['tmp'] >= menu[nodeIndex]['h']) {
			document.getElementById(menu[nodeIndex]['nav']).style.height = menu[nodeIndex]['h'] +'px';
			menu[nodeIndex]['vis'] = true;
			menu[nodeIndex]['transit'] = false;
			window.clearTimeout(menu[nodeIndex]['timer']);
		}
	}
}


function closeNode(node) {
	if (loaded) {
		nodeIndex = getIndex(node);
		menu[nodeIndex]['transit'] = true;
		window.clearTimeout(menu[nodeIndex]['timer']);
		menu[nodeIndex]['curr'] = parseInt(document.getElementById(menu[nodeIndex]['nav']).style.height);
		menu[nodeIndex]['tmp'] = menu[nodeIndex]['curr'] - 6;
		menu[nodeIndex]['class'] = '';
		if (menu[nodeIndex]['tmp'] > 0) {
			document.getElementById(menu[nodeIndex]['nav']).style.height = menu[nodeIndex]['tmp'] +'px';
			menu[nodeIndex]['timer'] = window.setTimeout("closeNode('"+node+"');", 10);
		}
		else if (menu[nodeIndex]['tmp'] <= 0) {
			document.getElementById(menu[nodeIndex]['nav']).style.height = 0 +'px';
			document.getElementById(menu[nodeIndex]['nav']).style.display = 'none';
			menu[nodeIndex]['vis'] = false;
			menu[nodeIndex]['transit'] = false;
			window.clearTimeout(menu[nodeIndex]['timer']);
		}
		pseudoClass(document.getElementById(menu[nodeIndex]['id']), '');
	}
}

function hover(obj, state) {
	itemIndex = getIndex(obj.id);
	if (loaded && state == 'on' && obj.id != currentSub) {
		window.clearTimeout(closeTimer);
		pseudoClass(obj, 'active');
		if (hasSub(obj.id)) {
			openNode(obj.id);
		}
	}
	else if (loaded && state == 'off') {
		if (hasSub(obj.id)) {
			nodeIndex = getIndex(obj.id);
			// document.getElementById(obj.id).setAttribute('class', menu[nodeIndex]['class']);
			pseudoClass(obj, menu[nodeIndex]['class']);
		}
		else {
			// document.getElementById(obj.id).setAttribute('class', '');
			if (obj.id != currentSub) {
				pseudoClass(obj, '');
			}
		}
		closeTimer = window.setTimeout("closeAll();", 2500);
	}
}

function pseudoClass(obj, nclass) {
	if (nclass == 'active') {
		obj.style.background = 'url('+ eval(obj.id +'_on.src') +')';
	}
	else if (nclass == 'expanded') {
		obj.style.background = 'url('+ eval(obj.id +'_ex.src') +')';
	}
	else {
		obj.style.background = 'url('+ eval(obj.id +'_off.src') +')';
	}
}

function closeAll() {
	if (loaded) {
		for (i=0;i<menu.length;i++) {
			if (menu[i]['vis'] && !menu[i]['act']) {
				window.clearTimeout(menu[i]['timer']);
				closeNode(menu[i]['id']);
			}
		}
	}
}

function startTimer() {
	closeTimer = window.setTimeout("closeAll();", 2500);
}

function clearTimer() {
	window.clearTimeout(closeTimer);
}

function turnOn(obj) {
	obj.firstChild.src = eval(obj.id +'_on.src');
}

function turnOff(obj) {
	obj.firstChild.src = eval(obj.id +'_off.src');
}

function newWindow(href, w, h) { // usage: <a href="mypage.html" onclick="return newWindow(this.href, 640, 480);">
	docoPopup = window.open(href, 'docoPopup', 'width='+w+', height='+h+', menubar=no, status=no, resizable=yes, toolbar=no');
	return false;
}

function mailingList(obj) {
//	alert(obj.href);
	mlistPop = window.open(obj.href, 'mlistpop', 'width=550,height=252,menubar=no,status=no,resizable=yes,toolbar=no');
	return false;
}
