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.PhotoGallery=Class.create({initialize:function(A){this.element=A;
this.gallery=this.element.readAttribute("gallery");
this.actor=this.element.readAttribute("actor");
this.actor=this.element.readAttribute("movie");
this.page=parseInt(this.element.readAttribute("page"));
this.index=parseInt(this.element.readAttribute("index"));
this.element.observe("photo:click",this.onPhotoClick.bindAsEventListener(this));
this.element.observe("photo:page",this.onPage.bindAsEventListener(this));
this.element.observe("photo:gallery",this.onChangeGallery.bindAsEventListener(this));
this.element.observe("photo:previous",this.onPreviousPhoto.bindAsEventListener(this));
this.element.observe("photo:next",this.onNextPhoto.bindAsEventListener(this));
},onPhotoClick:function(A){this.index=parseInt(A.memo.index);
new View.PhotoView("photoPlayerView",{photo:A.memo.photo,gallery:this.gallery});
document.fire("ads:refresh");
},onChangeGallery:function(A){this.gallery=A.memo.gallery;
this.page=1;
this.index=0;
new View.PhotoGalleryView("gallery",{gallery:this.gallery,page:this.page,index:this.index});
document.fire("ads:refresh");
},onPage:function(A){this.page=A.memo.page;
this.index=0;
new View.PhotoGalleryView("gallery",{gallery:this.gallery,page:this.page,index:this.index});
document.fire("ads:refresh");
},onPreviousPhoto:function(A){this.photos=$A(this.element.select("#thumbnails a[photo]"));
if(this.index>0){this.index-=1;
new View.PhotoView("photoPlayerView",{photo:this.photos[this.index].readAttribute("photo"),gallery:this.gallery});
}else{if(this.index==0&&this.page>1){this.page-=1;
this.index=14;
new View.PhotoGalleryView("gallery",{gallery:this.gallery,page:this.page,index:this.index});
}}document.fire("ads:refresh");
},onNextPhoto:function(B){this.photos=$A(this.element.select("#thumbnails a[photo]"));
var A=parseInt(this.element.down(".pagination").readAttribute("pages"));
if(this.index<this.photos.length-1){this.index+=1;
new View.PhotoView("photoPlayerView",{photo:this.photos[this.index].readAttribute("photo"),gallery:this.gallery});
}else{if(this.index==14&&this.page<A){this.page+=1;
this.index=0;
new View.PhotoGalleryView("gallery",{gallery:this.gallery,page:this.page,index:this.index});
}}document.fire("ads:refresh");
}});
View.PhotoGalleryView=Class.create(View.RemoteView,{render:function(A){new View.LoadingView(this.element,{message:"Loading gallery..."});
var B={viewGallery:"",gallery:A.gallery,page:A.page};
new Ajax.Request("/photos/gallery",{method:A.method,onSuccess:this.onSuccess.bind(this),onFailure:this.onFailure.bind(this),parameters:B});
$("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.options.gallery.indexOf("movie")>=0){Tracker.tag("PhotosGalleryMovie");
}else{if(this.options.gallery.indexOf("actor")>=0){Tracker.tag("PhotosGalleryActor");
}else{if(this.options.gallery.indexOf("user")>=0){Tracker.tag("PhotosGalleryUser");
}else{Tracker.tag("PhotosGallery");
}}}this.photos=$A(this.element.select("a[photo]"));
if(this.photos.size()>=0){new View.PhotoView("photoPlayerView",{photo:this.photos[this.options.index].readAttribute("photo"),gallery:this.options.gallery});
}}});
Component.PhotoGallerySelect=Class.create(Component.Select,{onChange:function(B){var A=$F(this.element);
if(A!="---"){this.element.fire("photo:gallery",{gallery:A});
}}});
Component.PhotoGalleryPageLink=Class.create(Component.Link,{onClick:function(C){C.stop();
var D=parseInt(this.element.readAttribute("page"));
var B=this.element.readAttribute("actor");
var A=this.element.readAttribute("movie");
this.element.fire("photo:page",{page:D,actor:B,movie:A});
}});
Component.PhotoLink=Class.create(Component.Link,{onClick:function(A){A.stop();
this.element.fire("photo:click",{photo:this.element.readAttribute("photo"),index:this.element.readAttribute("index")});
}});
View.PhotoView=Class.create(View.RemoteView,{render:function(A){new View.LoadingView(this.element,{message:"Loading photo..."});
var B={viewPhoto:"",p:A.photo,gallery:A.gallery};
new Ajax.Request("/photos/stage",{method:A.method,onSuccess:this.onSuccess.bind(this),onFailure:this.onFailure.bind(this),parameters:B});
},onSuccess:function(A){this.element.update(A.responseText);
new Component.Binder(this.element);
if(this.options.gallery.indexOf("movie")>=0){Tracker.tag("PhotoClickMovie");
}else{if(this.options.gallery.indexOf("actor")>=0){Tracker.tag("PhotoClickActor");
}else{if(this.options.gallery.indexOf("user")>=0){Tracker.tag("PhotoClickUser");
}else{Tracker.tag("PhotoClick");
}}}}});
Component.PhotoRating=Class.create(Component.Form,{initialize:function(A){this.element=$(A);
this.photo=this.element.readAttribute("photo");
$A($("ratingWidget").getElementsByTagName("INPUT")).each(function(B){$(B).observe("click",this.onRatingClick.bindAsEventListener(this));
}.bind(this));
},onRatingClick:function(A){if(currentUser.isLoggedIn()){new Ajax.Request("/photo.sv",{parameters:this.element.serialize()});
}$("ratingWidget").hide();
$("ratingSummary").show();
this.element.fire("photo:next");
}});
Component.PreviousPhotoLink=Class.create(Component.Link,{onClick:function(A){A.stop();
this.element.fire("photo:previous");
}});
Component.NextPhotoLink=Class.create(Component.Link,{onClick:function(A){A.stop();
this.element.fire("photo:next");
}});
var photoWidget={STATES:{READY:0,SAVING_FAVORITE:1,SAVED_FAVORITE:2,REMOVING_FAVORITE:3,REMOVED_UNFAVORITE:4},handleFavorite:function(A){if(!currentUser.isLoggedIn()){document.location="/photoAction.do?photoAction=addFavoritePhoto&photoId="+A;
return ;
}this.state=this.STATES.SAVING_FAVORITE;
this.paint();
var B="action=addPhotoFavorite&imageId="+A+"&makeCurrentFavorite=false";
new Ajax.Request("/photo.sv",{parameters:B,onComplete:this.processFavorite.bind(this)});
Tracker.tag("PhotosFavorite");
},processFavorite:function(){this.state=this.STATES.SAVED_FAVORITE;
this.paint();
},handleUnfavorite:function(A){this.state=this.STATES.REMOVING_FAVORITE;
this.paint();
var B="action=removePhotoFavorite&imageId="+A;
new Ajax.Request("/photo.sv",{parameters:B,asynchronous:true,onComplete:this.processUnfavorite.bind(this)});
Tracker.tag("PhotosUnfavorite");
},processUnfavorite:function(){this.state=this.STATES.REMOVED_FAVORITE;
this.paint();
},paint:function(){switch(this.state){case this.STATES.SAVING_FAVORITE:$("favoriteLink").hide();
$("savedFavorite").hide();
$("savingFavorite").show();
break;
case this.STATES.SAVED_FAVORITE:Element.hide($("favoriteLink"));
Element.hide($("savingFavorite"));
Element.show($("savedFavorite"));
break;
case this.STATES.REMOVING_FAVORITE:Element.hide($("unfavoriteLink"));
Element.hide($("removedFavorite"));
Element.show($("removingFavorite"));
break;
case this.STATES.REMOVED_FAVORITE:Element.hide($("unfavoriteLink"));
Element.hide($("removingFavorite"));
Element.show($("removedFavorite"));
break;
}}};
var photoAdminWidget={handleRemove:function(A){if(confirm("Are you sure you want to remove this photo?")){var B="action=removePhoto&imageId="+A;
new Ajax.Request("/photo.sv",{parameters:B,onComplete:this.processRemove.bind(this)});
}},processRemove:function(A){$("adminRemove").update(A.responseText);
},handleRemoveMovie:function(A){var B="action=removeMovie&imageId="+A;
new Ajax.Request("/photo.sv",{parameters:B,onComplete:this.processRemoveMovie.bind(this)});
},processRemoveMovie:function(A){$("adminRemoveMovie").update(A.responseText);
},handleRemoveActor:function(A){var B="action=removeActor&imageId="+A;
new Ajax.Request("/photo.sv",{parameters:B,onComplete:this.processRemoveActor.bind(this)});
},processRemoveActor:function(A){$("adminRemoveActor").update(A.responseText);
},handleSetMoviePoster:function(A){var B="action=setMoviePoster&imageId="+A;
new Ajax.Request("/photo.sv",{parameters:B,onComplete:this.processSetMoviePoster.bind(this)});
},processSetMoviePoster:function(A){$("adminSetMoviePoster").update(A.responseText);
}};
Component.PhotoSortForm=Class.create(Component.Form,{initialize:function($super,A){$super(A);
Sortable.create("favorites",{tag:"li",only:"photo",scroll:window,handle:"photoImg",constraint:false});
},onSubmit:function(A){$("photoSortSubmitBtn1").disabled=true;
$("photoSortSubmitBtn2").disabled=true;
return true;
}});
var ChatLink={visible:true,toggle:function(){ChatLink.visible=!ChatLink.visible;
if(ChatLink.visible){$("chatShowHideLink").update("Hide All");
$("photoChatComments").show();
}else{$("chatShowHideLink").update("Show Comments");
$("photoChatComments").hide();
}}};
Component.FlagPhotoLink=Class.create(Component.Link,{onClick:function(A){A.stop();
var B={action:"flagPhoto",flagType:this.element.readAttribute("type"),imageId:this.element.readAttribute("photo")};
new Ajax.Request("/photo.sv",{parameters:B,onSuccess:this.onSuccess.bind(this),onFailure:this.onFailure.bind(this)});
},onSuccess:function(A){this.element.replace(A.responseText);
},onFailure:function(A){new View.ErrorPopup(this.element,{title:"Whoops",content:"We ran into problems flagging this photo, but we'll fix it shortly."});
}});
Component.ClearPhotoFlagLink=Class.create(Component.Link,{onClick:function(A){A.stop();
var B={action:"clearFlag",flagType:this.element.readAttribute("type"),imageId:this.element.readAttribute("photo")};
new Ajax.Request("/photo.sv",{parameters:B,onSuccess:this.onSuccess.bind(this),onFailure:this.onFailure.bind(this)});
},onSuccess:function(A){this.element.replace("Flags cleared");
},onFailure:function(A){new View.ErrorPopup(this.element,{title:"Whoops",content:"We ran into problems flagging this photo, but we'll fix it shortly."});
}});
Component.RemovePhotoLink=Class.create(Component.Link,{onClick:function(A){A.stop();
var B={action:"removePhoto",imageId:this.element.readAttribute("photo")};
new Ajax.Request("/photo.sv",{parameters:B,onSuccess:this.onSuccess.bind(this),onFailure:this.onFailure.bind(this)});
},onSuccess:function(A){this.element.replace("Photo removed.");
},onFailure:function(A){new View.ErrorPopup(this.element,{title:"Whoops",content:"We ran into problems removing this photo, but we'll fix it shortly."});
}});
Component.RemovePhotoMovieLink=Class.create(Component.Link,{onClick:function(A){A.stop();
var B={action:"removeMovie",imageId:this.element.readAttribute("photo")};
new Ajax.Request("/photo.sv",{parameters:B,onSuccess:this.onSuccess.bind(this),onFailure:this.onFailure.bind(this)});
},onSuccess:function(A){this.element.replace("Movie association removed.");
},onFailure:function(A){new View.ErrorPopup(this.element,{title:"Whoops",content:"We ran into problems removing this association, but we'll fix it shortly."});
}});
Component.RemovePhotoActorLink=Class.create(Component.Link,{onClick:function(A){A.stop();
var B={action:"removeActor",imageId:this.element.readAttribute("photo")};
new Ajax.Request("/photo.sv",{parameters:B,onSuccess:this.onSuccess.bind(this),onFailure:this.onFailure.bind(this)});
},onSuccess:function(A){this.element.replace("Actor association removed.");
},onFailure:function(A){new View.ErrorPopup(this.element,{title:"Whoops",content:"We ran into problems removing this association, but we'll fix it shortly."});
}});
Component.RemovePhotoAssociationLink=Class.create(Component.Link,{onClick:function(C){C.stop();
var B={action:"removeMovie",imageId:this.element.readAttribute("photo")};
new Ajax.Request("/photo.sv",{parameters:B});
var A={action:"removeActor",imageId:this.element.readAttribute("photo")};
new Ajax.Request("/photo.sv",{parameters:A});
this.element.replace("Associations removed.");
}});
Component.PhotoUploadForm=Class.create(Component.Form,{onSubmit:function(A){var B=this.element.serialize(true);
if(B.caption=="Add a simple caption"){B.caption="";
}if(B.description=="Add a simple description"){B.description="";
}if(B.photo==""){A.stop();
new View.ErrorPopup(this.element,{title:"Oops!",content:"Don't forget to choose an image file."});
return false;
}if((B.actor||B.movie)&&(B.caption==""||B.description=="")){A.stop();
new View.ErrorPopup(this.element,{title:"Oops!",content:"Please provide a caption and description for this photo."});
return false;
}if(!B.terms1||!B.terms2||!B.terms3){A.stop();
new View.ErrorPopup(this.element,{title:"Oops!",content:"Please review (and agree) to all terms and conditions of service."});
return false;
}return true;
}});
Component.PhotoUpdateForm=Class.create(Component.Form,{onSubmit:function(A){var B=this.element.serialize(true);
if(B.caption=="Add a simple caption"){this.element.down("input[name=caption]").value="";
B.caption="";
}if(B.description=="Add a simple description"){this.element.down("input[name=caption]").value="";
B.description="";
}if((B.actor||B.movie)&&(B.caption==""||B.description=="")){A.stop();
new View.ErrorPopup(this.element,{title:"Oops!",content:"Please provide a caption and description for this photo."});
return ;
}if(!B.terms1||!B.terms2){A.stop();
new View.ErrorPopup(this.element,{title:"Oops!",content:"Please review (and agree) to the terms and conditions of service."});
return ;
}return true;
}});
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"));
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"));
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;
}}};




