/****************************************
*
* www.johnkeller.com
*
* mt.js
* created by movabletype.org
* modified by John Keller
*
* Info:
* Movable Type-related functions, modified to use my own toolkit
* instead of copyrighted functions from webreference.com
*
****************************************/


var _DOMAIN = ".johnkeller.com";

function OpenTrackback(c) {
	window.open(c, "trackback", "width=480,height=480,scrollbars=yes,status=yes");
}

function fixDate(date) {
	var base = new Date(0);
	var skew = base.getTime();

	if (skew > 0) {
		date.setTime(date.getTime() - skew);
	}
}

function rememberMe(f) {
	var now = new Date();
	fixDate(now);
	now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);

	// store "-" instead of blanks to assure complete erasure in forgetMe()
	_setCookie("mtcmtauth", ((f.author.value) ? f.author.value : "-"), now, _DOMAIN);
	_setCookie("mtcmtmail", ((f.email.value) ? f.email.value : "-"), now, _DOMAIN);
	_setCookie("mtcmthome", ((f.url.value) ? f.url.value : "-"), now, _DOMAIN);
}

function submitRememberMe(f) {
	if (f.bakecookie[0].checked) {
		rememberMe(f);
	}
}

function forgetMe(f) {
	_unsetCookie("mtcmtauth", _DOMAIN);
	_unsetCookie("mtcmtmail", _DOMAIN);
	_unsetCookie("mtcmthome", _DOMAIN);

	f.author.value = "";
	f.email.value = "";
	f.url.value = "";
}

function initCommentForm() {
	var mtCookie, isStored;

	isStored = false;
	if ((mtCookie = _cookie("mtcmtauth")) && (mtCookie != "-")) {
		document.comments_form.author.value = mtCookie;
		isStored = true;
	}
	if ((mtCookie = _cookie("mtcmtmail")) && (mtCookie != "-")) {
		document.comments_form.email.value = mtCookie;
		isStored = true;
	}
	if ((mtCookie = _cookie("mtcmthome")) && (mtCookie != "-")) {
		document.comments_form.url.value = mtCookie;
		isStored = true;
	}
	document.comments_form.bakecookie[0].checked = isStored;
	document.comments_form.bakecookie[1].checked = !isStored;
}
