document.observe('dom:loaded', function() {
	Loading.show();
	
	var buttons = new Array( 'btnHome', 'btnBuy', 'btnSell',
									'btnUpcoming', 'btnContact');
	var loadScripts = new Array(
		function(){makeScriptReady(buttons)},
		loadBuyingLinks,
		loadSellingLinks,
		loadUpcomingLinks
	);
	while(loadScripts.length>0) {
		loadScripts.shift()();	
	}
	isLoaded();
});

showPage = new function() {
	var views = new Array('home', 'buy', 'sell', 'upcoming', 'contact');
	function displayPage(ev) {
		//use button name to determine page name
		var el = Event.element(ev);
		var page = el.id.substr(3,1).toLowerCase()+el.id.substr(4);
		//hide all pages except requested
		for (var i=0; i<views.length; i++) {
			document.getElementById(views[i]).style.display = "none";	
		}
		//show requested page
		$(page).style.display = "block";
	}
	return displayPage;  //create closure to reuse array
}

loadUpcomingLinks = new loadLinks('xml/upcomingLinks.xml', 'upcomingLinks');
loadBuyingLinks = new loadLinks('xml/buyingLinks.xml', 'buyingLinks');
loadSellingLinks = new loadLinks('xml/sellingLinks.xml', 'sellingLinks');
