Component.FavoriteMovieAddLink=Class.create(Component.Link,{onClick:function(A){if(this.added||!currentUser.isLoggedIn()){return true;
}else{A.stop();
this.movie=this.element.readAttribute("movie");
var B="service=addMovie&mid="+this.movie+"&listId=FAV";
new Ajax.Request("/list.sv",{parameters:B,onSuccess:this.onSuccess.bind(this),onFailure:this.onFailure.bind(this)});
this.element.href="/movie-list/favorite";
this.element.update("Saving...");
}},onSuccess:function(A){this.added=true;
this.element.href="/movie-list/favorite";
this.element.update("Saved - View Favorites");
},onFailure:function(){document.location="/movie-list/add?type=FAV&movie="+this.movie;
}});
Component.MovieCommentDeleteLink=Class.create(Component.Link,{onClick:function(A){A.stop();
new View.ConfirmationPopup(this.element,{content:"Are you sure you want to delete this comment?",onConfirm:this.onDelete.bindAsEventListener(this)});
},onDelete:function(B){var A="/api/v1/movies/"+this.element.readAttribute("movie")+"/comments/"+this.element.readAttribute("comment")+".json";
new Ajax.Request(A,{parameters:{_method:"delete"},method:"post",onSuccess:this.onSuccess.bind(this),onFailure:this.onFailure.bind(this)});
},onSuccess:function(A){new Effect.Shrink(this.element.up("li"),{direction:"top-left",duration:0.5});
},onFailure:function(A){new View.ErrorPopup(this.element,{title:"Unexpected Error",content:"Failed to delete the comment."});
}});
Component.ShareReviewLink=Class.create(Component.Link,{onClick:function(A){new View.ShareReviewPopup(this.element);
}});
View.ShareReviewPopup=Class.create(View.Popup,{initialize:function($super,D){var E=new Template($F("reviewShareTemplate"));
var A={username:D.readAttribute("user"),reviewId:D.readAttribute("review")};
var B=new Template($("addThisWidgetTemplate").innerHTML).evaluate(A);
A["addThisWidget"]=new DecodingTemplate(B).evaluate(A);
var C={title:"Share This Review",buttons:new Array({name:"Close",value:"close"}),content:E.evaluate(A)};
$super(D,C);
},render:function($super,A){$super(A);
setTimeout("$('pagePopup').down('input').focus()",400);
setTimeout("$('pagePopup').down('input').select()",500);
}});
Component.MoreTheatersLink=Class.create(Component.Link,{onClick:function(B){B.stop();
var A=$(this.element.readAttribute("from"));
A.insert({top:"<input type='hidden' id='radius' name='radius' value='expanded'/>"});
A.submit();
}});
Component.DeferredShowtimesLoader=Class.create(Component.HashLoader,{onSuccess:function($super,A){$super(A);
if(A.responseText.length>0){var B=$$("p.notFound");
if(B!=null){B.each(function(C){C.hide();
});
}}}});
Component.ShowtimeInfoLink=Class.create(Component.Link,{onClick:function(A){A.stop();
var B="viewBuddyReviews=&userId=${currentUser.id}&movieId="+this.element.readAttribute("movie");
new Ajax.Updater("reviewsPanel","/rate.sv",{parameters:B,evalScripts:true});
}});
Component.ShowtimeDateSelectInlineRefresh=Class.create(Component.Select,{onChange:function(A){A.stop();
this.element.fire("date:change",{daysAhead:$F(this.element)});
}});
Component.ShowtimeInlineRefresh=Class.create(Component.Button,{onClick:function(A){A.stop();
this.element.fire("submit:click");
}});
Component.Showtimes=Class.create({initialize:function(A){this.element=A;
this.element.observe("date:change",this.onDateChange.bindAsEventListener(this));
this.element.observe("submit:click",this.onSubmitClick.bindAsEventListener(this));
},onSubmitClick:function(A){this.updateShowtimes();
},onDateChange:function(A){this.updateShowtimes();
},updateShowtimes:function(){$("showtimesListings").update("<div class='loading' style='width:100px;height:100px;'></div>");
var A=Form.serialize(this.element);
new Ajax.Request("/movie/service/showtimes",{parameters:A,onSuccess:this.onSuccess.bind(this),onFailure:this.onFailure.bind(this)});
},onSuccess:function(A){$("showtimesListings").update(A.responseText);
},onFailure:function(A){$("showtimesListings").update("Sorry, we were unable to retrieve showtimes.  Please try again later.");
}});
var DvdGalleryLinks=Class.create();
DvdGalleryLinks.prototype={STATES:{READY:0,LOADING:1,TIMEOUT:2,FAILURE:3},TEMPLATES:{LOADING:'<p class="loading">Loading movies...</p>',TIMEOUT:'<p class="error">Hmmm, no response...Please refresh your browser and try again.</p>',FAILURE:'<p class="error">Whoops, our servers coughed.  Please refresh your browser and try again.</p>'},initialize:function(){this.galleries=$A($("browse").getElementsByTagName("A"));
this.state=this.STATES.READY;
this.bind();
},bind:function(){this.galleries.each(function(A){Event.observe(A,"click",this.onClick.bindAsEventListener(this));
}.bind(this));
},onClick:function(A){Event.stop(A);
if(this.state!=this.STATES.LOADING){this.link=Event.element(A);
this.state=this.STATES.LOADING;
this.paint();
$("gallery").value=Element.readAttribute(this.link,"gallery");
$("page").value="1";
var B=Form.serialize("filters");
new Ajax.Request("/movie.sv",{parameters:B,onSuccess:this.onSuccess.bind(this),onFailure:this.onFailure.bind(this),onTimeout:this.onTimeout.bind(this)});
}},onSuccess:function(A){$("movies").update(A.responseText);
new DvdPaginationLinks();
new DvdSortingLinks();
this.state=this.STATES.READY;
this.paint();
Tracker.tag("MoviesDVDBrowse");
new Component.Binder($("movies"));
},onFailure:function(){this.state=this.STATES.FAILURE;
this.paint();
},onTimeout:function(){this.state=this.STATES.TIMEOUT;
this.paint();
},paint:function(){this.galleries.each(function(A){Element.removeClassName(A.parentNode,"selected");
});
Element.addClassName(this.link.parentNode,"selected");
switch(this.state){case this.STATES.READY:break;
case this.STATES.LOADING:$("movies").update(this.TEMPLATES.LOADING);
break;
case this.STATS.TIMEOUT:$("movies").update(this.TEMPLATES.TIMEOUT);
break;
case this.STATES.FAILURE:$("movies").update(this.TEMPLATES.FAILURE);
break;
}}};
var DvdPaginationLinks=Class.create();
DvdPaginationLinks.prototype={STATES:{READY:0,LOADING:1,TIMEOUT:2,FAILURE:3},TEMPLATES:{LOADING:'<p class="loading">Loading movies...</p>',TIMEOUT:'<p class="error">Hmmm, no response...Please refresh your browser and try again.</p>',FAILURE:'<p class="error">Whoops, our servers coughed.  Please refresh your browser and try again.</p>'},initialize:function(){if($("pagination")!=null){this.links=$A($("pagination").getElementsByTagName("A"));
this.state=this.STATES.READY;
this.bind();
}},bind:function(){this.links.each(function(A){Event.observe(A,"click",this.onClick.bindAsEventListener(this));
}.bind(this));
},onClick:function(A){Event.stop(A);
if(this.state!=this.STATES.LOADING){this.link=Event.element(A);
this.page=Element.readAttribute(this.link,"page");
this.state=this.STATES.LOADING;
this.paint();
$("page").value=this.page;
var B=Form.serialize("filters");
new Ajax.Request("/movie.sv",{parameters:B,onSuccess:this.onSuccess.bind(this),onFailure:this.onFailure.bind(this),onTimeout:this.onTimeout.bind(this)});
}},onSuccess:function(A){$("movies").update(A.responseText);
new DvdPaginationLinks();
new DvdSortingLinks();
this.state=this.STATES.READY;
this.paint();
Tracker.tag("MoviesDVDBrowse");
new Component.Binder($("movies"));
},onFailure:function(){this.state=this.STATES.FAILURE;
this.paint();
},onTimeout:function(){this.state=this.STATES.TIMEOUT;
this.paint();
},paint:function(){this.links.each(function(A){Element.removeClassName(A,"selected");
});
Element.addClassName(this.link,"selected");
switch(this.state){case this.STATES.READY:break;
case this.STATES.LOADING:$("movies").update(this.TEMPLATES.LOADING);
break;
case this.STATS.TIMEOUT:$("movies").update(this.TEMPLATES.TIMEOUT);
break;
case this.STATES.FAILURE:$("movies").update(this.TEMPLATES.FAILURE);
break;
}}};
var DvdSortingLinks=Class.create();
DvdSortingLinks.prototype={STATES:{READY:0,LOADING:1,TIMEOUT:2,FAILURE:3},TEMPLATES:{LOADING:'<p class="loading">Loading movies...</p>',TIMEOUT:'<p class="error">Hmmm, no response...Please refresh your browser and try again.</p>',FAILURE:'<p class="error">Whoops, our servers coughed.  Please refresh your browser and try again.</p>'},initialize:function(){this.links=$A($("sorting").getElementsByTagName("A"));
this.state=this.STATES.READY;
this.bind();
},bind:function(){this.links.each(function(A){Event.observe(A,"click",this.onClick.bindAsEventListener(this));
}.bind(this));
},onClick:function(A){Event.stop(A);
if(this.state!=this.STATES.LOADING){this.link=Event.element(A);
this.sort=Element.readAttribute(this.link,"sort");
this.state=this.STATES.LOADING;
this.paint();
$("sort").value=this.sort;
$("page").value="1";
var B=Form.serialize("filters");
new Ajax.Request("/movie.sv",{parameters:B,onSuccess:this.onSuccess.bind(this),onFailure:this.onFailure.bind(this),onTimeout:this.onTimeout.bind(this)});
}},onSuccess:function(A){$("movies").update(A.responseText);
new DvdPaginationLinks();
new DvdSortingLinks();
this.state=this.STATES.READY;
this.paint();
Tracker.tag("MoviesDVDBrowse");
new Component.Binder($("movies"));
},onFailure:function(){this.state=this.STATES.FAILURE;
this.paint();
},onTimeout:function(){this.state=this.STATES.TIMEOUT;
this.paint();
},paint:function(){this.links.each(function(A){Element.removeClassName(A,"selected");
});
Element.addClassName(this.link,"selected");
switch(this.state){case this.STATES.READY:break;
case this.STATES.LOADING:$("movies").update(this.TEMPLATES.LOADING);
break;
case this.STATS.TIMEOUT:$("movies").update(this.TEMPLATES.TIMEOUT);
break;
case this.STATES.FAILURE:$("movies").update(this.TEMPLATES.FAILURE);
break;
}}};
var DvdFilterLinks=Class.create();
DvdFilterLinks.prototype={STATES:{READY:0,LOADING:1,TIMEOUT:2,FAILURE:3},TEMPLATES:{LOADING:'<p class="loading">Loading movies...</p>',TIMEOUT:'<p class="error">Hmmm, no response...Please refresh your browser and try again.</p>',FAILURE:'<p class="error">Whoops, our servers coughed.  Please refresh your browser and try again.</p>'},initialize:function(){Event.observe("filterMinRatings","click",this.onClick.bindAsEventListener(this));
if($("filterAlreadyRated")!=null){Event.observe("filterAlreadyRated","click",this.onClick.bindAsEventListener(this));
}this.state=this.STATES.READY;
},onClick:function(A){if(this.state!=this.STATES.LOADING){this.state=this.STATES.LOADING;
this.paint();
$("page").value="1";
var B=Form.serialize("filters");
new Ajax.Request("/movie.sv",{parameters:B,onSuccess:this.onSuccess.bind(this),onFailure:this.onFailure.bind(this),onTimeout:this.onTimeout.bind(this)});
}},onSuccess:function(A){$("movies").update(A.responseText);
new DvdPaginationLinks();
new DvdSortingLinks();
this.state=this.STATES.READY;
this.paint();
Tracker.tag("MoviesDVDBrowse");
new Component.Binder($("movies"));
},onFailure:function(){this.state=this.STATES.FAILURE;
this.paint();
},onTimeout:function(){this.state=this.STATES.TIMEOUT;
this.paint();
},paint:function(){switch(this.state){case this.STATES.READY:break;
case this.STATES.LOADING:$("movies").update(this.TEMPLATES.LOADING);
break;
case this.STATS.TIMEOUT:$("movies").update(this.TEMPLATES.TIMEOUT);
break;
case this.STATES.FAILURE:$("movies").update(this.TEMPLATES.FAILURE);
break;
}}};
var quickRateWidget={STATES:{READY:0,LOADING_BATCH:1,LOADING_MOVIE:2,EMPTY:3},state:0,movies:new Array(),index:-1,position:0,handleBatch:function(){this.state=this.STATES.LOADING_BATCH;
var A="quickRateBatch=&position="+this.position;
new Ajax.Request("/quickrate.sv",{parameters:A,onComplete:this.processBatch.bind(this)});
},processBatch:function(A){this.state=this.STATES.READY;
A.responseText.evalScripts();
if(this.movies.length>this.index+1){this.handleNext();
}else{this.handleEmpty(A);
}},handleEmpty:function(A){this.states=this.STATES.EMPTY;
$("panel").update(A.responseText);
},handleNext:function(){if(this.index<this.movies.length-1){this.state=this.STATES.LOADING_MOVIE;
this.index+=1;
var A="nextQuickRate=&movieId="+this.movies[this.index];
new Ajax.Request("/quickrate.sv",{parameters:A,onComplete:this.processNext.bind(this)});
if(this.index-1>=0){var B="lastQuickRate=&movieId="+this.movies[this.index-1];
new Ajax.Request("/quickrate.sv",{parameters:B,onComplete:this.processPrevious.bind(this)});
}}else{this.handleBatch();
}},handlePrevious:function(){if(this.index>0){this.index-=1;
var A="nextQuickRate=&movieId="+this.movies[this.index];
new Ajax.Request("/quickrate.sv",{parameters:A,evalScripts:true,onComplete:this.processNext.bind(this)});
var B="lastQuickRate=&movieId="+this.movies[this.index-1];
new Ajax.Request("/quickrate.sv",{parameters:B,evalScripts:true,onComplete:this.processPrevious.bind(this)});
}},processNext:function(A){this.state=this.STATES.READY;
$("panel").update(A.responseText);
if(this.index>0){Tracker.tag("RatingQuick");
$("resultsBoxTitle").update("Last Movie Rated");
}document.fire("ads:refresh");
},processPrevious:function(A){$("results").update(A.responseText);
if(this.index==0){$("resultsBoxTitle").update("Quick Rate");
}},paint:function(){switch(this.state){case this.STATES.READY:break;
case this.STATES.LOADING:break;
}}};
var ListWidget=Class.create();
ListWidget.prototype={TEMPLATES:{link:new Template('<a href="#{href}">Saved -- View List</a>')},initialize:function(B,C,A){this.form=B;
this.dropdown=C;
this.movie=A;
this.onChangeHandler=this.onChange.bind(this);
Event.observe(this.dropdown,"change",this.onChangeHandler);
},onChange:function(A){this.list=$F(this.dropdown);
if(this.list=="NONE"){}else{if(!currentUser.isLoggedIn()){alert("Whoops, you'll need to register or sign-in first.");
}else{if(this.list=="NEW"){document.location="/movie-list/custom-list/create?type=USR&movie="+this.movie;
}else{var B=Form.serialize(this.form);
new Ajax.Request("/list.sv",{parameters:B,onSuccess:this.onSuccess.bind(this),onFailure:this.onFailure.bind(this),onTimeout:this.onTimeout.bind(this)});
$(this.form).update("Saving...");
}}}},onSuccess:function(response){var json=eval("("+response.responseText+")");
$(this.form).update(this.TEMPLATES.link.evaluate({href:json.list}));
},onFailure:function(A){$(this.form).update("Whoops, our server coughed.  Please refresh your browser and try again.");
},onTimeout:function(A){$(this.form).update("The network timed out.  Please refresh your browser and try again.");
}};
var LinkVoteWidget=Class.create();
LinkVoteWidget.prototype={STATES:{READY:0,SAVING:1},initialize:function(C,G,E,F,D,A,B){this.movieId=C;
this.similarMovieId=G;
this.thumbsUp=E;
this.thumbsDown=F;
this.thumbsImagePanel="match"+G;
this.savingText=D;
this.thumbs=A==undefined?Constants.THUMBS_NONE:A;
this.statPanel=B;
},handleVoteUp:function(A){this.state=this.STATES.SAVING;
switch(this.thumbs){case Constants.THUMBS_NONE:this.thumbs=Constants.THUMBS_UP;
break;
case Constants.THUMBS_UP:this.thumbs=Constants.THUMBS_NONE;
break;
case Constants.THUMBS_DOWN:this.thumbs=Constants.THUMBS_UP;
break;
}this.paint();
this.saveVote();
},handleVoteDown:function(A){this.state=this.STATES.SAVING;
switch(this.thumbs){case Constants.THUMBS_NONE:this.thumbs=Constants.THUMBS_DOWN;
break;
case Constants.THUMBS_UP:this.thumbs=Constants.THUMBS_DOWN;
break;
case Constants.THUMBS_DOWN:this.thumbs=Constants.THUMBS_NONE;
break;
}this.paint();
this.saveVote();
},saveVote:function(){var A="rateAction=doSuggestVote&movieId="+this.movieId+"&similarMovieId="+this.similarMovieId+"&thumbsId="+this.thumbs;
new Ajax.Request("/rate.sv",{parameters:A,asynchronous:true,onComplete:this.processVote.bind(this)});
},processVote:function(A){$(this.statPanel).innerHTML=A.responseText;
this.state=this.STATES.READY;
this.paint();
},paint:function(){switch(this.thumbs){case Constants.THUMBS_NONE:$(this.thumbsUp).className="thumb thumbsUpOff";
$(this.thumbsDown).className="thumb thumbsDownOff";
break;
case Constants.THUMBS_UP:$(this.thumbsUp).className="thumb thumbsUpOn";
$(this.thumbsDown).className="thumb thumbsDownOff";
break;
case Constants.THUMBS_DOWN:$(this.thumbsUp).className="thumb thumbsUpOff";
$(this.thumbsDown).className="thumb thumbsDownOn";
break;
}}};
var initialMovieItemGroup=0;
Component.VideoGallery=Class.create({initialize:function(A){this.element=A;
this.gallery=this.element.readAttribute("gallery");
this.element.observe("video:click",this.onVideoClick.bindAsEventListener(this));
},onVideoClick:function(A){this.index=parseInt(A.memo.index);
this.isClipLink=A.memo.clipLink;
$("movieIndex").value=""+this.index;
if(!this.isClipLink){movieItems.paint(A.target);
}new View.VideoView("videoPlayerView",{video:A.memo.video,gallery:this.gallery});
new View.VideoClipsView("videoClipsView",{video:A.memo.video});
new View.VideoReviewsView("videoReviewsView",{video:A.memo.video});
new View.VideoRatingsView("videoRatingsView",{video:A.memo.video,forcePage3:false});
new View.VideoAdminView("videoAdminView",{video:A.memo.video});
}});
Component.VideoLink=Class.create(Component.Link,{onClick:function(A){A.stop();
this.element.fire("video:click",{video:this.element.readAttribute("video"),index:this.element.readAttribute("index"),clipLink:false});
}});
Component.VideoClipLink=Class.create(Component.Link,{onClick:function(A){A.stop();
this.element.fire("video:click",{video:this.element.readAttribute("video"),index:$("movieIndex").value,clipLink:true});
}});
function ChoiceSelector(){this.choices=[];
}ChoiceSelector.prototype={addChoice:function(A){this.choices.push($(A));
},browseNext:function(){var A=parseInt($("movieIndex").value);
var B=(A==(this.choices.length-1))?this.choices[0]:this.choices[A+1];
B.fire("video:click",{video:B.readAttribute("video"),index:B.readAttribute("index")});
},browseBack:function(){var A=parseInt($("movieIndex").value);
var B=(A==0||A==-1)?this.choices[this.choices.length-1]:this.choices[A-1];
B.fire("video:click",{video:B.readAttribute("video"),index:B.readAttribute("index")});
},paint:function(B){for(var A=0;
A<this.choices.length;
A++){this.choices[A].removeClassName("selected");
}(B.up("li"))?B.up("li").addClassName("selected"):B.addClassName("selected");
}};
Component.RatingSummary=Class.create({initialize:function(A){this.element=A;
this.element.observe("wantToSee:click",this.onWantToSeeClick.bindAsEventListener(this));
this.element.observe("rateDone:click",this.onRateDone.bindAsEventListener(this));
this.element.observe("editRating:click",this.onEditRating.bindAsEventListener(this));
},onWantToSeeClick:function(A){if(!currentUser.isLoggedIn()){alert("Sign-in or register to save your ratings!");
}else{this.wantToSeeStatus=A.memo.clickOption;
if(this.wantToSeeStatus=="wts"){$("ratingSummaryStatusMessage").update("Want to See");
$("ratingSummaryStatusMessage").className="wts";
$("ratingSummaryRatingStars").hide();
}else{if(this.wantToSeeStatus=="ni"){$("ratingSummaryStatusMessage").update("Not Interested");
$("ratingSummaryStatusMessage").className="ni";
$("ratingSummaryRatingStars").hide();
}else{$("ratingSummaryStatusMessage").update("Already Seen It");
$("ratingSummaryStatusMessage").className="asi";
$("ratingSummaryRatingStars").show();
}}$("ratingSummaryPage1","ratingSummaryPage2","ratingSummaryPage3").invoke("hide");
$("ratingSummaryPage2").show();
}},onRateDone:function(A){new View.VideoRatingsView("videoRatingsView",{video:A.memo.video,forcePage3:true});
},onEditRating:function(A){$("ratingSummaryPage1","ratingSummaryPage2","ratingSummaryPage3").invoke("hide");
$("ratingSummaryPage1").show();
}});
Component.WantToSeeLink=Class.create(Component.Link,{onClick:function(A){A.stop();
this.element.fire("wantToSee:click",{clickOption:this.element.readAttribute("clickOption")});
}});
Component.RatingDoneButton=Class.create(Component.Link,{onClick:function(A){A.stop();
window.setTimeout('$("ratingDoneBtn").fire("rateDone:click", { video : $("ratingDoneBtn").readAttribute("video")  })',500);
}});
Component.EditRatingLink=Class.create(Component.Link,{onClick:function(A){A.stop();
this.element.fire("editRating:click");
}});
Component.ToggleTabsFullToggle=Class.create({initialize:function(A){this.element=$(A);
this.toggles=this.element.select("h2[tab]");
this.toggles.invoke("observe","click",this.onClick.bindAsEventListener(this));
this.element.observe("video:click",this.onNextTrailerChange.bindAsEventListener(this));
if(initialMovieItemGroup>0){this.loadInitialView(initialMovieItemGroup-1);
}},loadInitialView:function(A){this.element.down("div.panel",A).down("h2").addClassName("selected");
this.toggles.each(function(B){this.element.down(B.readAttribute("tab")).hide();
}.bind(this));
this.element.down(this.element.down("div.panel",A).down("h2").readAttribute("tab")).show();
},onClick:function(A){A.stop();
if(A.target.hasClassName("selected")){this.toggles.invoke("removeClassName","selected");
this.toggles.each(function(B){this.element.down(B.readAttribute("tab")).hide();
}.bind(this));
}else{this.toggles.invoke("removeClassName","selected");
A.target.addClassName("selected");
this.toggles.each(function(B){this.element.down(B.readAttribute("tab")).hide();
}.bind(this));
this.element.down(A.target.readAttribute("tab")).show();
}},onNextTrailerChange:function(A){if(A.target.up("ul").style.display=="none"){this.toggles.invoke("removeClassName","selected");
A.target.up("div.panel").down("h2").addClassName("selected");
this.toggles.each(function(B){this.element.down(B.readAttribute("tab")).hide();
}.bind(this));
this.element.down(A.target.up("div.panel").down("h2").readAttribute("tab")).show();
}}});
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.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});
}});
View.VideoView=Class.create(View.RemoteView,{render:function(A){var B="viewTrailer=&videoId="+A.video+"&gallery="+A.gallery;
new Ajax.Request("/trailers.sv",{parameters:B,onSuccess:this.onSuccess.bind(this)});
},onSuccess:function(A){this.element.update(A.responseText);
new Component.Binder(this.element);
document.fire("ads:refresh");
}});
View.VideoClipsView=Class.create(View.RemoteView,{render:function(A){var B="viewVideoClips=&videoId="+A.video;
new Ajax.Request("/trailers.sv",{parameters:B,onSuccess:this.onSuccess.bind(this)});
},onSuccess:function(A){this.element.update(A.responseText);
new Component.Binder(this.element);
}});
View.VideoReviewsView=Class.create(View.RemoteView,{render:function(A){var B="viewVideoReviews=&videoId="+A.video;
new Ajax.Request("/trailers.sv",{parameters:B,onSuccess:this.onSuccess.bind(this)});
},onSuccess:function(A){this.element.update(A.responseText);
new Component.Binder(this.element);
}});
View.VideoRatingsView=Class.create(View.RemoteView,{render:function(A){var B="viewVideoRatings=&videoId="+A.video;
this.forcePage3=A.forcePage3;
new Ajax.Request("/trailers.sv",{parameters:B,onSuccess:this.onSuccess.bind(this)});
},onSuccess:function(A){this.element.update(A.responseText);
new Component.Binder(this.element);
if(this.forcePage3){$("ratingSummaryPage1","ratingSummaryPage2","ratingSummaryPage3").invoke("hide");
$("ratingSummaryPage3").show();
}}});
View.VideoAdminView=Class.create(View.RemoteView,{render:function(A){var B="viewVideoAdmin=&videoId="+A.video;
new Ajax.Request("/trailers.sv",{parameters:B,onSuccess:this.onSuccess.bind(this)});
},onSuccess:function(A){this.element.update(A.responseText);
new Component.Binder(this.element);
}});
var addToFavoritesWidget=Class.create();
addToFavoritesWidget.prototype={initialize:function(B,A){this.thelink=B;
this.movie=A;
this.onClickHandler=this.onClick.bind(this);
Event.observe(this.thelink,"click",this.onClickHandler);
},onClick:function(A){if(!currentUser.isLoggedIn()){alert("Whoops, you'll need to register or sign-in first.");
}else{var B="service=addMovie&mid="+this.movie+"&listId=FAV";
new Ajax.Request("/list.sv",{parameters:B,onSuccess:this.onSuccess.bind(this),onFailure:this.onFailure.bind(this),onTimeout:this.onTimeout.bind(this)});
$(this.thelink).update("Saving...");
}},onSuccess:function(response){var json=eval("("+response.responseText+")");
$(this.thelink).update("Favorited!");
$(this.thelink).removeClassName("jlink");
Event.stopObserving(this.thelink,"click",this.onClickHandler);
},onFailure:function(A){$(this.thelink).update("Whoops, our server coughed.  Please refresh your browser and try again.");
},onTimeout:function(A){$(this.thelink).update("The network timed out.  Please refresh your browser and try again.");
}};
Component.ShowtimesMap=Class.create({template:new Template("<h2>#{name}</h2>#{address}<br/>#{city}, #{state}<form action='http://maps.google.com/maps' method='get' target='_blank'> <b>Get directions:</b><br/><input id='mg_daddr' name='daddr' value='#{address}, #{city}, #{state}' type='hidden'><input id='mg_saddr' name='saddr' type='text' class='search'><input value='Go' type='submit'></form>"),initialize:function(C){this.element=$(C);
if(GBrowserIsCompatible()){var E=this.element.serialize(true);
var D=new GMap2(this.element);
D.setCenter(new GLatLng(E.latitude,E.longitude),15);
D.setMapType(G_NORMAL_MAP);
D.addControl(new GSmallMapControl());
var A=new GMarker(new GLatLng(E.latitude,E.longitude));
D.addOverlay(A);
var B=this.template.evaluate(E);
A.openInfoWindowHtml(B);
}}});
Component.ChangeSkinLink=Class.create(Component.Link,{onClick:function(A){A.stop();
var B={skin:this.element.readAttribute("skin")};
new Ajax.Request("/skins/action/change",{parameters:B,onSuccess:this.onSuccess.bind(this)});
},onSuccess:function(A){new View.SuccessPopup(this.element,{title:"Profile Updated.",content:"Click 'ok' to check out your new profile skin.",onClose:this.onClose.bindAsEventListener(this)});
},onClose:function(A){document.location="/profile";
}});
Component.MovieSuggestionSearchForm=Class.create(Component.Form,{onSubmit:function(A){A.stop();
var B=this.element.serialize(true);
new Ajax.Request(this.element.action,{parameters:B,onComplete:this.onComplete.bind(this)});
new View.LoadingView($("results"),{message:"Searching suggestions..."});
},onComplete:function(A){this.element.down(".button").removeClassName("loading");
$("results").update(A.responseText);
new Component.Binder($("results"));
}});
View.MovieShowtimes=Class.create(View.RemoteView,{render:function(A){var B={movie:A.movie,theater:A.theater};
new Ajax.Request("/movie/inline-showtimes",{parameters:B,onSuccess:this.onSuccess.bind(this)});
},onSuccess:function(A){this.element.update(A.responseText);
new Component.Binder(this.element);
}});
var hubElements={hubMovies:new Array(),hubActors:new Array(),hubQuizzes:new Array(),initialize:function(){this.hubTrailer=null;
this.hubFeaturedMovie=null;
},handleTrailerLoad:function(){var A="action=getHubTrailer&trailerId="+this.hubTrailer;
new Ajax.Request("/trailers.sv",{parameters:A,onComplete:this.onSuccessTrailer.bind(this),onFailure:this.onFailureTrailer.bind(this),onTimeout:this.onTimeoutTrailer.bind(this)});
},onSuccessTrailer:function(A){$("hubTrailer").update(A.responseText);
$("hubTrailer").show();
},onFailureTrailer:function(A){$("hubTrailer").update("FAILED: "+A.responseText);
},onTimeoutTrailer:function(A){$("hubTrailer").update("TIMEOUT: "+A.responseText);
},handleFeaturedMovieLoad:function(){var A="movieAction=getHubFeaturedMovie&featuredMovieId="+this.hubFeaturedMovie;
new Ajax.Request("/movie.sv",{parameters:A,onComplete:this.onSuccessFeaturedMovie.bind(this),onFailure:this.onFailureFeaturedMovie.bind(this),onTimeout:this.onTimeoutFeaturedMovie.bind(this)});
},onSuccessFeaturedMovie:function(A){$("hubFeaturedMovie").update(A.responseText);
$("hubFeaturedMovie").show();
},onFailureFeaturedMovie:function(A){$("hubFeaturedMovie").update("FAILED: "+A.responseText);
},onTimeoutFeaturedMovie:function(A){$("hubFeaturedMovie").update("TIMEOUT: "+A.responseText);
},handleMoviesLoad:function(){var A="movieAction=getHubMovies&movieIds="+this.hubMovies;
new Ajax.Request("/movie.sv",{parameters:A,onComplete:this.onSuccessMovies.bind(this),onFailure:this.onFailureMovies.bind(this),onTimeout:this.onTimeoutMovies.bind(this)});
},onSuccessMovies:function(A){$("hubMovies").update(A.responseText);
$("hubMovies").show();
},onFailureMovies:function(A){$("hubMovies").update("FAILED: "+A.responseText);
},onTimeoutMovies:function(A){$("hubMovies").update("TIMEOUT: "+A.responseText);
},handleActorLoad:function(){var A="actorAction=getHubActors&actorIds="+this.hubActors;
new Ajax.Request("/actor.sv",{parameters:A,onComplete:this.onSuccessActor.bind(this),onFailure:this.onFailureActor.bind(this),onTimeout:this.onTimeoutActor.bind(this)});
},onSuccessActor:function(A){$("hubActors").update(A.responseText);
$("hubActors").show();
},onFailureActor:function(A){$("hubActors").update("FAILED: "+A.responseText);
},onTimeoutActor:function(A){$("hubActors").update("TIMEOUT: "+A.responseText);
},handleQuizLoad:function(){var A="gameAction=getHubQuizzes&quizIds="+this.hubQuizzes;
new Ajax.Request("/quiz.sv",{parameters:A,onComplete:this.onSuccessQuiz.bind(this),onFailure:this.onFailureQuiz.bind(this),onTimeout:this.onTimeoutQuiz.bind(this)});
},onSuccessQuiz:function(A){$("hubQuizzes").update(A.responseText);
$("hubQuizzes").show();
},onFailureQuiz:function(A){$("hubQuizzes").update("FAILED: "+A.responseText);
},onTimeoutQuiz:function(A){$("hubQuizzes").update("TIMEOUT: "+A.responseText);
},handlePhotosLoad:function(){if(this.hubMovies.length<1){return ;
}var A=new Array();
for(i=0;
i<this.hubMovies.length;
i++){A.push(this.hubMovies[i]);
}var B="action=getHubPhotos&movieIds="+A;
new Ajax.Request("/photo.sv",{parameters:B,onComplete:this.onSuccessPhotos.bind(this),onFailure:this.onFailurePhotos.bind(this),onTimeout:this.onTimeoutPhotos.bind(this)});
},onSuccessPhotos:function(A){$("hubPhotos").update(A.responseText);
$("hubPhotos").show();
},onFailurePhotos:function(A){$("hubPhotos").update("FAILED: "+A.responseText);
},onTimeoutPhotos:function(A){$("hubPhotos").update("TIMEOUT: "+A.responseText);
}};




