




/*
     FILE ARCHIVED ON 6:50:15 Jul 31, 2007 AND RETRIEVED FROM THE
     INTERNET ARCHIVE ON 8:21:39 Sep 3, 2011.
     JAVASCRIPT APPENDED BY WAYBACK MACHINE, COPYRIGHT INTERNET ARCHIVE.

     ALL OTHER CONTENT MAY ALSO BE PROTECTED BY COPYRIGHT (17 U.S.C.
     SECTION 108(a)(3)).
*/
function ajaxComment(formObj, targetURL) {
	new Ajax.Updater(
		{ success: 'commentlist' }, targetURL,
		{
			asynchronous: true,
			evalScripts: true,
			insertion: Insertion.Bottom,
			onComplete: function(request){complete(request)},
			onFailure: function(request){failure(request)},
			onLoading: function(request){loading()},
			parameters: Form.serialize(formObj)
		}
	);
}

function commentAdded(request) {
	if ($('errors')) { Element.hide('errors'); }
	new Effect.Appear($('commentlist').lastChild);
	$('comment').value = '';
	$('comment').disabled = true;
	$('submit').disabled = true;
	if ($('leavecomment')) { Element.remove('leavecomment'); }
	$('comments').innerHTML = parseInt($('comments').innerHTML) + 1;
	setTimeout('commentOpen();',15000);
}

function commentOpen() {
	$('comment').disabled = false;
	$('submit').disabled = false;
}

function failure(request) {
	Element.show('errors');
	$('errors').innerHTML = request.responseText;
	new Effect.Highlight('errors',{queue:'end'});
	if ($('leavecomment')) { Element.show('leavecomment'); }
}

function loading() {
	if ($('leavecomment')) { Element.hide('leavecomment'); }
	$('submit').disabled = true;
	$('comment').disabled = true;  
	Element.show('loading');
}

function complete(request) {
	Element.hide('loading');
	Element.show('commentform');
	commentOpen();

	if (request.status == 200) {commentAdded()}
	else {failure(request)};
}

