(function($){ 
	$.fn.forumEditor = function(containerId, previewButtonId, defaultText, numMessages) {
		var dialogContent = {
			'image':'<p>Insert an Image below:</p><p><input type="text" id="imgSelect"></p>',
			'link':'<p>Insert a Link below:</p><p><input type="text" id="urlSelect"></p>',
			'size':'<p>Select Font Size:</p><p><select id="fontSizeSelect"><option value="-1">-1</option><option value="1">1</option><option value="2">2</option><option value="3">3</option></select></p>',
			'quote':'<p>Person\'s Name:</p><p><input type="text" id="quotePerson"></p><p>Quoted Text:</p><p><textarea id="quoteText"></textarea></p>'
		};
		
		if (!$("#forumEditorDialog").length)
			$('body').append('<div id="forumEditorDialog"></div>');
			
		$("#forumEditorDialog").dialog({
			autoOpen: false,
			bgiframe: true,
			modal: true,
			resizable: false,
			width: 320,
			zIndex: 3000
		});
		
	  $(this).each(function() {
	  	var textarea = document.getElementById($(this).attr('id'));
	  	
	  	if (numMessages == 0 && defaultText.length > 0 && $(this).val().length == 0) {
	  		$(this).val(defaultText);
	  		$(this).focus(function() {
					clearComment(textarea);
					return false;
				});
	  	}
	  		
			if ($('#'+containerId).length) {
				$('#'+containerId).before(toolbar(textarea));
			}
			
			if ($('#'+previewButtonId).length) {
				$('#'+previewButtonId).click(function() {
					preview(textarea);
				});
			}
		});
		
		function bold(textarea) {
			textarea.value += '[b][/b]';
		}
		
		function italic(textarea) {
			textarea.value += '[i][/i]';
		}
		
		function underline(textarea) {
			textarea.value += '[u][/u]';
		}
		
		function list(textarea) {
			textarea.value += '[list]\n[*][/*]\n[*][/*]\n[*][/*]\n[/list]';
		}
		
		function quote(textarea) {
			$("#forumEditorDialog").dialog('option', 'title', 'Insert a Quote');
			$("#forumEditorDialog").dialog('option', 'buttons', {
				'Cancel':	function() { 
					$(this).dialog("close");
				},
				'Insert':	function() {
					$(this).dialog("close");
					var quotePersonName = '';
					
					if ($("#quotePerson").val().length > 0)
						quotePersonName = '='+$("#quotePerson").val();
					
					textarea.value += '[quote' + quotePersonName + ']' + $("#quoteText").val() +'[/quote]';
				}
			});
			
			openDialog('quote');
		}
		
		function image(textarea) {
			$("#forumEditorDialog").dialog('option', 'title', 'Insert an Image');
			$("#forumEditorDialog").dialog('option', 'buttons', {
				'Cancel':	function() { 
					$(this).dialog("close");
				},
				'Insert':	function() {
					$(this).dialog("close");
					textarea.value += '[img]'+ $("#imgSelect").val() +'[/img]';
				}
			});
			
			openDialog('image');
		}
		
		function link(textarea) {
			$("#forumEditorDialog").dialog('option', 'title', 'Insert a Link');
			$("#forumEditorDialog").dialog('option', 'buttons', {
				'Cancel':	function() { 
					$(this).dialog("close");
				},
				'Insert':	function() {
					$(this).dialog("close");
					textarea.value += '[url]'+ $("#urlSelect").val() +'[/url]';
				}
			});
			
			openDialog('link');
		}
		
		function size(textarea) {
			$("#forumEditorDialog").dialog('option', 'title', 'Choose Font Size');
			$("#forumEditorDialog").dialog('option', 'buttons', {
				'Cancel':	function() { 
					$(this).dialog("close");
				},
				'Insert':	function() {
					$(this).dialog("close");
					textarea.value += '[size='+ $("#fontSizeSelect").val() +'][/size]';
				}
			});
			
			openDialog('size');
		}
		
		function openDialog(type) {
			$("#forumEditorDialog").html(dialogContent[type]);
			
			$("#forumEditorDialog").dialog('open');
	
			window.onscroll = function() {
		  	$("#forumEditorDialog").dialog('option', 'position', 'center');
		  };
		}
		
		function clearComment(textarea) {
			if (textarea.value == defaultText)
				textarea.value = "";
		}
		
		function toolbar(textarea) {
			var tb = $('<div class="ft_forumPostFormatting">\
					<a href="javascript:void(0);" id="bbBold" class="ft_icon16Bold" title="Add bold tags eg. [b]bold[/b]"><!-- BOLD --></a>\
					<a href="javascript:void(0);" id="bbItalic" class="ft_icon16Italic" title="Add italic tags eg. [i]italic[/i]"><!-- ITALIC --></a>\
					<a href="javascript:void(0);" id="bbUnderline" class="ft_icon16Underline" title="Add underline tags eg. [u]underline[/u]"><!-- UNDERLINE --></a>\
					<a href="javascript:void(0);" id="bbSize" class="ft_icon16FontSize" title="Add font size tags eg. [size=1]size[/size] (sizes= -1, 1, 2, & 3)"><!-- FONT SIZE --></a>\
					<a href="javascript:void(0);" id="bbLink" class="ft_icon16Url" title="Add url tags eg. [url]http://www.footytips.com.au[/url]"><!-- URL --></a>\
					<a href="javascript:void(0);" id="bbImage" class="ft_icon16Image" title="Add image tags eg. [img]http://www.footytips.com.au/images/favicon.ico[/img]"><!-- IMAGE --></a>\
					<a href="javascript:void(0);" id="bbQuote" class="ft_icon16Quote" title="Add quote tags eg. [quote=footytips.com.au]footytips[/quote] (quote=username to include a username)"><!-- QUOTE --></a></div>');
	
			$('#bbBold', tb).click(function() {
				bold(textarea);
				return false;
			});
			
			$('#bbItalic', tb).click(function() {
				italic(textarea);
				return false;
			});
			
			$('#bbUnderline', tb).click(function() {
				underline(textarea);
				return false;
			});
			
			$('#bbSize', tb).click(function() {
				size(textarea);
				return false;
			});
			
			$('#bbLink', tb).click(function() {
				link(textarea);
				return false;
			});
			
			$('#bbImage', tb).click(function() {
				image(textarea);
				return false;
			});
			
			$('#bbQuote', tb).click(function() {
				quote(textarea);
				return false;
			});
			
			return tb;
		}
		
		function preview(textarea) {
			var messageText = textarea.value.replace(/\n/g, '\r\n');
			var encMessage = escape(messageText);
			var postStr = '&message='+encMessage;
			
			if ($("#threadTitle").length)
				postStr += '&title='+escape($("#threadTitle").val());
				
			if ($("#editReason").length)
				postStr += '&editReason='+escape($("#editReason").val());
	
			if ($("#bbPostPreview").length)
				getcontent('POST','/cfm/ft/sub/retrieve.cfm','&fg=forums&ff=previewPost&loadType=ajax', postStr, 'bbPostPreview', '');
		}
	};
	
	$.fn.commentEditor = function(defaultText, numMessages) {
	  $(this).each(function() {
	  	var textarea = document.getElementById($(this).attr('id'));
	  	
	  	if (numMessages == 0 && defaultText.length > 0) {
	  		$(this).val(defaultText);
	  		$(this).focus(function() {
					clearComment(textarea);
					//$(".ft_profileRightWallCommentButton").show();
					return false;
				});
	  	}
	  	
	  	
	  	/*
			$(this).blur(function() {
				$(".ft_profileRightWallCommentButton").hide();
			})
			*/
		});
		
		function clearComment(textarea) {
			if (textarea.value == defaultText)
				textarea.value = "";
		}
	};
	
	$.fn.autofill = function(options){
		var defaults = {
			defaultText : 'Search...',
			inactiveClass : 'ft_compsQuickFindText',
			activeClass : 'ft_compsQuickFindTextActive',
			inactiveColour: '#808080',
			activeColour: '#000000',
			pref: 'class',
			showButton: false,
			buttonText: '',
			buttonClass: 'ft_compsQuickFindButtonSearch',
			label: ''
		};
		
		var options = $.extend(defaults, options);
		
		return this.each(function(){
			var hasContent = $(this).val() != '' && $(this).val() != options.defaultText;
			
			if (options.pref == 'class') {
				$(this).addClass(options.inactiveClass);
				if (hasContent)
					$(this).addClass(options.activeClass);
					
				if (options.showButton) {
					$(this).after('<input class="' + options.buttonClass + '" value="' + options.buttonText + '" type="submit">')
				}
			}
			else {
				if (hasContent)
					$(this).css({color: options.activeColour});
				else
					$(this).css({color: options.inactiveColour});
					
				if (options.showButton) {
					$(this).after('<input value="' + options.buttonText + '" type="submit">')
				}
			}
			
			if (options.label.length > 0) {
				$(this).before('<p>' + options.label + '</p>')
			}
			
			
			if (!hasContent)
				$(this).val(options.defaultText);
			
			$(this).focus(function(){
				if ($(this).val() == options.defaultText) {
					if (options.pref == 'class')
						$(this).addClass(options.activeClass);
					else
						$(this).css({color: options.activeColour});
						
					$(this).val('');
				}
			});
			
			$(this).blur(function() {
				if ($(this).val() == '') {
					if (options.pref == 'class')
						$(this).removeClass(options.activeClass);
					else
						$(this).css({color: options.inactiveColour});
					
					$(this).val(options.defaultText);
				}
			});
		});
	};
	
})(jQuery);


