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 ratingSubmitQueue=new Array();
var ratingSubmitQueueLength=0;
var ajaxObj;
var d=document;
var curRatingIds=new Array();
var curRatings=new Array();
var origRatings=new Array();
var movieTitles=new Array();
var movieDbIds=new Array();
var rateSrc=new Array();
function rateScoreToImage(A,B){useNew=false;
if(B=="qck"||B=="wiz"||B=="mct"){useNew=true;
}if(A==0){return"http://static5.flixster.com/static/images/0stars."+(useNew?"new.":"")+"gif";
}if(A==1){return"http://static5.flixster.com/static/images/1stars."+(useNew?"new.":"")+"gif";
}if(A==2){return"http://static5.flixster.com/static/images/2stars."+(useNew?"new.":"")+"gif";
}if(A==3){return"http://static5.flixster.com/static/images/3stars."+(useNew?"new.":"")+"gif";
}if(A==4){return"http://static5.flixster.com/static/images/4stars."+(useNew?"new.":"")+"gif";
}if(A==5){return"http://static5.flixster.com/static/images/5stars."+(useNew?"new.":"")+"gif";
}if(A==6){return"http://static5.flixster.com/static/images/halfstars."+(useNew?"new.":"")+"gif";
}if(A==7){return"http://static5.flixster.com/static/images/1_halfstars."+(useNew?"new.":"")+"gif";
}if(A==8){return"http://static5.flixster.com/static/images/2_halfstars."+(useNew?"new.":"")+"gif";
}if(A==9){return"http://static5.flixster.com/static/images/3_halfstars."+(useNew?"new.":"")+"gif";
}if(A==10){return"http://static5.flixster.com/static/images/4_halfstars."+(useNew?"new.":"")+"gif";
}if(A==_NOT_INTERESTED){return"http://static5.flixster.com/static/images/0stars."+(useNew?"new.":"")+"gif";
}if(A==_WANT_TO_SEE){return"http://static5.flixster.com/static/images/0stars."+(useNew?"new.":"")+"gif";
}return"http://static5.flixster.com/static/images/0stars."+(useNew?"new.":"")+"gif";
}function flashSaveButton(){if($("widgetSaveBtn")){document.images["widgetSaveBtn"].src="http://static5.flixster.com/static/images/bt_save_ani.gif";
}}function commonWgt_ajaxSubmit(A){var B=commonWgt_getRateSubmitParams(A);
new Ajax.Request("/rate.sv",{parameters:B});
}var expWgt_openMovie="";
function expWgt_expand(A){expWgt_closeOpened();
expWgt_rateSet(A,curRatings[A]);
$("expWgtDisplay"+A).style.display="none";
$("expWgt_rateBox"+A).style.display="block";
expWgt_openMovie=A;
}function expWgt_collapse(A){$("expWgt_rateBox"+A).style.display="none";
$("expWgtDisplay"+A).style.display="block";
}function expWgt_closeOpened(){if(expWgt_openMovie!=""){expWgt_commentSet(expWgt_openMovie,$("commonWgt_commentBox"+expWgt_openMovie).value);
expWgt_rateSave(expWgt_openMovie);
expWgt_openMovie="";
}}function expWgt_rateClear(A){expWgt_commentSet(A,"");
expWgt_rateSet(A,0);
expWgt_rateSave(A);
}function expWgt_rateDone(A){expWgt_commentSet(A,$("commonWgt_commentBox"+A).value);
expWgt_rateSave(A);
}function expWgt_rateStarHover(B,A){document.images["expWgt_rateStarsBtn"+B].src=rateScoreToImage(A,"exp");
}function expWgt_rateStarsReset(A){rating=curRatings[A];
if(rating==_NOT_INTERESTED||rating==_WANT_TO_SEE){document.images["expWgt_rateStarsBtn"+A].src="http://static5.flixster.com/static/images/0stars.gif";
}else{document.images["expWgt_rateStarsBtn"+A].src=rateScoreToImage(rating,"exp");
}}function expWgt_commentSet(A,B){$("commonWgt_commentBox"+A).value=B;
if($("expWgt_comImg"+A)){if(B==""){$("expWgt_comImg"+A).style.display="none";
}else{$("expWgt_comImg"+A).style.display="inline";
}}}function expWgt_rateSet(A,B){curRatings[A]=B;
if(B==_NOT_INTERESTED){document.images["expWgt_rateNiImg"+A].src="http://static5.flixster.com/static/images/ni_on.gif";
document.images["expWgt_rateWsImg"+A].src="http://static5.flixster.com/static/images/ws.gif";
document.images["expWgt_rateStarsBtn"+A].src="http://static5.flixster.com/static/images/0stars.gif";
$("expWgt_rateStarsBtn"+A).className="expWgt_rateStars";
$("expWgt_rateStarBar"+A).className="expWgt_rateStarBar";
if($("expWgt_RerateBtn"+A)){$("expWgt_RerateBtn"+A).style.display="inline";
}if(document.images["expWgt_RateImg"+A]!=null){document.images["expWgt_RateImg"+A].src="http://static5.flixster.com/static/images/ni_flat.gif";
}}else{if(B==_WANT_TO_SEE){document.images["expWgt_rateNiImg"+A].src="http://static5.flixster.com/static/images/ni.gif";
document.images["expWgt_rateWsImg"+A].src="http://static5.flixster.com/static/images/ws_on.gif";
document.images["expWgt_rateStarsBtn"+A].src="http://static5.flixster.com/static/images/0stars.gif";
$("expWgt_rateStarsBtn"+A).className="expWgt_rateStars";
$("expWgt_rateStarBar"+A).className="expWgt_rateStarBar";
if($("expWgt_RerateBtn"+A)){$("expWgt_RerateBtn"+A).style.display="inline";
}if(document.images["expWgt_RateImg"+A]!=null){document.images["expWgt_RateImg"+A].src="http://static5.flixster.com/static/images/ws_flat.gif";
}}else{if(parseInt(B)==0){curRatings[A]=0;
document.images["expWgt_rateWsImg"+A].src="http://static5.flixster.com/static/images/ws.gif";
document.images["expWgt_rateNiImg"+A].src="http://static5.flixster.com/static/images/ni.gif";
$("expWgt_rateStarsBtn"+A).className="expWgt_rateStars";
$("expWgt_rateStarBar"+A).className="expWgt_rateStarBar";
if($("expWgt_RerateBtn"+A)){$("expWgt_RerateBtn"+A).style.display="none";
}if(document.images["expWgt_RateImg"+A]!=null){document.images["expWgt_RateImg"+A].src="http://static5.flixster.com/static/images/rateMe.gif";
}}else{curRatings[A]=parseInt(B);
document.images["expWgt_rateWsImg"+A].src="http://static5.flixster.com/static/images/ws.gif";
document.images["expWgt_rateNiImg"+A].src="http://static5.flixster.com/static/images/ni.gif";
$("expWgt_rateStarsBtn"+A).className="expWgt_rateStars expWgt_rateStars_mod_on";
$("expWgt_rateStarBar"+A).className="expWgt_rateStarBar expWgt_rateStarBar_mod_on";
if($("expWgt_RerateBtn"+A)){$("expWgt_RerateBtn"+A).style.display="inline";
}if(document.images["expWgt_RateImg"+A]!=null){document.images["expWgt_RateImg"+A].src=rateScoreToImage(curRatings[A],"exp");
}}}}}function expWgt_rateSave(A){expWgt_collapse(A);
commonWgt_rateSave(A,true);
expWgt_openMovie="";
}var fltWgt_openMovie="";
function fltWgt_rateStarHover(B,A,C){if($("fltWgt_rateStarsBtn"+B)){document.images["fltWgt_rateStarsBtn"+B].src=rateScoreToImage(A,C);
}}function fltWgt_rateStarsReset(A,B){rating=curRatings[A];
if(rating==_NOT_INTERESTED||rating==_WANT_TO_SEE){if($("fltWgt_rateStarsBtn"+A)){document.images["fltWgt_rateStarsBtn"+A].src="http://static5.flixster.com/static/images/0stars"+((B=="wiz"||B=="mct")?".new":"")+".gif";
}}else{if($("fltWgt_rateStarsBtn"+A)){document.images["fltWgt_rateStarsBtn"+A].src=rateScoreToImage(rating,B);
}}}function fltWgt_rateSet(mvID,rating,type,callback){if(curRatings[mvID]==rating&&curRatings[mvID]!=0){fltWgt_rateSet(mvID,0,type);
if(callback!=null){var code=callback+"('"+mvID+"', '0')";
eval(code);
}return ;
}else{document.fire("rating:score");
curRatings[mvID]=rating;
prepend="";
if(type=="small"){prepend="bt_";
}if(type=="wiz"||type=="mct"){prepend="wiz_";
}if(rating==_NOT_INTERESTED){if($("fltWgt_rateNiImg"+mvID)){document.images["fltWgt_rateNiImg"+mvID].src="http://static5.flixster.com/static/images/"+prepend+"ni_on.gif";
}}else{if($("fltWgt_rateNiImg"+mvID)){document.images["fltWgt_rateNiImg"+mvID].src="http://static5.flixster.com/static/images/"+prepend+"ni_off.gif";
}}if(rating==_WANT_TO_SEE){if($("fltWgt_rateWsImg"+mvID)){document.images["fltWgt_rateWsImg"+mvID].src="http://static5.flixster.com/static/images/"+prepend+"ws_on.gif";
}}else{if($("fltWgt_rateWsImg"+mvID)){document.images["fltWgt_rateWsImg"+mvID].src="http://static5.flixster.com/static/images/"+prepend+"ws_off.gif";
}}if(rating==_NOT_INTERESTED||rating==_WANT_TO_SEE||rating==0){if($("fltWgt_rateStarsBtn"+mvID)){document.images["fltWgt_rateStarsBtn"+mvID].src="http://static5.flixster.com/static/images/0stars"+((type=="wiz"||type=="mct")?".new":"")+".gif";
}}curRatings[mvID]=parseInt(rating);
if(callback!=null){var code=callback+"('"+mvID+"', '"+rating+"')";
eval(code);
}}if(type!="mct"){fltWgt_rateSave(mvID,true);
}else{}}function fltWgt_expandComment(A){if(fltWgt_openMovie==A){fltWgt_collapse(fltWgt_openMovie);
}else{fltWgt_closeOpened();
$("fltWgt_commentExpand"+A).style.display="block";
fltWgt_openMovie=A;
}}function fltWgt_collapse(A){$("fltWgt_commentExpand"+A).style.display="none";
fltWgt_rateSave(A,false);
fltWgt_openMovie="";
}function fltWgt_closeOpened(){if(fltWgt_openMovie!=""){fltWgt_collapse(fltWgt_openMovie);
}}function fltWgt_rateSave(A,B){commonWgt_rateSave(A,B);
}function fltWgt_commentSet(mvID,newComment,callback){$("commonWgt_commentBox"+mvID).value=newComment;
if(callback!=null){var code=callback+"('"+mvID+"')";
eval(code);
}}function fltWgt_rateClear(A,B){fltWgt_commentSet(A,"");
fltWgt_rateSet(A,0,B);
}_AJAX_PARAMS="rateAction=doRate&rateUser="+currentUser.id+"&key="+encodeURIComponent(currentUser.key);
_WANT_TO_SEE="12";
_NOT_INTERESTED="11";
function commonWgt_rateSave(A,D){if(currentUser.isLoggedIn()){commonWgt_ajaxSubmit(A);
if(curRatings[A]==_WANT_TO_SEE&&origRatings[A]!=_WANT_TO_SEE){if(D){var C=movieTitles[A];
if(C.length>30){C=C.substring(0,30)+"...";
}var B=C+" has been added to your list.";
}}}else{commonWgt_ajaxSubmit(A);
if(D){var C=movieTitles[A];
if(C.length>30){C=C.substring(0,30)+"...";
}alert("Your ratings will not be saved until you register or sign in!");
}}if($("widgetSaveBtn")){document.images["widgetSaveBtn"].src="http://static5.flixster.com/static/images/bt_saved.gif";
}}function commonWgt_getRateSubmitParams(B){var A=Math.random()*1000000;
var C=Math.round(A);
if(movieDbIds&&movieDbIds[B]){return(_AJAX_PARAMS+"&rateMovie="+movieDbIds[B]+"&rateScore="+curRatings[B]+"&rateComment="+encodeURIComponent($("commonWgt_commentBox"+B).value)+"&rateSource="+rateSrc[B]+"&rid="+C+"&ratingId="+(curRatingIds&&curRatingIds[B]?curRatingIds[B]:-1));
}else{}}



