Component.TextCounter=Class.create({initialize:function(A){this.element=$(A);
this.target=$(this.element.readAttribute("text"));
this.limit=parseInt(this.target.readAttribute("maxlength"));
this.target.observe("keyup",this.onKeyUp.bindAsEventListener(this));
},onKeyUp:function(A){this.element.update(this.limit-this.target.value.length);
}});
Component.TextDefault=Class.create({initialize:function(A){this.field=$(A);
this.message=this.field.readAttribute("message");
if(!TextUtils.hasText($F(this.field))){this.field.value=this.message;
}Event.observe($(this.field),"focus",this.onFocus.bind(this));
Event.observe($(this.field),"blur",this.onBlur.bind(this));
},onFocus:function(A){if($F(this.field)==this.message){this.field.value="";
}},onBlur:function(A){if(!TextUtils.hasText($F(this.field))){this.field.value=this.message;
}}});
Component.SingleClickForm=Class.create(Component.Form,{initialize:function($super,A){$super(A);
this.counter=0;
},onSubmit:function(A){if(this.counter>0){alert("Please wait -- we're working on your request.");
A.stop();
return false;
}else{this.counter++;
return true;
}}});




Component.ChatBox=Class.create({initialize:function(A){this.element=$(A);
this.element.observe("refresh:click",this.onRefresh.bindAsEventListener(this));
this.onRefresh();
},onRefresh:function(A){this.chatContainer=$(this.element.readAttribute("container"));
this.chatContainer.update("<p class='loading'>Loading chat...</p>");
new Ajax.Request(this.element.readAttribute("talkUrl"),{method:"get",onSuccess:this.onSuccess.bind(this)});
},onSuccess:function(A){this.chatContainer.update(A.responseText);
new Component.Binder(this.chatContainer);
}});
Component.ChatPostButton=Class.create(Component.Button,{onClick:function(B){B.stop();
this.form=this.element.up("form");
var A=Form.serialize(this.form);
new Ajax.Request(this.form.action,{method:"post",parameters:A,onSuccess:this.processPost.bind(this),onFail:this.processPost.bind(this)});
Tracker.tag("TalkCommentPostComment");
},processPost:function(A){this.element.fire("refresh:click");
this.textarea=this.form.down("textarea");
this.textarea.value="";
this.textCounter=this.form.down("span[component=TextCounter]");
if(this.textCounter){this.textCounter.update(this.textarea.readAttribute("maxlength"));
}}});
Component.ChatRefreshButton=Class.create(Component.Button,{onClick:function(A){A.stop();
this.element.fire("refresh:click");
}});
Component.ChatDeleteLink=Class.create(Component.Link,{onClick:function(B){B.stop();
if(confirm("Are you sure you want to delete this comment?")){var C=this.element.readAttribute("action");
var D=this.element.readAttribute("comment");
var A="talkAction="+C+"&commentId="+D;
new Ajax.Request("/talk.sv",{parameters:A,onSuccess:this.processDelete.bind(this),onFail:this.processDelete.bind(this)});
Tracker.tag("TalkCommentDeleteComment");
}},processDelete:function(){this.element.fire("refresh:click");
}});
Component.ChatPhotoLink=Class.create(Component.Link,{onClick:function(){if($("imageId")){var A=$("imageId").value;
var B="\n<a href='http://www.flixster.com/photos?p="+A+"'>http://www.flixster.com/photos?p="+A+"</a>\n";
$("photoComment").value=$("photoComment").value+B;
}else{alert("Whoops, please select a photo first.");
}}});
Component.ChatVideoLink=Class.create(Component.Link,{onClick:function(){if($("videoId")){var B=$("videoId").innerHTML;
var A="\n<a href='http://www.flixster.com/videos?videoId="+B+"'>http://www.flixster.com/videos?videoId="+B+"</a>\n";
$("videoComment").value=$("videoComment").value+A;
}else{alert("Whoops, please select a video first.");
}}});
Component.ChatFlagLink=Class.create(Component.Link,{onClick:function(A){A.stop();
this.comment=this.element.readAttribute("comment");
this.user=this.element.readAttribute("user");
$("flagComment").value=$("comment"+this.comment).innerHTML;
$("flagUserId").value=this.user;
$("warnUserForm").submit();
}});




