var Pixastic=function(){function t(t,a,e){var n=new Array;null==a&&(a=document),null==e&&(e="*");var r=a.getElementsByTagName(e),s=r.length,o=new RegExp("(^|\\s)"+t+"(\\s|$)");for(i=0,j=0;i<s;i++)o.test(r[i].className)&&(n[j]=r[i],j++);return n}function a(t,a){if(Pixastic.debug)try{a}catch(t){}}"undefined"!=typeof pixastic_parseonload&&pixastic_parseonload&&function(t){var a=!1,e=function(){a||(a=!0,t())};document.write('<script defer src="//:" id="__onload_ie_pixastic__"><\/script>');var i=document.getElementById("__onload_ie_pixastic__");i.onreadystatechange=function(){"complete"==i.readyState&&(i.parentNode.removeChild(i),e())},document.addEventListener&&document.addEventListener("DOMContentLoaded",e,!1),function(t,a,e){t.addEventListener?t.addEventListener(a,e,!1):t.attachEvent&&t.attachEvent("on"+a,e)}(window,"load",e)}((function(){for(var a=t("pixastic",null,"img"),e=t("pixastic",null,"canvas"),i=a.concat(e),n=0;n<i.length;n++)!function(){for(var t=i[n],a=[],e=t.className.split(" "),r=0;r<e.length;r++){var s=e[r];if("pixastic-"==s.substring(0,9)){var o=s.substring(9);""!=o&&a.push(o)}}if(a.length)if("img"==t.tagName.toLowerCase()){var c=new Image;if(c.src=t.src,c.complete)for(var h=0;h<a.length;h++){var l=Pixastic.applyAction(t,t,a[h],null);l&&(t=l)}else c.onload=function(){for(var e=0;e<a.length;e++){var i=Pixastic.applyAction(t,t,a[e],null);i&&(t=i)}}}else setTimeout((function(){for(var e=0;e<a.length;e++){var i=Pixastic.applyAction(t,t,a[e],null);i&&(t=i)}}),1)}()}));var e=function(){var t=document.createElement("canvas"),a=!1;try{a=!("function"!=typeof t.getContext||!t.getContext("2d"))}catch(t){}return function(){return a}}(),n=function(){var t,a=document.createElement("canvas"),e=!1;try{"function"==typeof a.getContext&&(t=a.getContext("2d"))&&(e="function"==typeof t.getImageData)}catch(t){}return function(){return e}}(),r=function(){var t=!1,a=document.createElement("canvas");if(e()&&n()){a.width=a.height=1;var i=a.getContext("2d");i.fillStyle="rgb(255,0,0)",i.fillRect(0,0,1,1);var r=document.createElement("canvas");r.width=r.height=1;var s=r.getContext("2d");s.fillStyle="rgb(0,0,255)",s.fillRect(0,0,1,1),i.globalAlpha=.5,i.drawImage(r,0,0);var o=i.getImageData(0,0,1,1).data;t=255!=o[2]}return function(){return t}}();return{parseOnLoad:!1,debug:!1,applyAction:function(t,e,i,n){n=n||{};var r,s,o="canvas"==t.tagName.toLowerCase();if(o&&Pixastic.Client.isIE())return Pixastic.debug&&a(),!1;var c=!1;Pixastic.Client.hasCanvas()&&(c=!!n.resultCanvas,s=(r=n.resultCanvas||document.createElement("canvas")).getContext("2d"));var h=t.offsetWidth,l=t.offsetHeight;if(o&&(h=t.width,l=t.height),0==h||0==l){if(null!=t.parentNode)return void(Pixastic.debug&&a());var d=t.style.position,g=t.style.left;t.style.position="absolute",t.style.left="-9999px",document.body.appendChild(t),h=t.offsetWidth,l=t.offsetHeight,document.body.removeChild(t),t.style.position=d,t.style.left=g}if("blurfast"!==i&&void 0!==n.retinaReady&&"yes"===n.retinaReady&&void 0!==n.devicePixelRatio&&(h=Math.floor(h*n.devicePixelRatio),l=Math.floor(l*n.devicePixelRatio),void 0!==t.naturalWidth&&void 0!==t.naturalHeight&&t.naturalWidth>0&&t.naturalHeight>0&&(h>t.naturalWidth||l>t.naturalHeight)&&(h=t.naturalWidth,l=t.naturalHeight)),i.indexOf("(")>-1){var p=i;i=p.substr(0,p.indexOf("("));var u=p.match(/\((.*?)\)/);if(u[1]){u=u[1].split(";");for(var f=0;f<u.length;f++)if(thisArg=u[f].split("="),2==thisArg.length)if("rect"==thisArg[0]){var v=thisArg[1].split(",");n[thisArg[0]]={left:parseInt(v[0],10)||0,top:parseInt(v[1],10)||0,width:parseInt(v[2],10)||0,height:parseInt(v[3],10)||0}}else n[thisArg[0]]=thisArg[1]}}n.rect?(n.rect.left=Math.round(n.rect.left),n.rect.top=Math.round(n.rect.top),n.rect.width=Math.round(n.rect.width),n.rect.height=Math.round(n.rect.height)):n.rect={left:0,top:0,width:h,height:l};var x=!1;if(Pixastic.Actions[i]&&"function"==typeof Pixastic.Actions[i].process&&(x=!0),!x)return Pixastic.debug&&a(),!1;if(!Pixastic.Actions[i].checkSupport())return Pixastic.debug&&a(),!1;Pixastic.Client.hasCanvas()?(r!==t&&(r.width=h,r.height=l),c||(r.style.width=h+"px",r.style.height=l+"px"),s.drawImage(e,0,0,h,l),t.__pixastic_org_image?(r.__pixastic_org_image=t.__pixastic_org_image,r.__pixastic_org_width=t.__pixastic_org_width,r.__pixastic_org_height=t.__pixastic_org_height):(r.__pixastic_org_image=t,r.__pixastic_org_width=h,r.__pixastic_org_height=l)):Pixastic.Client.isIE()&&void 0===t.__pixastic_org_style&&(t.__pixastic_org_style=t.style.cssText);var m={image:t,canvas:r,width:h,height:l,useData:!0,options:n};return!!Pixastic.Actions[i].process(m)&&(Pixastic.Client.hasCanvas()?(m.useData&&Pixastic.Client.hasCanvasImageData()&&(r.getContext("2d").putImageData(m.canvasData,n.rect.left,n.rect.top),r.getContext("2d").fillRect(0,0,0,0)),n.leaveDOM||(r.title=t.title,r.imgsrc=t.imgsrc,o||(r.alt=t.alt),o||(r.imgsrc=t.src),r.className=t.className,r.style.cssText=t.style.cssText,r.name=t.name,r.tabIndex=t.tabIndex,r.id=t.id,t.parentNode&&t.parentNode.replaceChild&&t.parentNode.replaceChild(r,t)),n.resultCanvas=r,r):t)},prepareData:function(t,a){var e=t.canvas.getContext("2d"),i=t.options.rect,n=e.getImageData(i.left,i.top,i.width,i.height),r=n.data;return a||(t.canvasData=n),r},process:function(t,a,e,i){if("img"==t.tagName.toLowerCase()){var n=new Image;if(n.src=t.src,n.complete){var r=Pixastic.applyAction(t,n,a,e);return i&&i(r,t),r}n.onload=function(){var r=Pixastic.applyAction(t,n,a,e);i&&i(r,t)}}if("canvas"==t.tagName.toLowerCase()){r=Pixastic.applyAction(t,t,a,e);return i&&i(r,t),r}},revert:function(t){if(Pixastic.Client.hasCanvas()){if("canvas"==t.tagName.toLowerCase()&&t.__pixastic_org_image)return t.width=t.__pixastic_org_width,t.height=t.__pixastic_org_height,t.getContext("2d").drawImage(t.__pixastic_org_image,0,0),t.parentNode&&t.parentNode.replaceChild&&t.parentNode.replaceChild(t.__pixastic_org_image,t),t}else Pixastic.Client.isIE()&&void 0!==t.__pixastic_org_style&&(t.style.cssText=t.__pixastic_org_style)},Client:{hasCanvas:e,hasCanvasImageData:n,hasGlobalAlpha:r,isIE:function(){return!!document.all&&!!window.attachEvent&&!window.opera}},Actions:{}}}();"undefined"!=typeof jQuery&&jQuery&&jQuery.fn&&(jQuery.fn.pixastic=function(t,a){var e=[];return this.each((function(){if("img"!=this.tagName.toLowerCase()||this.complete){var i=Pixastic.process(this,t,a);i&&e.push(i)}})),e.length>0?jQuery(e):this}),Pixastic.Actions.blurfast={process:function(t){var a=parseFloat(t.options.amount)||0,e=!(!t.options.clear||"false"==t.options.clear);if(a=Math.max(0,Math.min(5,a)),Pixastic.Client.hasCanvas()){var i=t.options.rect,n=t.canvas.getContext("2d");n.save(),n.beginPath(),n.rect(i.left,i.top,i.width,i.height),n.clip();var r=Math.round(t.width/2),s=Math.round(t.height/2),o=document.createElement("canvas");o.width=r,o.height=s;e=!1;for(var c=Math.round(20*a),h=o.getContext("2d"),l=0;l<c;l++){var d=Math.max(1,Math.round(r-l)),g=Math.max(1,Math.round(s-l));h.clearRect(0,0,r,s),h.drawImage(t.canvas,0,0,t.width,t.height,0,0,d,g),e&&n.clearRect(i.left,i.top,i.width,i.height),n.drawImage(o,0,0,d,g,0,0,t.width,t.height)}return n.restore(),t.useData=!1,!0}if(Pixastic.Client.isIE()){var p=10*a;return t.image.style.filter+=" progid:DXImageTransform.Microsoft.Blur(pixelradius="+p+")",t.options.fixMargin,t.image.style.marginLeft=(parseInt(t.image.style.marginLeft,10)||0)-Math.round(p)+"px",t.image.style.marginTop=(parseInt(t.image.style.marginTop,10)||0)-Math.round(p)+"px",!0}},checkSupport:function(){return Pixastic.Client.hasCanvas()||Pixastic.Client.isIE()}},Pixastic.Actions.desaturate={process:function(t){var a=!(!t.options.average||"false"==t.options.average);if(Pixastic.Client.hasCanvasImageData()){var e,i,n=Pixastic.prepareData(t),r=t.options.rect,s=r.width*r.height,o=4*s;if(a)for(;s--;)n[o-=4]=n[e=o+1]=n[i=o+2]=(n[o]+n[e]+n[i])/3;else for(;s--;)n[o-=4]=n[e=o+1]=n[i=o+2]=.3*n[o]+.59*n[e]+.11*n[i];return!0}if(Pixastic.Client.isIE())return t.image.style.filter+=" gray",!0},checkSupport:function(){return Pixastic.Client.hasCanvasImageData()||Pixastic.Client.isIE()}},Pixastic.Actions.glow={process:function(t){var a=parseFloat(t.options.amount)||0,e=parseFloat(t.options.radius)||0;if(a=Math.min(1,Math.max(0,a)),e=Math.min(5,Math.max(0,e)),Pixastic.Client.hasCanvasImageData()){var i=t.options.rect,n=document.createElement("canvas");n.width=t.width,n.height=t.height;var r=n.getContext("2d");r.drawImage(t.canvas,0,0);var s=Math.round(t.width/2),o=Math.round(t.height/2),c=document.createElement("canvas");c.width=s,c.height=o;for(var h=Math.round(20*e),l=c.getContext("2d"),d=0;d<h;d++){var g=Math.max(1,Math.round(s-d)),p=Math.max(1,Math.round(o-d));l.clearRect(0,0,s,o),l.drawImage(n,0,0,t.width,t.height,0,0,g,p),r.clearRect(0,0,t.width,t.height),r.drawImage(c,0,0,g,p,0,0,t.width,t.height)}for(var u=Pixastic.prepareData(t),f=Pixastic.prepareData({canvas:n,options:t.options}),v=i.width*i.height,x=4*v,m=x+1,_=x+2;v--;)(u[x-=4]+=a*f[x])>255&&(u[x]=255),(u[m-=4]+=a*f[m])>255&&(u[m]=255),(u[_-=4]+=a*f[_])>255&&(u[_]=255);return!0}},checkSupport:function(){return Pixastic.Client.hasCanvasImageData()}},Pixastic.Actions.laplace={process:function(t){var a=!(!t.options.invert||"false"==t.options.invert),e=parseFloat(t.options.edgeStrength)||0,i=parseInt(t.options.greyLevel)||0;if(e=-e,Pixastic.Client.hasCanvasImageData()){var n=Pixastic.prepareData(t),r=Pixastic.prepareData(t,!0),s=1/8,o=t.options.rect,c=o.width,h=o.height,l=4*c,d=h;do{var g=(d-1)*l,p=(1==d?0:d-2)*c*4,u=(d==h?d-1:d)*c*4,f=c;do{var v=g+(4*f-4),x=p+4*(1==f?0:f-2),m=u+4*(f==c?f-1:f),_=((-r[x-4]-r[x]-r[x+4]-r[v-4]-r[v+4]-r[m-4]-r[m]-r[m+4]+8*r[v])*s+(-r[x-3]-r[x+1]-r[x+5]-r[v-3]-r[v+5]-r[m-3]-r[m+1]-r[m+5]+8*r[v+1])*s+(-r[x-2]-r[x+2]-r[x+6]-r[v-2]-r[v+6]-r[m-2]-r[m+2]-r[m+6]+8*r[v+2])*s)/3+i;0!=e&&(_>127?_+=(_+1-128)*e:_<127&&(_-=(_+1)*e)),a&&(_=255-_),_<0&&(_=0),_>255&&(_=255),n[v]=n[v+1]=n[v+2]=_}while(--f)}while(--d);return!0}},checkSupport:function(){return Pixastic.Client.hasCanvasImageData()}},Pixastic.Actions.sepia={process:function(t){var a=parseInt(t.options.mode,10)||0;if(a<0&&(a=0),a>1&&(a=1),Pixastic.Client.hasCanvasImageData()){var e=Pixastic.prepareData(t),i=t.options.rect,n=i.width,r=4*n,s=i.height;do{var o=(s-1)*r,c=n;do{var h=o+4*(c-1);if(a)var l=.299*e[h]+.587*e[h+1]+.114*e[h+2],d=l+39,g=l+14,p=l-36;else{var u=e[h],f=e[h+1],v=e[h+2];d=.393*u+.769*f+.189*v,g=.349*u+.686*f+.168*v,p=.272*u+.534*f+.131*v}d<0&&(d=0),d>255&&(d=255),g<0&&(g=0),g>255&&(g=255),p<0&&(p=0),p>255&&(p=255),e[h]=d,e[h+1]=g,e[h+2]=p}while(--c)}while(--s);return!0}},checkSupport:function(){return Pixastic.Client.hasCanvasImageData()}};