$.extend({
	Footytips: {
		initialised: false,
		userId: 0,
		displayName: '',
		
		init: function(userId, displayName) {
			$.Footytips.userId = userId;
			$.Footytips.displayName = displayName;
			$.Footytips.initialised = true;
		},
		
		General: {
			focusLogin: function() {
				$("#userLogin").focus();
			},
			
			addDaysToDate: function(myDate, days) {
				var newDate = new Date(myDate.getTime() + days*24*60*60*1000);
				return newDate.getFullYear() + '-' + (newDate.getMonth()+1) + '-' + newDate.getDate() + ' ' + newDate.getHours() + ':' + newDate.getMinutes() + ':' + newDate.getSeconds();
			},
			
			fbShare: function(u, t) {
				var rand = parseInt(Math.random()*99999999);
				u += '&rand='+rand;
				window.open('http://www.facebook.com/sharer.php?&u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
				return false;
			}
		},
		
		AdServing: {
			viewTrailer: function(heading) {
				if (typeof(heading) == 'undefined')
					heading = 'View Trailer';
					
				if (!$("#adSpaceViewTrailer").length)
					$('body').append('<div id="adSpaceViewTrailer" style="padding: 2px 0px; text-align: center; width: 640px"><iframe id="adSpaceViewTrailerIframe" src="" scrolling="no" hspace="0" vspace="0" frameborder="0" marginheight="0" marginwidth="0" width="640" height="360" allowTransparency="true"></iframe></div>');
					
				$("#adSpaceViewTrailer").dialog({
					autoOpen: false,
					bgiframe: true,
					postition: 'center',
					modal: true,
					resizable: false,
					zIndex: 3000,
					title: heading,
					close: function(event, ui) {
						$(this).remove();
					}
				});
				
				if (navigator.userAgent.indexOf("MSIE")!= -1)
					$("#adSpaceViewTrailer").dialog('option', 'width', 665);
				else
					$("#adSpaceViewTrailer").dialog('option', 'width', 640);
					
				$("#adSpaceViewTrailer").dialog('open');
				
				$("#adSpaceViewTrailerIframe").attr('src', adhserver + allAdTags + '/AAMSZ=640X360/RESKIN=TRUE' + target + '?');
				
				window.onscroll = function() {
			  	$("#adSpaceViewTrailer").dialog('option', 'position', 'center');
			  };
			}
		},
		
		Messaging: {
			sendProfileMessage: function(toUserId, competitionId) {
				if (!$("#personalMsgDialog").length)
					$('body').append('<div id="personalMsgDialog"></div>');
					
				$("#personalMsgDialog").dialog({
					autoOpen: false,
					bgiframe: true,
					position: 'center',
					modal: true,
					title: 'Send Message',
					resizable: false,
					width: 440,
					zIndex: 3000
				});
				
				if (typeof(toUserId) == 'undefined')
					toUserId = $.Footytips.userId;
					
				var formStr = 'toUserId=' + toUserId;
				
				if (typeof(competitionId) != 'undefined')
					formStr += '&competitionId=' + competitionId;
				
				if ($.Footytips.initialised) {
					getcontent('POST','/cfm/ft/sub/retrieve.cfm','&fg=messages&ff=sendProfileMessage', formStr, 'personalMsgDialog', '$.Footytips.Messaging.updateDialog');
					
					$("#personalMsgDialog").dialog('open');
					
					window.onscroll = function() {
				  	$("#personalMsgDialog").dialog('option', 'position', 'center');
				  };
				}
			},
			
			submitProfileMessage: function(toUserId, competitionId) {
				if (typeof(toUserId) == 'undefined')
					toUserId = $.Footytips.userId;
				
				var formStr = 'toUserId=' + toUserId;
				formStr += '&personalMessage=' + escape($("#personalMessage").val())
			
				if (typeof(competitionId) != 'undefined')
					formStr += '&competitionId=' + competitionId;
					
				getcontent('POST','/cfm/ft/sub/retrieve.cfm','&fg=messages&ff=sendProfileMessage&send=1', formStr, 'personalMsgDialog', '$.Footytips.Messaging.updateDialog');
			},
		
			updateDialog: function(httpObj) {
				var buttonObj = {
					'Close': function() {
						$("#personalMsgDialog").dialog('close');
					}
				};
				
				if (httpObj.button == 'back') {
					buttonObj = {
						'Close': function() {
							$("#personalMsgDialog").dialog('close');
						},
						'Go Back to Send Message': function() {
							$.Footytips.Messaging.sendProfileMessage(httpObj.toUserId);
						}
					};
				}
				else if (httpObj.button == 'send') {
					buttonObj = {
						'Close': function() {
							$("#personalMsgDialog").dialog('close');
						},
						'Send Message' : function() {
							$.Footytips.Messaging.submitProfileMessage(httpObj.toUserId, httpObj.competitionId);
						}
					};
				}
				
				$("#personalMsgDialog").dialog('option', 'buttons', buttonObj);
			}
		},
		
		Tipping: {
			navigateAway: function() {
				if ($("#saveTips").length) {
					if (confirm("By leaving this page, your tips may not be saved.\n\nClick OK to leave this page or Cancel to stay and save your tips."))
						return true;
					else
						hideModal();
					
					return false;
				}
				else
					return true;
			},
			
			showUserTip: function(roundViewSportId) {
				var temp = roundViewSportId.split("_");
				var round = temp[0];
				var currSportId = temp[1];

				if (currSportId == 14)
					tipTitle = $.Footytips.displayName + '\'s Match '+round+' Tips';
				else
					tipTitle = $.Footytips.displayName + '\'s Round '+round+' Tips';
					
				if (!$("#viewUserTipsDialog").length)
					$('body').append('<div id="viewUserTipsDialog"></div>');

				$("#viewUserTipsDialog").dialog({
					autoOpen: false,
					bgiframe: true,
					postition: 'center',
					modal: true,
					title: tipTitle,
					resizable: false,
					width: 630,
					height: 560,
					zIndex: 3000,
					buttons: {
						'Close': function() {
							$(this).dialog('close');
						}
					}
				});
				
				getcontent('POST','/cfm/ft/sub/retrieve.cfm','&fg=profile&ff=viewTipsForRound&tipperId=' + $.Footytips.userId + '&round=' + round + '&sportId=' + currSportId,'','viewUserTipsDialog','');
				
				$("#viewUserTipsDialog").dialog('open');
				
				window.onscroll = function() {
			  	$("#viewUserTipsDialog").dialog('option', 'position', 'center');
			  };
			},
			
			showUserTips: function(userId, userName, round, roundName, sportId, showAsBlind) {
				var heading = unescape(userName) + '\'s ' + roundName + ' Tips';
				var showAsBlindStr = '';
				
				if (typeof(showAsBlind) != 'undefined')
					showAsBlindStr = '&showAsBlind=' + showAsBlind;

				if (!$("#viewUserTipsDialog").length)
					$('body').append('<div id="viewUserTipsDialog"></div>');

				$("#viewUserTipsDialog").dialog({
					autoOpen: false,
					bgiframe: true,
					postition: 'center',
					modal: true,
					resizable: false,
					width: 630,
					height: 560,
					zIndex: 3000,
					buttons: {
						'Close': function() {
							$(this).dialog('close'); 
						}
					}
				});
				
				getcontent('POST','/cfm/ft/sub/retrieve.cfm','&fg=profile&ff=viewTipsForRound&tipperId=' + userId + '&round=' + round + '&sportId=' + sportId + showAsBlindStr,'','viewUserTipsDialog','');
				
				$("#viewUserTipsDialog").dialog('option', 'title', heading);
				$("#viewUserTipsDialog").dialog('open');
				
				window.onscroll = function() {
			  	$("#viewUserTipsDialog").dialog('option', 'position', 'center');
			  };
			},
			
			noFlexiOdds: function() {
				$("#noFlexiOddsDialog").dialog({
					bgiframe: true,
					modal: true,
					title: 'No Betting Odds',
					resizable: false,
					width: 420,
					zIndex: 3000
					
				});
				
				$("#noFlexiOddsDialog").dialog('open');
				
				window.onscroll = function() {
			  	$("#noFlexiOddsDialog").dialog('option', 'position', 'center');
			  };
			},
			
			viewTipGuide: function(round, sportid) {
				if (!$("#ft_tipGuideMatchSelector").length)
					$('body').append('<div id="ft_tipGuideMatchSelector"></div>');
					
				$("#ft_tipGuideMatchSelector").dialog({
					autoOpen: false,
					bgiframe: true,
					postition: 'center',
					modal: false,
					title: 'footytips.com.au - Tip Guide',
					resizable: false,
					height: 600,
					width: 710,
					zIndex: 3000
				});
				
				getcontent('POST','/cfm/ft/sub/retrieve.cfm','&fg=tipguide&ff=tipguide&round='+round+'&sportId='+sportid+'&loadType=ajax','','ft_tipGuideMatchSelector','handlePage');
				
				$("#ft_tipGuideMatchSelector").dialog('open');
				
				window.onscroll = function() {
			  	$("#ft_tipGuideMatchSelector").dialog('option', 'position', 'center');
			  };
			},
			
			viewMatchTipGuide: function(content, matchId, round, sportid) {
				if (!$("#ft_tipGuideMatchSelector").length)
					$('body').append('<div id="ft_tipGuideMatchSelector"></div>');
					
				$("#ft_tipGuideMatchSelector").dialog({
					autoOpen: false,
					bgiframe: true,
					postition: 'center',
					modal: false,
					title: 'footytips.com.au - Tip Guide',
					resizable: false,
					height: 600,
					width: 710,
					zIndex: 3000
				});
				
				getcontent('POST','/cfm/ft/sub/retrieve.cfm','&fg=tipguide&ff=tipguide&content='+content+'&matchId='+matchId+'&round='+round+'&sportId='+sportid+'&loadType=ajax','','ft_tipGuideMatchSelector','handlePage');

				$("#ft_tipGuideMatchSelector").dialog('open');
				
				window.onscroll = function() {
			  	$("#ft_tipGuideMatchSelector").dialog('option', 'position', 'center');
			  };
			},
			
			marginHelp: function(context, sportCode) {
				if (sportCode == 'CRIC') {
					var marginInfo = "<strong>What is the margin?</strong><br />Here you must estimate what the highest individual batting score of the match will be. In test matches this refers to a single innings. In all formats (test, one-day and twenty20 matches) this estimate applies to all players on both teams.<br /><br />";
					marginInfo += "<strong>How is the round margin calculated?</strong><ul><li>If you tip the margin, your 'Round Margin' will equal 0 points/goals (like golf, lower is better).</li>";
					marginInfo += "<li>If you pick the incorrect margin, your 'Round Margin' will equal the difference between the actual individual batting score and the batting score tipped.</li></ul><br />";
					marginInfo += "<strong>How is the total margin calculated?</strong><ul><li>The 'Total Margin' is the combined sum of all the Round Margins in the tipping competition. Like the 'Round Margin', the lower your 'Total Margin' is the better ranking you will have.</li></ul><br />";
					marginInfo += "<strong>How does it affect rankings?</strong><ul><li>Round rankings will be determined by the user's weekly score for the round, then by a tippers 'Round Margin' and then by their 'Total Margin'.</li>";
					marginInfo += "<li>Leaderboard rankings will be determined by total score, and then by their 'Total Margin' and then by margin of the most recent round.</li></ul>";
				}
				else {
					var marginInfo = "<strong>What is the margin?</strong><br />Tippers are required to enter a winning team plus a margin for one game each round (the estimate number of points team A will beat team B by). It is used to separate tippers on the same score.<br /><br />";
					marginInfo += "<strong>How is the round margin calculated?</strong><ul><li>If you tip the winning Team and their exact winning margin, your 'Round Margin' will equal 0 points/goals (like golf, lower is better).</li>";
					marginInfo += "<li>If you pick the winning team, but not the winning margin, your 'Round Margin' will equal the difference between the actual game margin and the margin you tipped.</li>";
					marginInfo += "<li>If you tip the losing Team, your 'Round Margin' will equal the points/goals difference of the actual game margin PLUS the margin you tipped.</li></ul><br />";
					marginInfo += "<strong>How is the total margin calculated?</strong><ul><li>The 'Total Margin' is the combined sum of all the Round Margins in the tipping competition. Like the 'Round Margin', the lower your 'Total Margin' is the better ranking you will have.</li></ul><br />";
					marginInfo += "<strong>How does it affect rankings?</strong><ul><li>Round rankings will be determined by the user's weekly score for the round, then by a tippers 'Round Margin' and then by their 'Total Margin'.</li>";
					marginInfo += "<li>Leaderboard rankings will be determined by total score, and then by their 'Total Margin' and then by margin of the most recent round.</li></ul>";
					
				}
				
				
				if (!$("#marginHelpContainer").length)
					$('body').append('<div id="marginHelpContainer">' + marginInfo + '</div>');

				$("#marginHelpContainer").dialog({
					autoOpen: false,
					bgiframe: true,
					postition: 'center',
					modal: true,
					resizable: false,
					width: 500,
					zIndex: 3000,
					title: 'Margins Explained'
				});
				
				$("#marginHelpContainer").dialog('open');
				pageTracker._trackEvent(context, 'MarginExplained', sportCode, 0);
				
				window.onscroll = function() {
			  	$("#marginHelpContainer").dialog('option', 'position', 'center');
			  };
			}
		},
		
		Fantasy: {
			showTeam: function(sportId, thisTeam, thisRound, view, isLeaderboard) {
				var heading = 'View ' + $.Footytips.displayName + '\'s Team';
				var isTotal = '&isTotal=0';
				
				if (view == 'feeds' || $.Footytips.displayName.length == 0)
					heading = 'Team Details';
					
				if (isLeaderboard)
					isTotal = '&isTotal=1';
					
				if (!$("#viewFantasyTeam").length)
					$('body').append('<div id="viewFantasyTeam"></div>');
					
				$("#viewFantasyTeam").dialog({
					bgiframe: true,
					modal: true,
					title: heading,
					resizable: false,
					width: 720,
					height: 610,
					zIndex: 3000
				});

				getcontent('POST','/cfm/ft/sub/retrieve.cfm', 'fg=snapins&ff=teaminfo&fd=1&viewing=1&sportid=' + sportId + '&round=' + thisRound + '&teamid=' + thisTeam + isTotal, '', 'viewFantasyTeam','');
				
				$("#viewFantasyTeam").dialog('open');
				
				window.onscroll = function() {
			  	$("#viewFantasyTeam").dialog('option', 'position', 'center');
			  };
			},
			
			TeamAlertCheckBox: function(sportid, value) {
				getcontent('POST','/cfm/ft/sub/retrieve.cfm','&fg=teams&ff=setteamalertemail','&value='+value+'&sport='+sportid, '', '');
			}

		},
		
		Feeds: {
			displayedFeeds: {},
			commentPlaceHolder: 'Leave a comment...',

			showCommentInput: function(userFeedId) {
				$('#feedCommentInput_' + userFeedId).show();
				$('#feedCommentInput_' + userFeedId + ' textarea').focus();
			},
			
			postFeedComment: function(userFeedId, feedTypeId, competitionId) {
				var message = $('#feedCommentInput_' + userFeedId + ' textarea').val();
				
				if (typeof(competitionId) == 'undefined')
					competitionId = 0;
				
				if (typeof(feedTypeId) == 'undefined')
					feedTypeId = 0;
					
				getcontent('POST','/cfm/ft/sub/retrieve.cfm','&fg=feeds&ff=postFeedComment','&userFeedId=' + userFeedId + '&message=' + escape(message) + '&feedTypeId=' + feedTypeId + '&competitionId=' + competitionId, '', '$.Footytips.Feeds.handlePostedComment');
			},
			
			handlePostedComment: function(httpObj) {
				if (typeof($.Footytips.Feeds.displayedFeeds[httpObj.userFeedId]) != 'undefined')
				 $.Footytips.Feeds.displayedFeeds[httpObj.userFeedId]++;
				else 
				 $.Footytips.Feeds.displayedFeeds[httpObj.userFeedId] = 1;
				topRecords = $.Footytips.Feeds.displayedFeeds[httpObj.userFeedId];
				
				$('#feedCommentInput_' + httpObj.userFeedId + ' textarea').val($.Footytips.Feeds.commentPlaceHolder);
				$('#feedCommentInput_' + httpObj.userFeedId + ' textarea').blur();
				$.Footytips.Feeds.getFeedComments(httpObj.userFeedId, true, topRecords, httpObj.feedTypeId, httpObj.competitionId);
			},
			
			handleDisplayedComments: function(httpObj) {
				if (typeof(httpObj.removed) != 'undefined') {
			 		if (typeof(httpObj.userFeedCommentId) != 'undefined') {
			 			if (httpObj.removed) {
				 			topRecords = $.Footytips.Feeds.displayedFeeds[httpObj.userFeedId]-1;
				 			if (topRecords < 4)
				 				topRecords = 3;
				 				
				 			if (typeof(httpObj.feedTypeId) != 'undefined' && typeof(httpObj.competitionId) != 'undefined')
					 			$.Footytips.Feeds.getFeedComments(httpObj.userFeedId, true, topRecords, httpObj.feedTypeId, httpObj.competitionId);
					 		else
					 			$.Footytips.Feeds.getFeedComments(httpObj.userFeedId, true, topRecords);
				 		}
				 	}
				 	else if (httpObj.removed) {
			 			delete $.Footytips.Feeds.displayedFeeds[httpObj.userFeedId];
						$('#feedInstance_'+httpObj.userFeedId).remove();
					}
				}
				else
			 		$.Footytips.Feeds.displayedFeeds[httpObj.userFeedId] = httpObj.commentsDisplayed;
			},
			
			deleteFeed: function(userFeedId, feedTypeId, competitionId) {
				if (typeof(feedTypeId) == 'undefined')
					feedTypeId = 0;
					
				if (typeof(competitionId) == 'undefined')
					competitionId = 0;
					
				getcontent('POST','/cfm/ft/sub/retrieve.cfm','&fg=feeds&ff=removeFeed','&userFeedId=' + userFeedId + '&feedTypeId=' + feedTypeId + '&competitionId=' + competitionId, '', '$.Footytips.Feeds.handleDisplayedComments');
			},
			
			deleteFeedComment: function(userFeedId, userFeedCommentId, feedTypeId, competitionId) {
				if (typeof(feedTypeId) == 'undefined')
					feedTypeId = 0;
					
				if (typeof(competitionId) == 'undefined')
					competitionId = 0;
					
				getcontent('POST','/cfm/ft/sub/retrieve.cfm','&fg=feeds&ff=removeFeedComment', '&userFeedId=' + userFeedId + '&userFeedCommentId=' + userFeedCommentId + '&feedTypeId=' + feedTypeId + '&competitionId=' + competitionId, '', '$.Footytips.Feeds.handleDisplayedComments');
			},
			
			getFeedComments: function(userFeedId, useLiveDSN, topRecords, feedTypeId, competitionId) {
				if (typeof(useLiveDSN) == 'undefined')
					useLiveDSN = 0;
					
				if (typeof(topRecords) == 'undefined')
					topRecords = 0;
					
				if (typeof(feedTypeId) == 'undefined')
					feedTypeId = 0;
					
				if (typeof(competitionId) == 'undefined')
					competitionId = 0;
				
				getcontent('POST','/cfm/ft/sub/retrieve.cfm','&fg=feeds&ff=getFeedComments','&userFeedId=' + userFeedId + '&useLiveDSN=' + useLiveDSN + '&top=' + topRecords + '&feedTypeId=' + feedTypeId + '&competitionId=' + competitionId, 'feedCommentContainer_'+userFeedId, '$.Footytips.Feeds.handleDisplayedComments');
			},
			
			report: function(identifier, reportType) {
				if (typeof(reportType) == 'undefined')
					reportType = 'UserFeed';
					
				var formVars = '&reportType=' + reportType + '&identifier=' + identifier;
				var reportText = 'report' + reportType + '_' + identifier;
				
				getcontent('POST','/cfm/ft/sub/retrieve.cfm','&fg=feeds&ff=report', formVars, reportText, '');
			},
			
			initCommentTextAreas: function() {
				$(".ft_feedInstanceCommentsLeaveComment textarea").val($.Footytips.Feeds.commentPlaceHolder);
				
				$(".ft_feedInstanceCommentsLeaveComment textarea").focus(function() {
					var commentText = $(this).val();
					if (commentText == $.Footytips.Feeds.commentPlaceHolder) {
						$(this).val("");
						$(this).parents(".ft_feedInstanceCommentsLeaveComment").addClass("commentExpanded");
					}
				});
				
				$(".ft_feedInstanceCommentsLeaveComment textarea").blur(function() {
					var commentText = $(this).val();
					if (commentText == "" || commentText == $.Footytips.Feeds.commentPlaceHolder) {
						$(this).val($.Footytips.Feeds.commentPlaceHolder);
						$(this).parents(".ft_feedInstanceCommentsLeaveComment").removeClass("commentExpanded");
					}
				});
			}
		},
		
		FeedsModule: {
			displayedFeeds: {},

			showCommentInput: function(userFeedId) {
				$('#feedModuleCommentInput_' + userFeedId).show();
				$('#feedModuleCommentInput_' + userFeedId + ' textarea').focus();
			},
			
			postFeedComment: function(userFeedId) {
				var message = $('#feedModuleCommentInput_' + userFeedId + ' textarea').val();
				getcontent('POST','/cfm/ft/sub/retrieve.cfm','&fg=feeds&ff=postFeedComment','&userFeedId=' + userFeedId + '&message=' + escape(message), '', '$.Footytips.FeedsModule.handlePostedComment');
			},
			
			handlePostedComment: function(httpObj) {
				if (typeof($.Footytips.FeedsModule.displayedFeeds[httpObj.userFeedId]) != 'undefined')
				 $.Footytips.FeedsModule.displayedFeeds[httpObj.userFeedId]++;
				else 
				 $.Footytips.FeedsModule.displayedFeeds[httpObj.userFeedId] = 1;
				topRecords = $.Footytips.FeedsModule.displayedFeeds[httpObj.userFeedId];
				
				$('#feedModuleCommentInput_' + httpObj.userFeedId + ' textarea').val($.Footytips.Feeds.commentPlaceHolder);
				$('#feedModuleCommentInput_' + httpObj.userFeedId + ' textarea').blur();
				$.Footytips.FeedsModule.getFeedComments(httpObj.userFeedId, true, topRecords);
			},
			
			handleDisplayedComments: function(httpObj) {
				if (typeof(httpObj.removed) != 'undefined') {
					if (typeof(httpObj.userFeedCommentId) != 'undefined') {
			 			if (httpObj.removed) {
					 		topRecords = $.Footytips.FeedsModule.displayedFeeds[httpObj.userFeedId]-1;
					 		if (topRecords < 4)
					 			topRecords = 3;

					 		$.Footytips.FeedsModule.getFeedComments(httpObj.userFeedId, true, topRecords);
			 			}
				 	}
				 	else if (httpObj.removed) {
				 		delete $.Footytips.FeedsModule.displayedFeeds[httpObj.userFeedId];
						$('#feedModuleInstance_'+httpObj.userFeedId).remove();
					}
				}
				else
					$.Footytips.FeedsModule.displayedFeeds[httpObj.userFeedId] = httpObj.commentsDisplayed;
			},
			
			deleteFeed: function(userFeedId) {
				getcontent('POST','/cfm/ft/sub/retrieve.cfm','&fg=feeds&ff=removeFeed','&userFeedId=' + userFeedId, '', '$.Footytips.FeedsModule.handleDisplayedComments');
			},
			
			deleteFeedComment: function(userFeedId, userFeedCommentId) {
				getcontent('POST','/cfm/ft/sub/retrieve.cfm','&fg=feeds&ff=removeFeedComment', '&userFeedId=' + userFeedId + '&userFeedCommentId=' + userFeedCommentId, '', '$.Footytips.FeedsModule.handleDisplayedComments');
			},
			
			getFeedComments: function(userFeedId, useLiveDSN, topRecords) {
				if (typeof(useLiveDSN) == 'undefined')
					useLiveDSN = 0;
					
				if (typeof(topRecords) == 'undefined')
					topRecords = 0;
				
				getcontent('POST','/cfm/ft/sub/retrieve.cfm','&fg=feeds&ff=getFeedComments','&isFeedModule=1&userFeedId=' + userFeedId + '&useLiveDSN=' + useLiveDSN + '&top=' + topRecords, 'feedModuleCommentContainer_'+userFeedId, '$.Footytips.FeedsModule.handleDisplayedComments');
			}
		},
		
		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');
			}
		},
		
		Polls: {
			pollTopicObj: {},
			minAnswers: 2,
			maxAnswers: 5,
			maxQnChars: 255,
			answerArray: [{'answer':'','hidden':false},{'answer':'','hidden':false},{'answer':'','hidden':true},{'answer':'','hidden':true},{'answer':'','hidden':true}],
			savePollURL: '',
			closeDateTime: {},
			
			init: function(pollTopicObj, closeDateTime, minAnswers, maxAnswers, maxQnChars, savePollURL) {
				$.Footytips.Polls.pollTopicObj = pollTopicObj;
				$.Footytips.Polls.closeDateTime = closeDateTime;
				$.Footytips.Polls.minAnswers = minAnswers;
				$.Footytips.Polls.maxAnswers = maxAnswers;
				$.Footytips.Polls.maxQnChars = maxQnChars;
				$.Footytips.Polls.savePollURL = savePollURL;
				
				$.Footytips.Polls.countQnChar();
				
				$("#customDatePlaceHolder").html('<input type="text" id="datepicker" readonly /><input style="display:none;" type="hidden" name="endDate" id="endDate" readonly />');
				
				$("#datepicker").datepicker({
					dateFormat: 'dd/mm/yy',
					showOn: 'both',
					buttonImage: '/images/calendar.gif',
					buttonImageOnly: true,
					altField: '#endDate',
					altFormat: 'yy-mm-dd',
					maxDate: '+4w',
					minDate: '0'
				});
				
				$("#datepicker").datepicker('disable');
				
				$(".ft_pollsCreateSettingsSport").mouseover(function() {
					$.Footytips.Polls.highlightActiveStep('step1');
				});
				
				$(".ft_formRadio").parent().mouseover(function() {
					$.Footytips.Polls.highlightActiveStep('step4');
				});
				
				$("#ui-datepicker-div").mouseover(function() {
					$.Footytips.Polls.highlightActiveStep('step4');
				});
				
				$("#question").each(function() {
					$(this).keyup(function() {
		    		$.Footytips.Polls.countQnChar();
						$.Footytips.Polls.highlightActiveStep('step2');
					});
					
					$(this).focus(function(event) {
						$(this).addClass("ft_formInputActive");
						$.Footytips.Polls.highlightActiveStep('step2');
					});
					
					$(this).blur(function(event) {
						$(this).removeClass("ft_formInputActive");
					});
				});
				
				$("#previewPollButton").mouseover(function() {
					$.Footytips.Polls.highlightActiveStep('step5');
				});
				
				for (var i = 0; i < $.Footytips.Polls.answerArray.length; i++) {
					var ans = i + 1;
					
					$("#answer"+ans).keyup(new Function(
						'$.Footytips.Polls.storeAnswers(); \
						$.Footytips.Polls.highlightActiveStep(\'step3\'); \
						if ($(this).val().length > 0) $("#ansIcon'+ans+'").addClass("ft_icon16AllGood"); \
						else $("#ansIcon'+ans+'").removeClass("ft_icon16AllGood");'
					));
					
					$("#answer"+ans).focus(new Function(
						'$(this).addClass("ft_formInputActive"); \
						$.Footytips.Polls.highlightActiveStep(\'step3\');'
					));
					
					$("#answer"+ans).blur(new Function(
						'$(this).removeClass("ft_formInputActive"); '
					));
					
					$("#js_answer"+ans+"_delete").click(new Function('event',
						'$.Footytips.Polls.deleteAnswer('+ans+');\
						$("#answer'+ans+'").focus(); \
						event.preventDefault();'
					));
					
					if (ans < $.Footytips.Polls.answerArray.length)
						$("#js_answer"+ans+"_moveDown").click(new Function('event', '$.Footytips.Polls.reOrder('+ans+', 1); event.preventDefault();'));
					
					if (ans > 1)
						$("#js_answer"+ans+"_moveUp").click(new Function('event', '$.Footytips.Polls.reOrder('+ans+', -1); event.preventDefault();'));
					
					if ($.Footytips.Polls.answerArray[i].hidden)
						$("#js_answer"+(i+1)).hide();
				}
				
				$.Footytips.Polls.getLastShownAnswer(true);
				$.Footytips.Polls.storeAnswers();
						
				$("#js_btnAddAnswer").click(function(event) {
					$.Footytips.Polls.compactAnswers()
					var highestShown =$.Footytips.Polls. getLastShownAnswer(false);
					var nextToShow = highestShown+1;
					var shownAnswers = $.Footytips.Polls.countTotalShown();
					
					if (shownAnswers < $.Footytips.Polls.answerArray.length) {
						$.Footytips.Polls.answerArray[nextToShow].hidden = false;
						$("#js_answer"+(nextToShow+1)).show("fast");
						shownAnswers++;
						$.Footytips.Polls.getLastShownAnswer(true)
					}
					
					if (shownAnswers >= $.Footytips.Polls.answerArray.length)
						$("#js_btnAddAnswer").hide();
					
					event.preventDefault();
				});
				
				$("#previewPollButton").click(function(event) {
					
					$("#pollPreviewContentContainer").dialog({
						bgiframe: true,
						modal: true,
						resizable: false,
						width: 470,
						zIndex: 3000,
						title: 'Poll Preview'
					});
					
					postStr = '&pollTopicId='+$("#pollTopicId").val();
					postStr += '&question='+escape($("#question").val());
					postStr += '&endDateTime='+escape($.Footytips.Polls.getEndDate());
					for (var i = 0; i < $.Footytips.Polls.answerArray.length; i++) {
						ansNum = i+1;
						if (!$.Footytips.Polls.answerArray[i].hidden)
							postStr += '&answer'+ansNum+'='+escape($.Footytips.Polls.answerArray[i].answer);
					}
					getcontent('POST','/cfm/ft/sub/retrieve.cfm','&fg=polls&ff=pollPreview&loadType=ajax',postStr, 'pollPreviewContent', '$.Footytips.Polls.handlePreview');
					
					$("#pollPreviewContentContainer").dialog('open');
					event.preventDefault();
				});
				
				$.Footytips.Polls.detectCustomDate();
				
			},
			
			handlePreview: function(httpObj) {
				if (!httpObj.valid)
					$("#pollPreviewContentContainer").dialog('option', 'buttons', {
						'Close': function() {
							$(this).dialog('close')
						}
					});
				else {
					$("#pollPreviewContentContainer").dialog('option', 'buttons', {
						'No, I\'ll make changes': function() {
							$(this).dialog('close');
						},
						'Yes, Create My Poll': function() {
							$.Footytips.Polls.createPoll();
						}
					});
				}
			},
					
			getEndDate: function() {
				if ($("input[@name='closes']:checked").val() == 'customDate')
					closeDateTime.customDate = $("#endDate").val() + ' ' + $("#endTime").val();
				
				return closeDateTime[$("input[@name='closes']:checked").val()];
			},
			
			selectTopic: function(pollTopicId) {
				ftHideDDMenu('pollTopicSelector');
				$("#pollTopicId").val(pollTopicId);
				$("#pollTopicSelectorDropDownTitle").html($.Footytips.Polls.pollTopicObj[pollTopicId].desc);
				$("#pollTopicSelectorDropDown").siblings(".ftCompsDDTitleIcon").children(0).attr('class', $.Footytips.Polls.pollTopicObj[pollTopicId].icon);
			},
			
			detectCustomDate: function() {
				if ($("input[@name='closes']:checked").val() == 'customDate') {
					$("#datepicker").datepicker('enable');
					$("#endTime").attr('disabled', false);
				}
				else {
					$("#datepicker").datepicker('disable');
					$("#endTime").attr('disabled', true);
				}
			},
			
			storeAnswers: function() {
				for (var i = 0; i < $.Footytips.Polls.answerArray.length; i++) {
					var ansNum = i+1;
					$.Footytips.Polls.answerArray[i].answer = $("#answer" + ansNum).val();
				}
			},
			
			countQnChar: function() {
	   		var str = $("#question").val();
	   		var qCount = str.length;
	   		if (qCount > $.Footytips.Polls.maxQnChars)
	   			$("#js_pollsCreateCountInfo").attr('class', 'specialfont');
	   		else
	   			$("#js_pollsCreateCountInfo").attr('class', '');
	   			
		    $("#js_pollsCreateCount").html(qCount);
			},
			
			compactAnswers: function() {
				var ansArrCopy = [{'answer':'','hidden':true},{'answer':'','hidden':true},{'answer':'','hidden':true},{'answer':'','hidden':true},{'answer':'','hidden':true}];
				var startAt = 0;
				for (var i = 0; i < $.Footytips.Polls.answerArray.length; i++) {
					if (!$.Footytips.Polls.answerArray[i].hidden) {
						ansArrCopy[startAt].hidden = $.Footytips.Polls.answerArray[i].hidden;
						ansArrCopy[startAt].answer = $.Footytips.Polls.answerArray[i].answer;
						startAt++;
					}
				}
				
				for (var i = 0; i < ansArrCopy.length; i++) {
					$.Footytips.Polls.answerArray[i].answer = ansArrCopy[i].answer;
					$.Footytips.Polls.answerArray[i].hidden = ansArrCopy[i].hidden;
				}
				
				for (var i = 0; i < $.Footytips.Polls.answerArray.length; i++) {
					var ansNum = i+1;
					$("#answer"+ansNum).val($.Footytips.Polls.answerArray[i].answer);
					if ($.Footytips.Polls.answerArray[i].hidden)
						$("#js_answer"+ansNum).hide();
					else {
						$("#js_answer"+ansNum).show();
					}
				}
				
				$.Footytips.Polls.getLastShownAnswer(true);
			},
			
			deleteAnswer: function(ansNum) {
				if ($.Footytips.Polls.countTotalShown() > $.Footytips.Polls.minAnswers)
					$.Footytips.Polls.answerArray[ansNum-1].hidden = true;
				else
					$.Footytips.Polls.answerArray[ansNum-1].answer = '';
	
				$.Footytips.Polls.compactAnswers()
				if ($.Footytips.Polls.countTotalShown() < $.Footytips.Polls.answerArray.length)
					$("#js_btnAddAnswer").show("fast");
			},
			
			reOrder: function(ansNum, movement) {
				// movement: -1 (Up), 1 (Down)
				var otherAnsNum = ansNum + movement;
				var thisVal = $("#answer" + ansNum).val();
				var swapVal = $("#answer" + otherAnsNum).val();
				$.Footytips.Polls.answerArray[ansNum-1].answer = swapVal;
				$.Footytips.Polls.answerArray[(ansNum + movement - 1)].answer = thisVal;
				
				$.Footytips.Polls.compactAnswers()
			},
			
			getLastShownAnswer: function(hideSortButtons) {
				var highestShown = -1;
				for (var i = 0; i < $.Footytips.Polls.answerArray.length; i++) {
					if (!$.Footytips.Polls.answerArray[i].hidden) {
						highestShown = i;
					}
				}
				
				var totalShown = $.Footytips.Polls.countTotalShown();
				for (var i = 0; i < totalShown; i++) {
					var ansNum = i+1;
					if (ansNum == 1) {
						$("#js_answer"+ansNum+"_moveUp").removeClass('ft_icon16ArrowUp');
						$("#js_answer"+ansNum+"_moveUp").addClass('ft_icon16ArrowUpInactive');
					}
					else if (ansNum == totalShown) {
						$("#js_answer"+ansNum+"_moveDown").removeClass('ft_icon16ArrowDown');
						$("#js_answer"+ansNum+"_moveDown").addClass('ft_icon16ArrowDownInactive');
					}
					else {
						$("#js_answer"+ansNum+"_moveUp").removeClass('ft_icon16ArrowUpInactive');
						$("#js_answer"+ansNum+"_moveUp").addClass('ft_icon16ArrowUp');
						$("#js_answer"+ansNum+"_moveDown").removeClass('ft_icon16ArrowDownInactive');
						$("#js_answer"+ansNum+"_moveDown").addClass('ft_icon16ArrowDown');
					}
				}
	
				return highestShown;
			},
			
			countTotalShown: function() {
				var shownAnswers = 0;
				for (var i = 0; i < $.Footytips.Polls.answerArray.length; i++) {
					if (!$.Footytips.Polls.answerArray[i].hidden)
						shownAnswers++;
				}
				return shownAnswers;
			},
			
			createPoll: function() {
				$("form#frmCreatePoll").attr('action', $.Footytips.Polls.savePollURL)
				$("form#frmCreatePoll").submit();
			},
			
			highlightActiveStep: function(stepId) {
				$("div.ft_formStepActive").attr('class','ft_formStepInActive');
				$("#"+stepId).attr('class','ft_formStepActive');
			},
			
			
			viewNetworkVotes: function(pollId, ansNum) {
				var heading = "Who Voted For What?";
				if (ansNum === null)
					heading = "People you know who have voted";

				if (!$("#viewNetworkVotesContainer").length)
					$('body').append('<div id="viewNetworkVotesContainer"></div>');
					
				
				$("#viewNetworkVotesContainer").dialog({
					bgiframe: true,
					modal: true,
					title: heading,
					resizable: false,
					width: 420,
					zIndex: 3000,
					buttons: {
						'Close': function() {
							$(this).dialog("close");
						}
					}
				});

				getcontent('POST','/cfm/ft/sub/retrieve.cfm','&fg=polls&ff=networkVotes&pollId=' + pollId + '&answer=' + ansNum,'', 'viewNetworkVotesContainer', '');
				
				$("#viewNetworkVotesContainer").dialog('open');
				
				window.onscroll = function() {
			  	$("#viewNetworkVotesContainer").dialog('option', 'position', 'center');
			  };
			}
		},
		
		Profiles: {
			defaultText: "What\'s on your mind?",
			
			currentStatusMsg: '',
			
			sportId: '',
			
			detectSubmit: function(event) {
				var keynum;
				var keychar;
				var numcheck;
				
				if (window.event)
					keynum = event.keyCode;
				else if (event.which)
					keynum = event.which;
				
				if (keynum == 13) {
					$.Footytips.Profiles.saveStatus();
				}
			},
			
			saveStatus: function() {
				if (!$("#tempStatusMsg").length)
					$('body').append('<div id="tempStatusMsg" style="display:none;"></div>');
					
				if ($("#statusMessage").length)
					if ($("#statusMessage").val() != $.Footytips.Profiles.currentStatusMsg)
						getcontent('POST','/cfm/ft/sub/retrieve.cfm','&fg=profile&ff=setUserStatus','statusMessage=' + escape($("#statusMessage").val()), 'profileStatusMessage', '$.Footytips.Profiles.setStatusMessage');
					else {
						if ($("#statusMessage").val() == "What's on your mind?")
							var httpObj = {'saved': false, 'statusMessage': $.Footytips.Profiles.currentStatusMsg, 'useDefault': true};
						else
							var httpObj = {'saved': false, 'statusMessage': $.Footytips.Profiles.currentStatusMsg, 'useDefault': false};
						$.Footytips.Profiles.setStatusMessage(httpObj);
					}
			},
			
			clearStatus: function() {
				if (!$("#tempStatusMsg").length)
					$('body').append('<div id="tempStatusMsg" style="display:none;"></div>');
					
				getcontent('POST','/cfm/ft/sub/retrieve.cfm','&fg=profile&ff=setUserStatus','statusMessage=', 'profileStatusMessage', '$.Footytips.Profiles.setStatusMessage');
			},
			
			setStatusMessage: function(httpObj) {
				if ($.Footytips.Profiles.currentStatusMsg != unescape(httpObj.statusMessage))
					$.Footytips.Profiles.currentStatusMsg = unescape(httpObj.statusMessage);
				
				$.Footytips.Profiles.initStatusInput();
			},
			
			initStatusInput: function() {
				$("#statusMessage").focus(function() {
					$("#statusSubmit").show();
					$(".ft_profileTitleStatusInput").removeClass("ft_profileTitleStatusInputHover");
					$(".ft_profileTitleStatusInput").addClass("ft_profileTitleStatusInputFocus");
				});
				
				$("#statusMessage").mouseover(function() {
					$(".ft_profileTitleStatusInput").addClass("ft_profileTitleStatusInputHover");
				});
				
				$("#statusMessage").mouseout(function() {
					$(".ft_profileTitleStatusInput").removeClass("ft_profileTitleStatusInputHover");
				});
			},
			
			toggleMoreSports: function(obj) {
				var linkText = {more: 'More Sports', less: 'Less Sports'};
				var sportIsEnabled = false;
				if (obj.enabledSports.length > 0) {
					var sportArr = obj.enabledSports.split(',');
					for (var i=0; i < sportArr.length; i++) {
						if (sportArr[i] == obj.sportView)
							sportIsEnabled = true;
					}
				}
								
				if (obj.sportView == 0 || sportIsEnabled || obj.event == 'click') {
					if ($(".ft_profileMoreSportsTab").is(":hidden")) {
						$(".ft_profileMoreSportsTab").slideDown("fast");
						$("#profileMoreSportsLink").html(linkText.less)
					}
					else {
						$(".ft_profileMoreSportsTab").slideUp("fast");
						$("#profileMoreSportsLink").html(linkText.more)
					}
				}
				else {
					$("#profileMoreSportsLink").html(linkText.less)
				}
			},
			
			getMatesLadder: function(event, sportId, ladderView) {
				if ($("#profileMatesLadder").length) {
					getcontent('POST','/cfm/ft/sub/retrieve.cfm','&fg=profile&ff=getMatesLadder&userId=' + $.Footytips.userId + '&sportId=' + sportId + '&ladderView='+ladderView,'', 'profileMatesLadder', '');
				}
				
				event.preventDefault();
			},
			
			refreshMySportsNav: function(httpObj) {
				$("#profileMySportsNav").html(unescape(httpObj.content));
			},
			
			showMySportsSettings: function(sportView) {
				if (!$("#mySportsSettings").length)
					$('body').append('<div id="mySportsSettings"></div>');
					
				$("#mySportsSettings").dialog({
					bgiframe: true,
					modal: true,
					title: 'My Sport Settings',
					resizable: false,
					width: 420,
					height: 400,
					zIndex: 3000,
					buttons: {
						"Cancel": function() {
							$(this).dialog("close");
						},
						"Update Settings": function() {
							var sportIdList = '';
							var defaultView = 0;
							var hasDefaultView = false;
							var formStr = '';
							
							$("input:radio[name=defaultView]").each(function() {
								if ($(this).attr('checked'))
									defaultView = $(this).val();
							});
							
							$("#mySportsSettings input:checkbox[name=enabledSportId]").each(function(){
								if ($(this).attr('checked')) {
									if (sportIdList.length > 0)
										sportIdList += ','; 
										
									sportIdList += $(this).val();
									
									if ($(this).val() == defaultView)
										hasDefaultView = true;
								}
							});
							
							if (!hasDefaultView && defaultView != 0) {
								if (sportIdList.length > 0)
										sportIdList += ','; 
										
									sportIdList += defaultView;
							}
							
							formStr += '&enabledSportId=' + escape(sportIdList);
							if (!isNaN(defaultView))
								formStr += '&defaultView=' + defaultView;
							
							$("#mySportsSettings").dialog('close');
							
							getcontent('POST','/cfm/ft/sub/retrieve.cfm', '&fg=profile&ff=mySportsSettings&sportView=' + sportView, formStr, 'mySportsSettings', '$.Footytips.Profiles.refreshMySportsNav');
						}
					}
				});
				
				getcontent('POST','/cfm/ft/sub/retrieve.cfm', '&fg=profile&ff=mySportsSettings&userId=' + $.Footytips.userId + '&sportView=' + sportView, '', 'mySportsSettings', '');
				
				$("#mySportsSettings").dialog('open');
				
				window.onscroll = function() {
			  	$("#mySportsSettings").dialog('option', 'position', 'center');
			  };
			},
			
			saveHistorySettings: function(sportId, season, show, current) {
				if (!$("#tempData").length)
					$('body').append('<div id="tempData" style="display: none;"></div>');
					
				getcontent('POST','/cfm/ft/sub/retrieve.cfm','fg=profile&ff=saveScoreSettings&sportid=' + sportId + '&season=' + season + '&show=' + show + '&current=' + current, '', 'tempData', '$.Footytips.Profiles.refreshHistory');
			},
			
			refreshHistory: function(httpObj) {
				$.Footytips.Profiles.getGraphInfo(httpObj.sportId, httpObj.seasonYear, 'tip', 'ft_graph', 'HistoryData', httpObj.round);
			},
			
			getGraphInfo: function(sportId, seasonYear, tipType, graphName, graphType, round) {
				var urlStr = ''
				urlStr += '&userId=' + $.Footytips.userId;
				urlStr += '&sportId=' + sportId;
				urlStr += '&seasonYear=' + seasonYear;
				urlStr += '&tipType=' + tipType;
				urlStr += '&graphName=' + graphName;
				urlStr += '&graphType=' + graphType;
				if (typeof(round) != 'undefined') {
					urlStr += '&round=' + round;
				}
				
				getcontent('POST','/cfm/ft/sub/retrieve.cfm','&fg=profile&ff=getProfileGraphData' + urlStr, '', tipType+'GraphInfo', '$.Footytips.Graphs.getGraph');
			},
			
			checkInput: function(theForm) {
				if (theForm.searchCriteria.value.length == 0) {
					alert('Please enter a keyword to find a tipping competition.');
					return false;
				}
				return true;
			},
			
			forwardToComp: function(selectedItem) {
				var tipType = selectedItem.substr(0,2);
				var compSelector = selectedItem.split("_")[1];

				if (tipType == "tip") {
					if (compSelector == "createJoin")
						location.href = 'engine.cfm?l1=Competitions&l2=Competitions.MyComps';
					else if (typeof(compSelector) != 'undefined')
						location.href = 'engine.cfm?l1=Competitions&l2=Competitions.MyComps&total=1&fg=competitions&ff=ladders&competitionId='+compSelector;
				}
				else {
					if (compSelector == "createJoin")
						location.href = 'engine.cfm?l1=Fantasy&l2=Fantasy.Leagues';
					else if (typeof(compSelector) != 'undefined')
						location.href = 'engine.cfm?l1=Fantasy&l2=Fantasy.Leagues&allRounds=1&prm=2&fg=leagues&ff=ladderPage&competitionId='+compSelector;
				}
			},
			
			updateAvatar: function() {
				if (!$("#uploadAvatar").length)
					$('body').append('<div id="uploadAvatar"></div>');
					
				var buttonObj = {
					"Cancel": function() {
						$(this).dialog("close");
					},
					"Upload": function() {
						getcontent('POST','/cfm/ft/sub/retrieve.cfm', '&fg=profile&ff=updateAvatar&action=update','&uploadAvatar='+escape($("#uploadAvatarFile").val()), 'uploadAvatar', '$.Footytips.Profiles.refreshProfileModule');
					}
				};
					
				$("#uploadAvatar").dialog({
					bgiframe: true,
					modal: true,
					title: 'Update Avatar',
					resizable: false,
					width: 420,
					height: 200,
					zIndex: 3000
				});
				
				$("#uploadAvatar").dialog('option', 'buttons', buttonObj);
				
				getcontent('POST','/cfm/ft/sub/retrieve.cfm', '&fg=profile&ff=updateAvatar', '', 'uploadAvatar', '');
				
				$("#uploadAvatar").dialog('open');
				
				window.onscroll = function() {
			  	$("#uploadAvatar").dialog('option', 'position', 'center');
			  };
			},
						
			refreshProfileModule: function(httpObj) {
				if (typeof(httpObj.content) != 'undefined') {
					var buttonObj = {'Close': function() { $(this).dialog('close'); }};
					$("#" + httpObj.windowName).dialog('option', 'buttons', buttonObj);
					
					$("#profileUserModule").html(unescape(httpObj.content));
				}
				else
					$("#" + httpObj.windowName).dialog('close');
			},
			
			updateProfile: function() {
				if (!$("#updateProfileSettings").length)
					$('body').append('<div id="updateProfileSettings"></div>');
					
				var buttonObj = {
					"Cancel": function() {
						$(this).dialog("close");
					},
					"Update": function() {
						
						var formString = 'displayGender=';
						if ($("#displayGender").attr('checked'))
							formString += 1;
						else
							formString += 0;
						
						formString += '&displayLocation=';
						if ($("#displayLocation").attr('checked'))
							formString += 1;
						else
							formString += 0;
						
						formString += '&displayFavTeams=';
						if ($("#displayFavTeams").attr('checked'))
							formString += 1;
						else
							formString += 0;
						
						getcontent('POST','/cfm/ft/sub/retrieve.cfm', '&fg=profile&ff=updateProfileSettings&action=update', formString, 'updateProfileSettings', '$.Footytips.Profiles.refreshProfileModule');
					}
				};
						
				$("#updateProfileSettings").dialog({
					bgiframe: true,
					modal: true,
					title: 'Update Profile Settings',
					resizable: false,
					width: 420,
					height: 200,
					zIndex: 3000
				});
				
				$("#updateProfileSettings").dialog('option', 'buttons', buttonObj);
				
				getcontent('POST','/cfm/ft/sub/retrieve.cfm', '&fg=profile&ff=updateProfileSettings', '', 'updateProfileSettings', '');
				
				$("#updateProfileSettings").dialog('open');
				
				window.onscroll = function() {
			  	$("#updateProfileSettings").dialog('option', 'position', 'center');
			  };
			},
			
			updatePrivacy: function(context) {
				if (!$("#updateProfilePrivacy").length)
					$('body').append('<div id="updateProfilePrivacy"></div>');
					
				var buttonObj = {
					"Cancel": function() {
						$(this).dialog("close");
					},
					"Update": function() {
						
						var formString = 'displayFeeds=';
						if ($("#updateProfilePrivacy input:radio[name=displayFeeds]").attr('checked'))
							formString += $("#updateProfilePrivacy input:radio[name=displayFeeds]").val();
						
						formString += '&displayComments=';
						if ($("#updateProfilePrivacy input:radio[name=displayComments]").attr('checked'))
							formString += $("#updateProfilePrivacy input:radio[name=displayComments]").val();
						
						formString += '&displayCommentInput=';
						if ($("#updateProfilePrivacy input:radio[name=displayCommentInput]").attr('checked'))
							formString += $("#updateProfilePrivacy input:radio[name=displayCommentInput]").val();
						
						getcontent('POST','/cfm/ft/sub/retrieve.cfm', '&fg=profile&ff=updateProfilePrivacy&action=update&context='+context, formString, 'updateProfilePrivacy', '');
					}
				};
						
				$("#updateProfilePrivacy").dialog({
					bgiframe: true,
					modal: true,
					title: 'Update Profile Settings',
					resizable: false,
					width: 420,
					height: 300,
					zIndex: 3000
				});
				
				$("#updateProfilePrivacy").dialog('option', 'buttons', buttonObj);
				
				getcontent('POST','/cfm/ft/sub/retrieve.cfm', '&fg=profile&ff=updateProfilePrivacy&context='+context, '', 'updateProfilePrivacy', '');
				
				$("#updateProfilePrivacy").dialog('open');
				
				window.onscroll = function() {
			  	$("#updateProfilePrivacy").dialog('option', 'position', 'center');
			  };
			}
		},
		
		Mates: {
			addMate: function(userId) {
				if (!$("#addMateDialog").length)
					$('body').append('<div id="addMateDialog"></div>');
				
				$("#addMateDialog").dialog({
					bgiframe: true,
					modal: true,
					title: 'Add as Mate',
					resizable: false,
					width: 420,
					zIndex: 3000,
					buttons: {
						'Close': function() {
							$(this).dialog("close");
						}
					}
				});
				
				$("#addMateDialog").dialog('open');
				
				window.onscroll = function() {
			  	$("#addMateDialog").dialog('option', 'position', 'center');
			  };
			}
		},
		
		Graphs: {
			graphObj: '',
			
			createGraph: function(divId, formatting, width, height, bgcolor) {
				if (!$('#' + divId).length)
					$('body').append('<div id="' + divId + '"></div>');
				
				if (typeof(width) == 'undefined')
					width = '100%';
				
				if (typeof(height) == 'undefined')
					height = '100%';
					
				if (typeof(bgcolor) == 'undefined')
					bgcolor = '#FFFFFF';
				
				$.Footytips.Graphs.graphObj = new SWFObject("/swf/open-flash-chart.swf?r=" + new Date().getTime(), divId + "_ofc", width, height, "9.0.0", bgcolor);
				$.Footytips.Graphs.graphObj.addVariable("variables","true");
				$.Footytips.Graphs.graphObj.addVariable("set_data", formatting);
				$.Footytips.Graphs.graphObj.addParam("allowScriptAccess", "always");
				$.Footytips.Graphs.graphObj.addParam("wmode", "transparent");
			},
			
			drawGraph: function(divId, formatting) {
				if (typeof($.Footytips.Graphs.graphObj) != 'object')
					$.Footytips.Graphs.createGraph(divId, formatting);
					
				$.Footytips.Graphs.graphObj.write(divId);
			},
			
			getGraph: function(httpObj) {
				if (typeof(httpObj.view) != 'undefined' && typeof(httpObj.graphData) != 'undefined' && httpObj.view == 'graph') {
					if (typeof($.Footytips.Graphs.graphObj) != 'object')
						$.Footytips.Graphs.createGraph(ttpObj.graphName, httpObj.graphData);
						
					$.Footytips.Graphs.graphObj.addVariable("set_data", httpObj.graphData);
					$.Footytips.Graphs.graphObj.write(httpObj.graphName);
					//$.Footytips.Graphs.drawGraph(httpObj.graphName, httpObj.graphData);
				}
			}
		},
		
		Competitions: {
			sendMemberPassword: function(competitionId, userId) {
				if (!$("#sendPasswordDialog").length)
						$('body').append('<div id="sendPasswordDialog"></div>');
						
				$("#sendPasswordDialog").dialog({
					autoOpen: false,
					bgiframe: true,
					position: 'center',
					modal: true,
					title: 'Send Password',
					resizable: false,
					width: 440,
					zIndex: 3000,
					buttons: {
						'Close': function() {
							$(this).dialog('close');
						}
					}
				});
				
				if ($.Footytips.initialised) {
					getcontent('POST','/cfm/ft/sub/retrieve.cfm','&fg=competitions&ff=adminSendPassword', 'userId=' + userId + '&competitionId=' + competitionId, 'sendPasswordDialog', '');
					
					$("#sendPasswordDialog").dialog('open');
					
					window.onscroll = function() {
				  	$("#sendPasswordDialog").dialog('option', 'position', 'center');
				  };
				}
			},
			
			removeMemberConfirm: function(competitionId, userId) {
				if (!$("#removeCompMemberDialog").length)
						$('body').append('<div id="removeCompMemberDialog"></div>');
						
				$("#removeCompMemberDialog").dialog({
					autoOpen: false,
					bgiframe: true,
					position: 'center',
					modal: true,
					title: 'Remove Member',
					resizable: false,
					width: 440,
					zIndex: 3000
				});
				
				if ($.Footytips.initialised)
					getcontent('POST','/cfm/ft/sub/retrieve.cfm','&fg=competitions&ff=adminRemoveMember', '&action=confirm&userId=' + userId + '&competitionId=' + competitionId, 'removeCompMemberDialog', '$.Footytips.Competitions.handleRemoveMember');
			},
			
			removeMember: function(httpObj) {
				var buttonObj = {
					'Close': function() {
						$(this).dialog('close');
					}
				};
				
				if ($("#compMembersTable_"+httpObj.userId).length) {
					$("#compMembersTable_"+httpObj.userId).remove();
				}
				
				$("#removeCompMemberDialog").dialog('option', 'buttons', buttonObj);
			},

			handleRemoveMember: function(httpObj) {
				var buttonObj = new Object();
				if (httpObj.action == 'confirm') {
					if (httpObj.isSelf) {
						buttonObj = {
							'Close': function() {
								$(this).dialog('close');
							},
							'Leave': function() {
								getcontent('POST','/cfm/ft/sub/retrieve.cfm','&fg=competitions&ff=adminRemoveMember', '&action=remove&userId=' + httpObj.userId + '&competitionId=' + httpObj.competitionId, 'removeCompMemberDialog', '$.Footytips.Competitions.removeMember');
							}
						};
					}
					else {
						buttonObj = {
							'Close': function() {
								$(this).dialog('close');
							},
							'Remove': function() {
								getcontent('POST','/cfm/ft/sub/retrieve.cfm','&fg=competitions&ff=adminRemoveMember', '&action=remove&userId=' + httpObj.userId + '&competitionId=' + httpObj.competitionId, 'removeCompMemberDialog', '$.Footytips.Competitions.removeMember');
							}
						};
					}
				}
				else {
					buttonObj = {
						'Close': function() {
							$(this).dialog('close');
						}
					};
				}
				
				$("#removeCompMemberDialog").dialog('option', 'buttons', buttonObj);
				
				$("#removeCompMemberDialog").dialog('open');
				
				window.onscroll = function() {
			  	$("#removeCompMemberDialog").dialog('option', 'position', 'center');
			  };
			},
			
			adjustScores: function(competitionId, userId) {
				var formStr = 'competitionId=' + competitionId;
				formStr += '&userId=' + userId;
				if (!$("#adjustScoresDialog").length)
						$('body').append('<div id="adjustScoresDialog"></div>');
						
				$("#adjustScoresDialog").dialog({
					autoOpen: false,
					bgiframe: true,
					position: 'center',
					modal: true,
					title: 'Adjust Scores',
					resizable: false,
					width: 440,
					height: 400,
					zIndex: 3000					
				});
				
				if ($.Footytips.initialised) {
					getcontent('POST','/cfm/ft/sub/retrieve.cfm','&fg=competitions&ff=adminAdjustScores', formStr, 'adjustScoresDialog', '$.Footytips.Competitions.handleAdjustScores');
					
					$("#adjustScoresDialog").dialog('open');
					
					window.onscroll = function() {
				  	$("#adjustScoresDialog").dialog('option', 'position', 'center');
				  };
				}
			},
			
			adjustScoresFilter: function(competitionId, userId, sportId, gameCompId) {
				var formStr = 'competitionId=' + competitionId;
				formStr += '&userId=' + userId;
				formStr += '&sportId=' + sportId;
				if (typeof(gameCompId) != 'undefined') {
					formStr += '&gameCompId=' + gameCompId;
				}
				
				getcontent('POST','/cfm/ft/sub/retrieve.cfm','&fg=competitions&ff=adminAdjustScores', formStr, 'adjustScoresDialog', '$.Footytips.Competitions.handleAdjustScores');
			},
			
			updateAdjustedScores: function(competitionId, userId, sportId, gameCompId) {
				var formStr = 'competitionId=' + competitionId;
				formStr += '&userId=' + userId;
				formStr += '&sportId=' + sportId;
				formStr += '&gameCompId=' + gameCompId;
				formStr += '&action=update';
				
				$("input:text[name*=adjustedScore_]").each(function() {
					if (!isNaN($(this).val()))
						formStr += '&' + $(this).attr('name') + '=' + $(this).val();
				});
				
				getcontent('POST','/cfm/ft/sub/retrieve.cfm','&fg=competitions&ff=adminAdjustScores', formStr, 'adjustScoresDialog', '$.Footytips.Competitions.handleAdjustScores');
			},
			
			handleAdjustScores: function(httpObj) {
				var buttonObj = new Object();
				if (httpObj.hasDetails) {
					buttonObj = {
						'Close': function() {
							$(this).dialog('close');
						},
						'Update': function() {
							$.Footytips.Competitions.updateAdjustedScores(httpObj.competitionId, httpObj.userId, httpObj.sportId, httpObj.gameCompId);
						}
					};
				}
				else {
					buttonObj = {
						'Close': function() {
							$(this).dialog('close');
						}
					};
				}
				
				$("#adjustScoresDialog").dialog('option', 'buttons', buttonObj);
			},
			
			togglePayment: function(competitionId, userId) {
				var targetEID = 'compPayment_' + userId;
				var formStr = 'competitionId=' + competitionId;
				formStr += '&userId=' + userId;
						
				getcontent('POST','/cfm/ft/sub/retrieve.cfm','&fg=competitions&ff=togglePayment', formStr, targetEID, '');
			},
			
			report: function(id) {
				var urlVars = '&messageId=' + id;
				var reportEl = 'reportPost_'+ id;

				getcontent('POST','/cfm/ft/sub/retrieve.cfm','&fg=competitions&ff=report'+urlVars, '', reportEl, '');
			},
			
			previewInvite: function(competitionId, inviteMessage) {
				var urlStr = '&competitionId=' + competitionId;
				urlStr += '&inviteMessage=' + inviteMessage;
				if (!$("#previewInviteDialog").length)
						$('body').append('<div id="previewInviteDialog"></div>');
						
				$("#previewInviteDialog").dialog({
					autoOpen: false,
					bgiframe: true,
					position: 'center',
					modal: true,
					title: 'Preview Invitation',
					resizable: false,
					width: 615,
					height: 400,
					zIndex: 3000,
					buttons: {
						'Close': function() {
							$(this).dialog('close');
						}
					}				
				});
				
				getcontent('POST','/cfm/ft/sub/retrieve.cfm','&fg=competitions&ff=invitePreview'+ urlStr, '', 'previewInviteDialog', '');
				
				$("#previewInviteDialog").dialog('open');
				
				window.onscroll = function() {
			  	$("#previewInviteDialog").dialog('option', 'position', 'center');
			  };
				
			},
			
			getCompSummaryDetails: function(competitionId, sportId) {
				$('#myCompsInstance_'+competitionId).each(function() {
					getcontent('POST','/cfm/ft/sub/retrieve.cfm','&fg=competitions&ff=summaryModule&loadType=ajax&competitionId='+competitionId+'&sportView='+sportId, '', $(this).attr('id'), '');
				});
			},
			
			toggleCompSummaryDisplay: function(thisEl, competitionId, sportId) {
				if ($(thisEl).is('.ft_icon16Expand')) {
					$('#myCompsInstance_'+competitionId).each(function() {
						if ($(this).html().trim().length == 0)
							$.Footytips.Competitions.getCompSummaryDetails(competitionId, sportId);
							 
						$(this).show();
					});
					$(thisEl).attr('className', 'ft_icon16Contract');
				}
				else {
					$('#myCompsInstance_'+competitionId).each(function() {
						$(this).hide();
					});
					$(thisEl).attr('className', 'ft_icon16Expand');
				}
			}
		}
	}
});