var package_rating_staticServer="http://static5.flixster.com/static";
var RatingsApi={updateRating:function(B,D){var A="/api/v1/users/"+B.user+"/ratings/"+B.movie;
var C={score:B.score,source:B.source};
new Ajax.Request(A,{method:"put",onSuccess:D,parameters:C});
},updateReview:function(B,D){var A="/api/v1/users/"+B.user+"/ratings/"+B.movie;
var C={review:B.review,source:B.source};
new Ajax.Request(A,{method:"put",onSuccess:D,parameters:C});
},updateRatingAndReview:function(B,D){var A="/api/v1/users/"+B.user+"/ratings/"+B.movie;
var C={score:B.score,review:B.review,source:B.source};
new Ajax.Request(A,{method:"put",onSuccess:D,parameters:C});
},clearRating:function(A,B){RatingsApi.updateRatingAndReview(A,B);
}};
Component.RatingButton=Class.create({SCORE:-1,initialize:function(A){this.button=$(A);
this.score=parseInt($F(this.button));
this.controller=$(this.button.readAttribute("controller"));
this.button.observe("click",this.onClick.bindAsEventListener(this));
this.button.observe("mouseout",this.onMouseout.bindAsEventListener(this));
this.controller.observe("rating:score",this.onRate.bindAsEventListener(this));
this.controller.observe("rating:clear",this.onClear.bindAsEventListener(this));
},onClick:function(A){A.stop();
A.target.fire("rating:score",{score:this.SCORE});
},onRate:function(A){this.score=A.memo.score;
this.button.value=this.score;
this.paint(this.score);
},onMouseout:function(A){this.paint(this.score);
},onClear:function(A){this.score=-1;
this.button.value=this.score;
this.paint(this.score);
}});
Component.RatingWtsButton=Class.create(Component.RatingButton,{SCORE:12,initialize:function($super,A){$super(A);
this.button.observe("mouseover",this.onMouseover.bindAsEventListener(this));
},onMouseover:function(A){if(this.score!=this.SCORE){$(this.button).setStyle({backgroundPosition:"-148px -30px"});
}},paint:function(A){if(A==this.SCORE){$(this.button).setStyle({backgroundPosition:"-74px -30px"});
}else{$(this.button).setStyle({backgroundPosition:"0px -30px"});
}}});
Component.RatingNiButton=Class.create(Component.RatingButton,{SCORE:11,initialize:function($super,A){$super(A);
this.button.observe("mouseover",this.onMouseover.bindAsEventListener(this));
},onMouseover:function(A){if(this.score!=this.SCORE){$(this.button).setStyle({backgroundPosition:"-148px -45px"});
}},paint:function(A){if(A==this.SCORE){$(this.button).setStyle({backgroundPosition:"-74px -45px"});
}else{$(this.button).setStyle({backgroundPosition:"0px -45px"});
}}});
Component.RatingStars=Class.create(Component.RatingButton,{initialize:function($super,A){$super(A);
this.button.observe("mousemove",this.onMousemove.bindAsEventListener(this));
},onMousemove:function(A){this.paint(this.map(A));
},onClick:function(A){A.stop();
this.button.blur();
var B=this.map(A);
if(B==this.score){B=-1;
}A.target.fire("rating:score",{score:B});
},map:function(B){var C=B.pointerX();
var D=B.target.cumulativeOffset().left;
var A=C-D;
if($R(0,6).include(A)){return 6;
}else{if($R(7,13).include(A)){return 1;
}else{if($R(14,20).include(A)){return 7;
}else{if($R(21,27).include(A)){return 2;
}else{if($R(28,34).include(A)){return 8;
}else{if($R(35,41).include(A)){return 3;
}else{if($R(42,49).include(A)){return 9;
}else{if($R(50,55).include(A)){return 4;
}else{if($R(56,62).include(A)){return 10;
}else{if($R(63,70).include(A)){return 5;
}else{return -1;
}}}}}}}}}}},paint:function(A){switch(A){case 1:$(this.button).setStyle({backgroundPosition:"-56px 0px"});
break;
case 2:$(this.button).setStyle({backgroundPosition:"-42px 0px"});
break;
case 3:$(this.button).setStyle({backgroundPosition:"-28px 0px"});
break;
case 4:$(this.button).setStyle({backgroundPosition:"-14px 0px"});
break;
case 5:$(this.button).setStyle({backgroundPosition:"0px 0px"});
break;
case 6:$(this.button).setStyle({backgroundPosition:"-56px -15px"});
break;
case 7:$(this.button).setStyle({backgroundPosition:"-42px -15px"});
break;
case 8:$(this.button).setStyle({backgroundPosition:"-28px -15px"});
break;
case 9:$(this.button).setStyle({backgroundPosition:"-14px -15px"});
break;
case 10:$(this.button).setStyle({backgroundPosition:"0px -15px"});
break;
default:$(this.button).setStyle({backgroundPosition:"-70px 0px"});
}}});
Component.RatingCancelLink=Class.create(Component.Link,{onClick:function(A){A.stop();
this.element.fire("rating:cancel",{});
}});
Component.RatingEditLink=Class.create(Component.Link,{onClick:function(A){A.stop();
this.element.fire("rating:edit",{});
}});
Component.RatingClearButton=Class.create(Component.Button,{onClick:function(A){A.stop();
A.target.fire("rating:clear",{score:-1});
}});
Component.ReviewWidget=Class.create({initialize:function(A){this.textarea=$(A);
this.hasDefaultText=(this.textarea.readAttribute("defaultText")!=null);
if(this.hasDefaultText){this.defaultTextValue=this.textarea.readAttribute("defaultText");
if($F(this.textarea)==null||$F(this.textarea).blank()){this.textarea.value=this.defaultTextValue;
}}this.controller=$(this.textarea.readAttribute("controller"));
this.textarea.observe("focus",this.onFocus.bindAsEventListener(this));
this.controller.observe("rating:clear",this.onClear.bindAsEventListener(this));
},onFocus:function(A){A.target.fire("review:change",{});
if(this.hasDefaultText){if($F(this.textarea)==this.defaultTextValue){this.textarea.value="";
}}},onClear:function(A){this.textarea.value="";
}});
Component.ReviewSaveButton=Class.create({initialize:function(A){this.button=A;
this.controller=$(this.button.readAttribute("controller"));
this.button.observe("click",this.onClick.bindAsEventListener(this));
},onClick:function(A){A.stop();
A.target.fire("review:save",{});
}});




