// multi_bucket
//List the default titles from each bucket from top to bottom.
var selectedTitles = new Array('0');
var numTitles = new Array('2');

function switchVisible(showId, hideId, active_link, inactive_link) {
	document.getElementById(hideId).style.display = "none";
	document.getElementById(showId).style.display = "block";
	document.getElementById(active_link).style.color = "#444";
	document.getElementById(inactive_link).style.color = "#666";
}

function clickMulti(bucketNum, titleNum) {
	//If this title is not already selected
	if (titleNum != selectedTitles[bucketNum]) {
		var idNewTitle = 'multibucket' + bucketNum + '_' + titleNum;
		var idNewContent = 'content' + bucketNum + '_' + titleNum;
		var idOldTitle = 'multibucket' + bucketNum + '_' + selectedTitles[bucketNum];
		var idOldContent = 'content' + bucketNum + '_' + selectedTitles[bucketNum];
		//Hide the old content and display the new
		document.getElementById(idOldContent).style.display = "none";
		document.getElementById(idNewContent).style.display = "block";
		//If this is the top title
		if (titleNum == 0) {
			//Set the new title to the over state
			document.getElementById(idNewTitle).style.backgroundImage = "url(/images/bucket_title.gif)";
			document.getElementById(idNewTitle).style.backgroundColor = "#ccc9c3";
			document.getElementById(idNewTitle).style.margin = "0 0 0 0";
			//If the old title was not the bottom title
			if (selectedTitles[bucketNum] != numTitles[bucketNum] - 1) {
				document.getElementById(idOldTitle).style.backgroundColor = "#e6e3da";
				document.getElementById(idOldTitle).style.margin = "0 1px 1px 1px";
			}
			//Else the old title was the bottom title
			else {
				document.getElementById(idOldTitle).style.backgroundImage = "url(/images/bucket_title_bot_off.gif)";
				document.getElementById(idOldTitle).style.backgroundColor = "#e6e3da";
				document.getElementById(idOldTitle).style.margin = "0 0 0 0";
			}
		}
		//If this is not the bottom title
		else if (titleNum != numTitles[bucketNum] - 1) {
			//Set the new title to the over state
			document.getElementById(idNewTitle).style.backgroundColor = "#ccc9c3";
			document.getElementById(idNewTitle).style.margin = "0 1px 0 1px";
			//If the old title is the top title
			if (selectedTitles[bucketNum] == 0) {
				document.getElementById(idOldTitle).style.backgroundImage = "url(/images/bucket_title_off.gif)";
				document.getElementById(idOldTitle).style.backgroundColor = "#e6e3da";
				document.getElementById(idOldTitle).style.margin = "0 0 1px 0";
			}
			//If the old title was not the bottom title
			else if (selectedTitles[bucketNum] != numTitles[bucketNum] - 1) {
				document.getElementById(idOldTitle).style.backgroundColor = "#e6e3da";
				document.getElementById(idOldTitle).style.margin = "0 1px 1px 1px";
			}
			//Else the old title was the bottom title
			else {
				document.getElementById(idOldTitle).style.backgroundImage = "url(/images/bucket_title_bot_off.gif)";
				document.getElementById(idOldTitle).style.backgroundColor = "#e6e3da";
				document.getElementById(idOldTitle).style.margin = "0 0 0 0";
			}
		}
		//Else this is the bottom title
		else {
			//Set the new title to the over state
			document.getElementById(idNewTitle).style.backgroundImage = "none";
			document.getElementById(idNewTitle).style.backgroundColor = "#ccc9c3";
			document.getElementById(idNewTitle).style.margin = "0 1px 0 1px";
			//If the old title is the top title
			if (selectedTitles[bucketNum] == 0) {
				document.getElementById(idOldTitle).style.backgroundImage = "url(/images/bucket_title_off.gif)";
				document.getElementById(idOldTitle).style.backgroundColor = "#e6e3da";
				document.getElementById(idOldTitle).style.margin = "0 0 1px 0";
			}
			//Else the old title was not the bottom title
			else {
				document.getElementById(idOldTitle).style.backgroundColor = "#e6e3da";
				document.getElementById(idOldTitle).style.margin = "0 1px 1px 1px";
			}
		}
	}
	selectedTitles[bucketNum] = titleNum;
}

function overMulti(bucketNum, titleNum) {
	//If this title is not already selected
	if (titleNum != selectedTitles[bucketNum]) {
		var id = 'multibucket' + bucketNum + '_' + titleNum;
		//If this is the top title
		if (titleNum == 0) {
			document.getElementById(id).style.backgroundImage = "url(/images/bucket_title_on.gif)";
			document.getElementById(id).style.backgroundColor = "#d7d5ce";
		}
		//If this is not the bottom title
		else if (titleNum != numTitles[bucketNum] - 1) {
			document.getElementById(id).style.backgroundColor = "#d7d5ce";
		}
		//Else this is the bottom title
		else {
			document.getElementById(id).style.backgroundImage = "url(/images/bucket_title_bot_on.gif)";
			document.getElementById(id).style.backgroundColor = "#d7d5ce";
		}
	}
}

function offMulti(bucketNum, titleNum) {
	//If this title is not already selected
	if (titleNum != selectedTitles[bucketNum]) {
		var id = 'multibucket' + bucketNum + '_' + titleNum;
		if (titleNum == 0) {
			document.getElementById(id).style.backgroundImage = "url(/images/bucket_title_off.gif)";
			document.getElementById(id).style.backgroundColor = "#e6e3da";
		}
		//If this is not the bottom title
		else if (titleNum != numTitles[bucketNum] - 1) {
			document.getElementById(id).style.backgroundColor = "#e6e3da";
		}
		//Else if this is the bottom title
		else {
			document.getElementById(id).style.backgroundImage = "url(/images/bucket_title_bot_off.gif)";
			document.getElementById(id).style.backgroundColor = "#e6e3da";
		}
	}
}

function displayArchiveByYear(year) {
   $(curYear).style.display = 'none';
   $(year.value).style.display = 'block';
   curYear = year.value;
}
