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




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




var watchnowMode="movies";
Component.ViewingStage=Class.create(Component.FlashMovieMeeboBarDecoupler);
function showPage(C,B,A){for(i=1;
i<(C+1);
i++){$(A+i).style.display="none";
}$(A+B).style.display="block";
}function slideToPage(E,C,B){var D=document.getElementById("hdnPage_"+C);
var F=E-D.value;
var A=0;
if(watchnowMode=="tv"){A=744;
}else{if(watchnowMode=="movies"){switch(C){case 2:A=744;
break;
default:A=338;
}}}if(F==0){return ;
}else{(F>0)?MoveRight(F,C,B,A):MoveLeft(-F,C,B,A);
}}function buildPagination(I,H,L,C,D){var J=false;
var A=false;
var B=false;
var E="";
var G="&nbsp;|&nbsp;";
if(I>1){if(C){J=(H>1)?true:false;
E+=(!J)?("<span>Previous</span>"+G):("<span class='jlink' onclick='handlePaging("+I+","+(H-1)+',"'+L+'", '+C+", "+D+")'>Previous</span>"+G);
}var F=G;
for(i=0;
i<I;
i++){B=(H==(i+1))?true:false;
if(C){(i==(I-1))?F="":F=G;
}else{F="";
}var K=(C)?(i+1):"";
E+=(B)?("<span class='currentPage'>"+K+"</span>"+F):("<span class='jlink' onclick='handlePaging("+I+","+(i+1)+',"'+L+'", '+C+", "+D+")'>"+K+"</span>"+F);
}if(C){A=(H==I)?false:true;
E+=(!A)?(G+"<span>Next</span>"):(G+"<span class='jlink' onclick='handlePaging("+I+","+(H+1)+',"'+L+'", '+C+", "+D+")'>Next</span>");
}}$(L+"pagination").update(E);
}function handlePaging(D,C,A,E,B){buildPagination(parseInt(D),C,A,E,B);
if(B!=null){slideToPage(C,B,D);
}else{showPage(parseInt(D),C,A);
}}function toggleMoviesAndTV(A){if(A!="tv"){$("movieBox").style.display="block";
$("tvBox").style.display="none";
$("movieTab").className="selected";
$("tvTab").className="";
}else{$("movieBox").style.display="none";
$("tvBox").style.display="block";
$("movieTab").className="";
$("tvTab").className="selected";
}}function shuffleBigBoxCopy(E,F,B,A){var G=document.getElementById("hdnCopy_"+F);
var D=document.getElementById("BigBox_"+F+"_"+-G.value);
var C=B*A;
if(E==0){if(D.style.left==(C+"px")){D.style.left=(-C+"px");
}}else{if(D.style.left==(((-C*2)+B)+"px")){D.style.left=(B+"px");
}}}function getElementIdPrefix(B){var A="";
if(watchnowMode=="tv"){switch(B){case 1:A="featuredShows_";
break;
case 2:A="featuredEpisodes_";
break;
default:A="";
}}else{if(watchnowMode=="movies"){switch(B){case 1:A="mostWatched_";
break;
case 2:A="recentlyAdded_";
break;
case 3:A="friendsWatched_";
break;
default:A="";
}}}return A;
}function MoveLeft(C,G,B,A){var D=parseInt(B);
if(D==1){alert("No more listings available.");
return ;
}var E=document.getElementById("hdnPage_"+G);
var H=document.getElementById("hdnCopy_"+G);
if(E.value==1){shuffleBigBoxCopy(0,G,A,B);
setBoxEffect((A*C),G);
E.value=D;
H.value=H.value*-1;
}else{setBoxEffect((A*C),G);
var F=parseInt(E.value)-C;
E.value=F;
}buildPagination(parseInt(B),E.value,getElementIdPrefix(G),false,G);
}function MoveRight(C,G,B,A){var D=parseInt(B);
if(D==1){alert("No more listings available.");
return ;
}var E=document.getElementById("hdnPage_"+G);
var H=document.getElementById("hdnCopy_"+G);
if(E.value==D){shuffleBigBoxCopy(1,G,A,B);
setBoxEffect((-1*(A*C)),G);
E.value=1;
H.value=H.value*-1;
}else{setBoxEffect((-1*(A*C)),G);
var F=parseInt(E.value)+C;
E.value=F;
}buildPagination(parseInt(B),E.value,getElementIdPrefix(G),false,G);
}function setBoxEffect(A,B){var C=document.getElementById("hdnCopy_"+B);
new Effect.MoveBy(("BigBox_"+B+"_"+(C.value)),0,A,{duration:0.4,transition:Effect.Transitions.sinoidal,queue:{position:"end",scope:"bigboxscope"}});
new Effect.MoveBy(("BigBox_"+B+"_"+(-C.value)),0,A,{duration:0.4,transition:Effect.Transitions.sinoidal,queue:{position:"end",scope:"bigboxcopyscope"}});
}var ChatLink={visible:true,toggle:function(){ChatLink.visible=!ChatLink.visible;
if(ChatLink.visible){$("chatShowHideLink").update("Hide Chat");
$("chatBoxComments").show();
chatBoxWidget.disabled=false;
}else{$("chatShowHideLink").update("Show Comments");
$("chatBoxComments").hide();
chatBoxWidget.disabled=true;
}}};
function toggleTabs(C,A){if(A!=null){if(watchnowMode=="movies"){var B="videoId="+A+"&selectedChatTab="+(C=="chat");
new Ajax.Request("/watch-movies/service/switch-review-chat-tab",{parameters:B});
}else{if(watchnowMode=="tv"){var B="videoId="+A+"&selectedChatTab="+(C=="tvChat");
new Ajax.Request("/watch-tv/service/switch-episodes-chat-tab",{parameters:B});
}}}if(C=="chat"){$("chatBox").style.display="block";
$("reviewsBox").style.display="none";
$("movieInfoBox").style.display="none";
$("chatTab").className="selected";
$("reviewsTab").className="";
$("movieInfoTab").className="";
}else{if(C=="reviews"){$("chatBox").style.display="none";
$("reviewsBox").style.display="block";
$("movieInfoBox").style.display="none";
$("chatTab").className="";
$("reviewsTab").className="selected";
$("movieInfoTab").className="";
}else{if(C=="movieInfo"){$("chatBox").style.display="none";
$("reviewsBox").style.display="none";
$("movieInfoBox").style.display="block";
$("chatTab").className="";
$("reviewsTab").className="";
$("movieInfoTab").className="selected";
}else{if(C=="tvChat"){$("tvChatBox").style.display="block";
$("episodesBox").style.display="none";
$("chatTab").className="selected";
$("episodesTab").className="";
}else{if(C=="episodes"){$("tvChatBox").style.display="none";
$("episodesBox").style.display="block";
$("chatTab").className="";
$("episodesTab").className="selected";
}}}}}}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).className="";
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.GenreSelect=Class.create(Component.Select,{onChange:function(A){$("genre").value=$F(this.element);
document.indexForm.submit();
}});
Component.RemoveVideo=Class.create(Component.Link,{onClick:function(A){new View.ConfirmationPopup(this.element,{content:"Are you sure",onConfirm:this.onConfirm.bindAsEventListener(this)});
},onConfirm:function(A){this.element.up("form").submit();
}});
function handleDOBform(elForm,messagingDiv){var month=elForm.month.options[elForm.month.selectedIndex].value;
var day=elForm.day.options[elForm.day.selectedIndex].value;
var year=elForm.year.options[elForm.year.selectedIndex].value;
var movie=elForm.movieId.value;
var movieRating=elForm.movieRating.value;
var params="huluDob="+month+"-"+day+"-"+year;
params+="&movieId="+movie;
new Ajax.Request("/watch-movies/service/set-hulu-dob",{parameters:params,onSuccess:function(response){var json=eval("("+response.responseText+")");
var userMeetsAgeRequirements=json.allow;
if(userMeetsAgeRequirements){Modalbox.hide();
}else{$(messagingDiv).update('This movie is rated <span style="border:solid 1px #000;margin:0 3px;padding:1px 3px;font-weight:bold;">'+movieRating+"</span>, so we can't show it to you.<br /><br />Please try some of our other fine programming.  "+'<br /><br />Please contact <a href="/support/contact">Flixster Customer Service</a> if you believe your settings are incorrect.<br /><br /><input type="button" value="OK" onclick="location.href=\'/watch-movies\';"/>');
}},onFailure:function(response){$(messagingDiv).update("Whoops, our server coughed.  Please refresh your browser and try again.");
},onTimeout:function(response){$(messagingDiv).update("The network timed out.  Please refresh your browser and try again.");
}});
}if(!window.Modalbox){var Modalbox=new Object();
}Modalbox.Methods={overrideAlert:false,focusableElements:new Array,currFocused:0,initialized:false,active:true,options:{title:"ModalBox Window",overlayClose:true,width:500,height:90,overlayOpacity:0.65,overlayDuration:0.25,slideDownDuration:0.5,slideUpDuration:0.5,resizeDuration:0.25,inactiveFade:true,transitions:true,loadingString:"Please wait. Loading...",closeString:"Close window",closeValue:"&times;",params:{},method:"get",autoFocusing:true,aspnet:false},_options:new Object,setOptions:function(A){Object.extend(this.options,A||{});
},_init:function(B){Object.extend(this._options,this.options);
this.setOptions(B);
this.MBoverlay=new Element("div",{id:"MB_overlay",opacity:"0"});
this.MBwindow=new Element("div",{id:"MB_window",style:"display: none"}).update(this.MBframe=new Element("div",{id:"MB_frame"}).update(this.MBheader=new Element("div",{id:"MB_header"}).update(this.MBcaption=new Element("div",{id:"MB_caption"}))));
this.MBclose=new Element("a",{id:"MB_close",title:this.options.closeString,href:"javascript:void 0;"}).update("<span></span>");
this.MBheader.insert({"bottom":this.MBclose});
this.MBcontent=new Element("div",{id:"MB_content"}).update(this.MBloading=new Element("div",{id:"MB_loading"}).update(this.options.loadingString));
this.MBframe.insert({"bottom":this.MBcontent});
var A=this.options.aspnet?$(document.body).down("form"):$(document.body);
A.insert({"top":this.MBwindow});
A.insert({"top":this.MBoverlay});
this.initScrollX=window.pageXOffset||document.body.scrollLeft||document.documentElement.scrollLeft;
this.initScrollY=window.pageYOffset||document.body.scrollTop||document.documentElement.scrollTop;
this.hideObserver=this._hide.bindAsEventListener(this);
this.kbdObserver=this._kbdHandler.bindAsEventListener(this);
this._initObservers();
this.initialized=true;
},show:function(B,A){if(!this.initialized){this._init(A);
}this.content=B;
this.setOptions(A);
if(this.options.title){$(this.MBcaption).update(this.options.title);
}else{$(this.MBheader).hide();
$(this.MBcaption).hide();
}if(this.MBwindow.style.display=="none"){this._appear();
this.event("onShow");
}else{this._update();
this.event("onUpdate");
}},hide:function(A){if(this.initialized){if(A&&typeof A.element!="function"){Object.extend(this.options,A);
}this.event("beforeHide");
if(this.options.transitions){Effect.SlideUp(this.MBwindow,{duration:this.options.slideUpDuration,transition:Effect.Transitions.sinoidal,afterFinish:this._deinit.bind(this)});
}else{$(this.MBwindow).hide();
this._deinit();
}}else{throw ("Modalbox is not initialized.");
}},_hide:function(A){A.stop();
if(A.element().id=="MB_overlay"&&!this.options.overlayClose){return false;
}this.hide();
},alert:function(B){var A='<div class="MB_alert"><p>'+B+'</p><input type="button" onclick="Modalbox.hide()" value="OK" /></div>';
Modalbox.show(A,{title:"Alert: "+document.title,width:300});
},_appear:function(){if(Prototype.Browser.IE&&!navigator.appVersion.match(/\b7.0\b/)){window.scrollTo(0,0);
this._prepareIE("100%","hidden");
}this._setWidth();
this._setPosition();
if(this.options.transitions){$(this.MBoverlay).setStyle({opacity:0});
new Effect.Fade(this.MBoverlay,{from:0,to:this.options.overlayOpacity,duration:this.options.overlayDuration,afterFinish:function(){new Effect.SlideDown(this.MBwindow,{duration:this.options.slideDownDuration,transition:Effect.Transitions.sinoidal,afterFinish:function(){this._setPosition();
this.loadContent();
}.bind(this)});
}.bind(this)});
}else{$(this.MBoverlay).setStyle({opacity:this.options.overlayOpacity});
$(this.MBwindow).show();
this._setPosition();
this.loadContent();
}this._setWidthAndPosition=this._setWidthAndPosition.bindAsEventListener(this);
Event.observe(window,"resize",this._setWidthAndPosition);
},resize:function(G,H,C){var F=$(this.MBwindow).getHeight();
var D=$(this.MBwindow).getWidth();
var E=$(this.MBheader).getHeight();
var B=$(this.MBcontent).getHeight();
var A=((F-E+H)<B)?(B+E-F):H;
if(C){this.setOptions(C);
}if(this.options.transitions){new Effect.ScaleBy(this.MBwindow,G,A,{duration:this.options.resizeDuration,afterFinish:function(){this.event("_afterResize");
this.event("afterResize");
}.bind(this)});
}else{this.MBwindow.setStyle({width:D+G+"px",height:F+A+"px"});
setTimeout(function(){this.event("_afterResize");
this.event("afterResize");
}.bind(this),1);
}},resizeToContent:function(A){var B=this.options.height-this.MBwindow.offsetHeight;
if(B!=0){if(A){this.setOptions(A);
}Modalbox.resize(0,B);
}},resizeToInclude:function(C,B){var D=$(C);
var A=D.getHeight()+parseInt(D.getStyle("margin-top"))+parseInt(D.getStyle("margin-bottom"))+parseInt(D.getStyle("border-top-width"))+parseInt(D.getStyle("border-bottom-width"));
if(A>0){if(B){this.setOptions(B);
}Modalbox.resize(0,A);
}},_update:function(){$(this.MBcontent).update("");
this.MBcontent.appendChild(this.MBloading);
$(this.MBloading).update(this.options.loadingString);
this.currentDims=[this.MBwindow.offsetWidth,this.MBwindow.offsetHeight];
Modalbox.resize((this.options.width-this.currentDims[0]),(this.options.height-this.currentDims[1]),{_afterResize:this._loadAfterResize.bind(this)});
},loadContent:function(){if(this.event("beforeLoad")!=false){if(typeof this.content=="string"){var htmlRegExp=new RegExp(/<\/?[^>]+>/gi);
if(htmlRegExp.test(this.content)){this._insertContent(this.content.stripScripts());
this._putContent(function(){this.content.extractScripts().map(function(script){return eval(script.replace("<!--","").replace("// -->",""));
}.bind(window));
}.bind(this));
}else{new Ajax.Request(this.content,{method:this.options.method.toLowerCase(),parameters:this.options.params,onSuccess:function(transport){var response=new String(transport.responseText);
this._insertContent(transport.responseText.stripScripts());
this._putContent(function(){response.extractScripts().map(function(script){return eval(script.replace("<!--","").replace("// -->",""));
}.bind(window));
});
}.bind(this),onException:function(instance,exception){Modalbox.hide();
throw ("Modalbox Loading Error: "+exception);
}});
}}else{if(typeof this.content=="object"){this._insertContent(this.content);
this._putContent();
}else{Modalbox.hide();
throw ("Modalbox Parameters Error: Please specify correct URL or HTML element (plain HTML or object)");
}}}},_insertContent:function(B){$(this.MBcontent).hide().update("");
if(typeof B=="string"){setTimeout(function(){this.MBcontent.update(B);
}.bind(this),1);
}else{if(typeof B=="object"){var A=B.cloneNode(true);
if(B.id){B.id="MB_"+B.id;
}$(B).select("*[id]").each(function(C){C.id="MB_"+C.id;
});
this.MBcontent.appendChild(A);
this.MBcontent.down().show();
if(Prototype.Browser.IE){$$("#MB_content select").invoke("setStyle",{"visibility":""});
}}}},_putContent:function(A){if(this.options.height==this._options.height){setTimeout(function(){Modalbox.resize(0,$(this.MBcontent).getHeight()-$(this.MBwindow).getHeight()+$(this.MBheader).getHeight(),{afterResize:function(){this.MBcontent.show().makePositioned();
this.focusableElements=this._findFocusableElements();
this._setFocus();
setTimeout(function(){if(A!=undefined){A();
}this.event("afterLoad");
}.bind(this),1);
}.bind(this)});
}.bind(this),1);
}else{this._setWidth();
this.MBcontent.setStyle({overflow:"auto",height:$(this.MBwindow).getHeight()-$(this.MBheader).getHeight()-13+"px"});
this.MBcontent.show();
this.focusableElements=this._findFocusableElements();
this._setFocus();
setTimeout(function(){if(A!=undefined){A();
}this.event("afterLoad");
}.bind(this),1);
}},activate:function(A){this.setOptions(A);
this.active=true;
$(this.MBclose).observe("click",this.hideObserver);
if(this.options.overlayClose){$(this.MBoverlay).observe("click",this.hideObserver);
}$(this.MBclose).show();
if(this.options.transitions&&this.options.inactiveFade){new Effect.Appear(this.MBwindow,{duration:this.options.slideUpDuration});
}},deactivate:function(A){this.setOptions(A);
this.active=false;
$(this.MBclose).stopObserving("click",this.hideObserver);
if(this.options.overlayClose){$(this.MBoverlay).stopObserving("click",this.hideObserver);
}$(this.MBclose).hide();
if(this.options.transitions&&this.options.inactiveFade){new Effect.Fade(this.MBwindow,{duration:this.options.slideUpDuration,to:0.75});
}},_initObservers:function(){$(this.MBclose).observe("click",this.hideObserver);
if(this.options.overlayClose){$(this.MBoverlay).observe("click",this.hideObserver);
}if(Prototype.Browser.IE){Event.observe(document,"keydown",this.kbdObserver);
}else{Event.observe(document,"keypress",this.kbdObserver);
}},_removeObservers:function(){$(this.MBclose).stopObserving("click",this.hideObserver);
if(this.options.overlayClose){$(this.MBoverlay).stopObserving("click",this.hideObserver);
}if(Prototype.Browser.IE){Event.stopObserving(document,"keydown",this.kbdObserver);
}else{Event.stopObserving(document,"keypress",this.kbdObserver);
}},_loadAfterResize:function(){this._setWidth();
this._setPosition();
this.loadContent();
},_setFocus:function(){if(this.focusableElements.length>0&&this.options.autoFocusing==true){var A=this.focusableElements.find(function(B){return B.tabIndex==1;
})||this.focusableElements.first();
this.currFocused=this.focusableElements.toArray().indexOf(A);
A.focus();
}else{if($(this.MBclose).visible()){$(this.MBclose).focus();
}}},_findFocusableElements:function(){this.MBcontent.select("input:not([type~=hidden]), select, textarea, button, a[href]").invoke("addClassName","MB_focusable");
return this.MBcontent.select(".MB_focusable");
},_kbdHandler:function(B){var A=B.element();
switch(B.keyCode){case Event.KEY_TAB:B.stop();
if(A!=this.focusableElements[this.currFocused]){this.currFocused=this.focusableElements.toArray().indexOf(A);
}if(!B.shiftKey){if(this.currFocused==this.focusableElements.length-1){this.focusableElements.first().focus();
this.currFocused=0;
}else{this.currFocused++;
this.focusableElements[this.currFocused].focus();
}}else{if(this.currFocused==0){this.focusableElements.last().focus();
this.currFocused=this.focusableElements.length-1;
}else{this.currFocused--;
this.focusableElements[this.currFocused].focus();
}}break;
case Event.KEY_ESC:break;
case 32:this._preventScroll(B);
break;
case 0:if(B.which==32){this._preventScroll(B);
}break;
case Event.KEY_UP:case Event.KEY_DOWN:case Event.KEY_PAGEDOWN:case Event.KEY_PAGEUP:case Event.KEY_HOME:case Event.KEY_END:if(Prototype.Browser.WebKit&&!["textarea","select"].include(A.tagName.toLowerCase())){B.stop();
}else{if((A.tagName.toLowerCase()=="input"&&["submit","button"].include(A.type))||(A.tagName.toLowerCase()=="a")){B.stop();
}}break;
}},_preventScroll:function(A){if(!["input","textarea","select","button"].include(A.element().tagName.toLowerCase())){A.stop();
}},_deinit:function(){this._removeObservers();
Event.stopObserving(window,"resize",this._setWidthAndPosition);
if(this.options.transitions){Effect.toggle(this.MBoverlay,"appear",{duration:this.options.overlayDuration,afterFinish:this._removeElements.bind(this)});
}else{this.MBoverlay.hide();
this._removeElements();
}$(this.MBcontent).setStyle({overflow:"",height:""});
},_removeElements:function(){$(this.MBoverlay).remove();
$(this.MBwindow).remove();
if(Prototype.Browser.IE&&!navigator.appVersion.match(/\b7.0\b/)){this._prepareIE("","");
window.scrollTo(this.initScrollX,this.initScrollY);
}if(typeof this.content=="object"){if(this.content.id&&this.content.id.match(/MB_/)){this.content.id=this.content.id.replace(/MB_/,"");
}this.content.select("*[id]").each(function(A){A.id=A.id.replace(/MB_/,"");
});
}this.initialized=false;
this.event("afterHide");
this.setOptions(this._options);
},_setWidth:function(){$(this.MBwindow).setStyle({width:this.options.width+"px",height:this.options.height+"px"});
},_setPosition:function(){$(this.MBwindow).setStyle({left:Math.round((Element.getWidth(document.body)-Element.getWidth(this.MBwindow))/2)+"px"});
},_setWidthAndPosition:function(){$(this.MBwindow).setStyle({width:this.options.width+"px"});
this._setPosition();
},_getScrollTop:function(){var A;
if(document.documentElement&&document.documentElement.scrollTop){A=document.documentElement.scrollTop;
}else{if(document.body){A=document.body.scrollTop;
}}return A;
},_prepareIE:function(A,B){$$("html, body").invoke("setStyle",{width:A,height:A,overflow:B});
$$("select").invoke("setStyle",{"visibility":B});
},event:function(A){if(this.options[A]){var B=this.options[A]();
this.options[A]=null;
if(B!=undefined){return B;
}else{return true;
}}return true;
}};
Object.extend(Modalbox,Modalbox.Methods);
if(Modalbox.overrideAlert){window.alert=Modalbox.alert;
}Effect.ScaleBy=Class.create();
Object.extend(Object.extend(Effect.ScaleBy.prototype,Effect.Base.prototype),{initialize:function(B,C,D,A){this.element=$(B);
var A=Object.extend({scaleFromTop:true,scaleMode:"box",scaleByWidth:C,scaleByHeight:D},arguments[3]||{});
this.start(A);
},setup:function(){this.elementPositioning=this.element.getStyle("position");
this.originalTop=this.element.offsetTop;
this.originalLeft=this.element.offsetLeft;
this.dims=null;
if(this.options.scaleMode=="box"){this.dims=[this.element.offsetHeight,this.element.offsetWidth];
}if(/^content/.test(this.options.scaleMode)){this.dims=[this.element.scrollHeight,this.element.scrollWidth];
}if(!this.dims){this.dims=[this.options.scaleMode.originalHeight,this.options.scaleMode.originalWidth];
}this.deltaY=this.options.scaleByHeight;
this.deltaX=this.options.scaleByWidth;
},update:function(A){var C=this.dims[0]+(this.deltaY*A);
var B=this.dims[1]+(this.deltaX*A);
C=(C>0)?C:0;
B=(B>0)?B:0;
this.setDimensions(C,B);
},setDimensions:function(A,D){var E={};
E.width=D+"px";
E.height=A+"px";
var C=Math.round((A-this.dims[0])/2);
var B=Math.round((D-this.dims[1])/2);
if(this.elementPositioning=="absolute"||this.elementPositioning=="fixed"){if(!this.options.scaleFromTop){E.top=this.originalTop-C+"px";
}E.left=this.originalLeft-B+"px";
}else{if(!this.options.scaleFromTop){E.top=-C+"px";
}E.left=-B+"px";
}this.element.setStyle(E);
}});
Component.SeriesSelector=Class.create(Component,{initialize:function($super,A){$super(A.down("#seriesProfile"));
var B=A.readAttribute("selected");
if(B){B=A.down("[seriesId="+B+"]");
if(B){this.setSelected(B);
}}$("seriesList").select("a").each(function(C){C.observe("click",this.onSeriesClick.bindAsEventListener(this,C));
}.bind(this));
},setSelected:function(A){A=A.up("li");
if(A!=this.selected){A.addClassName("selected");
if(this.selected){this.selected.removeClassName("selected");
}this.selected=A;
return true;
}else{return false;
}},onSeriesClick:function(C,B){return true;
C.stop();
if(this.setSelected(B)){var A="/api/v1/watch-now/tv/series/"+B.readAttribute("seriesId");
var D="_format=json";
new Ajax.Request(A,{method:"get",parameters:D,onSuccess:this.onSeriesLoad.bindAsEventListener(this),onFailure:function(){location.href=B.readAttribute("href");
}});
}},onSeriesLoad:function(response){var series=eval("("+response.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"});
}}});




