Event.observe(document,"dom:loaded",function(){function a(){$$(".movie_invitation_tooltip").invoke("hide")}var b=$$(".movie-add-invitation");if(b.length){b.invoke("observe","click",openLinkInDialog);b=$$(".movie-add-invitation-with-tooltip");if(b.length){var c=null,d=null;b.invoke("observe","mouseout",function(){c=a.delay(0.1)});b.invoke("observe","mouseover",function(){clearTimeout(c);a();var f=this.up(".button_fav_movie");f.identify();d=f.id;var e=f.next();e&&!e.hasClassName("movie_invitation_tooltip")&&
(e=null);if(e)e.show();else{var i=f.down(".tooltip_href").href;new Ajax.Request(i,{onComplete:function(g){g=Application.ajaxResponseProcess(g);if(g.html){f.insert({after:g.html});e=f.next();if(!e)return!1;g=f.getDimensions();var h=f.positionedOffset();e.setStyle({top:h.top+g.height+"px",left:h.left-5+"px"});e.observe("mouseover",function(){clearTimeout(c)});e.observe("mouseout",function(){clearTimeout(c);c=a.delay(0.1)});f.id==d&&f.down(".movie_invitation_tooltip").show()}}})}})}}});
MovieInvitationComments=Class.create({initialize:function(a){this.container=$(a.container);this.containerInit()},containerInit:function(){this.container.observe("click",this.containerClickEvent.bindAsEventListener(this));this.container.observe("MovieInvitationComments:commentAdded",this.commentAddEvent.bindAsEventListener(this));this.container.observe("MovieInvitationComments:formClosed",function(a){$("showComments_"+a.memo.showId).removeClassName("add-comments-mode")})},commentAddEvent:function(a){a=
a.memo.comment;var b=$("showComments_"+a.showId);b.removeClassName("add-comments-mode");b.down(".wall-item-comments-form-container").down("form").remove();b=b.down(".wall-item-comments-list");b.insert(a.html);this.commentsListContainerFix(b)},commentsListContainerFix:function(a){a.childElements().length?a.up().addClassName("with-comments"):a.up().removeClassName("with-comments")},showLaunchCommentForm:function(a,b){a||(a=this.container.down(".wall-item-comment-link"));b||(b=this.container.down(".wall-comments-add"));
var c=this.container.down(".wall-item-comments"),d=this.container.down(".wall-item-comments-form-container"),f=d.down(".wall-item-comments-form");if(f){f.remove();c.removeClassName("add-comments-mode")}else{b.startWaiting("inputWaiting");new Ajax.Request(a.href,{onComplete:function(e){b.stopWaiting();if((e=Application.ajaxResponseProcess(e))&&e.error!==!0&&e.formHTML){c.addClassName("add-comments-mode");d.insert(e.formHTML)}}})}},containerClickEvent:function(a){var b=a.element();if(b.hasClassName("wall-item-comment-link"))this.showLaunchCommentForm(b);
else if(b.hasClassName("wall-comments-add"))this.showLaunchCommentForm(null,b);else if(b.hasClassName("wall-item-comment-delete")){a.stop();new Ajax.Request(b.href,{onComplete:function(c){if((c=Application.ajaxResponseProcess(c))&&c.error!==!0){c=b.up(".wall-item-comments-list");b.up(".comment-info").remove();this.commentsListContainerFix(c)}}.bind(this)})}},commentFormInit:function(a){new SimpleAjaxForm(a,{message:messageController=new SimpleMessage($(a).up(1).select(".error_comment").first()),onBeforeSubmit:function(){window.simpleUIBlocker.block()},
onResponseReceived:function(){window.simpleUIBlocker.unblock()},customCallback:function(d){d.comment&&$(a).fire("MovieInvitationComments:commentAdded",d)}});if(item_with_hint){$($(a).elements.ok).disable();item_with_hint.observe("focus",function(){$($(a).elements.ok).enable()})}else $($(a).elements.comment_body).activate();var b=$(a).viewportOffset(),c=document.viewport.getHeight();b[1]<0?window.scrollBy(0,b[1]):b[1]-c>-10&&window.scrollBy(0,b[1]-c+$(a).getHeight());$(a).down(".close").observe("click",
function(d){d.stop();d=$(a);var f=d.elements.parent_id.value;d.descendants().invoke("stopObserving");d.fire("MovieInvitationComments:formClosed",{showId:f});d.remove()})}});
RecommendMovie=Class.create({initialize:function(a){this.formId=a;this.attachEvents()},attachEvents:function(){$$(".container-add-friend-email").invoke("observe","click",function(a){if(a.element().id=="addFriendEmailLink"){a.stop();this.addFriendEmail()}}.bindAsEventListener(this));$(this.formId).observe("submit",function(a){a.stop();var b=!1,c=0;$$(".email-added").each(function(d){d.removeClassName("error-email");emailVal=$F(d);if(emailVal!=""&&!this.isEmail(emailVal)){b=!0;d.addClassName("error-email")}else emailVal!=
""&&(c+=1)}.bind(this));b?this.showErrorMessage("Format email incorect"):c==0?this.showErrorMessage("Adaug\u0103 cel pu\u0163in un prieten"):$(this.formId).submit()}.bindAsEventListener(this))},addFriendEmail:function(){new Insertion.Bottom("containerFriendsEmail",'<input type="text" name="friend_email[]" class="text email-added" value="">')},isEmail:function(a){return/^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+@[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$/.test(a)},showErrorMessage:function(a){messageContaier=
$("messageContainerFriendsEmail");messageContaier.down(".box_alert_content").update(a);messageContaier.show()},hideErrorMessage:function(){messageContaier=$("messageContainerFriendsEmail");messageContaier.hide()}});

