var Index={start:function(){Index.fixWidth();$(window).resize(Index.fixWidth);$("#more a").click(function(){var a=$(".morestars:hidden");a.eq(0).slideDown(600);if(a.length==1){$("#more").slideUp(600)}});$(".video div").each(function(){var c=$("span",this).text();if(c==""){return}c=c.substr(1,c.length-2);c=c.split(",");var a=c.length;if(a==0){return}c.sort(function(h,e){return h.length>e.length?-1:h.length<e.length?1:0});var d=$("div",this).html();var f;var g="";for(var b=0;b<a;++b){f=new RegExp("([^;>]|^)("+c[b]+")([^&<]|$)","i");if(f.test(d)){d=d.replace(f,'$1<a href="/?q=&quot;'+c[b]+'&quot;">$2</a>$3',d)}else{if(g!=""){g+=", "}g+='<a href="/?q=&quot;'+c[b]+'&quot;">'+c[b]+"</a>"}}if(g!=""){$("div",this).html(d+" ("+g+")")}else{$("div",this).html(d)}});if(typeof pronvid_video_id!="undefined"){Index.addActions(pronvid_video_id,$("#buttons").get(0),false)}$("#content img").each(function(){var b=$(this).attr("id");if(b.length==0){return}b=b.substr(1);var a='<a href="javascript:void(0);"><img width="24" height="24" src="/?images/report.png&amp;v=1" alt="Report a broken link" /></a><a href="javascript:void(0);"><img width="24" height="24" src="/?images/add.png&amp;v=1" alt="Add to a collection" /></a>';if(typeof pronvid_priv!="undefined"){a+='<a href="javascript:void(0);"><img width="24" height="24" src="/?images/rem.png&amp;v=1" alt="Remove from private collection" /></a>'}$(this).qtip({content:a,position:"topRight",hide:{fixed:true},style:{padding:0},api:{beforeShow:function(){if(typeof this.pronvid!="undefined"){return}this.pronvid=true;Index.addActions(b,this.elements.tooltip,this)}}})});Index.message=$("<div>").css({position:"absolute",top:0,left:"10px",width:"288px",padding:"6px",opacity:0.7,backgroundColor:"black",color:"white",zIndex:4999,overflow:"hidden"}).hide()},showMessage:function(a,b){var c=b.elements.target.parent().parent();Index.message.remove().appendTo(c).text(a).fadeIn(500).delay(1000).fadeOut(500)},fixWidth:function(){var a=Math.floor(100/Math.floor($("#videos").width()/324))+"%";$(".video").css({width:a})},addActions:function(c,a,b){$("img",a).qtip({content:"Add to a collection",position:{corner:{target:"topMiddle",tooltip:"bottomMiddle"}},style:{tip:true},api:{onRender:function(){this.elements.tooltip.qtip("api").updateContent(this.elements.target.attr("alt"),true)}}});$("a",a).eq(0).click(function(){if(confirm("Report this link as broken?")){$("img",this).qtip("destroy");$(this).remove();if(b!=false){b.hide();b.updateWidth();Index.showMessage("reported",b)}$.post("/?video-broken",{id:c})}return false});$("a",a).eq(1).qtip({content:{title:{text:"Add to a collection",button:"Close"},text:'<form method="post" action="/?collection-add"><input type="text" name="collection" size="32" class="inputtext" /><input type="hidden" name="id" value="'+c+'" /><input type="submit" value="Add" class="inputbutton" /></form>'},position:{target:$(document.body),corner:"center"},show:{when:"click"},hide:false,style:{padding:"14px",width:"100%"},api:{onRender:function(){var e=this;var d=$("input:text",this.elements.content);d.suggest({click:function(){this.input.val(this.suggestions[this.current].s)},suggest:function(){var h=this.text.toLowerCase();var f=pv_collections.length;var g=0;if($.cookie("private")!=null){if($.cookie("private").indexOf(h)>=0){this.suggestions.push({s:$.cookie("private"),d:"your private collection"})}}for(;g<f&&this.suggestions.length<10;++g){if(pv_collections[g].indexOf(h)==0){this.suggestions.push({s:pv_collections[g]})}}for(g=0;g<f&&this.suggestions.length<10;++g){if(pv_collections[g].indexOf(h)>0){this.suggestions.push({s:pv_collections[g]})}}}});$("form",this.elements.content).submit(function(){$.post(this.action,{id:c,collection:d.val()},function(g,f){if(f=="success"){if(g.substr(0,1)==1){alert(g.substr(2))}else{if(g.substr(0,1)==2){if(confirm(g.substr(2))){$.post(this.url,this.data+"&confirm=1",this.success)}}else{e.hide();if(b!=false){Index.showMessage(g.substr(2),b)}d.val("")}}}});return false})},beforeShow:function(){Extended.blanket.fadeIn(this.options.show.effect.length);if(b!=false){b.hide()}var d=this;$(window).bind("keypress.pronvid",function(f){if(f.keyCode==27){d.hide()}})},onShow:function(){$("input:text",this.elements.content).focus()},onHide:function(){$(window).unbind("keypress.pronvid");Extended.blanket.fadeOut(this.options.hide.effect.length)}}});if(typeof pronvid_priv!="undefined"){$("a",a).eq(2).click(function(){if(confirm("Do you really want to remove this video from your collection?")){b.hide();$("img",this).qtip("destroy");$(this).remove();b.updateWidth();$.post("/?collection-remove",{id:c,collection:pronvid_priv},function(e,d){Index.showMessage(e,b)})}return false})}}};$(document).ready(Index.start);