// Applications JS

// Handles states and UI elements for the navigation and content layers
// Master Delegate Method
function showBox(id) {
	$('box-wrapper').show();
	// alert("id is " + id);
	getBoxContent(id)
	positionPointer(id);
}

// shows the pointer next to the correct menu item
function positionPointer(id) {
	$('box-pointer').style.display = "block";
	switch(id)
	{
		case "gigs":
			$('box-pointer').style.top = "230px";
		break
		case "images":
			$('box-pointer').style.top = "304px";
		break
		case "headlines":
			$('box-pointer').style.top = "380px";
		break
		case "mixes":
			$('box-pointer').style.top = "460px";
		break
		case "releases":
			$('box-pointer').style.top = "540px";
		break
		case "videos":
			$('box-pointer').style.top = "616px";
		break
	}
}

// make ajax call to retrieve box content
function getBoxContent(contentId) {
	// console.log("submitting request");
	new Ajax.Request(
		('/' + contentId + "?format=js&api_key=toddlat-FeNZLcN7evKN7SKsWugNXyW"),
		{ asynchronous: true, 
			evalScripts: true,
			method: 'get',
			onLoading: function(request){
				toggleLoader()
			},
			onComplete: function(request){
				toggleLoader()
			}
		});
}

// UI handlers
function toggleLoader() { Toggle.display('loader') }

function resetBoxes() {
	$('box-wrapper').hide();
	$('box-pointer').hide();
}

function setupPage() {
	$('box-wrapper').hide();
	$('box-pointer').hide();
	$('loader').hide();
}