// JavaScript Document

$(document).ready(function(){
	
	var AjaxCall = function(clickedObj) {
		var ajaxVariables = "forumNo=" + $("#forumNo").val() + "&threadNo=" + clickedObj.name + "&returnURL=" + $("#returnUrl").val();
		$.ajax({
   				type: "post",
   				url: "/?forums.toggleStickyThread",
				contentType: "application/x-www-form-urlencoded; charset=UTF-8",
   				data: ajaxVariables,
				dataType: "html",
				async: false,
				beforeSend: function (XMLHttpRequest) {
  					// alert("test");
				},
   				complete: function(msg) {
					//alert(msg.responseText);
					var removeDebug = msg.responseText.split("</td></td>");
					$("#threadListContent").html(removeDebug[0]);
					 bindStickyBehaviour();
				}
 			});
	};
	
	
	
	var bindStickyBehaviour = function () {
		$('#threadListContent .toggleSticky').attr("href","javascript:void(0);");
		$('#threadListContent .toggleSticky').click(function(){ 
				AjaxCall(this);						  
	 	}); 
	};
	
	
	bindStickyBehaviour();
	
	
});
