$.ajaxSetup ({
    cache: false
});

$(function() {
	loadDocuments(0);
	$("a.new-window").attr("target", "_blank");
});

normalCoords = new Array(0, -33, -58, -83, -108, -133, -158, -183, -208, -233);
overCoords   = new Array(-266, -299, -324, -349, -374, -399, -424, -449, -474, -499);
activeCoords = new Array(-532, -565, -590, -615, -640, -665, -690, -715, -740, -765);
activeMenu   = -1;

function loadDocuments(id) {
	// Restore all backgrounds to defaults and highlight the selected
	restoreBackgrounds();
	showActiveState(id);
	
	// Load the requested document
	$("#ajax").load("documents.html #d" + id);
	return false;
}

function restoreBackgrounds() {
	var bgLength = normalCoords.length;

	for (var i = 0; i < bgLength; i ++) {
		$("#m" + i).css("background-position", "0 " + normalCoords[i] + "px");
	}
}

function showOverState(id) {
	if (id != activeMenu) {
		$("#m" + id).css("background-position", "0 " + overCoords[id] + "px");
	}
}

function showNormalState(id) {
	if (id != activeMenu) {
		$("#m" + id).css("background-position", "0 " + normalCoords[id] + "px");
	}
}

function showActiveState(id) {
	$("#m" + id).css("background-position", "0 " + activeCoords[id] + "px");
	activeMenu = id;
}
