	
		
function debug(aMsg) {
	setTimeout(function() { throw new Error("[debug] " + aMsg); }, 0);
}

//function that creates hidden spans (with index numbers) containing submenu items, which can then be revealed on an event
function makeSubMenu() {	
	
	//create array for sumenu lists
	var ULArray = new Array();
			
	//fill array primaryLinks with main menu items - these will keep index for the submenu items
	var primaryLinks = document.getElementById("menu").getElementsByTagName("ul");							
	//for every main menu item
	for (var i = 0; i < primaryLinks.length; i++) {
		
		//debug(document.getElementById("menu").getElementsByTagName("div")[i].getElementsByTagName("a")[0]);
		//create a hidden span with a number that matches the main menu index
		document.write("<span id='subLinks" + i + "' style='display: none;'>");
		
		//submenu list heading from main link innerHTML
		document.write("<h2>" + document.getElementById("menu").getElementsByTagName("div")[i].getElementsByTagName("a")[0].innerHTML + "</h2>");
		
		//fill the span with the contents of the submenu list items, that match the main menu indices
		for (var j = 0; j < primaryLinks[i].getElementsByTagName("li").length; j++) {
			ULArray[i] = primaryLinks[i].getElementsByTagName("li")[j].innerHTML;
			//window.alert("works here");
			document.write(ULArray[i]);
		}
		//close hidden span
		document.write("</span>");
	}
	
}

//initialise the variable that holds the value of the last submenu list shown
var previousMenu = "";
var previousLinks = "";
//function that shows the submenu list span that corresponds to the main menu item that has been mousedOver
function showSubLinks(primaryLink) {
	//if the ID of the previously displayed span exists, then hide it
	if (previousLinks) {
		document.getElementById(previousLinks).style.display = "none";		
		//debug("previousLinks: " + previousLinks + " currentlinks is: " + subLinksId);	
	}	

	if (previousMenu) {
  	previousMenu.style.color = "#FFFFFF";
  }
	primaryLink.style.color = "#880000";
	//get id name of main menu item
	idString = primaryLink.id;
	//get number on end of main menu item ID
	idNum = idString.substring(8, 9);	
	//store number in string variable, prefix with "subLinks"
	subLinksId = "subLinks" + idNum;	
	
	//display the span using the substring generated ID
	document.getElementById(subLinksId).style.display = "block";
		
	//debug("DEBUG: " + document.getElementById(subLinksId).style.display);
	
	//on main menu item mousOut store the value of the last displayed span, 
	//so it can be hidden on the mousOver of the next link
/*	primaryLink.onmouseout = function() {			
		previousMenu = primaryLink;
		previousLinks = subLinksId;		
	} */
		previousMenu = primaryLink;
		previousLinks = subLinksId;		
	
}


//initialise interval that causes scroll to continue on mousedown
var scrollInterval = 0;
//function that facilitates scrolling via JS call on link
function scrollArea(scrollElement, scrollSpeed, buttonElement) {

	//scroll action
	function scrollAction() {
		//debug(scrollElement.scrollTop + " " + scrollSpeed);
		scrollElement.scrollTop += scrollSpeed;
	}
	
	//causes scroll action to recur until user releases mouse button
	scrollInterval = setInterval(scrollAction, 50, [scrollElement, scrollSpeed]);	

	//when user releases mouse button, clear interval stoping the scroll action
	buttonElement.onmouseup = function(scrollinterval) {
		//window.alert("mouseup");
		clearInterval(scrollInterval);
	}
	
}

function subLinkInit(targetLink, linkItem) {
  targetLink.getElementsByTagName("a")[linkItem].style.color = "#880000"; 
}


//this hides submenu items from javascript enabled browsers, so they only show on mouseover of the main links
//when browser has JS off, the submenu links will come up under the main menu items. 
//relatively graceful degradation. 
document.write("	<style><!--	#menu ul {display: none;} #artists {overflow: hidden; }  --></style>");
	
