Component.UserCommentDeleteLink=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),onCancel:this.onCancel.bindAsEventListener(this)});
},onCancel:function(){},onDelete:function(){new Ajax.Request("/api/v1/users/"+this.element.readAttribute("user")+"/comments/"+this.element.readAttribute("comment")+".json",{parameters:{_method:"delete"},method:"post",onSuccess:this.onSuccess.bind(this),onFailure:this.onFailure.bind(this)});
Tracker.tag("RemoveProfileComment");
},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.FriendSelect=Class.create(Component.Select,{onChange:function(A){if($F(this.element)!=""){document.location=$F(this.element);
}}});
Component.NominateSuperReviewerLink=Class.create(Component.Link,{onClick:function(A){A.stop();
var B="userId=${user.id}&eliteRole=REV";
new Ajax.Request("/elites/action/nominate",{parameters:B,onSuccess:this.onSuccess.bind(this)});
},onSuccess:function(A){window.location.reload(true);
}});
Component.BlockUserLink=Class.create(Component.Link,{onClick:function(A){A.stop();
new View.ConfirmationPopup(this.element,{content:"Are you sure you want to block this member?",onConfirm:this.onBlock.bindAsEventListener(this)});
},onBlock:function(){this.blocked=this.element.readAttribute("blocked");
this.blocker=this.element.readAttribute("blocker");
var A={_format:"json",_method:"post"};
new Ajax.Request("/api/v1/users/"+this.blocked+"/blocks",{parameters:A,method:"post",onSuccess:this.onSuccess.bind(this),onFailure:this.onFailure.bind(this)});
this.element.update("...");
},onSuccess:function(A){this.element.replace("Blocked.");
},onFailure:function(A){this.element.update("Oops, please try again later.");
}});
Component.UnblockUserLink=Class.create(Component.Link,{onClick:function(A){A.stop();
new View.ConfirmationPopup(this.element,{content:"Are you sure you want to unblock this member?",onConfirm:this.onBlock.bindAsEventListener(this)});
},onBlock:function(){this.blocked=this.element.readAttribute("blocked");
this.blocker=this.element.readAttribute("blocker");
var A={_format:"json",_method:"delete"};
new Ajax.Request("/api/v1/users/"+this.blocked+"/blocks/"+this.blocker,{parameters:A,method:"post",onSuccess:this.onSuccess.bind(this),onFailure:this.onFailure.bind(this)});
this.element.update("...");
},onSuccess:function(A){this.element.replace("Unblocked.");
},onFailure:function(A){this.element.update("Oops, please try again later.");
}});
Component.RemoveBuddyLink=Class.create(Component.Link,{onClick:function(A){A.stop();
new View.ConfirmationPopup(this.element,{content:"Are you sure you want to remove this friend?",onConfirm:this.onDelete.bindAsEventListener(this)});
},onDelete:function(){var B=this.element.readAttribute("me");
var A=this.element.readAttribute("friend");
var C={_method:"delete",_format:"json"};
new Ajax.Request("/api/v1/users/"+B+"/friends/"+A,{parameters:C,onSuccess:this.onSuccess.bind(this),onFailure:this.onFailure.bind(this)});
},onSuccess:function(A){this.element.replace("Removed.");
},onFailure:function(A){this.element.replace("Oops, please try again later.");
}});
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.FlashWidget=Class.create(Component.FlashMovieMeeboBarDecoupler);




Component.RemoveBuddyLink=Class.create(Component.Link,{onClick:function(A){A.stop();
new View.ConfirmationPopup(this.element,{content:"Are you sure you want to remove this friend?",onConfirm:this.onDelete.bindAsEventListener(this)});
},onDelete:function(){var B=this.element.readAttribute("me");
var A=this.element.readAttribute("friend");
var C={_method:"delete",_format:"json"};
new Ajax.Request("/api/v1/users/"+B+"/friends/"+A,{parameters:C,onSuccess:this.onSuccess.bind(this),onFailure:this.onFailure.bind(this)});
},onSuccess:function(A){this.element.replace("Removed.");
},onFailure:function(A){this.element.replace("Oops, please try again later.");
}});
Component.RemoveBuddyGalleryLink=Class.create(Component.RemoveBuddyLink,{onSuccess:function(A){new Effect.Shrink(this.element.up(".row"),{direction:"top-left",duration:0.5});
},onFailure:function(A){new Effect.Shrink(this.element.up(".row"),{direction:"top-left",duration:0.5});
}});
Component.RemovePendingBuddyLink=Class.create(Component.Link,{onClick:function(A){A.stop();
new View.ConfirmationPopup(this.element,{content:"Are you sure you want to remove this pending friend?",onConfirm:this.onDelete.bindAsEventListener(this)});
},onDelete:function(){var A={user:this.element.readAttribute("friend")};
new Ajax.Request("/friends/action/remove-pending-friend",{parameters:A,onSuccess:this.onSuccess.bind(this),onFailure:this.onFailure.bind(this)});
},onSuccess:function(A){new Effect.Shrink(this.element.up(".row"),{direction:"top-left",duration:0.5});
},onFailure:function(A){new Effect.Shrink(this.element.up(".row"),{direction:"top-left",duration:0.5});
}});
Component.TopFriendsForm=Class.create(Component.Form,{initialize:function($super,A){$super(A);
this.element.observe("top:add",this.onAdd.bindAsEventListener(this));
this.element.observe("top:remove",this.onRemove.bindAsEventListener(this));
this.sort();
},sort:function(){Sortable.create("sortableFriends",{tag:"li",scroll:window,handle:"thumbnail",constraint:false});
},onSubmit:function(A){this.element.select("input[type=submit]").each(function(B){B.disable();
});
return true;
},onAdd:function(B){var A=new Template("<li id='friends_#{user}'><input type='hidden' name='buddy' value='#{user}' /><div class='thumbnail'><img src='#{thumbnail}' /></div><div>#{username}</div><div class='delete'>[ <input type='button' value='delete' component='TopFriendsRemoveButton' user='#{user}' /> ]</div></li>");
$("sortableFriends").insert({bottom:A.evaluate(B.memo)});
new Component.Binder("friends_"+B.memo.user);
this.sort();
},onRemove:function(A){$("friends_"+A.memo.user).remove();
$("buddy"+A.memo.user).removeClassName("selected");
}});
Component.TopFriendsAddLink=Class.create(Component.Link,{onClick:function(A){A.stop();
this.element.up("li").addClassName("selected");
this.element.fire("top:add",{user:this.element.readAttribute("user"),username:this.element.readAttribute("username"),thumbnail:this.element.readAttribute("thumbnail")});
}});
Component.TopFriendsRemoveLink=Class.create(Component.Link,{onClick:function(A){A.stop();
this.element.up("li").removeClassName("selected");
this.element.fire("top:remove",{user:this.element.readAttribute("user")});
}});
Component.TopFriendsRemoveButton=Class.create(Component.Button,{onClick:function(A){A.stop();
this.element.fire("top:remove",{user:this.element.readAttribute("user")});
}});




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"});
}}});




