// JavaScript Document
$(document).ready( function() {
	$('.btnLike a').click( function(e) {
		e.preventDefault();

		thisLi = $(this).parent('li');
		postNo = $(this).parents('div.Post').attr('id');
		ajaxVariables = "&postNo=" + postNo + "&ajaxRequest=true";

		$(this).css({'background-position':'0 -50px'});

		$.ajax({
			type: "post",
			url: "/?home.agree" + ajaxVariables,
			success: function(msg) {
				if (thisLi.prev().is('li.txtLikeThis')) {
					thisLiPrev = thisLi.prev('li.txtLikeThis');
					thisLiPrev.html("You and " + thisLiPrev.html());
					thisLiPrev.find('span.jsInsertTxtOther').text("other ");
				}
				else {
					$("<li class='txtLikeThis'>You Like This</li>").insertBefore(thisLi);
				}
				thisLi.remove();
			} // Close Success
		});	// Close Ajax	
	}); // Close .btnLike a.click

	$('.subscribe').after("<div id='subscribeAjaxTextPlacement'></div>");

	$('.subscribeThread').click( function(e) {
		_this = $(this);
		_this.attr("disabled","disabled");
		threadNo = $('.Post:first').attr('id');
		if ($(this).is(':checked')) {
			url = "/?Home.subscribeThread";
		}
		else {
			url = "/?Home.unSubscribeThread";
		}
		$.ajax({
			url: url + "&threadNo=" + $('#thisThreadNo').val(),
			success: function(msg) {
				_this.removeAttr("disabled");
				if (_this.is(':checked')) {
					htmlOut = "<span class='GoodAction'>Subscribed to Topic</span>";
				}
				else {
					htmlOut = "<span class='BadAction'>Unsubscribed to Topic</span>";
				}
				$('#subscribeAjaxTextPlacement').html(htmlOut);
				$('#subscribeAjaxTextPlacement span').fadeOut(2500);
			} // Close success
		}); // Close Ajax
	}); // Close .subscribeThread.click
}); // Close document.ready
