IMAGE_URL.charAt(IMAGE_URL.length-1)!='/'?IMAGE_URL2=IMAGE_URL+'/':IMAGE_URL2=IMAGE_URL;PHOTO_URL.charAt(PHOTO_URL.length-1)!='/'?PHOTO_URL2=PHOTO_URL+'/':PHOTO_URL2=PHOTO_URL;var pageFeedVideos=[];function FeedVideo(textInput,videoButton,photoButton,truthGameButton,pollsButton,type,container,loggedIn){this.hideInputFunction=function(){};this.showInputFunction=function(){};var _0=this;if(textInput.length>0){this.textInput=textInput}if(videoButton.length>0){this.videoButton=videoButton}if(photoButton.length>0){this.photoButton=photoButton}if(truthGameButton.length>0){this.truthGameButton=truthGameButton}if(pollsButton.length>0){this.pollsButton=pollsButton}this.type=type;this.doLinkCheck=true;this.loggedIn=loggedIn;this.container=container;this.init=function(){_0.feedVideoIndex=pageFeedVideos.length;pageFeedVideos[_0.feedVideoIndex]=_0;_0.initIcon();_0.activateLinkCheck(_0.textInput,'textArea')};this.initFeedItem=function(showInputFunction,hideInputFunction){if(typeof(hideInputFunction)=='function'){this.hideInputFunction=hideInputFunction}if(typeof(showInputFunction)=='function'){this.showInputFunction=showInputFunction}};this.activateLinkCheck=function(selector,type){if(_0.loggedIn==1){selector.bind('paste',function(e){window.setTimeout("pageFeedVideos["+_0.feedVideoIndex+"].checkLink('"+type+"');",100)})}};this.checkLink=function(type){if(_0.doLinkCheck==true&&_0.loggedIn==1){if((!$('div.photoHandlerContainer:visible',_0.container).length>0)||!($('div.snapPhotoContainer:visible',_0.container).length>0||$('div.photoUploadContainer:visible',_0.container).length>0||$('div.photoSelectContainer:visible',_0.container).length>0)){$('div.videoPreview',_0.container).remove();if(type=='textArea'){text=_0.textInput.val()}else if(type=='addArea'){text=_0.addVideoInput.val()}if(text.indexOf('http://www.youtube.com/')>=0||(type=='addArea'&&text.length>0)){var regex=/http\:\/\/www\.youtube\.com\/watch(\?|#!)v=([\w-]{11})/;var videoInfo=text.match(regex);if(videoInfo!=null){if(_0.type=='feedItem'){if(Feed.pageName=='FeedService'){var maxDescriptionLength=135;var maxTitleLength=80}else if(Feed.pageName=='Profile'){var maxDescriptionLength=108;var maxTitleLength=64}else if(Feed.pageName=='HALWide'){var maxDescriptionLength=75;var maxTitleLength=44}}var data={videoId:videoInfo[2],displayType:Feed.displayType,maxDescriptionLength:maxDescriptionLength,maxTitleLength:maxTitleLength};$.ajax({dataType:'jsonp',data:data,url:MyYearbook.URLs.www+'apps/video/JSON/YouTubePreview',success:function(data){if(data.result!=false){_0.videoButton.addClass('addVideoInactive');_0.photoButton.removeClass('addPhotoInactive');if(typeof(_0.truthGameButton)!=='undefined'){_0.truthGameButton.removeClass('addTruthGameButtonInactive')}if(typeof(_0.pollsButton)!=='undefined'){_0.pollsButton.removeClass('addPollInactive')}_0.doLinkCheck=false;_0.textInput.after(data.result).siblings('div.photoHandlerContainer:visible').children('img.closeContainer').trigger('click');$('img.ytClosePreview').bind('click',function(){$('div.videoPreview',_0.container).remove();_0.videoButton.removeClass('addVideoInactive');_0.doLinkCheck=true;Feed.postType='status'});_0.textInput.siblings('div.addVideo').remove();if(_0.type=='feedItem'){Feed.postType='video'}}else if(_0.type==='feedItem'){_0.errorDisplay(data.error)}}})}else if(_0.type=='feedItem'){_0.errorDisplay('This is not a valid YouTube URL.')}}}}};this.errorDisplay=function(message){_0.showAddVideo();if($('div.feedError',_0.container).length>0){$('div.feedError',_0.container).html(message)}else{$('div.addVideo',_0.container).css('height','90px');$('div.addVideoInstructions',_0.container).css('margin-top','10px').before('<div class="feedError">'+message+'</div>')}};this.initIcon=function(){_0.videoButton.bind('click',_0.showAddVideo)};this.showAddVideo=function(){_0.videoButton.siblings('div.videoPreview').children('img.ytClosePreview').trigger('click');_0.videoButton.addClass('addVideoInactive');_0.photoButton.removeClass('addPhotoInactive');if(typeof(_0.truthGameButton)!=='undefined'){_0.truthGameButton.removeClass('addTruthGameInactive')}if(typeof(_0.pollsButton)!=='undefined'){_0.pollsButton.removeClass('addPollInactive')}if(_0.loggedIn==1&&!($('div.addVideo',_0.container).length>0)){Feed.postType='status';TruthGame.hideTruthGameForm();ChatterPolls.hidePollCreationForm();_0.showInputFunction(false);var addVideoMarkup='<div class="addVideo"><img class="closeContainer" src="'+IMAGE_URL2+'updateicons/notifications_x.gif" /><div class="clear"> </div><div class="addVideoInstructions">Enter YouTube Video URL:<br /><img src="'+IMAGE_URL2+'images/Feed/logo_youtube_sm.png" alt="YouTube" class="youTubeIconSmall"/><input type="text" class="videoURL" /></div></div>';_0.videoButton.siblings('div.photoHandlerContainer').after(addVideoMarkup).hide().children().hide();_0.addVideoInput=$('div.addVideo input.videoURL');_0.activateLinkCheck(_0.addVideoInput,'addArea');$('div.addVideo input.videoURL',_0.container).focus()}else{_0.buildLoggedOut()}$('div.addVideo img.closeContainer',_0.container).bind('click',_0.closeAddVideoArea)};this.buildLoggedOut=function(){if(!$('div.addVideo',_0.container).length>0){_0.videoButton.siblings('div.truthGameCreationContainer').children('img.closeContainer').trigger('click');ChatterPolls.hidePollCreationForm();var loggedOutMarkup='<div class="addVideo loggedOutArea"><img class="closeContainer" src="'+IMAGE_URL2+'updateicons/notifications_x.gif" /><div class="clear"> </div>'+'<span>Please </span><a href="'+SITE_URL+'?mysession=cmVnaXN0cmF0aW9uX3JlZ2lzdHJhdGlvbiZyZWZlcnJlcj0wJm9sZD0x" class="normaltextlink">sign up</a> or <a href="'+SITE_URL+'?mysession=cmVnaXN0cmF0aW9uX3JlZ2lzdHJhdGlvbiZyZWZlcnJlcj0wJm9sZD0x" class="normaltextlink">log in</a><span> to post a video.</span>'+'</div>';_0.videoButton.siblings('div.photoHandlerContainer').after(loggedOutMarkup).hide().children().hide()}};this.closeAddVideoArea=function(){_0.videoButton.removeClass('addVideoInactive');$(this).parent().remove();_0.hideInputFunction();Feed.statusErrorDisplay(false)}};function postVideoFeedItem(isMatchingFeedFilter){if($('#updateStatusContainer div.videoPreview').length>0){var text=$('#statusInput').val();var videoId=$('div.videoPreview ul.ytDataArea').attr('data-video-id');var xslFile='FeedDisplay';if($('#HALFeed').hasClass('HALObject_narrow')){xslFile='FeedDisplayHALNarrow'}else if($('#HALFeed').hasClass('HALObject_wide')){xslFile='FeedDisplayHALWide'}var source=$('body').attr('data-application');var data={videoId:videoId,text:text,isMatchingFeedFilter:isMatchingFeedFilter,xslFile:xslFile,source:source};if(typeof Recaptcha=='object'){data.recaptcha_response_field=Recaptcha.get_response();data.recaptcha_challenge_field=Recaptcha.get_challenge()}$.ajax({dataType:'jsonp',data:data,url:MyYearbook.URLs.www+'apps/video/JSON/add',success:function(data){if(data.result!=false){$('#updateStatusContainer div.videoPreview').siblings('div.addVideoButton').removeClass('addVideoInactive');$('#statusInput').val('');$('#updateStatusContainer div.videoPreview img.ytClosePreview').trigger('click');$('#feedMessageArea').remove();$('#statusCountDownArea').text('140').css('color','#CCC');Status.setPageCaptcha(data.nextRequiresCaptcha);Feed.buildNewFeedItem(data);Status.hideInput()}else{if(data.captchaError==true){Status.setPageCaptcha(data.nextRequiresCaptcha);Feed.toggleCaptcha(true);$('#statusInput').siblings('div.aiCaptchaBox').find('#recaptcha_response_field').trigger('focus')}else{Feed.statusErrorDisplay(data.error)}}}})}};