function toggleDisplayAllSubcategories(action) {
	if (action == "open") {
		document.getElementById("blank_of_the_day").style.display = "block";
		document.getElementById("car").style.display = "block";
		document.getElementById("food").style.display = "block";
		document.getElementById("geek").style.display = "block";
		document.getElementById("goalie").style.display = "block";
		document.getElementById("hockey").style.display = "block";
		document.getElementById("motorcycle").style.display = "block";
	} else {
		document.getElementById("blank_of_the_day").style.display = "none";
		document.getElementById("car").style.display = "none";
		document.getElementById("food").style.display = "none";
		document.getElementById("geek").style.display = "none";
		document.getElementById("goalie").style.display = "none";
		document.getElementById("hockey").style.display = "none";
		document.getElementById("motorcycle").style.display = "none";
	}
}

/**
 * Toggles CSS display property of an element between none and block.
 * 
 * @param elementID The ID of the element to toggle.
 */
function toggleDisplay(elementID) {
	currentDisplay = document.getElementById(elementID).style.display;
	if (currentDisplay == "none") {
		document.getElementById(elementID).style.display = "block";
	} else {
		document.getElementById(elementID).style.display = "none";
	}
}

/**
 * Opens specified file in a new window.
 * 
 * Called from blog content files.
 * 
 * Carryover function from version 1.0.
 * 
 * @param file       File (image or page) to open.
 * @param window     Window name.
 * @param attributes JavaScript attributes for opening a new window.
 */
function newWindow(file,window,attributes) {
	msgWindow=open(file,window,attributes);
}

/**
 * Checks to make sure selected archive date is within NutzO! existence limits
 * and loads selected archive into the content frame.
 * 
 * Called from blog sidebar.
 * 
 * @param startYear  	Earliest archive year.
 * @param startMonth 	Earliest month of earliest archive year.
 */
function loadArchive(startYear, startMonth) {
	year = document.archiveForm.archiveYear.value;
	month = document.archiveForm.archiveMonth.value;
	today = new Date();
	currentYear = today.getFullYear();
	currentMonth = today.getMonth() + 1;
	if (year == startYear && month < startMonth) {
		month = startMonth;
		document.archiveForm.archiveMonth.value = month;
	}
	if (year == currentYear && month > currentMonth) {
		if (currentMonth < 10) {
			currentMonth = "0" + currentMonth;
		}
		month = currentMonth;
		document.archiveForm.archiveMonth.value = month;
	}
	archiveFile = "http://www.soopahviv.net/blog/archives/" + year + "/" + month + "/index.php";
	document.location = archiveFile;
}

/**
 * Sets all links in document to open in a new browser window via target="_blank".
 * Does not set target if already specified in html tag.
 * Ignores aim and e-mail links.
 * 
 * Called via onload in <body> tag from sidebars.
 */
function targetLinksToBlank() {
	for (var i=0; i<=(document.links.length-1); i++) {
		if ((document.links[i].href.substring(0,3) != "aim") &&
			(document.links[i].href.substring(0,6) != "mailto") &&
			(document.links[i].target.length == 0)) {
			document.links[i].target = "_blank";
		}
	}
}

/**
 * Sets all links in document to open over current page.
 * 
 * Called from blog content files.
 */
function targetLinksToTop() {
	for (var i=0; i<=(document.links.length-1); i++) {
		document.links[i].target = "_top";
	}
}

/**
 * Adds text onto end of form element value.
 * Form element can be text box or textarea.
 * 
 * @param formElement	The form element to add onto.
 * @param text   		The text to insert.
 */
function addText(formElement, text) {
	formElement.value += text;
}
