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 isOldPage=false;
var RatingManager={cache:new Cache(),options:{url:"/rate.sv",parameters:""},save:function(B,A,E,C){RatingManager.cache.put(A,E);
if(B!=null&&B!=""){var D="rateAction=doRateScore&rateMovie="+A+"&rateScore="+E+"&rateSource="+C+RatingManager.options.parameters;
new Ajax.Request(RatingManager.options.url,{parameters:D});
}},find:function(A){return RatingManager.cache.get(A);
}};
var ReviewManager={cache:new Cache(),options:{url:"/rate.sv",parameters:""},save:function(C,B,A,D){ReviewManager.cache.put(B,A);
if(C!=null&&C!=""){var E="rateAction=doRateReview&rateMovie="+B+"&rateComment="+encodeURIComponent(A)+"&rateSource="+D+RatingManager.options.parameters;
new Ajax.Request(ReviewManager.options.url,{parameters:E});
}},find:function(A){return ReviewManager.cache.get(A);
}};
var RatingWidget=Class.create();
RatingWidget.prototype={initialize:function(B,A,D,C){this.user=B;
this.movie=A;
this.score=D;
this.source=C;
if((this.source=="HOM")||(this.source=="SPL")||(this.source=="QIK")||(this.source=="MVT")){isOldPage=true;
}this.stars=new RatingStars(this);
this.buttons=new RatingButtons(this);
if($("clear"+this.movie)!=null){Event.observe($("clear"+this.movie),"click",this.onClear.bind(this));
}},onRate:function(A){if(!(this.user!=null&&this.user!="")){Tracker.trackEvent("Rating Widget","Anonymous Rating Attempt","Movie Detail");
new View.ErrorPopup("stars"+this.movie,{title:"Whoops",content:"<a href='/userAuth.do?displayRegister='>Register</a> or <a href='/userAuth.do?displayLogin='>login</a> to save and share all of your ratings and reviews!"});
return ;
}if(this.score==A){this.score=0;
}else{this.score=A;
}document.fire("rating:score",{movie:this.movie,score:this.score});
RatingManager.save(this.user,this.movie,this.score,this.source);
this.stars.paint(this.score);
this.buttons.paint(this.score);
},onClear:function(){this.score=0;
RatingManager.save(this.user,this.movie,this.score,this.source);
this.stars.paint(this.score);
this.buttons.paint(this.score);
}};
var RatingStars=Class.create();
RatingStars.prototype={initialize:function(A){this.widget=A;
Event.observe("stars"+this.widget.movie,"mousemove",this.onMousemove.bindAsEventListener(this));
Event.observe("stars"+this.widget.movie,"mouseout",this.onMouseout.bindAsEventListener(this));
Event.observe("stars"+this.widget.movie,"click",this.onClick.bindAsEventListener(this));
this.paint(this.widget.score);
},onMousemove:function(A){var B=this.map(A);
this.paint(B);
},onMouseout:function(A){this.paint(this.widget.score);
},onClick:function(A){var B=this.map(A);
this.widget.onRate(B);
},map:function(E){var D=Position.cumulativeOffset(Event.element(E));
var C=Event.element(E);
var A=0;
if(E.offsetX){A=E.offsetX;
}else{if(C.offsetX!=null){var B=C.offsetX;
A=E.layerX-B;
}else{if(E.layerX){var B=Position.cumulativeOffset(C)[0];
A=E.layerX-B;
C.offsetX=B;
}}}if($R(0,7).include(A)){return 6;
}else{if($R(8,14).include(A)){return 1;
}else{if($R(15,22).include(A)){return 7;
}else{if($R(23,29).include(A)){return 2;
}else{if($R(30,37).include(A)){return 8;
}else{if($R(38,44).include(A)){return 3;
}else{if($R(45,52).include(A)){return 9;
}else{if($R(53,59).include(A)){return 4;
}else{if($R(60,66).include(A)){return 10;
}else{if($R(67,74).include(A)){return 5;
}else{return -1;
}}}}}}}}}}},paint:function(A){if(isOldPage){switch(A){case 1:$("stars"+this.widget.movie).src="http://static5.flixster.com/static/images/rating/1.0.gif";
break;
case 2:$("stars"+this.widget.movie).src="http://static5.flixster.com/static/images/rating/2.0.gif";
break;
case 3:$("stars"+this.widget.movie).src="http://static5.flixster.com/static/images/rating/3.0.gif";
break;
case 4:$("stars"+this.widget.movie).src="http://static5.flixster.com/static/images/rating/4.0.gif";
break;
case 5:$("stars"+this.widget.movie).src="http://static5.flixster.com/static/images/rating/5.0.gif";
break;
case 6:$("stars"+this.widget.movie).src="http://static5.flixster.com/static/images/rating/0.5.gif";
break;
case 7:$("stars"+this.widget.movie).src="http://static5.flixster.com/static/images/rating/1.5.gif";
break;
case 8:$("stars"+this.widget.movie).src="http://static5.flixster.com/static/images/rating/2.5.gif";
break;
case 9:$("stars"+this.widget.movie).src="http://static5.flixster.com/static/images/rating/3.5.gif";
break;
case 10:$("stars"+this.widget.movie).src="http://static5.flixster.com/static/images/rating/4.5.gif";
break;
default:$("stars"+this.widget.movie).src="http://static5.flixster.com/static/images/rating/0.0.gif";
}}else{switch(A){case 1:$("stars"+this.widget.movie).className="ratingStars ratingWidget score10";
$("currentScore").className="ratingStars score10";
break;
case 2:$("stars"+this.widget.movie).className="ratingStars ratingWidget score20";
$("currentScore").className="ratingStars score20";
break;
case 3:$("stars"+this.widget.movie).className="ratingStars ratingWidget score30";
$("currentScore").className="ratingStars score30";
break;
case 4:$("stars"+this.widget.movie).className="ratingStars ratingWidget score40";
$("currentScore").className="ratingStars score40";
break;
case 5:$("stars"+this.widget.movie).className="ratingStars ratingWidget score50";
$("currentScore").className="ratingStars score50";
break;
case 6:$("stars"+this.widget.movie).className="ratingStars ratingWidget score05";
$("currentScore").className="ratingStars score05";
break;
case 7:$("stars"+this.widget.movie).className="ratingStars ratingWidget score15";
$("currentScore").className="ratingStars score15";
break;
case 8:$("stars"+this.widget.movie).className="ratingStars ratingWidget score25";
$("currentScore").className="ratingStars score25";
break;
case 9:$("stars"+this.widget.movie).className="ratingStars ratingWidget score35";
$("currentScore").className="ratingStars score35";
break;
case 10:$("stars"+this.widget.movie).className="ratingStars ratingWidget score45";
$("currentScore").className="ratingStars score45";
break;
default:$("stars"+this.widget.movie).className="ratingStars ratingWidget score00";
$("currentScore").className="ratingStars score00";
}}}};
var RatingButtons=Class.create();
RatingButtons.prototype={initialize:function(A){this.widget=A;
if($("wts"+this.widget.movie)){Event.observe("wts"+this.widget.movie,"click",this.onWtsClick.bindAsEventListener(this));
if(!isOldPage){Event.observe("wts"+this.widget.movie,"mouseover",this.onWtsMouseOver.bindAsEventListener(this));
Event.observe("wts"+this.widget.movie,"mouseout",this.onWtsMouseOut.bindAsEventListener(this));
}}if($("ni"+this.widget.movie)){Event.observe("ni"+this.widget.movie,"click",this.onNiClick.bindAsEventListener(this));
if(!isOldPage){Event.observe("ni"+this.widget.movie,"mouseover",this.onNiMouseOver.bindAsEventListener(this));
Event.observe("ni"+this.widget.movie,"mouseout",this.onNiMouseOut.bindAsEventListener(this));
}}this.paint(this.widget.score);
},onWtsClick:function(A){this.widget.onRate(12);
},onWtsMouseOver:function(A){$("wts"+this.widget.movie).className="ratingInterest ratingWidget wtsHover";
},onWtsMouseOut:function(A){if(this.widget.score==12){$("wts"+this.widget.movie).className="ratingInterest ratingWidget wtsOn";
}else{$("wts"+this.widget.movie).className="ratingInterest ratingWidget wtsOff";
}},onNiClick:function(A){this.widget.onRate(11);
},onNiMouseOver:function(A){$("ni"+this.widget.movie).className="ratingInterest ratingWidget niHover";
},onNiMouseOut:function(A){if(this.widget.score==11){$("ni"+this.widget.movie).className="ratingInterest ratingWidget niOn";
}else{$("ni"+this.widget.movie).className="ratingInterest ratingWidget niOff";
}},paint:function(A){if(isOldPage){switch(A){case 11:if($("ni"+this.widget.movie)){$("ni"+this.widget.movie).src="http://static5.flixster.com/static/images/rating/ni.on.gif";
}if($("wts"+this.widget.movie)){$("wts"+this.widget.movie).src="http://static5.flixster.com/static/images/rating/ws.off.gif";
}break;
case 12:if($("ni"+this.widget.movie)){$("ni"+this.widget.movie).src="http://static5.flixster.com/static/images/rating/ni.off.gif";
}if($("wts"+this.widget.movie)){$("wts"+this.widget.movie).src="http://static5.flixster.com/static/images/rating/ws.on.gif";
}break;
default:if($("ni"+this.widget.movie)){$("ni"+this.widget.movie).src="http://static5.flixster.com/static/images/rating/ni.off.gif";
}if($("wts"+this.widget.movie)){$("wts"+this.widget.movie).src="http://static5.flixster.com/static/images/rating/ws.off.gif";
}}}else{switch(A){case 11:if($("ni"+this.widget.movie)){$("ni"+this.widget.movie).className="ratingInterest ratingWidget niOn";
$("currentScore").className="ratingInterest niOn";
}if($("wts"+this.widget.movie)){$("wts"+this.widget.movie).className="ratingInterest ratingWidget wtsOff";
}break;
case 12:if($("ni"+this.widget.movie)){$("ni"+this.widget.movie).className="ratingInterest ratingWidget niOff";
}if($("wts"+this.widget.movie)){$("wts"+this.widget.movie).className="ratingInterest ratingWidget wtsOn";
$("currentScore").className="ratingInterest wtsOn";
}break;
default:if($("ni"+this.widget.movie)){$("ni"+this.widget.movie).className="ratingInterest ratingWidget niOff";
}if($("wts"+this.widget.movie)){$("wts"+this.widget.movie).className="ratingInterest ratingWidget wtsOff";
}}}}};
var ReviewWidget=Class.create();
ReviewWidget.prototype={initialize:function(B,A,C){this.user=B;
this.movie=A;
this.source=C;
Event.observe($("comment"+this.movie),"focus",this.onFocus.bindAsEventListener(this));
if($("save"+this.movie)!=null){Event.observe($("save"+this.movie),"click",this.onSave.bindAsEventListener(this));
}else{Event.observe($("comment"+this.movie),"blur",this.onSave.bindAsEventListener(this));
}if($("clear"+this.movie)!=null){Event.observe($("clear"+this.movie),"click",this.onClear.bindAsEventListener(this));
}},onFocus:function(A){if($("save"+this.movie)!=null){$("save"+this.movie).src="http://static5.flixster.com/static/images/bt_save_ani.gif";
}},onSave:function(A){var B=false;
if(!(this.user!=null&&this.user!="")){Tracker.trackEvent("Review Widget","Anonymous Review Attempt","Movie Detail");
new View.ErrorPopup("save"+this.movie,{title:"Whoops",content:"<a href='/userAuth.do?displayRegister='>Register</a> or <a href='/userAuth.do?displayLogin='>login</a> to save and share all of your ratings and reviews!"});
return ;
}if($("save"+this.movie)!=null){$("save"+this.movie).src="http://static5.flixster.com/static/images/bt_saved.gif";
}if($("currentComment")!=null){var C=$F("comment"+this.movie).replace(/\n/gi,"<br/>");
$("currentComment").update(C);
}if($("comment"+this.movie).readAttribute("message")!=null){if($F("comment"+this.movie).strip()!=($("comment"+this.movie).readAttribute("message")).strip()){B=true;
}}else{B=true;
}if(B){ReviewManager.save(this.user,this.movie,$F("comment"+this.movie),this.source);
}},onClear:function(A){$("comment"+this.movie).value="";
if($("currentComment")!=null){$("currentComment").update("");
}ReviewManager.save(this.user,this.movie,$F("comment"+this.movie),this.source);
}};
var Images={cache:function(){if(isOldPage){var J=new Image();
J.src="http://static5.flixster.com/static/images/rating/0.0.gif";
var I=new Image();
I.src="http://static5.flixster.com/static/images/rating/1.0.gif";
var H=new Image();
H.src="http://static5.flixster.com/static/images/rating/2.0.gif";
var G=new Image();
G.src="http://static5.flixster.com/static/images/rating/3.0.gif";
var F=new Image();
F.src="http://static5.flixster.com/static/images/rating/4.0.gif";
var E=new Image();
E.src="http://static5.flixster.com/static/images/rating/5.0.gif";
var D=new Image();
D.src="http://static5.flixster.com/static/images/rating/0.5.gif";
var C=new Image();
C.src="http://static5.flixster.com/static/images/rating/1.5.gif";
var B=new Image();
B.src="http://static5.flixster.com/static/images/rating/2.5.gif";
var A=new Image();
A.src="http://static5.flixster.com/static/images/rating/3.5.gif";
var M=new Image();
M.src="http://static5.flixster.com/static/images/rating/4.5.gif";
var L=new Image();
L.src="http://static5.flixster.com/static/images/rating/ni.on.gif";
var K=new Image();
K.src="http://static5.flixster.com/static/images/rating/ws.on.gif";
}}};
Event.observe(window,"load",Images.cache);




