/**
 * onArcade 2.3.0
 * Copyright © 2006-2010 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 bb=new Array(0,0,0,0,0);

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).click(full_screen.close);full_screen.file.click(function(h){h.stopPropagation()});if(full_screen.overlay==null){a=$(document).height();full_screen.overlay=$.createElement("div").attr("id","resize_overlay").width(d).height(a>e?a:e).insertBefore(document.body.firstChild)}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);$(document).unbind("click",full_screen.close);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});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)}};


function bb_code(code,text_id){var message=doc_id(text_id);var bb_code;message.focus();switch(code){case 0:bb_code="b";break;case 1:bb_code="i";break;case 2:bb_code="u";break;case 3:bb_code="s";break;case 4:bb_code="quote";break;}if(bb[code]%2==0)bb_code="["+bb_code+"]";else bb_code="[/"+bb_code+"]";bb[code]++;if(document.selection)document.selection.createRange().text=bb_code;else if(message.selectionStart||message.selectionStart==0)message.value=message.value.substring(0,message.selectionStart)+bb_code+message.value.substring(message.selectionEnd,message.value.length);else message.value+=bb_code;}function emoticon(code,text_id){var message=doc_id(text_id);message.focus();if(document.selection)document.selection.createRange().text=code;else if(message.selectionStart||message.selectionStart==0)message.value=message.value.substring(0,message.selectionStart)+code+message.value.substring(message.selectionEnd,message.value.length);else message.value+=code;}


var bb=new Array(0,0,0,0,0);function get_position(obj){var left_pos=0;var top_pos=0;if(obj.offsetParent){do{left_pos+=obj.offsetLeft;top_pos+=obj.offsetTop;}while(obj=obj.offsetParent);}else if(obj.x){left_pos+=obj.x;top_pos+=obj.y;}var jada=new Array(left_pos,top_pos);return jada;}function get_window_dimensions(){var width=0;var height=0;if(window.innerWidth){width=window.innerWidth;height=window.innerHeight;}else if(document.documentElement.clientWidth&&document.documentElement.clientWidth!=0){width=document.documentElement.clientWidth;height=document.documentElement.clientHeight;}else{width=document.body.clientWidth;height=document.body.clientHeight;}var jada=new Array(width,height);return jada;}function addLoadEvent(func){var oldonload=window.onload;if(typeof window.onload!='function'){window.onload=func;}else{window.onload=function(){oldonload();func();}}}function doc_id(id){return document.getElementById(id);}function nl2br(string){return string.replace(/(\\r)?\\n/g,"<br />");}function nohtml(string){string=string.replace(/"/g,'&quot;');string=string.replace(/</g,'&lt;');string=string.replace(/>/g,'&gt;');return string;}function check_all(){for(var i=0;i<document.form.elements.length;i++){var e=document.form.elements[i];if(e.name!="all"&&e.type=="checkbox")e.checked=document.form.all.checked;}}function link_out(link_id){window.open(siteurl+"/links.php?a=out&l="+link_id);return false;}function confirm_delete(){if(confirm(sure_delete))return true;else return  false;}function verify_link_add(){if(document.form.link_title.value==""||document.form.link_url.value==""||document.form.link_description.value==""||document.form.link_email.value==""){alert(all_fields_required);return false;}else return  true;}function verify_submit(){if(doc_id("title").value==""||doc_id("description").value==""||doc_id("upload_file").value==""||doc_id("upload_image").value==""){alert(all_fields_required);return false;}else return  true;}function verify_sponsor(){if(document.getElementById("os0").value==''||document.getElementById("os1").value==''||document.getElementById("os1").value=='http://'){alert(all_fields_required);return false;}else return  true;}function score_comment_form(comment_id){doc_id("edit_comment_"+comment_id).innerHTML='<input type="text" size="20" maxlength="50" id="score_comment" /> <input type="submit" value="'+submit_button+'" onclick="edit_score_comment('+comment_id+')" />';doc_id("edit_comment_"+comment_id).firstChild.focus();}function comment_verification(){if(doc_id("comment_verification").style.display=="none"){doc_id("comment_verification").style.display="block";doc_id("c_verification_image").src=siteurl+"/includes/verification_image.php";}}function refresh_image(image_id){doc_id(image_id).src=siteurl+"/includes/verification_image.php?"+Math.random();}function tell_friend_pop(){var tell_friend=doc_id("tell_friend_popup");try{var file_info=doc_id("file_info");var position=get_position(file_info);}catch(e){alert("There was an error: "+e);return false;}tell_friend.style.display="block";if(doc_id("friend_verification")){refresh_image("friend_verification");}left_plus=(file_info.offsetWidth-tell_friend.offsetWidth)/2;tell_friend.style.top=(position[1]+170)+"px";tell_friend.style.left=(position[0]+left_plus-300)+"px";}function report_broken(){var report_broken=doc_id("report_broken_popup");try{var file_info=doc_id("file_info");var position=get_position(file_info);}catch(e){alert("There was an error: "+e);return false;}report_broken.style.display="block";left_plus=(file_info.offsetWidth-report_broken.offsetWidth)/2;report_broken.style.top=(position[1]+90)+"px";report_broken.style.left=(position[0]+left_plus - 300)+"px";}function close_popup(popup){doc_id(popup+"_popup").style.display="none";if(popup=='tell_friend'){doc_id("friend_email").value="";if(doc_id("friend_verification_code")){doc_id("friend_verification_code").value="";}doc_id("tell_friend_error").innerHTML="<br />";doc_id("tell_friend_form").style.display="";}}function bb_code(code,text_id){var message=doc_id(text_id);var bb_code;message.focus();switch(code){case 0:bb_code="b";break;case 1:bb_code="i";break;case 2:bb_code="u";break;case 3:bb_code="s";break;case 4:bb_code="quote";break;}if(bb[code]%2==0)bb_code="["+bb_code+"]";else bb_code="[/"+bb_code+"]";bb[code]++;if(document.selection)document.selection.createRange().text=bb_code;else if(message.selectionStart||message.selectionStart==0)message.value=message.value.substring(0,message.selectionStart)+bb_code+message.value.substring(message.selectionEnd,message.value.length);else message.value+=bb_code;}function emoticon(code,text_id){var message=doc_id(text_id);message.focus();if(document.selection)document.selection.createRange().text=code;else if(message.selectionStart||message.selectionStart==0)message.value=message.value.substring(0,message.selectionStart)+code+message.value.substring(message.selectionEnd,message.value.length);else message.value+=code;}function makeHttpRequest(url,callback_function, return_json,post_data){var xmlHttp,response;try{xmlHttp=new XMLHttpRequest();}catch(e){try{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}}if(!xmlHttp)return;xmlHttp.onreadystatechange=function(){if(xmlHttp.readyState==4||xmlHttp.readyState=="complete"){if(return_json){try{response=eval('('+xmlHttp.responseText+')');}catch(e){alert('There was an error: '+e+'\nResponse: '+xmlHttp.responseText);}}else{response=xmlHttp.responseText;}callback_function(response);}};if(post_data){xmlHttp.open("POST",url,true);xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");xmlHttp.send(post_data);}else{xmlHttp.open("GET",url,true);xmlHttp.send(null);}}function favourites_menu(link){if(!document.getElementById("favourites_menu")){var fav_menu=document.createElement("div");fav_menu.setAttribute("id","favourites_menu");document.body.appendChild(fav_menu);}else{var fav_menu=doc_id("favourites_menu");if(fav_menu.style.display=="block")return;}var position=get_position(link);fav_menu.style.display="block";fav_menu.style.top=(position[1]+17)+"px";fav_menu.style.left=(position[0]+2)+"px";fav_menu.innerHTML=loader;function back_function(server_r){contents='<ul>';for(i=0;i<server_r.length;i++)contents+='<li><a href="'+server_r[i].url+'">'+server_r[i].title+'</a></li> ';contents+='</ul>';fav_menu.innerHTML=contents;document.onclick=function(){doc_id("favourites_menu").style.display="none";document.onclick=null;};fav_menu.onclick=stop_event;}makeHttpRequest(siteurl+"/usercp.php?a=favourites&ajax=1",back_function, true);}function submit_report_broken(file_id){doc_id("submit_report_broken").disabled=true;function back_function(server_r){document.getElementById("report_broken_popup").innerHTML=server_r.message;setTimeout("close_popup('report_broken')",1000);}makeHttpRequest(siteurl+"/file.php?a=report_broken&f="+file_id,back_function, true,"broken_reason="+doc_id("broken_reason").value);}function submit_tell_friend(file_id){var error=doc_id("tell_friend_error");var submit=doc_id("submit_tell_friend");submit.disabled=true;function back_function(server_r){error.innerHTML=server_r.message;submit.disabled=false;if(server_r.error==0){doc_id("tell_friend_form").style.display="none";setTimeout("close_popup('tell_friend')",1000);}}var query="your_name="+doc_id("your_name").value+"&your_email="+doc_id("your_email").value+"&friend_email="+doc_id("friend_email").value;if(document.getElementById("friend_verification_code"))query+="&friend_verification_code="+doc_id("friend_verification_code").value;makeHttpRequest(siteurl+"/file.php?a=tellafriend&f="+file_id,back_function, true,query);}function make_favorite(file_id){function back_function(server_r){if(server_r.image == "make_favorite"){doc_id("make_favorite_img").innerHTML="Add Favorite";}else{doc_id("make_favorite_img").innerHTML="Remove Favorite";}}makeHttpRequest(siteurl+"/file.php?a=make_favorite&f="+file_id,back_function, true);}function edit_score_comment(score_id){var comment=doc_id("edit_comment_"+score_id);data_s="edit_comment="+doc_id("score_comment").value;comment.innerHTML=loader;makeHttpRequest(siteurl+"/scores.php?a=edit_comment&s="+score_id,function(server_r){comment.innerHTML=server_r.comment;},true,data_s);}function display_comments(file_id,comment_page){doc_id("file_comments").innerHTML="<br />"+loader;makeHttpRequest(siteurl+"/file.php?f="+file_id+"&a=comments&p="+comment_page,function(response){doc_id("file_comments").innerHTML=response;},false);}function submit_comment(file_id){var submit=doc_id("submit_comment");var error=doc_id("comment_error");var loader=doc_id("loader");submit.disabled=true;loader.style.display="";function back_function(server_r){error.innerHTML=server_r.message;if(server_r.error==0){doc_id("comment_form").style.display="none";doc_id("new_comment").style.display="block";doc_id("new_comment").innerHTML='<div class="comment_left"><img src = "'+server_r.avatar+'" /></div><div class="comment_right"><div class="comment_username">'+server_r.user+'</div><div class="comment_desc">'+nl2br(server_r.comment)+'</div></div>';}else{submit.disabled=false;loader.style.display="none";}}if(document.getElementById("verification_code")){send_d="message="+doc_id("message").value+"&verification_code="+doc_id("verification_code").value;}else{send_d="message="+doc_id("message").value;}makeHttpRequest(siteurl+"/file.php?a=submit_comment&f="+file_id,back_function, true,send_d);}function report_comment(comment_id){if(confirm(sure_spam)){doc_id("report_"+comment_id).style.display="none";makeHttpRequest(siteurl+"/file.php?a=report_comment&c="+comment_id,function(){},false);}}
