function grayscale(a){var b=document.createElement("canvas");var c=b.getContext("2d");var d=new Image;d.src=a;b.width=d.width;b.height=d.height;c.drawImage(d,0,0);var e=c.getImageData(0,0,b.width,b.height);for(var f=0;f<e.height;f++){for(var g=0;g<e.width;g++){var h=f*4*e.width+g*4;var i=(e.data[h]+e.data[h+1]+e.data[h+2])/3;e.data[h]=i;e.data[h+1]=i;e.data[h+2]=i}}c.putImageData(e,0,0,0,0,e.width,e.height);return b.toDataURL()}function randomrange(a,b,c){var d=a+Math.random()*(b-a);return typeof c=="undefined"?Math.round(d):d.toFixed(c)}function setimg(a,b){$(a).attr("src",b)}function glitch(a,b,c){var d="";var e=b.replace("data:image/png;base64,","");var f=c;console.log(c);for(var g in e){if(g==f){var h=Math.floor(Math.random()*9);d+=h}else{d+=e[g]}}var i="data:image/png;base64,"+d;setimg(a,i)}function draw(a,b,c){$("body").append("<canvas id ='c1'></canvas>");$("canvas").css({display:"none"});var d=document.getElementById("c1");d.width=$(a).width();d.height=$(a).height();if(!d||!d.getContext){return false}var e=d.getContext("2d");var f=new Image;f.src=b;e.drawImage(f,0,0);imgdata=document.getElementById("c1").toDataURL("image/png");glitch(a,imgdata,c)}window.log=function(){log.history=log.history||[];log.history.push(arguments);if(this.console){arguments.callee=arguments.callee.caller;var a=[].slice.call(arguments);typeof console.log==="object"?log.apply.call(console.log,console,a):console.log.apply(console,a)}};(function(a){function b(){}for(var c="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,timeStamp,profile,profileEnd,time,timeEnd,trace,warn".split(","),d;d=c.pop();){a[d]=a[d]||b}})(function(){try{console.log();return window.console}catch(a){return window.console={}}}());$.fn.valign=function(){return this.each(function(a){var b=$(this).height();var c=$(this).parent().height();var d=Math.ceil((c-b)/2);var d=d-20;$(this).css("top",d)})};(function(a){a.fn.glitch=function(b){var c={};this.each(function(){var c=a(this).attr("src");var d=this;draw(d,c,b)});return this}})(jQuery);$(window).load(function(){$(".latestimg img").fadeIn(500);$(".latestimg img").each(function(){var a=$(this);a.css({position:"absolute"}).wrap("<div class='img_wrapper' style='display: inline-block'>").clone().addClass("img_grayscale").css({position:"absolute","z-index":"4",opacity:"0"}).insertBefore(a).queue(function(){var a=$(this);a.parent().css({width:this.width,height:this.height});a.dequeue()});this.src=grayscale(this.src)});$(".guilloche").mouseover(function(){$(".latestimg img").parent().find("img:first").stop().animate({opacity:1},500)});$(".guilloche").mouseout(function(){$(".img_grayscale").stop().animate({opacity:0},250)});$("#twitter a").valign();$("#text .thin:nth-child(4n)").addClass("last");$(".glitchme").glitch(randomrange(500,2e4))})
