var Video={autoplay:false,start:function(){Video.previousSize=(Cookie.read("videosize")||6).toInt();var B=Video.step2dims(Video.previousSize,true);Video.resizeParents(B);if(typeof __snotr_ipad=="undefined"){Video.player=new Swiff(__snotr_player,{id:"player",width:B.w,height:B.h,container:"player-wrap",params:{wMode:"window",allowFullScreen:true},vars:{video:__snotr_id,autoload:"true",autoplay:Video.autoplay,startat:__snotr_startat}})}else{var A=$("player");A.setAttribute("width",B.w);A.setAttribute("height",B.h)}Video.initSizeSlider();if($("rv-good")){Video.initRateVideo()}Video.initSpread();MoreVideos.start();VideosLinks.start()},play:function(){if(!Video.autoplay&&(typeof Video.player!="undefined")){Video.player.toElement().playVideo()}Video.autoplay="true"},seek:function(A){document.location.hash="#player";Video.player.toElement().seekVideo(A-1)},step2dims:function(B,A){return{w:40*B+280,h:30*B+(A?240:210)}},resizeParents:function(A){$("wrap").setStyle("width",(A.w+330)+"px");$("content").setStyle("width",A.w+"px");$("player-wrap").setStyle("height",A.h+"px")},initSizeSlider:function(){var A=new Slider("vs-area","vs-knob",{steps:16,onChange:function(B){var C=Video.step2dims(B);$("vs-info").setStyle("display","block");$("vs-info").set("html",C.w+" x "+C.h+" px")},onComplete:function(C){$("vs-info").setStyle("display","none");if(C!=Video.previousSize){Video.previousSize=C;var D=Video.step2dims(C,true);Video.resizeParents(D);var B=$("player");B.setAttribute("width",D.w);B.setAttribute("height",D.h);Cookie.write("videosize",C,{path:"/",duration:365,domain:".snotr.com"})}}}).set(Video.previousSize);$("vs-reset").addEvent("click",function(){A.set(6)})},initSpread:function(){$$("#embed, #mail").addEvent("mousedown",function(A){if(A){A.stop()}if(this.className=="shown"){if(this.id=="embed"){$("embedinfo").setStyle("display","none")}else{$("mailform").setStyle("display","none")}this.className="hidden"}else{if(this.id=="embed"){$("mailform").setStyle("display","none");$("embedinfo").setStyle("display","block");$("mail").className="hidden"}else{$("embedinfo").setStyle("display","none");$("mailform").setStyle("display","block");$("embed").className="hidden"}this.className="shown"}});$("recipient-add").addEvent("click",function(){$("recipient-inputs").adopt(new Element("p").adopt(new Element("input").setProperties({type:"text",name:"to-mail[]",size:"30"})).adopt(new Element("a").setProperty("href","javascript:void(0);").addEvent("click",Video.removeAddress).adopt(new Element("img").setProperties({src:"/images/recipient-remove.png",width:"16",height:"16",alt:"[remove]",title:"Remove this recipient"}))))});$("embedinfo").addEvent("submit",function(B){B.stop();var A=(this.autoplay.checked?"&autoplay=on":"");new Request({url:"/ajax-embedcode.php",method:"get",data:"id="+this.id.value+"&width="+this.width.value+"&height="+this.height.value+A,onSuccess:function(C){$$("#embedinfo pre").set("html","<pre>"+C+"</pre>")}}).send()});$("clipboard").addEvent("click",function(B){B.stop();var A=($("embedinfo").autoplay.checked?"&autoplay=on":"");new Request({url:"/ajax-embedcode.php",method:"get",data:"clipboard&id="+$("embedinfo").id.value+"&width="+$("embedinfo").width.value+"&height="+$("embedinfo").height.value+A,onSuccess:function(C){Video.player.toElement().setClipboard(C);alert("The code is copied to your clipboard.")}}).send()});$("mailform").addEvent("submit",function(A){A.stop();this.set("send",{onSuccess:function(B){if(B.indexOf("Error")!=-1){alert(B)}else{$("mailform").set("html","<p>"+B+"</p>")}}});this.send()})},initRateVideo:function(){$("rv-good").addEvent("click",function(A){A.stop();Video.rate.send("id="+__snotr_id+"&rate=good");urchinTracker("/rate/good")});$("rv-bad").addEvent("click",function(A){A.stop();Video.rate.send("id="+__snotr_id+"&rate=bad");urchinTracker("/rate/bad")})},rate:new Request({url:"/ajax-rate.php",method:"get",onSuccess:function(A){$("ratevideo").set("html","<p>"+A+"</p>")}}),removeAddress:function(A){this.getParent().destroy()}};var MoreVideos={start:function(){this.element=$("mvlist");this.scopePos=1;$("mv-newer").addEvent("click",function(A){A.stop();MoreVideos.scroll("left")});$("mv-older").addEvent("click",function(A){A.stop();MoreVideos.scroll("right")})},move:function(){this.eff.start("left",(this.scopePos-1)*-104)},scroll:function(C){var A=(C=="left"?-1:1);try{if(this.element.childNodes[this.scopePos+A].className=="end"){return }else{this.scopePos+=A}}catch(B){return }if(this.scopePos>0&&this.scopePos<this.element.childNodes.length-1){this.move()}else{this.updateList(A)}},updateList:function(scrollOffset){var qs="start_published="+this.element.childNodes[this.scopePos].id.substring(3)+"&load_num="+(scrollOffset*-5);new Request({url:"/ajax-morevideos.php",method:"get",onSuccess:function(responseText){var newVideos=new Array();eval("newVideos = "+responseText);var leftPos=MoreVideos.element.getStyle("left").toInt();var listClone=MoreVideos.element.clone(true,true);newVideos.each(function(currentVideo){var newLi=new Element("li");if(currentVideo.length==0){newLi.className="end";newLi.adopt(new Element("img",{src:(scrollOffset==-1?"/images/mv-end-left.png":"/images/mv-end-right.png"),alt:(scrollOffset==-1?"You are at the first video":"You are at the last video")}))}else{newLi.id="mv-"+currentVideo[2];newLi.adopt(new Element("a",{href:"/video/"+currentVideo[0],title:currentVideo[1]}).adopt(new Element("img",{src:"http://s.mnstat.com/"+currentVideo[0]+"-small.jpg",alt:currentVideo[1]})))}if(scrollOffset==-1){if(listClone.childNodes.length==10){listClone.removeChild(listClone.lastChild)}MoreVideos.scopePos++;leftPos-=104;newLi.injectTop(listClone)}else{if(listClone.childNodes.length==10){listClone.removeChild(listClone.firstChild);MoreVideos.scopePos--;leftPos+=104}newLi.injectInside(listClone)}});listClone.setStyle("left",leftPos+"px");MoreVideos.element=listClone.replaces(MoreVideos.element);MoreVideos.eff=new Fx.Tween(MoreVideos.element,{duration:700,transition:"quad:out",wait:false});MoreVideos.move()}}).send(qs)}};var VideosLinks={start:function(){$$("p.comment-body").each(function(C,B){var A=C.innerHTML;A=A.replace(/(\d+):(\d+)/g,'<a href="/video/'+__snotr_id+':$1:$2" onclick="Video.seek(($1 * 60) + $2); return false">$1:$2</a>');A=A.replace(/((\d+) seconds|secs)/ig,'<a href="/video/'+__snotr_id+':0:$2" onclick="Video.seek($2); return false">$1</a>');C.innerHTML=A})}};window.addEvent("domready",Video.start);if(document.location.hash.indexOf("#comment")!=0){if(Browser.Engine.webkit||Browser.Engine.presto){Video.autoplay=true}else{window.addEvent("focus",Video.play)}};