if(document.images) {
	// preload
	navimg1 = new Image();
	navimg1.src = "/personal/images/nav_imageisfound_on.gif";
	navimg2 = new Image();
	navimg2.src = "/personal/images/nav_personalblog_on.gif";
	navimg3 = new Image();
	navimg3.src = "/personal/images/nav_websites_on.gif";
	navimg4 = new Image();
	navimg4.src = "/personal/images/nav_cats_on.gif";
	navimg5 = new Image();
	navimg5.src = "/personal/images/nav_resources_on.gif";
	navimg6 = new Image();
	navimg6.src = "/personal/images/nav_about_on.gif";
}
function nav(imgName, state) {
	document.images[imgName].src = "/personal/images/nav_" + imgName + "_" + state + ".gif";
}

var siteWidth = 650;
function getWidth() {
	var n_win = window.innerWidth ? window.innerWidth : 0;
	var n_docel = document.documentElement ? document.documentElement.clientWidth : 0;
	var n_body = document.body ? document.body.clientWidth : 0;
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	var currentWidth = n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
	if(currentWidth < siteWidth)
		return siteWidth;
	else
		return currentWidth;
}

var old_index = 0;
var timeout_id;
function clear_timeouts() {
	if(document.getElementById) {
		if(timeout_id != null)
			self.clearTimeout(timeout_id);
	}
}
function popupon(index, leftPx) {
	if(document.getElementById) {
		clear_timeouts();
		if(old_index != 0) {
			if(document.getElementById(old_index + "Sub"))
				document.getElementById(old_index + "Sub").style.display = "none";
			nav(old_index, "off");
		}
		if(document.getElementById(index + "Sub")) {
			document.getElementById(index + "Sub").style.top = 280;
			document.getElementById(index + "Sub").style.left = ((getWidth() - siteWidth) / 2) + leftPx;
			document.getElementById(index + "Sub").style.display = "inline";
		}
		nav(index, "on");
		old_index = index;
	}
}
function popupoff() {
	if(document.getElementById) {
		if(old_index != 0)
			timeout_id = setTimeout("if(document.getElementById(old_index + 'Sub'))document.getElementById(old_index + 'Sub').style.display = 'none';nav(old_index, 'off');", 100);
	}
}

function addComment(postID) {
	if(document.getElementById("commentDiv" + postID).style.display == "none")
		viewComments(postID);
	var commentWin = window.open("comments_add.cfm?postID=" + postID, "commentWin", "width=500,height=450,scrollbars=yes,resizable=yes");
	commentWin.focus();
}
function viewComments(postID) {
	if(document.getElementById("commentDiv" + postID).style.display == "none") {
		document.getElementById("commentDiv" + postID).style.display = "inline";
		document.getElementById("commentsShow" + postID).style.display = "none";
		document.getElementById("commentsHide" + postID).style.display = "inline";
	}
	else {
		document.getElementById("commentDiv" + postID).style.display = "none";
		document.getElementById("commentsShow" + postID).style.display = "inline";
		document.getElementById("commentsHide" + postID).style.display = "none";
	}
}

