
Phpfox.forum = 
{
	quickReply: function()
	{		
		var sTextValue = $('#text').val();
		
		if (empty(sTextValue))
		{
			alert(oTranslations['forum.provide_a_reply']);
			
			return false;
		}
		
		$('#js_reply_process').html($.ajaxProcess(oTranslations['forum.adding_your_reply']));
		$('#js_quick_reply_form .button').attr('disabled', true).addClass('disabled');
		$('#js_quick_reply_form #text').attr('disabled', true).addClass('disabled');		
		
		$('#js_quick_reply_form').ajaxCall('forum.addReply', 'val[text]=' + sTextValue);
		
		return false;
	},
	
	goAdvanced: function()
	{
		$('#js_advance_reply_textarea').val($('#text').val());
		$('#js_advance_reply_form').submit();
	},
	
	processReply: function(iPostId)
	{		
		$.scrollTo('#post' + iPostId, 800);
		
		$('#js_reply_process').html('');
		$('#text').val('');
		$('#js_total_post_count').val((parseInt($('#js_total_post_count').val()) + 1));
		$('#js_quick_reply_form .button').attr('disabled', false).removeClass('disabled');
		$('#js_quick_reply_form #text').attr('disabled', false).removeClass('disabled');	
		$('#js_post_entry').html('');	
	},
	
	deletePost: function(iPostId)
	{
		if (!confirm(oTranslations['forum.are_you_sure']))
		{
			return false;
		}
		
		$.ajaxCall('forum.deletePost', 'id=' + iPostId);
		$('#post' + iPostId).html('<div class="valid_message" style="margin:0px;">' + oTranslations['forum.post_successfully_deleted'] + '</div>').fadeOut(5000);
		
		var iCnt = 0;
		$('.js_post_count').each(function()
		{
			iCnt++;	
		});
		
		if (!iCnt)
		{
			// $('#site_content').html('<div class="valid_message" style="margin:0px;">' + oTranslations['forum.post_and_thread_successfully_deleted'] + '</div>');
		}
		
		return false;
	},
	
	deleteThread: function(iThread)
	{
		if (!confirm(oTranslations['forum.are_you_sure']))
		{
			return false;
		}		
		
		$.ajaxCall('forum.deleteThread', 'thread_id=' + iThread);
		
		// $('#site_content').html('<div class="valid_message" style="margin:0px;">' + oTranslations['forum.thread_successfully_deleted'] + '</div>');
		
		return false;
	},
	
	stickThread: function(iThread, iType)
	{
		$('.dropContent').hide();
		
		$.ajaxCall('forum.stickThread', 'thread_id=' + iThread + '&type_id=' + iType);
		
		return false;
	},
	
	closeThread: function(iThread, iType)
	{
		$('.dropContent').hide();
		
		$.ajaxCall('forum.closeThread', 'thread_id=' + iThread + '&type_id=' + iType);
		
		return false;
	},
	
	selected: function(oObj, iPostId)
	{	
		if ($(oObj).hasClass('selected'))
		{
			var sCookie = getCookie('forum_quote');
			
			setCookie('forum_quote', sCookie.replace(iPostId + ',', ''));
			
			$(oObj).removeClass('selected');
		}
		else
		{
			$(oObj).addClass('selected');
			
			setCookie('forum_quote', getCookie('forum_quote') + iPostId + ',');
		}		
		
		return false;
	},
	
	processQuotes: function()
	{
		var sValue = getCookie('forum_quote');
		
		if (!empty(sValue))
		{
			var aParts = explode(',', sValue);
			
			for (i in aParts)
			{
				if (empty(aParts[i]))
				{
					continue;
				}				
				
				$('#js_forum_quote_' + aParts[i]).addClass('selected');
			}
		}
	}
}