/*
throbber.js v 0.1 2011-09-18
http://aino.com
Copyright (c) 2011, Aino
Licensed under the MIT license.
*/
function google_ad_request_done(a){var b=a.length;if(!(0>=b)&&$("google_afc_ads")){var c="";for(i=0;i'+a[i].line1+''+a[i].line2+" "+a[i].line3+''+a[i].visible_url+"";c?$("google_afc_ads").set("html","Sponsored Links
"+c).addClass("ad-loaded"):$("google_afc_ads").dispose()}}
(function(a){var b=a.document,c=Math,d="getContext"in b.createElement("canvas"),e=function(a,b){var a=a||{},c;for(c in b)a[c]=b[c];return a},h=function(a,b,c){c=c?-2:2;a.translate(b/c,b/c)},g,j,l,p,q;Throbber=function(e){var k=this.elem=b.createElement("canvas"),m=this;isNaN(e)||(e={size:e});this.o={size:34,rotationspeed:6,clockwise:!0,color:"#fff",fade:300,fallback:!1,alpha:1};this.configure(e);this.phase=-1;d?(this.ctx=k.getContext("2d"),k.width=k.height=this.o.size):this.o.fallback&&(k=this.elem=
new Image,k.src=this.o.fallback);var f=m.o,n=0,s=1E3/f.fade/f.fps,o=m.step,r=k.style,t="filter"in r&&f.fallback&&!d;this.loop=function(){if(m.phase==3){n=n-s;if(n<=0)m.phase=0}if(m.phase==1){n=n+s;if(n>=1)m.phase=2}if(t)r.filter="alpha(opacity="+c.min(f.alpha*100,c.max(0,Math.round(n*100)))+")";else if(!d&&f.fallback)r.opacity=n;else if(d){var b=m.ctx,e=o;g=1-n||0;p=1;q=-1;var k=f.size;if(f.clockwise===false){p=-1;q=1}b.clearRect(0,0,k,k);b.globalAlpha=f.alpha;b.lineWidth=f.strokewidth;for(j=0;j<
f.lines;j++){l=j+e>=f.lines?j-f.lines+e:j+e;b.strokeStyle="rgba("+f.color.join(",")+","+c.max(0,l/f.lines-g)+")";b.beginPath();b.moveTo(k/2,k/2-f.padding/2);b.lineTo(k/2,0);b.stroke(f.strokewidth);h(b,k,false);b.rotate(p*(360/f.lines)*c.PI/180);h(b,k,true)}if(f.rotationspeed){b.save();h(b,k,false);b.rotate(q*(360/f.lines/(20-f.rotationspeed*2))*c.PI/180);h(b,k,true)}o=o===0?m.o.lines:o-1}a.setTimeout(m.loop,1E3/f.fps)}};Throbber.prototype={constructor:Throbber,appendTo:function(a){this.elem.style.display=
"none";a.appendChild(this.elem);return this},configure:function(h){var j,g,f=this.o;e(f,h||{});j=f.color;d?(g=b.createElement("i"),g.style.display="none",g.style.color=j,b.body.appendChild(g),j=a.getComputedStyle(g,null).getPropertyValue("color").replace(/^rgba?\(([^\)]+)\)/,"$1").replace(/\s/g,"").split(",").splice(0,4),b.body.removeChild(g),g=4==j.length?j.pop():1):(j=!1,g=1);e(f,e({padding:f.size/2,strokewidth:c.max(1,c.min(f.size/30,3)),lines:c.min(30,f.size/2+4),alpha:g||1,fps:c.min(30,f.size+
4)},h));f.color=j;this.step=f.lines;return this},start:function(){this.elem.style.display="block";-1==this.phase&&this.loop();this.phase=1;return this},stop:function(){this.phase=3;return this},toggle:function(){2==this.phase?this.stop():this.start()}}})(this);
var Brozar=new Class({Implements:[Options,Events],options:{url:null,containerWidth:null,promoVideo:!1,thumbnailWidth:180,widthBuffer:110,onClipSelected:function(){}},cache:new Hash,pageNumber:1,itemsPerPage:10,itemOffset:null,streamOffset:null,scrollDirection:null,scrollActive:!1,RESIZE_UPDATE_INTERVAL:500,initialize:function(a,b){this.container=$(a);if(null===this.container)throw Error("Invalid element supplied to Brozar");this.setOptions(b);this.attachEvents();this.setInitialValues();this.request=
new Request.HTML({url:this.options.url,method:"get",onSuccess:function(a,b,e){this.processHtml(e);this.cache.set(this.getKey(),e);var h=$$(".brozar_promo .promo_clip .thumbnail_wrapper")[0];$$(".brozar_promo .promo_clip a").addEvent("click",function(a){var b=h.get("href"),c=parseInt(b.split("/")[1],10);this.whLogBrozarClick(c,"brozar_promo");a.preventDefault();this.stored_brozar_promo_url=b}.bind(this))}.bind(this)});this.loadPage()},attachEvents:function(){this.bound={onWindowResize:this.onWindowResize.bind(this)};
window.addEvent("resize:pause("+this.RESIZE_UPDATE_INTERVAL+")",this.bound.onWindowResize);this.container&&this.container.addEvent("click:relay(a)",this.onBrozarClick.bind(this))},setInitialValues:function(){this.lastContainerWidth=this.options.containerWidth||this.container.getSize().x;this.itemsPerPage=this.calculateItemsPerPage();this.lastListWidth=this.itemsPerPage*this.options.thumbnailWidth;if(this.streamOffset=Cookie.read("stream_offset"))this.pageNumber=Math.floor(this.streamOffset/this.itemsPerPage)+
1},resetStreamCalculations:function(){this.pageNumber=1;this.itemOffset=this.streamOffset=this.scrollDirection=null},calculateItemsPerPage:function(){var a=(this.lastContainerWidth-this.options.widthBuffer)/this.options.thumbnailWidth,a=0.9this.itemsPerPage&&a.each(function(a,d){"left"===this.scrollDirection&&d>=b?
a.destroy():"right"===this.scrollDirection&&d'+Copy.translate("count_comments",!1,{COUNT:1})+""):
null!==a&&(j=a.get("text").toInt()+1,a.set("text",Copy.translate("count_comments",1!==j,{COUNT:j})));Browser.ie&&7>=Browser.version?g.getElements("article").inject(l?c:b,l?"bottom":"before"):g.getElements("article").inject(l?c:b,l?"bottom":"before").setStyle("opacity",0).set("tween",{duration:250}).fade(1);Comment.resetForm(b)},onFailure:function(b){if(403===b.status)alert(Copy.dict.no_comments_for_you);else for(var c in JSON.decode(b.responseText))a.getElement(":input[name="+c+"]").addClass("validation-failed")}});
a.getElement(".guidelines")&&(a.getElement(".guidelines").removeEvents("click"),a.getElement(".guidelines").addEvent("click",function(a){a.stop();this.getParent("fieldset").getNext(".alert").toggle()}));Comment.setupUrlField(a)}},setupUrlField:function(a){a.getElements(".over-text").each(function(a){new OverText(a,{textOverride:a.get("data-placeholder")})})},resetUrlField:function(){OverText.update()},collapseReplyBoxes:function(){$$(".comment_reply").hide()},collapseCommentBox:function(){var a=$("comment");
a.getElement(".comment").isVisible()&&((new Element("a",{href:"#",html:Copy.translate("open_comment_box"),"class":"comment_toggle",events:{click:function(a){a.stop();Comment.openCommentBox();Comment.collapseReplyBoxes()}}})).inject(a),a.getElement(".comment").hide())},openCommentBox:function(){var a,b=$("comment");if(a=b.getElement(".comment_toggle"))b.getElement(".comment").show(),a.dispose(),Comment.resetUrlField.delay(50,this,[b])},setupAddReply:function(a,b){var c=$("comments"),d=b.getElement("form"),
c=c.getElements("."+a.get("id")+":not(.reply_form)").getLast(),e=a.get("id");Comment.resetForm(d);Comment.hideTools(a,"reply");b.toggle();Comment.collapseCommentBox();if(b.isDisplayed())if(b.getElement("textarea").focus(),new Form.Validator(d),"undefined"!==typeof Comment.reply_requests[e])Comment.reply_requests[e].target=c;else{var h=Comment.getContext(),g=h[0],h=h[1];Comment.reply_requests[e]=new Form.Request.Append(d,c,{extraData:{version:Global.getVersion(),token:vimeo.xsrft,context_type:g,context_id:h},
inject:"after",onBeforeEffect:function(){Comment.hideTools(a);b.toggle()},onSuccess:function(a){var b=$("count"),c;null!==b&&(c=b.get("text").toInt()+1,b.set("text",Copy.translate("count_comments",1!==c,{COUNT:c})));Comment.reply_requests[e].target=a;Comment.openCommentBox()},onFailure:function(a){if(403===a.status)alert(Copy.dict.no_comments_for_you);else for(var b in JSON.decode(a.responseText))d.getElement(":input[name="+b+"]").addClass("validation-failed")}})}Comment.resetUrlField(d)},setupEditComment:function(a){var b=
a.getElement(".comment_edit"),c=b.getElement("form"),d=a.getElement(".text");Comment.resetForm(c);Comment.hideTools(a,"edit");d.toggle();b.toggle();b.isDisplayed()&&(b.getElement("textarea").focus(),new Form.Validator(c),new Form.Request(c,a,{extraData:{token:vimeo.xsrft},onFailure:function(a){if(403===a.status)alert(Copy.dict.no_comments_for_you);else for(var b in JSON.decode(a.responseText))c.getElement(":input[name="+b+"]").addClass("validation-failed")}}))},setupDeleteComment:function(a){var b=
$("comments"),c=a.getElement(".comment_delete"),d=a.getElement(".text"),e=c.getElement("form");Comment.hideTools(a,"delete");d.show();c.toggle();c.isDisplayed()&&(c=Comment.getContext(),new Form.Request(e,null,{extraData:{token:vimeo.xsrft,context_type:c[0],context_id:c[1]},onSuccess:function(){var c=a,d=$("comments").getElement("h2"),e=$("count"),l=null!==e?e.get("text").toInt()-1:null;!a.hasClass("sticky")&&!a.hasClass("reply")&&(c=b.getElements("."+a.get("id")),c=(new Element("article",{"class":"main"})).surround(c));
c.get("dissolve").chain(function(){this.destroy()}.bind(c)).dissolve();0===l?d.set("html",Copy.dict.first_comment):null!==e&&e.set("text",Copy.translate("count_comments",1!==l,{COUNT:l}))}}))},onPermalinkClick:function(a){null!==window.location.hash.toString().match(/^#?\/?[0-9]+/)&&(a.stop(),Global.smoothScroll(this.get("href"),null,{set_hash:!0,full_href:!0}))},disableLoading:function(){var a=$("while_loading");a&&(a.getSiblings("a").hide(),a.show())},enableLoading:function(){var a=$("while_loading");
a&&(a.hide(),a.getSiblings("a").show())},onLoadSuccess:function(a,b,c){var a=$("pagination"),b=Elements.from(c),d={};if(a){b[0].hasClass("reply")&&a.getPrevious().hasClass("reply_form")&&a.getPrevious().destroy();1===Comment.page?($("comments").set("html",""),b.inject($("comments")),a.removeClass("hide"),Comment.page++):b.inject(a,"before");if(!c.contains("pagination"))for(;"comment"!==a.getNext().get("id");)a.getNext().destroy();a.destroy()}else d.last_page=!0;Signal.comments.request.success.dispatch(d);
Comment.enableLoading();window.Clip&&"undefined"!==typeof Clip.checkCommentHash&&Clip.checkCommentHash();Comment.setupAddComment()},onLoadRequest:function(){Comment.disableLoading()},onLoadMoreClick:function(a){a&&a.stop();if(this.hasClass("disabled"))return!1;Comment.pager=this;Comment.page=this.get("data-page");Comment.request.send({data:{action:"comments",page:Comment.page}})},onCommentOver:function(){var a;(a=this.getElement(".comment_tools"))&&a.show()},onCommentOut:function(){var a=!0,b;this.getElements(".tool").each(function(b){b.isDisplayed()&&
(a=!1)});!1!==a&&(b=this.getElement(".comment_tools"))&&b.hide()},onAction:function(a){var b,c;this.hasClass("reply")?(a.stop(),b=this.getParent(".article"),a=$(b.get("data-parent-id")),c=this.getNext(".comment_reply"),Comment.collapseReplyBoxes(),Comment.setupAddReply(a,c),Comment.setupUrlField(b)):this.hasClass("edit")?(a.stop(),Comment.setupEditComment(this.getParent(".article"))):this.hasClass("delete")?(a.stop(),Comment.setupDeleteComment(this.getParent(".article"))):this.hasClass("cancel")&&
(a.stop(),b=this.getParent("form"),a=this.getParent(".article").getElement(".text"),null!==a&&a.show(),b.getParent().hide(),Comment.openCommentBox())},onHashtagFound:function(a){var b=a.getNext(".reply_form");Global.smoothScroll(a);Comment.search.stop();b&&(a=b.get("data-parent-id"),Comment.setupAddReply($(a),b.getElement(".comment_reply")),Comment.collapseCommentBox())},onHashtagNotFound:function(){Comment.requests_made
'+Copy.dict.loading+"
").show();Clip.adderRequest.send({url:vimeo.config.clip.url})}, loadStats:function(){var a=$("stats");Clip.infoElement.getElements(".video_more").each(function(a){"stats"!==a.get("id")&&a.hide()});a.set("html",''+Copy.dict.loading+"
").show();Clip.statsViewRequest.send({url:vimeo.config.clip.url})},loadSubscribe:function(){Clip.subscribe_btn=Clip.subscribe_btn||$$("#tools #follow_btn")[0];var a=$("follow"),b=parseInt(Clip.subscribe_btn.get("data-subscribed"),10);Clip.subscribe_btn.set("data-subscribed",1-b);a.set("html",''+ Copy.dict.loading+"
");b?Clip.subscribe_btn.removeClass("following").addClass("unfollowing"):(Clip.infoElement.getElements(".video_more").each(function(a){"follow"!==a.get("id")&&a.hide()}),a.show(),Clip.subscribe_btn.addClass("btn_disabled"));Clip.subscribeRequest.send({url:vimeo.config.user.url})},toggleCollection:function(){var a=this.get("data-type"),b=this.get("checked"),c=null,d;"remove_only"===this.get("data-permission")&&this.set("disabled",!0);(new Request.JSON({url:vimeo.config.clip.url, method:"post",data:{action:"toggle_collection",type:a,id:this.get("value"),toggle:b?"add":"remove",token:vimeo.xsrft},onSuccess:function(e){e.success?(c=this.getParent(".col").getElement(".message"),clearTimeout(Clip.adderStatusMessageTweenTimer[a]),c.hide().removeClass(b?"red":"green").addClass(b?"green":"red").set("html",(b?e.status===Clip.STATUS_PENDING?Copy.dict.pending:Copy.dict.added:Copy.dict.removed)+"!").tween("opacity","1").setStyle("top",this.getPosition().y-c.getParent().getPosition().y- 3+"px").show(),Clip.adderStatusMessageTweenTimer[a]=function(){c.tween("opacity",0)}.delay(3E3)):this.checked=!1;"group_adds_limit_reached"===e.status?(d=$("groups"),d.getElements("input:not(:checked)").each(function(a){a.getNext("label").addClass("disabled");a.disabled=true;d.getElement("p.tip").removeClass("hidden")})):"group_adds_limit_below"===e.status&&(d=$("groups"),d.getElements("input:disabled").each(function(a){a.getNext("label").removeClass("disabled");a.disabled=false}))}.bind(this)})).send()}, onHistoryChange:function(a,b,c){""!==c.pathname&&(!History.hasPushState()&&!a&&(a=History.getPathName()),b=parseInt(a.split("/").getLast(),10),Clip.loadClip(a),Signal.clip.changed.dispatch(b))},loadClip:function(a){Clip.playerRequest.send({data:{clip_id:a.split("/").getLast(),server:vimeo.url,context:"clip_page",action:"player"}});Clip.infoRequest.send({url:a});Clip.downloadLoaded=!1;Clip.adderLoaded=!1;Clip.statsLoaded=!1;Clip.play_log_recorded=!1},getFlickrs:function(){var a=[],b;(b=$("flickr_thumbnails"))&& b.getElements("img").each(function(b){a.push(b.get("data-large-image"))});return a},getPhotoUrls:function(){var a=[],b;(b=$("flickr_thumbnails"))&&b.getElements("img").each(function(b){a.push(b.get("data-pageurl"))});return a},setupFlickrGallery:function(a){var b=Clip.getFlickrs();b.length&&(Clip.photoPageUrls=Clip.getPhotoUrls(),Clip.gallery=new Gallery(a,b,{mainImage:a.getElement(".main_portrait"),canClose:!1,moveNextOnMain:!1,onChange:function(a){Clip.gallery.getMainImage().getParent("a").set("href", Clip.photoPageUrls[a])}}),$("flickr_thumbnails").getElements("img").each(function(a,b){a.addEvent("click",function(a){a.stop();Clip.gallery.load(b)})}))},goPrev:function(){Clip.brozar_loaded&&Cookie.write("stream",$("streams").get("data-stream"),{domain:vimeo.domain,path:"/"});Clip.navPrevRequest.send({url:vimeo.config.clip.url})},goNext:function(){Clip.brozar_loaded&&Cookie.write("stream",$("streams").get("data-stream"),{domain:vimeo.domain,path:"/"});Clip.navNextRequest.send({url:vimeo.config.clip.url})}, openDownloadPane:function(){var a=$("download");Clip.downloadLoaded?(Clip.infoElement.getElements(".video_more").each(function(a){"download"!==a.get("id")&&a.hide()}),$$("#tools .btn:not(.download)").removeClass("active"),$$("#tools .download").toggleClass("active"),a.toggle()):Clip.loadDownload()},onDownloadClick:function(a){a.preventDefault();Clip.openDownloadPane()},onTipjarClick:function(a){a.preventDefault();a=$("tipjar");Clip.tipjarLoaded?(Clip.infoElement.getElements(".video_more").each(function(a){"tipjar"!== a.get("id")&&a.hide()}),$$("#tools .btn:not(.tipjar)").removeClass("active"),$$("#tools .tipjar").toggleClass("active"),a.toggle()):Clip.loadTipjar()},onAdderClick:function(a){a.preventDefault();a=$("adder");Clip.adderLoaded?(Clip.infoElement.getElements(".video_more").each(function(a){"adder"!==a.get("id")&&a.hide()}),$$("#tools .btn:not(.adder)").removeClass("active"),$$("#tools .adder").toggleClass("active"),a.toggle()):Clip.loadAdder()},onStatsClick:function(a){a.preventDefault();a=$("stats"); Clip.statsLoaded?(Clip.infoElement.getElements(".video_more").each(function(a){"stats"!==a.get("id")&&a.hide()}),$$("#tools .btn:not(.stats)").removeClass("active"),$$("#tools .stats").toggleClass("active"),a.toggle(),$("change_settings")&&Cookie.write("auto_load_stats",a.isVisible()?"1":"0",{domain:vimeo.domain,path:"/",duration:365})):(Cookie.write("auto_load_stats","1",{domain:vimeo.domain,path:"/",duration:365}),Clip.loadStats())},onSubscribeHover:function(a){Clip.subscribe_btn=Clip.subscribe_btn|| $$("#tools #follow_btn")[0];!Clip.subscribe_btn.hasClass("active")&&!Clip.subscribing&&("mouseover"===a.type?Clip.subscribe_btn.set("html",Clip.subscribe_btn.get("data-hover-text")):Clip.subscribe_btn.set("html",Clip.subscribe_btn.get("data-btn-text")))},onSubscribeClick:function(a){a.preventDefault();Clip.subscribing||(Clip.subscribe_btn=Clip.subscribe_btn||$$("#tools #follow_btn")[0],$("follow"),parseInt(Clip.subscribe_btn.get("data-subscribed"),10),!Clip.subscribing&&!a.target.hasClass("active")? (Clip.subscribing=!0,Clip.loadSubscribe()):(Clip.subscribe_btn.removeClass("active").addClass("following").set("html",Clip.subscribe_btn.get("data-hover-text")),$("follow").hide(),Clip.subscribing=!1))},onDeleteClick:function(){if($$("#lightbox_container #lightbox_content #delete").length){var a=$("delete_form"),b=$("delete_error");new Form.Validator(a);var c=$("delete_submit_btn");new Form.Request(a,"delete_submit_btn",{requestOptions:{url:location.href},extraData:{action:"delete"},onSend:function(){b.set("html", "")},onSuccess:function(a,b,c,g){location.href=JSON.decode(g)},onFailure:function(c){a.fireEvent("reset");a.getElement(":input[name=password]").addClass("validation-failed");b.set("html",JSON.decode(c.responseText).password)}});a.addEvent("keyup:relay(input[name=password])",function(a,b){""!==b.get("value")?c.set("disabled",!1):c.set("disabled",!0)})}},setupScrollCheck:function(){Clip.scrollCheck&&(Clip.scrollCheck.stop(),Clip.scrollCheck=null);Clip.scrollCheck=new ScrollSpy({min:205,onEnter:Clip.scrollEvent})}, addAdSpy:function(){var a=0;null!==Clip.brozar_element&&(a=Clip.brozar_element.getSize().y);var b=$("ad");null!==$("google_afc_ads")&&(Clip.adTextSpy=new ScrollSpy({min:$("google_afc_ads").getPosition().y-a-window.getSize().y,onEnter:Clip.adTextEvent}));null!==b&&(Clip.adSpy=new ScrollSpy({min:$("ad").getPosition().y-a-window.getSize().y,onEnter:Clip.adEvent}))},adEvent:function(){Clip.adSpy.stop();_gaq.push(["_trackEvent","scroll","ad_view","clip_page",void 0,!0])},adTextEvent:function(){Clip.adTextSpy.stop(); _gaq.push(["_trackEvent","scroll","text_ad_view","clip_page",void 0,!0])},scrollEvent:function(){Clip.scrollCheck.stop();_gaq.push(["_trackEvent","scroll","scroll","clip_page",void 0,!0])},onKeyboardShortcut:function(a){a&&History.push("/"+a)},onWindowResize:function(){var a=window.getHeight();a