$.extend(true, $.Footytips, {
	Forums: {
		report: function(id, type, pollId) {
			var urlVars = '';
			var reportEl = '';
			
			if (type == 'posts') {
				urlVars = '&postId='+id;
				reportEl = 'reportPost_'+id;
			}
			else if (type == 'threads') {
				urlVars = '&threadId='+id;
				reportEl = 'reportThread_'+id;
			}
			
			if (!isNaN(pollId))
				urlVars += '&pollId='+id;
				
			
			if (urlVars.length > 0 && reportEl.length > 0) {
				getcontent('POST','/cfm/ft/sub/retrieve.cfm','&fg=forums&ff=report'+urlVars, '', reportEl, '');
			}
		},
		
		deletePost: function(postId, retainedData) {
			if (!$("#tempData").length)
				$('body').append('<div id="tempData" style="display:none;"></div>');
				
			getcontent('POST','/cfm/ft/sub/retrieve.cfm','&fg=forums&ff=delete&postId='+postId, retainedData, 'tempData', '$.Footytips.Forums.reloadComments');
		},
		
		reloadComments: function(httpObj) {
			var retainedDataArr = httpObj.retainedDataList.split(',');
			for(var i=0; i < retainedDataArr.length; i++) {
				if (retainedDataArr[i] == 'MATCHID') {
					getcontent('POST','/cfm/ft/sub/retrieve.cfm','&fg=tipping&ff=matchComments&matchId='+httpObj.MATCHID+'&sportid='+httpObj.SPORTID,'','matchCommentDialog','$.Footytips.Forums.setNavigateAway');
				}
			}
		},
		
		setNavigateAway: function(httpObj) {
			$("#matchCommentDialog a").each(function() {
				if (typeof($(this).attr('onclick')) != 'function') {
					$(this).click(function(event) {
						$.Footytips.Tipping.navigateAway();
					});
				}
			});
		},
		
		viewMatchComments: function(matchTitle, matchId, sportid) {
			if (!$("#matchCommentDialog").length)
				$('body').append('<div id="matchCommentDialog"></div>');
				
			$("#matchCommentDialog").dialog({
				autoOpen: false,
				bgiframe: true,
				postition: 'center',
				modal: true,
				title: matchTitle,
				resizable: false,
				width: 680,
				height: 400,
				zIndex: 3000
			});
			
			getcontent('POST','/cfm/ft/sub/retrieve.cfm','&fg=tipping&ff=matchComments&matchId='+matchId+'&sportId='+sportid,'','matchCommentDialog','$.Footytips.Forums.setNavigateAway');
			
			$("#matchCommentDialog").dialog('open');
			
			window.onscroll = function() {
		  	$("#matchCommentDialog").dialog('option', 'position', 'center');
		  };
		},
		
		postMatchComment: function(threadId, textareaId, matchId, sportId) {
			if (matchComment = document.getElementById(textareaId)) {
				getcontent('POST','/cfm/ft/sub/retrieve.cfm','&fg=forums&ff=post&loadType=ajax&threadId='+threadId,'message='+escape(matchComment.value)+'&matchId='+matchId+'&sportid='+sportId,'matchCommentDialog','$.Footytips.Forums.reloadComments');
			}
		},
		
		closeMatchComments: function(httpObj) {
			$("#matchCommentDialog").dialog('close');
		}
	}
});