Component.VideoGallery=Class.create({initialize:function(A){this.element=A;
this.gallery=this.element.readAttribute("gallery");
this.page=parseInt(this.element.readAttribute("page"));
this.element.observe("video:click",this.onVideoClick.bindAsEventListener(this));
this.element.observe("video:page",this.onPage.bindAsEventListener(this));
this.element.observe("video:gallery",this.onGalleryChange.bindAsEventListener(this));
},onVideoClick:function(A){this.index=parseInt(A.memo.index);
new View.VideoView("videoPlayerView",{video:A.memo.video,gallery:this.gallery});
},onGalleryChange:function(A){this.gallery=A.memo.gallery;
this.page=1;
new View.VideoGalleryView("gallery",{gallery:this.gallery,page:this.page});
},onPage:function(A){this.page=A.memo.page;
new View.VideoGalleryView("gallery",{gallery:this.gallery,page:this.page});
}});
Component.VideoGallerySelect=Class.create(Component.Select,{onChange:function(B){var A=$F(this.element);
if(A!="---"){this.element.fire("video:gallery",{gallery:A});
}}});
Component.VideoGalleryPageLink=Class.create(Component.Link,{onClick:function(A){A.stop();
var B=parseInt(this.element.readAttribute("page"));
this.element.fire("video:page",{page:B});
}});
Component.VideoLink=Class.create(Component.Link,{onClick:function(A){A.stop();
this.element.fire("video:click",{video:this.element.readAttribute("video")});
}});
Component.ReportBadYouTubeLink=Class.create(Component.Link,{onClick:function(A){A.stop();
var B="action=reportBrokenYouTubeVideo&videoId="+this.element.readAttribute("video");
new Ajax.Request("/video.sv",{parameters:B});
this.element.replace("Thanks -- we'll fix the video soon.");
}});
Component.FlagVideoLink=Class.create(Component.Link,{onClick:function(C){C.stop();
var B=this.element.readAttribute("video");
var A=this.element.readAttribute("flag");
var D="action=flagVideo"+"&flagType="+A+"&videoId="+B;
new Ajax.Request("/video.sv",{parameters:D,onSuccess:this.onSuccess.bind(this),onFailure:this.onFailure.bind(this)});
},onSuccess:function(A){this.element.replace("Video flagged - Thanks!");
},onFailure:function(A){new View.ErrorPopup(this.element,{title:"Error",content:A.responseText});
}});
Component.ClearVideoFlagsLink=Class.create(Component.Link,{onClick:function(C){C.stop();
var B=this.element.readAttribute("video");
var A=this.element.readAttribute("type");
var D="action=clearFlag"+"&flagType="+A+"&videoId="+B;
new Ajax.Request("/video.sv",{parameters:D,onSuccess:this.onSuccess.bind(this),onFailure:this.onFailure.bind(this)});
this.element.update("Clearing flags...");
},onSuccess:function(A){this.element.replace("Flags cleared.");
},onFailure:function(A){new View.ErrorPopup(this.element,{title:"Error",content:A.responseText});
}});
Component.RemoveVideoLink=Class.create(Component.Link,{onClick:function(A){A.stop();
if(this.element.readAttribute("warn")=="false"){this.onDelete();
}else{new View.ConfirmationPopup(this.element,{content:"Are you sure you want to delete this video?",onConfirm:this.onDelete.bindAsEventListener(this)});
}},onDelete:function(B){this.element.update("Removing...");
var A=this.element.readAttribute("video");
var C="action=removeVideo&videoId="+A;
new Ajax.Request("/video.sv",{parameters:C,onSuccess:this.onSuccess.bind(this),onFailure:this.onFailure.bind(this)});
},onSuccess:function(A){this.element.replace("Video removed.");
},onFailure:function(A){new View.ErrorPopup(this.element,{title:"Error",content:A.responseText});
}});
Component.FavoriteVideoAddLink=Class.create(Component.Link,{onClick:function(B){B.stop();
var A=this.element.readAttribute("video");
if(!currentUser.isLoggedIn()){new View.ErrorPopup(this.element,{title:"Oops",content:"Login or register to save your favorite videos."});
}else{var C="action=addVideoClipFavorite&videoId="+A+"&makeCurrentFavorite=false";
new Ajax.Request("/video.sv",{parameters:C,onSuccess:this.onSuccess.bind(this)});
this.element.update("Saving...");
Tracker.tag("VideosMakeDefault");
}},onSuccess:function(A){this.element.replace("<a href='"+this.element.readAttribute("saved")+"'>Saved - View Favorites</a>");
},onFailure:function(A){new View.ErrorPopup(this.element,{title:"Error",content:A.responseText});
}});
Component.FavoriteVideoRemoveLink=Class.create(Component.Link,{onClick:function(B){B.stop();
var A=this.element.readAttribute("video");
var C="action=removeVideoClipFavorite&videoId="+A;
new Ajax.Request("/video.sv",{parameters:C,onSuccess:this.onSuccess.bind(this)});
this.element.update("Removing...");
Tracker.tag("VideosUnfavorite");
},onSuccess:function(A){this.element.replace("<a href='"+this.element.readAttribute("saved")+"'>Removed - View Favorites</a>");
},onFailure:function(A){new View.ErrorPopup(this.element,{title:"Error",content:A.responseText});
}});
Component.RemoveVideoMovieLink=Class.create(Component.Link,{onClick:function(B){B.stop();
this.element.update("Removing...");
var A=this.element.readAttribute("video");
var C="action=removeMovie&videoId="+A;
new Ajax.Request("/video.sv",{parameters:C,onSuccess:this.onSuccess.bind(this),onFailure:this.onFailure.bind(this)});
},onSuccess:function(A){this.element.replace("Movie removed.");
},onFailure:function(A){new View.ErrorPopup(this.element,{title:"Error",content:A.responseText});
}});
Component.RemoveVideoActorLink=Class.create(Component.Link,{onClick:function(B){B.stop();
this.element.update("Removing...");
var A=this.element.readAttribute("video");
var C="action=removeActor&videoId="+A;
new Ajax.Request("/video.sv",{parameters:C,onSuccess:this.onSuccess.bind(this),onFailure:this.onFailure.bind(this)});
},onSuccess:function(A){this.element.replace("Actor removed.");
},onFailure:function(A){new View.ErrorPopup(this.element,{title:"Error",content:A.responseText});
}});
Component.RemoveVideoAssociationLink=Class.create(Component.Link,{onClick:function(D){D.stop();
var C=this.element.readAttribute("video");
this.element.update("Removing...");
var B="action=removeMovie&videoId="+C;
new Ajax.Request("/video.sv",{parameters:B,onSuccess:this.onSuccess.bind(this),onFailure:this.onFailure.bind(this)});
var A="action=removeActor&videoId="+C;
new Ajax.Request("/video.sv",{parameters:A,onSuccess:this.onSuccess.bind(this),onFailure:this.onFailure.bind(this)});
},onSuccess:function(A){this.element.replace("Associations removed.");
},onFailure:function(A){new View.ErrorPopup(this.element,{title:"Error",content:A.responseText});
}});
Component.VideoSortForm=Class.create(Component.Form,{initialize:function($super,A){$super(A);
Sortable.create("favorites",{tag:"li",only:"video",scroll:window,handle:"videoImg",constraint:false});
},onSubmit:function(A){$("videoSortSubmitBtn1").disabled=true;
$("videoSortSubmitBtn2").disabled=true;
}});
Component.ViewingStage=Class.create(Component.FlashMovieMeeboBarDecoupler);
View.VideoGalleryView=Class.create(View.RemoteView,{render:function(A){new View.LoadingView(this.element,{message:"Loading gallery..."});
var B="viewGallery=&gallery="+A.gallery+"&pageNav="+A.page;
new Ajax.Request("/video.sv",{parameters:B,onSuccess:this.onSuccess.bind(this)});
$("galleryId").hide();
$("galleryStatus").update("Loading...");
},onSuccess:function(A){this.element.update(A.responseText);
new Component.Binder(this.element);
$("galleryStatus").update("Now Viewing");
$("galleryId").show();
if(this.gallery.indexOf("favorite-videos")>=0){Tracker.tag("VideoLivefavoriteVideos");
}else{if(this.gallery.indexOf("movie-videos")>=0){Tracker.tag("VideoLivemovieVideos");
}else{if(this.gallery.indexOf("actor-videos")>=0){Tracker.tag("VideoLiveactorVideos");
}else{if(this.gallery.indexOf("top-this-week")>=0){Tracker.tag("VideoLivetopVideosThisWeek");
}else{if(this.gallery.indexOf("top-this-month")>=0){Tracker.tag("VideoLivetopVideosThisMonth");
}else{if(this.gallery.indexOf("top-all-time")>=0){Tracker.tag("VideoLivetopVideosAllTime");
}else{Tracker.tag("VideoLiverecentVideos");
}}}}}}}});
View.VideoView=Class.create(View.RemoteView,{render:function(A){new View.LoadingView(this.element,{message:"Loading video..."});
var B="viewVideo=&videoId="+A.video+"&gallery="+A.gallery;
new Ajax.Request("/video.sv",{parameters:B,onSuccess:this.onSuccess.bind(this)});
},onSuccess:function(A){this.element.update(A.responseText);
new Component.Binder(this.element);
if(this.gallery.indexOf("favoriteVideos")>=0){Tracker.tag("VideoLiveVideo"+this.options.gallery.substr(0,14));
}else{if(this.gallery.indexOf("movieVideos")>=0){Tracker.tag("VideoLiveVideo"+this.options.gallery.substr(0,11));
}else{if(this.gallery.indexOf("actorVideos")>=0){Tracker.tag("VideoLiveVideo"+this.options.gallery.substr(0,11));
}else{Tracker.tag("VideoLiveVideo"+this.options.gallery);
}}}document.fire("ads:refresh");
}});
var ChatLink={visible:true,toggle:function(){ChatLink.visible=!ChatLink.visible;
if(ChatLink.visible){$("chatShowHideLink").update("Hide All");
$("videoChatComments").show();
}else{$("chatShowHideLink").update("Show Comments");
$("videoChatComments").hide();
}}};
var actorSearchWidget={handleFocus:function(A){if(A.value=="Type in an actor name, and press SEARCH"){A.value="";
}},search:function(){var A="action=searchActors&"+Form.Element.serialize($("asearch"));
$("actorSearchResults").update('<span class="loading"><img src="${flixster:getStaticHost()}/images/wait.gif" alt="Searching..."/>&nbsp;&nbsp;Searching...</span>');
new Ajax.Updater("actorSearchResults","/photo.sv",{parameters:A,asynchronous:true,evalScripts:true});
},captureEnterOnSearch:function(A){if(this.pressedEnterKey(A)){this.search();
return false;
}return true;
},pressedEnterKey:function(A){var B;
if(window.event){B=A.keyCode;
}else{if(A.which){B=A.which;
}}if(B==13){return true;
}else{return false;
}}};
var movieSearchWidget={handleFocus:function(A){if(A.value=="Type in a movie name, and press SEARCH"){A.value="";
}},search:function(){var A="action=searchMovies&"+Form.Element.serialize($("msearch"));
$("movieSearchResults").update('<span class="loading"><img src="${flixster:getStaticHost()}/images/wait.gif" alt="Searching..."/>Searching...</span>');
new Ajax.Updater("movieSearchResults","/photo.sv",{parameters:A,asynchronous:true,evalScripts:true});
},captureEnterOnSearch:function(A){if(this.pressedEnterKey(A)){this.search();
return false;
}return true;
},pressedEnterKey:function(A){var B;
if(window.event){B=A.keyCode;
}else{if(A.which){B=A.which;
}}if(B==13){return true;
}else{return false;
}}};
var VIDEO_TABS={YOUTUBE:0,IFILM:1,FLIQZ:2};
var videoTabWidget={click:function(A){this.tab=A;
this.paint();
},paint:function(){switch(this.tab){case VIDEO_TABS.YOUTUBE:$("youtubeTab").style.backgroundColor="#efefef";
$("youtubeTab").style.borderBottom="1px solid #efefef";
$("ifilmTab").style.backgroundColor="#ffffff";
$("ifilmTab").style.borderBottom="1px solid #000000";
$("fliqzTab").style.backgroundColor="#ffffff";
$("fliqzTab").style.borderBottom="1px solid #000000";
break;
case VIDEO_TABS.IFILM:$("youtubeTab").style.backgroundColor="#ffffff";
$("youtubeTab").style.borderBottom="1px solid #000000";
$("ifilmTab").style.backgroundColor="#efefef";
$("ifilmTab").style.borderBottom="1px solid #efefef";
$("fliqzTab").style.backgroundColor="#ffffff";
$("fliqzTab").style.borderBottom="1px solid #000000";
break;
case VIDEO_TABS.FLIQZ:$("youtubeTab").style.backgroundColor="#ffffff";
$("youtubeTab").style.borderBottom="1px solid #000000";
$("ifilmTab").style.backgroundColor="#ffffff";
$("ifilmTab").style.borderBottom="1px solid #000000";
$("fliqzTab").style.backgroundColor="#efefef";
$("fliqzTab").style.borderBottom="1px solid #efefef";
break;
}switch(this.tab){case VIDEO_TABS.YOUTUBE:Element.hide($("ifilmView"));
Element.hide($("fliqzView"));
Element.show($("youtubeView"));
break;
case VIDEO_TABS.IFILM:Element.hide($("youtubeView"));
Element.hide($("fliqzView"));
Element.show($("ifilmView"));
break;
case VIDEO_TABS.FLIQZ:Element.hide($("youtubeView"));
Element.hide($("ifilmView"));
Element.show($("fliqzView"));
break;
}switch(this.tab){case VIDEO_TABS.YOUTUBE:$("youtubeRadio").checked="true";
break;
case VIDEO_TABS.IFILM:$("ifilmRadio").checked="true";
break;
case VIDEO_TABS.FLIQZ:$("fliqzRadio").checked="true";
break;
}}};




