function addEvent(obj, evType, fn) {
	if(obj.addEventListener) {
		obj.addEventListener(evType, fn, false);
		return true;
	} else if(obj.attachEvent) {
		var r = obj.attachEvent("on" + evType, fn);
		return r;
	} else {
		return false;
	}
}
function hideNotification() {
	hide(document.getElementById("notification"));
}
function show(obj) {
	obj.style.display = "";
}
function hide(obj) {
	obj.style.display = "none";
}
function toggle(obj) {
	obj.style.display = obj.style.display == "" ? "none" : "";
}
function urlPrompt(str, url) {
	if(confirm(str)) {
		window.location = url;
	}
}
function updateTitle() {
	document.getElementById("preview_title").innerHTML = document.newpost.posttitle.value;
}
function updateBody() {
	document.getElementById("preview_body").innerHTML = document.newpost.postbody.value.replace(/\n/g, "<br>");
}
function updateCTitle() {
	document.getElementById("preview_ctitle").innerHTML = document.newcomm.commname.value;
}
function updateCBody() {
	document.getElementById("preview_cbody").innerHTML = document.newcomm.commbody.value.replace(/\n/g, "<br>");
}
function post() {
	show(document.getElementById("new_post"));
	updateTitle();
	updateBody();
}
function comment(loggedin) {
	show(document.getElementById("new_comm"));
	hide(document.getElementById("ccontrol"));
	if(!loggedin) {
		updateCTitle();
	}
	updateCBody();
}
function human(str) {
	if(str == "1") {
		document.getElementById("submitbutton").disabled = false;
	} else {
		document.getElementById("submitbutton").disabled = true;
	}
}
function cancelEdit() {
	hide(document.getElementById("new_post"));
	show(document.getElementById("control"));
}
function cancelComm() {
	hide(document.getElementById("new_comm"));
	show(document.getElementById("ccontrol"));
}
function email() {
	var rand1 = Math.floor(Math.random() * 10);
	var rand2 = Math.random() > 0.5 ? "+" : "-";
	var rand3 = Math.floor(Math.random() * 10);
	var reply = prompt("What is " + rand1 + rand2 + rand3 + "?", "");
	if(reply == eval(rand1 + rand2 + rand3)) {
		var first = "mikejsavage";
		var second = "gmail";
		var third = "com";
		document.getElementById("email").href = "mailto:" + first + "@" + second + "." + third;
		document.getElementById("email").innerHTML = first + "@" + second + "." + third;
	} else {
		alert("The correct answer was " + eval(rand1 + rand2 + rand3) + ". Try again.");
	}
}
function highlightRow(obj, cursor) {
	obj.style.background = "#CCCCCC";
	if(cursor) {
		document.body.style.cursor = "pointer";
	}
}
function dimRow(obj, cursor) {
	obj.style.background = "#FFFFFF";
	if(cursor) {
		document.body.style.cursor = "default";
	}
}
function inputFocus(obj, value) {
	if(obj.value == value) {
		obj.value = "";
		obj.style.color = "#000000";
	}
}
function inputBlur(obj, value) {
	if(obj.value == "") {
		obj.value = value;
		obj.style.color = "#666";
	} else if(obj.value == value) {
		obj.style.color = "#666";
	} else {
		obj.style.color = "#000000";
	}
}
function addEvent(obj,evType,fn){if(obj.addEventListener){obj.addEventListener(evType,fn,false);return true;}else if(obj.attachEvent){var r=obj.attachEvent("on"+evType,fn);return r;}else{return false;}}
function hideNotification(){hide(document.getElementById("notification"));}
function show(obj){obj.style.display="";}
function hide(obj){obj.style.display="none";}
function toggle(obj){obj.style.display=obj.style.display==""?"none":"";}
function urlPrompt(str,url){if(confirm(str)){window.location=url;}}
function updateTitle(){document.getElementById("preview_title").innerHTML=document.newpost.posttitle.value;}
function updateBody(){document.getElementById("preview_body").innerHTML=document.newpost.postbody.value.replace(/\n/g,"<br>");}
function updateCTitle(){document.getElementById("preview_ctitle").innerHTML=document.newcomm.commname.value;}
function updateCBody(){document.getElementById("preview_cbody").innerHTML=document.newcomm.commbody.value.replace(/\n/g,"<br>");}
function post(){show(document.getElementById("new_post"));updateTitle();updateBody();}
function comment(loggedin){show(document.getElementById("new_comm"));hide(document.getElementById("ccontrol"));if(!loggedin){updateCTitle();}
updateCBody();}
function human(str){if(str=="1"){document.getElementById("submitbutton").disabled=false;}else{document.getElementById("submitbutton").disabled=true;}}
function cancelEdit(){hide(document.getElementById("new_post"));show(document.getElementById("control"));}
function cancelComm(){hide(document.getElementById("new_comm"));show(document.getElementById("ccontrol"));}
function email(){var rand1=Math.floor(Math.random()*10);var rand2=Math.random()>0.5?"+":"-";var rand3=Math.floor(Math.random()*10);var reply=prompt("What is "+rand1+rand2+rand3+"?","");if(reply==eval(rand1+rand2+rand3)){var first="mikejsavage";var second="gmail";var third="com";document.getElementById("email").href="mailto:"+first+"@"+second+"."+third;document.getElementById("email").innerHTML=first+"@"+second+"."+third;}else{alert("The correct answer was "+eval(rand1+rand2+rand3)+". Try again.");}}
function highlightRow(obj,cursor){obj.style.background="#CCCCCC";if(cursor){document.body.style.cursor="pointer";}}
function dimRow(obj,cursor){obj.style.background="#FFFFFF";if(cursor){document.body.style.cursor="default";}}
function inputFocus(obj,value){if(obj.value==value){obj.value="";obj.style.color="#000000";}}
function inputBlur(obj,value){if(obj.value==""){obj.value=value;obj.style.color="#666";}else if(obj.value==value){obj.style.color="#666";}else{obj.style.color="#000000";}}