TruthGame={inputTextLimit:75,inputTextMin:3,activateTruthGameButton:function(truthGameButton){truthGameButton.unbind('click');truthGameButton.siblings('div.addVideoButton').removeClass('addVideoInactive');truthGameButton.siblings('div.addPhotoButton').removeClass('addPhotoInactive');truthGameButton.siblings('div.addPollButton').removeClass('addPollInactive');truthGameButton.addClass('addTruthGameInactive');truthGameButton.siblings('div.photoHandlerContainer').hide().children().hide();truthGameButton.siblings('div.addVideo').remove()},deactivateTruthGameButton:function(truthGameButton){truthGameButton.removeClass('addTruthGameInactive');truthGameButton.unbind('click');TruthGame.bindEvents(['getTruthGame'],$('#updateStatusContainer'))},getTruthGameForm:function(){var ajaxUrl=MyYearbook.URLs.Chatter+'truthGame/json/';var truthGameCreationContainer=$('#updateStatusContainer div.truthGameCreationContainer');var truthGameButton=$('div.addTruthGameButton','#updateStatusContainer');if(truthGameCreationContainer.length>0){myb.checkLogin(TruthGame.showTruthGameForm)}else{$.ajax({url:ajaxUrl+'truthGameForm',dataType:'jsonp',success:function(result){TruthGame.getTruthGameFormCallback(result,truthGameButton.parent())}})}},initTruthGameForm:function(){Status.activateSubmitButton(Status.submitButton);Status.submitButton.unbind('click').bind('click',TruthGame.submitTruthGame);var truthGameButton=$('div.addTruthGameButton','#updateStatusContainer');TruthGame.activateTruthGameButton(truthGameButton);truthGameButton.siblings('div.pollCreationContainer').children('img.closeContainer').trigger('click');$('#fauxStatusInput').hide();$('#statusInput').hide();$('#statusCountDownArea').hide();Feed.activateContainerAutoClose(TruthGame.containerMouseLeaveFunction,TruthGame.containerMouseEnterFunction);Feed.toggleCaptcha(true);$('#truth1').focus()},showTruthGameForm:function(loggedIn){if(loggedIn===true){$('#updateStatusContainer div.truthGameCreationContainer').show();TruthGame.initTruthGameForm()}else{$('#updateStatusContainer div.truthGameCreationContainer').remove();TruthGame.getTruthGameForm()}},getTruthGameFormCallback:function(result,container){var truthGameContainer=$(result.display).insertAfter($('div.photoHandlerContainer',container));TruthGame.initTruthGameForm();$('img.closeContainer',truthGameContainer).click(TruthGame.hideTruthGameForm);$('#updateStatusContainer div.truthGameCreationContainer div.truthGameInputContainer').each(function(){var inputCountdown=new InputCountdown($(this).children('input'),$(this).children('span.truthInputCountDownArea'),TruthGame.inputTextLimit,TruthGame.inputCountDownCallback);inputCountdown.init()})},inputCountDownCallback:function(){if($('#truth1').val().length<=75&&$('#truth2').val().length<=75&&$('#lie').val().length<=75){Status.activateSubmitButton(Status.submitButton);$('#statusUpdateButton').bind('click',TruthGame.submitTruthGame)}else{Status.deactivateSubmitButton(Status.submitButton)}},hideTruthGameForm:function(){Feed.deactivateContainerAutoClose(TruthGame.containerMouseLeaveFunction,TruthGame.containerMouseEnterFunction);TruthGame.deactivateTruthGameButton($('div.addTruthGameButton','#updateStatusContainer'));$('#fauxStatusInput').show();$('#statusCountDownArea').show();$('#updateStatusContainer div.truthGameCreationContainer').hide();$('#truth1').val('').siblings('span.truthInputCountDownArea').html('75');$('#truth2').val('').siblings('span.truthInputCountDownArea').html('75');$('#lie').val('').siblings('span.truthInputCountDownArea').html('75');$('#updateStatusContainer div.truthGameCreationContainer').siblings('div.addTruthGameInactive').removeClass('addTruthGameInactive');Feed.postType='status';TruthGame.showError(false);$('#statusUpdateButton').unbind('click');Status.statusButtonBind($('#statusUpdateButton'));Feed.toggleCaptcha(false)},showError:function(message){var errorContainer=$('#updateStatusContainer div.truthGameError');if(message===false){errorContainer.remove()}else{if(errorContainer.length>0){errorContainer.html(message)}else{markup='<div class="truthGameError">'+message+'</div>';$(markup).insertAfter('#updateStatusContainer div.truthGameInstructions')}}},submitTruthGame:function(){var truth1=$('#truth1').val();var truth2=$('#truth2').val();var lie=$('#lie').val();var ajaxUrl=MyYearbook.URLs.Chatter+'truthGame/json/';if(truth1.length===0&&truth2.length===0&&lie.length===0){TruthGame.showError('You must complete all three fields to continue.')}else if(truth1.length<3||truth2.length<3||lie.length<3||truth1.length>75||truth2.length>75||lie.length>75){TruthGame.showError('All entries must be between 3 and 75 characters.')}else{var sendData={};sendData.truth1=truth1;sendData.truth2=truth2;sendData.lie=lie;sendData.isMatchingFeedFilter=Feed.isMatchingFeedFilter;sendData.xslFile=Feed.displayType;if(typeof Recaptcha!='undefined'){sendData.recaptcha_response_field=Recaptcha.get_response();sendData.recaptcha_challenge_field=Recaptcha.get_challenge()}$.ajax({url:ajaxUrl+'createGame',dataType:'jsonp',data:sendData,success:function(result){TruthGame.submitTruthGameCallback(result)}})}},submitTruthGameCallback:function(result){Status.setPageCaptcha(result.nextRequiresCaptcha);if(result.success===true){Feed.buildNewFeedItem(result);TruthGame.hideTruthGameForm()}else{TruthGame.showError(result.error)}},bindEvents:function(names,container){if(container.length>0){for(var x in names){switch(names[x]){case'getTruthGame':$('div.addTruthGameButton',container).click(TruthGame.getTruthGameForm);break;case'submitGuess':$('img.truthGameGuessButton',container).bind('click',TruthGame.submitGuess);break}}}},initFeedPage:function(){TruthGame.bindEvents(['getTruthGame'],$('#updateStatusContainer'))},initFeedItems:function(container){TruthGame.bindEvents(['submitGuess'],$('div.feedItem_TruthGame',container))},submitGuess:function(){var feedItemArea=$(this).parents('div.feedItemArea');var gameUUID=feedItemArea.attr('data-reference-uuid');var guessIndex=$(this).parent().children('label').children('input:checked').attr('value');var expandPhotos=1;var displayTypeContainer=$('#displayTypeContainer');var ajaxUrl=MyYearbook.URLs.Chatter+'truthGame/json/';if(displayTypeContainer.hasClass('view')){expandPhotos=3}else if($('#HALFeed').length<1&&displayTypeContainer.hasClass('profile')!=true){expandPhotos=2}TruthGame.showGuessLoading(feedItemArea);$.ajax({url:ajaxUrl+'guess',dataType:'jsonp',data:{gameUUID:gameUUID,guessIndex:guessIndex,xslFile:Feed.displayType,expandPhotos:expandPhotos},success:function(result){TruthGame.submitGuessCallback(result,feedItemArea)}})},showGuessLoading:function(feedItemArea){feedItemArea.find('div.truthGuessContainer').hide().after('<div class="truthGameLoadingContainer"><div>Checking your</div><div>answer...</div><img class="truthGameLoadingImage" src="'+IMAGE_URL+'ajax_black_big_trans.gif"></div>')},submitGuessCallback:function(result,oldContainer){if(result.success===true){if(typeof result.renderedItem==='string'){var similarPosts=$('span.showSimilarPosts',oldContainer);var container=$(result.renderedItem).insertAfter(oldContainer);if(similarPosts.length>0){$(similarPosts).insertAfter($('div.feedComments',container))}if($('li.comment:last-child',container).children('span.id').html()!==result.commentId){$(result.commentContent).appendTo($('ul.comments',container))}var featuredAI=oldContainer.find('#ChatterFeaturedItemActionIcons');if(featuredAI.length>0){container.find('div.actionIcons').remove()}oldContainer.find('#ChatterFeaturedItemSponsored').add(featuredAI).appendTo(container.find('div.posterPhotoContainer'));oldContainer.remove();eval(result.aiMembersJS);eval(result.aiIconSetsJS);ActionIcons.init(container);container.find('a.btnActionIcon:not(.aiFan)').hide();Feed.initItems(container);$('div.input textarea',container.parent()).val('').parent().addClass('hidden').siblings('.fauxInput').removeClass('hidden');var postCommentInput=$('input.postCommentInput',container.parent());if(postCommentInput.hasClass('captchaCommentButton')){postCommentInput.insertAfter(postCommentInput.siblings('div.addPhotoButton')).removeClass('captchaCommentButton')}Comments.showPostError(container.parent(),false);Comments.setPageCaptcha(result.nextRequiresCaptcha)}}else if(result.success===false){oldContainer.find('div.truthGameLoadingContainer').remove();oldContainer.find('div.truthGuessContainer').show();$.dragonAlertHTML(result.error,{title:'2 Truths & a Lie'})}var postComment=container.find('div.feedItemRightContainer').children('div.boxNub, div.feedComments').removeClass('hidden').find('div.postComment');Feed.blurCommentsArea(postComment)},containerMouseLeaveFunction:function(){$(document).bind('mousedown',TruthGame.hideInputWithTimeOut)},containerMouseEnterFunction:function(){$(document).unbind('mousedown',TruthGame.hideInputWithTimeOut)},hideInputWithTimeOut:function(){setTimeout(TruthGame.hideTruthGameForm,100)}};