/**
 * onArcade 2.3.2
 * Copyright © 2006-2011 Hans Mäesalu & Eveterm OÜ, All Rights Reserved
 **
 * ONARCADE IS NOT FREE SOFTWARE!
 * http://www.onarcade.com
 **/
$(document).ajaxError(function(a,b,c,d){alert(c.url+" returned error:\n"+d)});$.createElement=function(a){return jQuery(document.createElement(a))};function nl2br(a){return a.replace(/(\\r)?\\n/g,"<br />")}function is_empty(a){for(i in a)return false;return true}function nohtml(a){a=a.replace(/"/g,"&quot;");a=a.replace(/</g,"&lt;");return a=a.replace(/>/g,"&gt;")}function field_number(a){return parseInt(a.replace(/[^0-9]/g,""))}
function check_all(a){a=$(a);var b=$(a).is(":checked");a.closest("form").find("input[type='checkbox']").each(function(){$(this).attr("checked",b)})}function confirm_delete(){return confirm(lang.sure_delete)?true:false}
var loader={url:siteurl+"images/load.gif",replace:function(a){if(typeof a=="string")a=$("#"+a);else a.jQuery||(a=$(a));var b=(a.height()-16)/2;if(b<0)b=0;a.html('<div class="center"><img src="'+loader.url+'" style="width: 16px; height:16px; margin: '+b+'px 0px;" /></div>')},insert:function(a){if(typeof a=="string")a=$("#"+a);var b=a.next();b.size()>0&&b.hasClass("loader")?b.show():$.createElement("img").attr("src",loader.url).addClass("loader").insertAfter(a);a.get(0).nodeName.toLowerCase()=="input"&&
a.attr("disabled",true)},remove:function(a){if(typeof a=="string")a=$("#"+a);var b=a.next();b.size()>0&&b.hasClass("loader")&&b.hide();a.get(0).nodeName.toLowerCase()=="input"&&a.attr("disabled",false)}},error={insert:function(a,b,c){if(typeof b=="string")b=$("#"+b);if(c==undefined)c=[];if(c.after){if(b.next().size()>0&&(b.next().hasClass("error")||b.next().hasClass("error_green")))var d=b.next()}else if(b.prev().size()>0&&(b.prev().hasClass("error")||b.prev().hasClass("error_green")))d=b.prev();
if(d==undefined){d=$.createElement("div");c.after?d.insertAfter(b):d.insertBefore(b)}d.attr("class",c.error==false?"error_green":"error");d.text(a);d.hide();d.slideDown(250);c.error==false&&c.hide&&d.delay(1E3*c.hide).slideUp(250)}},url_hash={set_hash:function(a,b){var c=""+location.hash;if(c.length==0||c=="#")location.hash=a+"/"+b;else{var d=c.match(RegExp("(#|^|/)"+a+"/[0-9]+"));if(d!=null)location.hash=c.replace(""+d[0],""+d[1]+a+"/"+b);else location.hash+="/"+a+"/"+b}},get_hash:function(a){a=
(""+location.hash).match(RegExp("(#|^|/)"+a+"/([0-9]+)"));return a==null?null:parseInt(a[2])}},image_verification={image_url:siteurl+"includes/verification_image.php",refresh_image:siteurl+"images/reload.png",refresh:function(){$(this).prev().attr("src",image_verification.image_url+"?"+Math.random())},attach:function(a){a=$("#"+a);if(a.size()!=0)if(a.children("div.image_verification").size()>0)a.find("img.refresh_image").click();else{var b=$.createElement("div").addClass("image_verification");$.createElement("img").attr("src",
image_verification.image_url).addClass("code_image").appendTo(b);$.createElement("img").attr("src",image_verification.refresh_image).addClass("refresh_image").appendTo(b).click(image_verification.refresh);$.createElement("input").attr({type:"text",maxlength:4,name:"image_verification"}).addClass("small").appendTo(b);a.append(b)}}},favourites_menu={link:null,menu:null,content:null,loaded:false,create:function(){favourites_menu.menu=$.createElement("div").addClass("bubble").width("150px").attr("id",
"favourites_menu");favourites_menu.content=$.createElement("div").appendTo(favourites_menu.menu);$.createElement("div").addClass("bubble_up").appendTo(favourites_menu.menu);$(document.body).append(favourites_menu.menu)},load:function(){$.getJSON(siteurl+"usercp.php?a=get_favourites&ajax=1",function(a){favourites_menu.content.empty();var b;for(i in a){b=$.createElement("p");$.createElement("a").attr("href",a[i].url).text(a[i].title).appendTo(b);b.appendTo(favourites_menu.content)}favourites_menu.loaded=
true})},open:function(){favourites_menu.menu==null&&favourites_menu.create();favourites_menu.menu.show();var a=favourites_menu.link.offset();favourites_menu.menu.css({left:a.left+"px",top:a.top+24+"px"});$(document).bind("click",favourites_menu.close);favourites_menu.menu.click(function(b){b.stopPropagation()});if(favourites_menu.loaded==false){loader.replace(favourites_menu.content);favourites_menu.load()}},close:function(){$("#favourites_menu").hide();$(document).unbind("click",favourites_menu.close)},
init:function(){favourites_menu.link=$("#favourites_link");favourites_menu.link.click(function(a){favourites_menu.open();a.stopPropagation();return false})}};$(document).ready(favourites_menu.init);
function tab_menu(a,b){this.tabs_id=a;this.contents_id=b;this.tab=[];this.content=[];this.tab_functions=[];this.initiating=false;this.get_content=function(c){return this.content.eq(c)};this.get_tab=function(c){return this.tab.eq(c)};this.click_tab=function(c){var d=parseInt(c.data("id"));this.tab.removeClass("selected");c.addClass("selected");this.content.hide();this.content.eq(d).show();this.content.eq(d).children(".error,.error_green").hide();if(url_hash.get_hash(this.tabs_id)!=null||d>0)url_hash.set_hash(this.tabs_id,
d+1);if(this.tab_functions[d]!=undefined)for(i in this.tab_functions[d])this.tab_functions[d][i]()};this.add_action=function(c,d){if(this.tab_functions[c]!=undefined)this.tab_functions[c].push(d);else this.tab_functions[c]=[d]};this.init=function(){var c=this;this.ul=$("#"+this.tabs_id);this.div=this.contents_id==undefined?this.ul.nextAll("div:first"):$("#"+this.contents_id);this.tab=this.ul.find("li>a");this.content=this.div.children("div").hide();if(this.tab.size()!=this.content.size())window.alert("ERROR! Tabs and contents not equal.");
else{this.tab.each(function(g){$(this).data("id",g).click(function(j,f){c.initiation=f!=undefined&&f==true;c.initiating=f!=undefined&&f==true;c.click_tab($(this));return false})});var d=0,e=url_hash.get_hash(this.tabs_id);if(e!=null){e--;if(e<this.tab.size())d=e}this.tab.eq(d).trigger("click",[true])}}}
var scroller={files:[],width:70,height:59,size:0,moving:false,scroller:null,scroller_width:0,ul:null,ul_width:0,title:null,active:null,interval:null,current_offset:0,goal_offset:0,show_title:function(a){if(scroller.title==null)scroller.title=$.createElement("div").addClass("title").click(function(){scroller.active.click()}).appendTo(scroller.scroller);scroller.title.show();scroller.active=$(this);scroller.title.text(scroller.active.attr("alt"));a=a.pageX-scroller.scroller.offset().left-scroller.title.width()/
2;if(a<0)a=0;scroller.title.css("left",a+"px")},hide_title:function(){scroller.title.hide()},mouse_move:function(a){a=a.pageX-scroller.scroller.offset().left;scroller.goal_offset=a*((scroller.ul_width-scroller.scroller_width)/scroller.scroller_width);scroller.moving||scroller.start_move()},go_to:function(a){window.location=a.data},build_list:function(){scroller.ul=$.createElement("ul");var a;for(i in scroller.files){a=$.createElement("li");$.createElement("img").attr("src",scroller.files[i][2]).width(scroller.width).height(scroller.height).attr("alt",
scroller.files[i][0]).mouseenter(scroller.show_title).bind("click",scroller.files[i][1],scroller.go_to).appendTo(a);a.appendTo(scroller.ul)}scroller.ul.appendTo(scroller.scroller);scroller.scroller_width=scroller.scroller.width();scroller.ul_width=a.outerWidth()*scroller.size;scroller.ul.width(scroller.ul_width);scroller.scroller.mouseleave(scroller.hide_title).mousemove(scroller.mouse_move)},start_move:function(){scroller.interval=setInterval(scroller.move,10);scroller.moving=true},stop_move:function(){clearInterval(scroller.interval);
scroller.moving=false},move:function(){if(scroller.current_offset!=scroller.goal_offset){var a=scroller.goal_offset-scroller.current_offset,b=a/25;if(a>0){if(b<1)b=1;scroller.current_offset+=b;if(scroller.current_offset>scroller.goal_offset){scroller.current_offset=scroller.goal_offset;scroller.stop_move()}}else{if(b>-1)b=-1;scroller.current_offset+=b;if(scroller.current_offset<scroller.goal_offset){scroller.current_offset=scroller.goal_offset;scroller.stop_move()}}scroller.ul.css("left","-"+scroller.current_offset+
"px")}},init:function(a,b){if(scroller.files.length!=0){scroller.scroller=$("#scroller");scroller.width=a;scroller.height=b;scroller.size=this.files.length;scroller.build_list()}}};function link_out(a){window.open(siteurl+"/links.php?a=out&id="+a);return false}
var rate_file={rating:0,active:0,file_id:0,element:null,star:[],images:[],hover:function(){var a=$(this).data("star");for(i=1;i<=a;i++)rate_file.star[i].attr("src",siteurl+"images/star_hover.png")},clear:function(){for(i=1;i<=5;i++)rate_file.star[i].attr("src",rate_file.images[i])},submit:function(){loader.insert(rate_file.star[5]);$.post(siteurl+"/file.php?f="+rate_file.file_id+"&a=rate&ajax=1",{rating:$(this).data("star")},function(a){rate_file.rating=a.rating;rate_file.active=0;rate_file.draw();
rate_file.element.append("<span>"+a.message+"</span>")},"json")},draw:function(){this.element.empty();var a;for(i=1;i<=5;i++){this.star[i]=$.createElement("img").attr("title",this.rating+" / 5").data("star",i);if(i<=this.rating)this.star[i].attr("src",siteurl+"images/star.png");else{a=i-this.rating;a<0.75?this.star[i].attr("src",siteurl+"images/star"+(a<0.25?"":"_half")+".png"):this.star[i].attr("src",siteurl+"images/star_empty.png")}if(this.active==1){this.images[i]=this.star[i].attr("src");this.star[i].css("cursor",
"pointer").click(rate_file.submit).mouseover(rate_file.hover).mouseout(rate_file.clear)}this.star[i].appendTo(this.element)}},init:function(a){this.element=$("#file_rating");this.file_id=a;this.draw();(new Image).src=siteurl+"images/star_hover.png"}};function make_favorite(a){$.getJSON(siteurl+"file.php?a=make_favorite&f="+a+"&ajax=1",function(b){b.error||$("#make_favorite").attr("src",siteurl+"images/"+b.image+".png")})}
var full_screen={real_width:0,real_height:0,file:null,overlay:null,button:null,iframes:null,open:function(){full_screen.file.parent().css("height",full_screen.file.parent().height()+"px");full_screen.iframes=$("iframe:visible").hide();var a=full_screen.file.position();full_screen.file.css({position:"absolute",top:a.top+"px",left:a.left+"px"});var b=$(window).scrollTop(),c=full_screen.file.offset(),d=$(window).width(),e=$(window).height(),g=d-30,j=g/full_screen.real_width,f=full_screen.real_height*
j;if(f>e){f=e-30;j=f/full_screen.real_height;g=full_screen.real_width*j}full_screen.file.animate({top:a.top-c.top+(e-f)/2+b,left:a.left-c.left+(d-g)/2,width:g,height:f},1E3);$(document).one("click",full_screen.close);full_screen.file.click(function(h){h.stopPropagation()});if(full_screen.overlay==null){b=$(document).height();full_screen.overlay=$.createElement("div").attr("id","resize_overlay").width(d).height(b>e?b:e).css({top:a.top-c.top,left:a.left-c.left}).insertBefore(full_screen.file)}else full_screen.overlay.show()},
close:function(){full_screen.file.stop();full_screen.overlay.hide();full_screen.file.css("position","static").width(full_screen.real_width).height(full_screen.real_height);full_screen.iframes.show()},init:function(){full_screen.file=$("#resize_file");if(full_screen.file.size()!=0){full_screen.real_width=this.file.width();full_screen.real_height=this.file.height();full_screen.button=$("#full_screen").show().click(function(){full_screen.open();return false})}}};
function submit_tell_friend(a,b){var c=a.find("input:submit");loader.insert(c);$.post(siteurl+"file.php?a=tell_friend&f="+b+"&ajax=1",a.serializeArray(),function(d){loader.remove(c);error.insert(d.message,a,{hide:3,error:d.error});if(!d.error){a.find("input:text").val("");image_verification.attach("tell_image_verification")}},"json")}
function submit_report_broken(a,b){var c=a.find("input:submit");loader.insert(c);$.post(siteurl+"file.php?a=report_broken&f="+b+"&ajax=1",a.serializeArray(),function(d){loader.remove(c);error.insert(d.message,a,{error:d.error});d.error||a.delay(250).slideUp()},"json")}
var preloader={time:10,ad:null,file:null,loader:null,hide:function(a){a==true&&preloader.loader.children("div").stop();preloader.ad.slideUp();preloader.file.slideDown();full_screen.button!=null&&full_screen.button.show()},init:function(){this.ad=$("#file_ad_box");if(this.ad.size()!=0){this.loader=$("#ad_loader");this.file=$("#file_box").hide();full_screen.button!=null&&full_screen.button.hide();$("#no_wait").children("a").click(function(){preloader.hide(true);return false});this.loader.children("div").animate({width:"100%"},
this.time*1E3,"linear",preloader.hide)}}};function init_file_info(a){$("#make_favorite").click(function(){make_favorite(a);return false});rate_file.init(a);full_screen.init();$("#tell_friend_form").submit(function(){submit_tell_friend($(this),a);return false});$("#report_broken_form").submit(function(){submit_report_broken($(this),a);return false});var b=new tab_menu("file_tabs");b.add_action(1,function(){image_verification.attach("tell_image_verification")});b.init();preloader.init()}
function init_frame(){$("#file_frame").height($(window).height()-$("#file_frame_info").height())}
var comments={file_id:0,page:1,comments:null,form:null,button:null,spam_actions:function(a){var b=a.find(".text:first");b.hide();a.find(".report:first").hide();a.mouseenter(function(){b.is(":hidden")&&b.slideDown()});a.mouseleave(function(){b.is(":visible")&&b.slideUp()})},load:function(a){loader.replace(this.comments);this.comments.load(siteurl+"file.php?a=comments&ajax=1&f="+this.file_id+"&p="+a,null,function(){comments.attach()})},submit:function(){loader.insert(this.button);$.post(siteurl+"file.php?a=submit_comment&ajax=1&f="+
this.file_id,this.form.serializeArray(),function(a){error.insert(a.message,comments.form,{error:a.error});if(a.error)loader.remove(comments.button);else{comments.form.slideUp();a=$.createElement("div").addClass("comment").html('<p><span class="user">'+a.user+'</span> <span class="date">('+a.date+')</span></p><p class="text">'+a.comment+"</p>");var b=comments.comments.children("div:first-child");b.size()>0?b.before(a):comments.comments.append(a)}},"json")},report:function(a){a=a.closest(".comment");
a.addClass("spam");comments.spam_actions(a);$.getJSON(siteurl+"file.php?a=report_comment&ajax=1&id="+field_number(a.attr("id")))},page_click:function(){comments.page+=$(this).hasClass("next")?1:-1;comments.load(comments.page);return false},attach:function(){this.comments.children("div.arrow_nav").find(".next, .previous").click(this.page_click);this.comments.find(".report").click(function(){comments.report($(this))});this.comments.find(".spam").each(function(){comments.spam_actions($(this))})},init:function(a){this.file_id=
a;this.comments=$("#comments");this.attach();this.form=$("#comment_form");if(this.form.size()>0){this.button=this.form.find("input:submit");this.form.submit(function(){comments.submit();return false});var b=$("#comment_verification_field");b.size()>0&&$("#comment").focusin(function(){if(b.is(":hidden")){b.show();image_verification.attach("comment_verification_field")}})}}},score_comment={score_id:0,comment:null,button:null,change:function(a){this.comment=a.closest("p");this.score_id=field_number(this.comment.attr("id"));
this.button=a.detach();this.comment.empty();a=$.createElement("form");var b=$.createElement("input").attr("type","text").width("100%").css("margin",0).appendTo(a);$.createElement("input").attr("type","submit").val(lang.submit).appendTo(a);a.submit(function(){score_comment.submit(b.val());return false}).appendTo(this.comment);b.focus()},submit:function(a){loader.replace(this.comment);$.post(siteurl+"scores.php?a=edit_comment&ajax=1&id="+score_comment.score_id,{comment:a},function(b){if(b.error)alert(b.message);
else{score_comment.comment.html(b.comment+" ");score_comment.comment.append(score_comment.button)}},"json")}};function init_scores(a){rate_file.init(a);$("#change_comment").click(function(){score_comment.change($(this));return false})}
var bb_code={codes:[["text_bold.png","b"],["text_italic.png","i"],["text_underline.png","u"],["text_strikethrough.png","s"],["text_center.png","center"],["text_right.png","right"],["text_quote.png","quote"],["text_url.png","url"],["text_image.png","img"]],emoticons:[["happy.gif",":)"],["sad.gif",":("],["wink.gif",";)"],["@.gif",":@"],["cool.gif",":8"],["wave.gif",":wave:"],["think.gif",":think:"],["clap.gif",":clap:"]],open:{},insert_emoticon:function(a,b){a=" "+a+" ";b.focus();if(document.selection)document.selection.createRange().text=
a;else if(b.selectionStart||b.selectionStart==0){var c=b.selectionStart,d=b.selectionEnd,e=b.scrollTop;b.value=b.value.substring(0,c)+a+b.value.substring(d,b.value.length);b.selectionStart=c+a.length;b.selectionEnd=c+a.length;b.scrollTop=e}else b.value+=a},get_tag:function(a){if(bb_code.open[a]==undefined||bb_code.open[a]==false){bb_code.open[a]=true;return"["+a+"]"}else{bb_code.open[a]=false;return"[/"+a+"]"}},insert_code:function(a,b){b.focus();if(document.selection)var c=document.selection.createRange().text,
d="ie";else if(b.selectionStart||b.selectionStart==0){var e=b.selectionStart,g=b.selectionEnd,j=b.scrollTop,f=b.value.substring(0,e),h=b.value.substring(g,b.value.length);c=b.value.substring(e,g);d="other"}if(a=="url")if(d=="ie")if(c.length>0)if(c.match(/^https?:\/\//i))document.selection.createRange().text="[url="+c+"]"+c+"[/url]";else document.selection.createRange().text="[url=http://]"+c+"[/url]";else document.selection.createRange().text="[url=http://]text[/url]";else if(d=="other")if(c.length>
0)if(c.match(/^https?:\/\//i)){b.value=f+"[url="+c+"]"+c+"[/url]"+h;e+=6+c.length;g=e+c.length}else{b.value=f+"[url=http://]"+c+"[/url]"+h;e+=5;g=e+7}else{b.value=f+"[url=http://]text[/url]"+h;e+=5;g=e+7}else b.value+="[url=http://]text[/url]";else if(a=="img")if(d=="ie")document.selection.createRange().text=c.length>0?"[img]"+c+"[/img]":"[img]http://[/img]";else if(d=="other")if(c.length>0){b.value=f+"[img]"+c+"[/img]"+h;e+=5;g=e+c.length}else{b.value=f+"[img]http://[/img]"+h;e+=5;g+=12}else b.value+=
"[img]http://[/img]";else if(d=="ie"){if(c.length>0)document.selection.createRange().text="["+a+"]"+c+"[/"+a+"]";else document.selection.createRange().text=bb_code.get_tag(a);b.focus()}else if(d=="other")if(c.length>0){b.value=f+"["+a+"]"+c+"[/"+a+"]"+h;e+=a.length+2;g+=a.length+2}else{a=bb_code.get_tag(a);b.value=f+a+h;e+=a.length;g=e}else b.value+=bb_code.get_tag(a);if(d=="other"){b.selectionStart=e;b.selectionEnd=g;b.scrollTop=j}},attach_emoticons:function(a,b){a=$("#"+a);b=$("#"+b).get(0);var c=
$.createElement("p");for(i in bb_code.emoticons)$.createElement("img").attr("src",siteurl+"images/"+bb_code.emoticons[i][0]).attr("alt",bb_code.emoticons[i][1]).attr("title",bb_code.emoticons[i][1]).click(function(){bb_code.insert_emoticon($(this).attr("alt"),b)}).addClass("bb_emoticon").appendTo(c);c.appendTo(a)},attach_codes:function(a,b){a=$("#"+a);b=$("#"+b).get(0);var c=$.createElement("p");for(i in bb_code.codes)$.createElement("img").attr("src",siteurl+"images/"+bb_code.codes[i][0]).attr("alt",
bb_code.codes[i][1]).attr("title",bb_code.codes[i][1]).click(function(){bb_code.insert_code($(this).attr("alt"),b)}).addClass("bb_code").appendTo(c);c.appendTo(a)},attach:function(a,b){bb_code.attach_emoticons(a,b);bb_code.attach_codes(a,b)}};