Component.ExpandoRatingWidget=Class.create({initialize:function(A){this.element=$(A);
this.currentView=null;
this.isAnonUser=true;
this.isInitialized=false;
this.element.observe("mouseover",this.onLazyInit.bindAsEventListener(this));
},onLazyInit:function(){if(!this.isInitialized){this.isInitialized=true;
this.rating=this.element.serialize(true);
this.rating.unsavedScore=this.rating.score;
this.isAnonUser=(this.rating.user==null||this.rating.user.blank());
this.element.observe("rating:score",this.onRate.bindAsEventListener(this));
this.element.observe("rating:clear",this.onClear.bindAsEventListener(this));
this.element.observe("review:save",this.onSave.bindAsEventListener(this));
this.element.observe("rating:edit",this.onEdit.bindAsEventListener(this));
this.element.observe("rating:cancel",this.onCancel.bindAsEventListener(this));
}},onRate:function(A){this.rating.unsavedScore=A.memo.score;
A.memo.rating=this.rating;
},onEdit:function(){if(!this.isAnonUser){this.makeEditable();
}else{this.showAnonAlert();
}},onClear:function(A){this.rating.score=-1;
this.rating.unsavedScore=-1;
this.rating.review="";
RatingsApi.clearRating(this.rating);
A.memo.rating=this.rating;
this.makeNonEditable();
},onSave:function(A){var B=this.element.select("textarea.commentField").first();
this.rating.review=($F(B)==B.readAttribute("defaultText")||$F(B).blank())?"":$F(B);
this.rating.score=this.rating.unsavedScore;
RatingsApi.updateRatingAndReview(this.rating);
A.memo.rating=this.rating;
this.makeNonEditable();
},onCancel:function(){this.makeNonEditable();
},makeEditable:function(){this.element.down(".elementsWrapper").makePositioned();
this.currentView=new View.RatingElementsEditable(this.element,{eid:this.element.readAttribute("id"),rating:this.rating});
},makeNonEditable:function(){this.element.undoPositioned();
this.currentView=new View.RatingElementsNonEditable(this.element,{eid:this.element.readAttribute("id"),rating:this.rating});
},showAnonAlert:function(){new View.ErrorPopup(this.element,{title:"Whoops",content:"To rate movies, you must be logged in"});
}});
View.RatingElementsEditable=Class.create(View.AbstractView,{render:function(C){var B="";
var A="http://static5.flixster.com/static/images/pixel.gif";
C.rating.wtsBtnState=((parseInt(C.rating.score)==12)?"On":"Off");
C.rating.niBtnState=((parseInt(C.rating.score)==11)?"On":"Off");
C.rating.scoreCssCode=this.cssScoreMap(parseInt(C.rating.score))+"";
if($("expandoRatingWidgetInputForm")!=null){if($("expandoRatingWidgetInputForm").up("form")!=$(C.eid)){$("expandoRatingWidgetInputForm").getOffsetParent().undoPositioned();
}$("expandoRatingWidgetInputForm").remove();
}this.element.down(".elementsWrapper").innerHTML+="<div id='expandoRatingWidgetInputForm' class='inputForm'>&nbsp;</div>";
B="";
B+="<h4>";
B+="<span class='closeBtn' component='RatingCancelLink'>&nbsp;</span>";
B+="Rate &quot;"+C.rating.movieTitle+"&quot;";
B+="</h4>";
B+="<div class='controls'>";
B+="<input type='image' value='"+C.rating.score+"' class='wtsBtn ratingInterest wts"+C.rating.wtsBtnState+"' src='"+A+"' component='RatingWtsButton'  controller='"+C.eid+"'/>";
B+="<input type='image' value='"+C.rating.score+"' class='niBtn ratingInterest ni"+C.rating.niBtnState+"' src='"+A+"' component='RatingNiButton' controller='"+C.eid+"'/>";
B+="<input type='image' value='"+C.rating.score+"' class='scoreBtn ratingStars score"+C.rating.scoreCssCode+"' src='"+A+"' component='RatingStars' controller='"+C.eid+"'/>";
B+="<textarea class='commentField' component='ReviewWidget' controller='"+C.eid+"' defaultText='Add a review...'>"+C.rating.review.escapeHTML()+"</textarea>";
B+="<input type='image' src='"+A+"' component='ReviewSaveButton' controller='"+C.eid+"' class='saveBtn' />";
if(C.rating.showClear=="true"){B+="<a href='#' component='RatingClearButton' class='clearLink'>clear rating</a>";
}B+="<a href='#' component='RatingCancelLink' class='cancelLink'>cancel</a>";
B+="</div>";
$("expandoRatingWidgetInputForm").update(B);
new Component.Binder(this.element);
},cssScoreMap:function(A){switch(A){case 1:return 10;
break;
case 2:return 20;
break;
case 3:return 30;
break;
case 4:return 40;
break;
case 5:return 50;
break;
case 6:return 5;
break;
case 7:return 15;
break;
case 8:return 25;
break;
case 9:return 35;
break;
case 10:return 45;
break;
case 11:return"wts";
break;
case 12:return"ni";
break;
default:return 0;
}}});
View.RatingElementsNonEditable=Class.create(View.AbstractView,{render:function(C){var B="";
var A="http://static5.flixster.com/static/images/pixel.gif";
var E=(parseInt(C.rating.score)>-1);
var D=(C.rating.review!="");
B+="<div class='elementsWrapper'>\n";
if(D){B+="<input type='image' src='"+A+"' component='RatingEditLink' class='editCommentBtn'/>\n";
}B+="<input type='image' src='"+A+"' component='RatingEditLink' class='"+((E)?"editBtn":"rateBtn")+"'/>\n";
B+="</div>";
this.element.update(B);
new View.RatingScoreView(this.element.down(".elementsWrapper"),C.rating);
new Component.Binder(this.element);
}});
View.RatingScoreView=Class.create(View.AbstractView,{render:function(A){switch(parseInt(A.score)){case 1:this.element.insert({"top":"<span class='ratingStars score10'> </span>\n"});
break;
case 2:this.element.insert({"top":"<span class='ratingStars score20'> </span>\n"});
break;
case 3:this.element.insert({"top":"<span class='ratingStars score30'> </span>\n"});
break;
case 4:this.element.insert({"top":"<span class='ratingStars score40'> </span>\n"});
break;
case 5:this.element.insert({"top":"<span class='ratingStars score50'> </span>\n"});
break;
case 6:this.element.insert({"top":"<span class='ratingStars score05'> </span>\n"});
break;
case 7:this.element.insert({"top":"<span class='ratingStars score15'> </span>\n"});
break;
case 8:this.element.insert({"top":"<span class='ratingStars score25'> </span>\n"});
break;
case 9:this.element.insert({"top":"<span class='ratingStars score35'> </span>\n"});
break;
case 10:this.element.insert({"top":"<span class='ratingStars score45'> </span>\n"});
break;
case 11:this.element.insert({"top":"<span class='ratingInterest niOn'> </span>\n"});
break;
case 12:this.element.insert({"top":"<span class='ratingInterest wtsOn'> </span>\n"});
break;
default:this.element.insert({"top":"\n"});
}}});




