jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options.expires=-1;}
var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000));}else{date=options.expires;}
expires='; expires='+date.toUTCString();}
var path=options.path?'; path='+options.path:'';var domain=options.domain?'; domain='+options.domain:'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');}else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break;}}}
return cookieValue;}};$(function(){$.plugins=$.plugins||{};$.plugins.cache=window.sessionStorage||{};$.plugins.settings={cache:true,ajax:{cache:true},context:$(document),target:$('head',this.context),init:function(){},preLoad:function(){},postLoad:function(){}};var defaults=$.plugins.settings,cache=$.plugins.cache;Plugin=function(name,settings){var that=this;this.name=name;for(var i in settings){that[i]=settings[i];};this.context=this.context||settings.context;this.target=this.target||settings.target;this.loaded={};this.queue=[];this.ajaxQueue=[];$(window).unload(function(){for(i in this.ajaxQueue){console.log(this.ajaxQueue[i]);this.ajaxQueue[i].abort();}});this.init.apply(this);return this;};Plugin.prototype.getFile=function(url){if(!url||typeof url!='string'){throw new Error('$.plugin.getFile(url) - url {String} must be specified');}
var that=this,extension=url.split('.')[url.split('.').length-1],fileId=url.replace(/\W/gi,''),cached=cache[url],caching=(defaults.cache===true||defaults.cache=='true');if(caching&&this.loaded[url]){return this;}
this.beforeGet(url);$('[data-file-id="'+fileId+'"]').remove();if(caching&&cached&&cached!='undefined'){if(extension=='css'){this.target.append('<style type="text\/css" rel="stylesheet" data-file-id="'+fileId+'">'+cached+'<\/style>');}
else{this.target.append('<script type="text\/javascript" data-file-id="'+fileId+'">'+cached+'<\/script>');}
setTimeout(function(){that.afterGet(url);},0);}else{if(extension=='css'){(function(){var opts=$.extend({url:url},defaults.ajax),onSuccess=opts.success||function(){};opts.success=function(response){onSuccess.apply(this,arguments);that.loaded[url]=true;cache[url]=response;that.target.append('<style type="text\/css" rel="stylesheet" data-file-id="'+fileId+'">'+response+'<\/style>');that.afterGet(url);};$.ajax(opts);})();}
else{(function(){var opts=$.extend({dataType:"script",url:url},defaults.ajax),onSuccess=opts.success||function(){};opts.success=function(){onSuccess.apply(this,arguments);var response=(typeof arguments[0]=='string')?arguments[0]:null;cache[url]=response;that.loaded[url]=true;that.afterGet(url);};var o=$.ajax(opts);that.ajaxQueue.push(o);})();}}
return this;};Plugin.prototype.beforeGet=function(url){this.queue.push(url);defaults.preLoad.call(this,url);return this;};Plugin.prototype.afterGet=function(url){var that=this,callback=this.tmp_callback,index=$.inArray(url,this.queue);if(index==-1){throw new Error('$.plugin.afterGet(url) - Ignoring postLoad for file that should not be in queue:\n '+url);return this;}
this.queue.splice(index,1);this.ajaxQueue.splice(index,1)
if(this.queue.length==0&&callback){setTimeout(function(){callback.apply(that);delete that.tmp_callback;},0);}
defaults.postLoad.call(this,url);return this;};Plugin.prototype.get=function(){var that=this,files=(typeof this.files=='string')?[this.files]:this.files,callback=arguments[0]||this.callback;this.tmp_callback=callback;if(this.isNeeded()!==true){return this;}
var getFile=function(file){that.getFile(file);};for(var i=0;i<files.length;i++){(function(){var file=files[i];if($.browser.opera){setTimeout(function(){getFile(file);},500);}
else{getFile(file);}})();}
return this;};Plugin.prototype.isNeeded=function(){var that=this,selectors=(typeof this.selectors=='string')?[this.selectors]:this.selectors,isNeeded;for(var i=0;i<selectors.length;i++){var selector=selectors[i];if($(selector,that.context).length>0){isNeeded=true;break;}};return isNeeded||this;};$.extend($,{plugin:function(name,param){var self=$.plugin;if(arguments.length==0){for(var i in $.plugins){if(i=='settings'||i=='cache'){continue;}$.plugins[i].get();};return self;}
else if(typeof name!='string'){throw new Error('$.plugin(name,[settings||callback])\n\t\t@param name\t\t{String}\n\t\t@param settings\t{Object}\n\t\t@param callback\t{Function}');return self;}
if(typeof param=='object'){$.plugins[name]=new Plugin(name,$.extend(defaults,param));}
else{var plugin=$.plugins[name];if(typeof plugin!='object'){throw new Error('$.plugin: '+name+' is not specified');return self;}
if(typeof param=='function'){plugin.get(param);}
else if(!param){return plugin;}}
return self;},getPlugin:function(){return $.plugin.apply(this,arguments);}});});(function(jQuery){var hotkeys={};hotkeys.version='(beta)(0.0.6)';hotkeys.all={};hotkeys.newid=function(){return(Math.random()*0x10000000000|0).toString(32).substring(1);};hotkeys.special_keys={27:'esc',9:'tab',32:'space',13:'return',8:'backspace',145:'scroll',20:'capslock',144:'numlock',19:'pause',45:'insert',36:'home',46:'del',35:'end',33:'pageup',34:'pagedown',37:'left',38:'up',39:'right',40:'down',112:'f1',113:'f2',114:'f3',115:'f4',116:'f5',117:'f6',118:'f7',119:'f8',120:'f9',121:'f10',122:'f11',123:'f12'};hotkeys.shift_nums={"`":"~","1":"!","2":"@","3":"#","4":"$","5":"%","6":"^","7":"&","8":"*","9":"(","0":")","-":"_","=":"+",";":":","'":"\"",",":"<",".":">","/":"?","\\":"|"};hotkeys.handler=function(event){var options=event.data;var element=event.currentTarget;element=(element.nodeType===3)?element.parentNode:element;if(options['disableInInput']){var jTarget=jQuery(element);var elem=jQuery(event.target);if(jTarget.is("input")||jTarget.is("textarea")||jTarget.is("select")||elem.is("input")||elem.is("textarea")||elem.is("select")){return true;}}
var code=event.which,type=event.type,special=hotkeys.special_keys[code],character=!special&&String.fromCharCode(code).toLowerCase(),shift=event.shiftKey,ctrl=event.ctrlKey,alt=event.altKey||event.originalEvent.altKey,meta=event.metaKey,propagate=true,mapPoint=null;if(jQuery.browser.opera||jQuery.browser.safari||options.checkParent){while(!hotkeys.all[element.id]&&element.parentNode){element=element.parentNode;}}
var key=(element===document&&element)||element.id;var cbMap=hotkeys.all[key].events[type].callbackMap;if(!shift&&!ctrl&&!alt&&!meta){mapPoint=cbMap[special]||(character&&cbMap[character]);}
else{var modif='';if(alt)modif+='alt+';if(ctrl)modif+='ctrl+';if(shift)modif+='shift+';if(meta)modif+='meta+';mapPoint=cbMap[modif+special];if(!mapPoint){if(character){mapPoint=cbMap[modif+character]||cbMap[modif+hotkeys.shift_nums[character]];}}}
if(mapPoint){mapPoint.cb(event);if(!mapPoint.propagate){event.stopPropagation();event.preventDefault();return false;}
else{return true;}}};hotkeys.add=function(combi,options,callback){if(jQuery.isFunction(options)){callback=options;options={};}
var opt={},defaults={type:'keydown',propagate:false,disableInInput:true,target:document,checkParent:true};opt=jQuery.extend(opt,defaults,options||{});combi=combi.toLowerCase();if(!hotkeys.all[opt.target]){hotkeys.all[opt.target]={events:{}};}
if(!hotkeys.all[opt.target].events[opt.type]){hotkeys.all[opt.target].events[opt.type]={callbackMap:{}}
var target=opt.target===document&&opt.target||jQuery("#"+opt.target)[0];jQuery(target).bind(opt.type,opt,hotkeys.handler);}
hotkeys.all[opt.target].events[opt.type].callbackMap[combi]={cb:callback,propagate:opt.propagate};return jQuery;};hotkeys.bind=hotkeys.add;hotkeys.remove=function(exp,opt){opt=opt||{};target=opt.target||document;type=opt.type||'keydown';exp=exp.toLowerCase();delete hotkeys.all[target].events[type].callbackMap[exp]
return jQuery;};jQuery.hotkeys=hotkeys;return jQuery;})(jQuery);;(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);ux={init:function(){$("a[rel~='popup']").click(function(){var screenX=typeof window.screenX!='undefined'?window.screenX:window.screenLeft,screenY=typeof window.screenY!='undefined'?window.screenY:window.screenTop,outerWidth=typeof window.outerWidth!='undefined'?window.outerWidth:document.body.clientWidth,outerHeight=typeof window.outerHeight!='undefined'?window.outerHeight:(document.body.clientHeight-22),width=800,height=500,left=parseInt(screenX+((outerWidth-width)/2),10),top=parseInt(screenY+((outerHeight-height)/2.5),10),features=('width='+width+',height='+height+',left='+left+',top='+top+',scrollbars=yes'+',resizable=yes'+',location=no'+',toolbar=no');window.open($(this).attr("href"),'popup',features).focus();return false;});$("#viewHTMLOptions").toggle(function(){$(this).removeClass('bulletLeft');$(this).addClass('bulletDown');$("#tagTable").slideToggle();return false;},function(){$(this).removeClass('bulletDown');$(this).addClass('bulletLeft');$("#tagTable").slideToggle();return false;});$("#clickMore").toggle(function(){$("#readMore").slideToggle();return false;},function(){$("#readMore").slideToggle();return false;});$('.toolbar .toolbarButton').click(function(){$('.toolbar .toolbarButton').toggleClass('active');});$("#recaptcha_reload_btn, #recaptcha_switch_audio_btn, #recaptcha_whatsthis_btn").attr("tabindex",-1);ux.unsafeFilter();ux.setMainMenu();var ads=$('div.ads.box');if(ads.length>0&&$('ol.bookmarks').length>0)ux.adsAlwaysVisible(ads);if($('ol.bookmarks').length>0)ux.hideOps();ux.initCollapsibleBoxes();ux.allTagsLoad();ux.initSearchInput();ux.initFastLogin();ux.initJumpToPage();ux.notificationMessages();},unsafeFilter:function(){if(jQuery.cookie){ckId='VISUALIZEUS-unsafe';unsafeFilter=$.cookie(ckId);}else unsafeFilter=false;if(unsafeFilter=='1'||unsafeFilter==true){$('img.unsafeFilter').fadeOut();$('a.safeFilter').text('Safe filter is OFF').removeClass('safe').addClass('unsafe');}else{$('img.unsafeFilter').show();$('a.safeFilter').text('Safe filter is ON').removeClass('unsafe').addClass('safe');}
$('a.safeFilter.unsafe').live('click',function(){$('img.unsafeFilter').show();if(jQuery.cookie)$.cookie(ckId,'0',{path:'/'});$('a.safeFilter').text('Safe filter is ON').removeClass('unsafe').addClass('safe');$.ajax({type:'POST',data:{'ajax':1},url:"/ajaxUnsafe/",dataType:"xml",timeout:30000,});return false;});$('a.safeFilter.safe').live('click',function(){$('img.unsafeFilter').hide();if(jQuery.cookie)$.cookie(ckId,'1',{path:'/'});$('a.safeFilter').text('Safe filter is OFF').removeClass('safe').addClass('unsafe');$.ajax({type:'POST',data:{'ajax':1},url:"/ajaxUnsafe/",dataType:"xml",timeout:30000,});return false;});},adsAlwaysVisible:function($obj){$(window).scroll(function(e){ux.stickElem(e,$obj);});},stickElem:function(e,$obj){var window_ScrollTop=$(window).scrollTop();var stickClass="fixed_ad";if(!$obj.data(stickClass)){$obj.data(stickClass,{css:{position:$obj.css('position'),top:$obj.css('top')},offset:$obj.offset()});}
var objOrig=$obj.data(stickClass);var isSticky=$obj.hasClass(stickClass);if(window_ScrollTop>objOrig.offset.top&&!isSticky){$obj.css({position:'fixed',top:0}).addClass(stickClass);}else if(window_ScrollTop<objOrig.offset.top&&isSticky){$obj.css(objOrig.css).removeClass(stickClass);}},setMainMenu:function(){$(".nav > .sub").prepend('<a href="#" class="dropdown"></a>');$(".nav .sub").addClass('subMenu');$(".nav .sub a.dropdown").toggle(function(){$(".nav .sub.sfHover a.dropdown").click();$(this).parent(".sub").addClass('sfHover').addClass('clicked');$(this).addClass('clicked');$("html").one('click',function(){$(".nav .sub.sfHover a.dropdown").click();});},function(){$(this).parent(".sub").removeClass('sfHover').removeClass('clicked');$(this).removeClass('clicked');});$(".nav .sub").hover(function(){$(this).addClass('clicked');},function(){var t=this;if($(this).attr('class').indexOf('sfHover')==-1){setTimeout(function(){$(t).removeClass('clicked')},150);}});$('.nav').prepend('<a href="#" class="dropdown"></a>');},hideOps:function(context){},showConfirmation:function(ele,item,callback,confirmText){var link=$(ele).parents("ul");$("ol.bookmarks li.confirm").remove();if(link.children("li.confirm").length<1){if(confirmText==undefined||!confirmText)confirmText="Are you sure?";var confirmDelete="<li class='confirm'>"+confirmText+" <a id='yesLink' href='#' rel='"+item+"'>Yes</a> - <a href='#' id='noLink'>No</a></li>";link.children("li.operations").hide();link.prepend(confirmDelete);link.children("li.confirm").children("a#yesLink").click(function(){callback(link,item);return false;});link.children("li.confirm").children("a#noLink").click(function(){link.children("li.confirm").remove();return false;});}},resortThumbs:function(){var thumbs=$("#bookmarks li.xfolkentry");thumbs.each(function(i){$(this).removeClass('third');if(((i+1)%3)==0)$(this).addClass('third');});},initCollapsibleBoxes:function(){$("h3.dropdown").hover(function(){$(this).addClass('hover');},function(){$(this).removeClass('hover');});$("h3.dropdown").bind('click',ux.collapsibleClick);$("h3.dropdown").each(function(){rmb=$(this).hasClass('remember');if(rmb&&jQuery.cookie){ckId='VISUALIZEUS-sidebar-'+this.id;collapsed=$.cookie(ckId);}else collapsed=null;if(collapsed=='1'){$(this).nextAll("ul").hide();$(this).removeClass('bulletDown').addClass('bulletLeft');if(rmb&&jQuery.cookie)$.cookie(ckId,'1',{path:'/'});}else if((collapsed=='0')||(!$(this).hasClass('bulletDown')&&!$(this).hasClass('bulletLeft'))){$(this).nextAll("ul").show();$(this).removeClass('bulletLeft').addClass('bulletDown');if(rmb&&jQuery.cookie)$.cookie(ckId,'0',{path:'/'});}});},collapsibleClick:function(){rmb=$(this).hasClass('remember');if(rmb)ckId='VISUALIZEUS-sidebar-'+this.id;if($(this).hasClass('bulletDown')){$(this).nextAll("ul").hide();$(this).removeClass('bulletDown').addClass('bulletLeft');if(rmb&&jQuery.cookie)$.cookie(ckId,'1',{path:'/'});}else{$(this).nextAll("ul").show();$(this).removeClass('bulletLeft').addClass('bulletDown');if(rmb&&jQuery.cookie)$.cookie(ckId,'0',{path:'/'});}
return false;},allTagsLoad:function(){$("#Tags.dropdown").unbind('click').click(function(){if($(this).hasClass('bulletDown')){$(this).nextAll("ul").hide();$(this).removeClass('bulletDown').addClass('bulletLeft');}else{$(this).removeClass('bulletLeft').addClass('bulletDown');$(this).nextAll("ul").html("<li style='color:#999;'><img style='margin-right:0.6em; vertical-align: top;' src='http://cdnstatic.visualizeus.com//css/images/indicator.white.gif' width='16' height'16' />loading tags...</li>").show();var h3Tags=$(this);$.ajax({type:'GET',url:"/ajaxAllTags/",data:{'username':browsingUsername},dataType:"html",timeout:30000,error:function(xhr,status,err){alert("An error happened when processing your request.\nPlease, try refreshing");},success:function(response){h3Tags.nextAll("ul").remove();if(!response)response="<ul><li style='color:#999;'>No more tags!</li>";h3Tags.after(response).show();h3Tags.unbind('click').bind('click',ux.collapsibleClick);}});}
return false;}).show();},initSearchInput:function(){labelText=$("#search label[for=terms]").text();labelText=labelText.substring(0,labelText.length-2);$("#search input#terms").val(labelText);$("input#terms").focus(function(){$(this).val("").unbind("focus");});},initFastLogin:function(){$("#loginLink").click(function(){$("#header p#access").hide();$("#header form#search").hide();$("#fastLogin").show();return false;});$("#fastLogin input, .paginator input").focus(function(){if($(this).hasClass('default'))
$(this).removeClass('default').val('');}).blur(function(){if($(this).val()==""){$(this).val($(this)[0].defaultValue).addClass('default');}});},initJumpToPage:function(){$(".paginator form").submit(function(){val=$(".paginator input");lastP=$(".paginator span.jump").attr('id');if(parseInt(val.val())>parseInt(lastP)){val.val(lastP);}});},notificationMessages:function(){$("#mainContent > p.success, #mainContent > p.message").append('<span id="closeBtn"><a href="#">(hide)</a></span>');$("#mainContent > p.success > span > a, #mainContent > p.message > span > a").click(function(){var msgBox=$(this).parent().parent();if(msgBox.attr('id')&&msgBox.attr('id').indexOf('msg_')!=-1){if(jQuery.cookie)
$.cookie('VISUALIZEUS-'+msgBox.attr('id'),'disabled',{expires:2419200,path:'/'});}
msgBox.slideUp();return false;});},displayOverlay:function(text,classMsg){var obj=$('<div class="overlayMessage '+classMsg+'">'+text+'</div>').appendTo('body').show().animate({opacity:0.75},500);return obj;},overlayMessage:function(text,classMsg){ux.displayOverlay(text,classMsg).fadeOut('slow',function(){$(this).remove();});},hideOverlay:function(classMsg){id='div.overlayMessage';if(classMsg)id+='.'+classMsg;$(id).fadeOut('slow',function(){$(this).remove();});}};operations={ops:[],init:function(context){if(!context)context=document;operations.ops={'delete':{callback:operations.deleteBookmark},'block':{callback:operations.flagBookmark,text:"Do you think is unsafe?"},'moderate':{callback:operations.moderateBookmark}};for(oper in operations.ops){$('li.operations a.'+oper,context).click(function(){var op=$(this).attr('class');var href=String($(this).attr('href'));href=href.substring(0,href.lastIndexOf('/'));href=href.substring(href.lastIndexOf('/')+1,href.length);ux.showConfirmation(this,href,operations.ops[op].callback,operations.ops[op].text);return false;});}
$("li.operations a.share",context).click(function(){if($("ul#shareLinks a#back").length==0)
$("ul#shareLinks").append('<a style="float:right;" id="back" href="#">back</a>');$("ul#shareLinks a#back").click(function(){$(this).parents("ul#shareLinks").hide();return false;});$("ul#shareLinks").show();return false;});},deleteBookmark:function(ele,item){ele.children(".confirm").html("Deleting, please wait...");if(item.constructor.toString().indexOf(Array)==-1){var bId=String(item);var inputs={'ajax':'1','id':bId};}else var inputs={'ajax':'1','bulk':'1','id[]':item};$.ajax({type:'POST',url:"/ajaxDelete.php",data:inputs,timeout:30000,error:function(xhr,status,err){alert("An error happened when processing your request.\nPlease, try refreshing");},complete:function(obj,response){ux.resortThumbs();},success:function(response){if($("result",response).text()=='true'){$(ele).children(".confirm").html("Done!").animate({opacity:1.0},3000).fadeOut('slow',function(){$(this).parent().parent('li.xfolkentry').remove();});if(inputs['bulk']=='1'){$("input[type=checkbox].bulkCheckbox:checked").each(function(){this.checked=false;});location.reload();}}else{if(inputs['bulk']=='1')
ele.children(".confirm").html('Something went wrong! Please try refreshing');else{var link='Failed! Try <a href="%s">this link</a> instead';link=link.replace('%s','/delete/'+bId+'/');ele.children(".confirm").html(link);}}}});},flagBookmark:function(ele,item){ele.children("li.confirm").html("Flagging, please wait...");var bId=String(item);$.ajax({type:'GET',url:"/flag/image/"+bId+"/",data:{'ajax':'1'},timeout:30000,error:function(xhr,status,err){alert("An error happened when processing your request.\nPlease, try refreshing");},complete:function(obj,response){ux.resortThumbs();},success:function(response){if($("result",response).text()=='true'){$(ele).children("li.confirm").css('text-transform','none').html("This image is now flagged as unsafe for you. If enough people also flag it, it will be mark as unsafe for everyone. Thanks!");$(ele).children("li.image").children('a').children("img").fadeOut('fast',function(){this.src="http://cdnstatic.visualizeus.com/css/images/thumbUnsafe.png";}).fadeIn('fast');;}else{var link='Failed! Try <a href="%s">this link</a> instead';link=link.replace('%s','/flag/image/'+bId+'/');ele.children("li.confirm").html(link);}}});},moderateBookmark:function(ele,item){ele.children("li.confirm").html("Moderating, please wait...");var bId=String(item);$.ajax({type:'GET',url:"/flag/image/"+bId+"/",data:{'ajax':'1','moderate':'1'},timeout:30000,error:function(xhr,status,err){alert("An error happened when processing your request.\nPlease, try refreshing");},complete:function(obj,response){ux.resortThumbs();},success:function(response){if($("result",response).text()=='true'){$(ele).children("li.confirm").html("Done!").animate({opacity:1.0},3000).fadeOut('slow',function(){$(this).parent().parent('li.xfolkentry').remove();});}else{var link='Failed! Try <a href="%s">this link</a> instead';link=link.replace('%s','/flag/image/'+bId+'/?moderate=1');ele.children("li.confirm").html(link);}}});}};hotkeys={picsPerRow:3,nRow:Math.round($(window).height()/450),scrollPos:[],shortcuts:{},init:function(){$(document).resize(function(){var nRow=Math.round($(window).height()/400);});hotkeys.shortcuts={'d':hotkeys.down,'s':hotkeys.up,'space':hotkeys.down,'a':hotkeys.prevPage,'f':hotkeys.nextPage,'j':hotkeys.nextRow,'k':hotkeys.prevRow,'h':hotkeys.prevPage,'l':hotkeys.nextPage,'t':hotkeys.goTop,'y':hotkeys.goHome};for(key in hotkeys.shortcuts)
$.hotkeys.add(key,{propagate:false,disableInInput:true},hotkeys.shortcuts[key]);},getScrollList:function(){$('li.xfolkentry').each(function(i){hotkeys.scrollPos[i]=Math.round($(this).offset().top);});},goTop:function(){if($(window).scrollTop()!=0)
$.scrollTo(0,200);},goHome:function(){if($('a[href*="/register/"]').length==0){for(key in hotkeys.shortcuts)
$.hotkeys.remove(key);ux.overlayMessage('home');window.location.href='/home/';}},nextPage:function(){if($('a.next').length){for(key in hotkeys.shortcuts)
$.hotkeys.remove(key);ux.overlayMessage('next page');window.location.href=($('a.next').attr('href'));}},prevPage:function(){if($('a.prev').length){for(key in hotkeys.shortcuts)
$.hotkeys.remove(key);ux.overlayMessage('prev page');window.location.href=($('a.prev').attr('href'));}},down:function(){var currentPos=$(window).scrollTop();var i=0;var nScroll=hotkeys.picsPerRow*hotkeys.nRow;hotkeys.getScrollList();while((currentPos>hotkeys.scrollPos[i])&&(i<hotkeys.scrollPos.length)){i=i+nScroll;}
if((i+nScroll)<(hotkeys.scrollPos.length-1)){$.scrollTo($('#bookmark'+(i+nScroll)),300,{offset:-20});}else{hotkeys.nextPage();}
return false;},up:function(){var currentPos=$(window).scrollTop();var i=0;var nScroll=hotkeys.picsPerRow*hotkeys.nRow;hotkeys.getScrollList();while((currentPos>hotkeys.scrollPos[i])&&(i<hotkeys.scrollPos.length)){i=i+nScroll;}
if(i>=hotkeys.scrollPos.length){$.scrollTo($('#bookmark'+(i-(nScroll+hotkeys.picsPerRow))),300,{offset:-20});}else if(i>0){$.scrollTo($('#bookmark'+(i-nScroll)),300,{offset:-20});}else{hotkeys.prevPage();}
return false;},nextRow:function(){var oldnRow=hotkeys.nRow;hotkeys.nRow=1;hotkeys.down();hotkeys.nRow=oldnRow;},prevRow:function(){var oldnRow=hotkeys.nRow;hotkeys.nRow=1;hotkeys.up();hotkeys.nRow=oldnRow;}};jQuery(function($){ux.init();operations.init();if(jQuery.hotkeys){hotkeys.init();}});
