
var openMenuEle = '';
var openMenuParent = ''

function toggleMenu(elementId, parentId) {

	// if there are no menus open
	if(openMenuEle == ''){

		// open one
		document.getElementById(elementId).style.display = 'block';

		// swap the arrow image
		document.getElementById(parentId).className = 'parent_open';

		// store the new name
		openMenuEle = elementId;
		openMenuParent = parentId;

	} else {

		// if we have clicked on the one thats already open
		if(openMenuEle == elementId){

			// so hide it
			var thatEle = document.getElementById(openMenuEle);
			thatEle.style.display = 'none';

			// swap the arrow image
			document.getElementById(openMenuParent).className = 'parent_closed';

			// and now there are no menus open
			openMenuEle = '';
			openMenuParent = '';

		} else {
		// we have clicked on a new menu

			// hide the current one
			document.getElementById(openMenuEle).style.display = 'none';

			// show the new one
			document.getElementById(elementId).style.display = 'block';

			// swap the old arrow image
			document.getElementById(openMenuParent).className = 'parent_closed';

			// swap the new arrow image
			document.getElementById(parentId).className = 'parent_open';

			// store the new name
			openMenuEle = elementId;
			openMenuParent = parentId;

		}

	}

}

function init() {
	// toggleMenu('menu_3', 'parent_3');
}
window.onload = init;
