function elementStyle(elementId,styleIndex,stValue,stValue2,stValue3) {
	var error = new Array();

	/* input checking */
	if ((typeof(elementId) == "undefined") || (elementId == null)) { error.push("Parameter 'elementId' is not defined"); }
	else if (!document.getElementById(elementId)) { error.push("Value '"+elementId+"' specified for parameter 'elementId' is not valid"); }
	if ((typeof(styleIndex) == "undefined") || (styleIndex == null)) { error.push("Parameter 'styleIndex' is not defined"); }
	if ((typeof(stValue) == "undefined") || (stValue == null)) { error.push("Parameter 'stValue' is not defined"); }
	if (error.length > 0) {
		alert("Error(s): "+error.toString());
		return false;
	}

	/* display */
	if (styleIndex.toLowerCase() == "display") {
		if (stValue == "toggle") {
			if (document.getElementById(elementId).style.display == "") { document.getElementById(elementId).style.display = "none"; }
			else { document.getElementById(elementId).style.display = ""; }
		}
		else if (stValue == "show") { document.getElementById(elementId).style.display = ""; }
		else if (stValue == "hide") { document.getElementById(elementId).style.display = "none"; }
		else { alert("Error: The value '"+stValue+"' specified for 'stValue' for 'styleIndex=display' is invalid."); return false; }
	}

	/* className */
	else if (styleIndex.toLowerCase() == "classname") {
		if (stValue == "set") { document.getElementById(elementId).className = stValue; }
		else if (stValue == "toggle") {
			if (document.getElementById(elementId).className == stValue2) { document.getElementById(elementId).className = stValue3; }
			else if (document.getElementById(elementId).className == stValue3) { document.getElementById(elementId).className = stValue2; }
		}
		else { alert("Error: The value '"+stValue+"' specified for 'stValue' for 'styleIndex=className' is invalid."); return false; }
	}
	else { alert("Error: The value '"+styleIndex+"' specified for parameter 'styleIndex' is invalid."); return false; }

	return true;
}
function sendEmail(number,articleId) {
	ajaxGetData("/sendIt.php","message"+number,"articleId="+articleId+"&userEmail="+document.getElementById('userEmail'+number).value+"&userName="+document.getElementById('userName'+number).value+"&theirEmail="+document.getElementById('theirEmail'+number).value);
}
function sendIt() {
	if (document.getElementById('sendIt1').style.display == 'none') { document.getElementById('sendIt1').style.display = ''; }
	else { document.getElementById('sendIt1').style.display = 'none'; }
}
var ajaxQueue = new Object();
ajaxQueue.ajaxReqs = new Array();
function ajaxGetData(filePath,elementId,additionalVars) {
	var error = new Array();

	/* input checks */
	if ((typeof(filePath) == "undefined") || (filePath == null)) { error.push("Parameter 'filePath' is not defined."); }
	if ((typeof(elementId) != "undefined") && (elementId != null) && (document.getElementById(elementId) == null)) { error.push("The elementId specified as '"+elementId+"' does not exist."); }
	if (error.length > 0) {
		alert("Error(s): "+error.toString());
		return false;
	}

	document.getElementById(elementId).innerHTML = 'Loading...'; 
	ajaxQueue.ajaxReqs.push(new Array(filePath,additionalVars,elementId));
	ajaxProcessQueue();
}
function ajaxProcessQueue() {
	if (ajaxQueue.ajaxReqs.length == 0) { return true; }

	/* processing queue
	   to be kept in sync with code in js:messageLog()
	   with exception to notToLog being undefined and messageType for messageLog() */
	var ajaxRequest = ajaxQueue.ajaxReqs.shift();
	try { var ajax = ((window.XMLHttpRequest) ? new XMLHttpRequest():new ActiveXObject("Microsoft.XMLHTTP")); }
	catch (error) { messageLog("error",ajaxRequest[3],"An unknown error occured when creating AJAX object; unable to return requested data."); return false; }
	try { ajax.open("POST",ajaxRequest[0]); }
	catch (error) { messageLog("error",ajaxRequest[3],"An unknown error occured when posting to file '"+ajaxRequest[0]+"'; unable to return requested data."); return false; }
	try { ajax.setRequestHeader("Content-type","application/x-www-form-urlencoded"); }
	catch (error) { messageLog("error",ajaxRequest[3],"An unknown error occured when setting request header; unable to return requested data."); return false; }
	try { ajax.send("filePath="+ajaxRequest[0]+"&"+ajaxRequest[1]+"&elementId="+ajaxRequest[2]); }
	catch (error) { messageLog("error",ajaxRequest[3],"An unknown error occured when sending AJAX directives to file; unable to return requested data."); return false; }
	ajax.onreadystatechange = function() {
		if ((ajax.readyState == 4) && (ajax.status == 200)) {
			if (document.getElementById(ajaxRequest[2]) != null) { var tagName = document.getElementById(ajaxRequest[2]).tagName.toLowerCase(); }
			if ((tagName == "div") || (tagName == "p")) { document.getElementById(ajaxRequest[2]).innerHTML = ajax.responseText; }
			else if (tagName == "img") { document.getElementById(ajaxRequest[2]).src = ajax.responseText; }
			else if ((tagName == "textarea") || (tagName == "input")) { document.getElementById(ajaxRequest[2]).value = ajax.responseText; }
			else if (document.getElementById(ajaxRequest[2]) != null) { alert("Error: The element '"+ajaxRequest[2]+"' has an HTML tag of '"+tagName+"', which is not supported.  Unable to return requested data."); }
			ajaxProcessQueue();
		}
		else if ((ajax.readyState == 4) && (ajax.status == 404)) { alert("Error: The page requested by ajaxGetData() for element '"+ajaxRequest[2]+"' does not exist; unable to return requested data."); return false; }
		else if (ajax.readyState == 4) { alert("Error: '"+ajax.status+"' was returned with ajaxGetData() request for element '"+ajaxRequest[2]+"'; unable to return requested data."); return false; }
	}
}
setTimeout('ajaxProcessQueue()',1000);

