var Video={start:function(){if($("videosize")){Video.initVideoSize()}if($("embed")){Video.initEmbed()}
if($("morevideos")){MoreVideos.start()}},initVideoSize:function(){var A=new Slider("vs-area","vs-knob",{steps:16,onChange:function(B){
	$("vs-info").setStyle("display","block");
	$("vs-info").setHTML((40*B+280)+" x "+(30*B+210)+" px")},onComplete:function(E){
		$("vs-info").setStyle("display","none");
		if(this.oldStep==undefined){MoreVideos.oldStep=6}
		if(E!=this.oldStep){this.oldStep=E;var D=40*E+280;var B=30*E+240;
		var C=$("player");C.setAttribute("width",D);
		C.setAttribute("height",B);Cookie.write("videosize",E,{path:"/",duration:365})}}}).set((Cookie.read("videosize")||6).toInt());
		$("vs-reset").addEvent("click",function(){A.set(6)})},initEmbed:function(){var A=$("embed-link");var B=new Fx.Slide("embedinfo",{duration:350,onComplete:function(C){if(C.className=="down"){C.className="up"}else{C.className="down"}}.pass(A)});B.hide();A.addEvent("click",function(C){C.stop();B.toggle()});$("embedinfo").addEvent("submit",function(D){D.stop();var C=(this.autoplay.checked?"&autoplay=on":"");new Request({method:"get",onSuccess:function(E){$$("#embedinfo pre").setHTML("<pre>"+E+"</pre>")}}).send("/ajax-embedcode.php","id="+this.id.value+"&width="+this.width.value+"&height="+this.height.value+C)})},initRateVideo:function(){$("rv-good").addEvent("click",function(A){A.stop();urchinTracker("/rate/good");Video.rateVideo(this.getProperty("rel"),"good")});$("rv-bad").addEvent("click",function(A){A.stop();urchinTracker("/rate/bad");Video.rateVideo(this.getProperty("rel"),"bad")})},rateVideo:function(B,A){new Request({url:"/ajax-rate.php",method:"get",onSuccess:function(C){$("ratevideo").setHTML("<p>"+C+"</p>")}}).send("id="+B+"&rate="+A)},initAddComment:function(){$$("#commentsmilies img").each(function(A){A.addEvent("click",Video.insertSmiley.pass(" "+A.getProperty("alt")+" "))})},insertSmiley:function(B){var A=$("ac-input");A.focus();if(document.selection){var C=document.selection.createRange();C.text=B}else{if(A.selectionStart||A.selectionStart=="0"){A.value=A.value.substring(0,A.selectionStart)+B+A.value.substring(A.selectionEnd)}else{A.value+=B}}}};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://videos.snotr.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)}};window.addEvent("domready",Video.start);