(function(a){var e=[],b=0,i={};function n(b){var c=[];a.extend(this,{width:b.width,height:b.height,ctx:b.getContext("2d"),save:function(){this.ctx.save();c.push({width:this.width,height:this.height})},restore:function(){this.ctx.restore();a.extend(this,c.pop())}})}var j=function(){var a=function(b,a){b.ctx.translate(a,a);b.width-=2*a;b.height-=2*a};return{action:{paint:function(){}},shrink:a,defaultShrink:a,setAction:function(a){this.action=a}}}();function h(c,b){return a.extend({},j,c,{opts:b,savedOpts:b})}function d(b){return h({paint:function(c){c.save();this.action.opts=a.extend(true,this.action.savedOpts);a.each(b,function(){this.paint(c)});c.restore()},setAction:function(c){this.action=c;a.each(b,function(){this.action=c})}})}var k=d;function l(d,c){var b=i[d];if(!b)throw"Unknown plugin: "+d;c=a.extend({},b.defaultOpts||{},c);return h(b,c)}function m(f){f+=" ";var g=0;function m(a){msg=a+" at "+g+": ..."+f.substring(g)+"\nin "+f;alert(msg);throw msg;}function a(){return f.charAt(g)}function e(){return f.charAt(g++)}function b(){while(/\s/.exec(a()))e()}function c(d){b();for(var c=0;c<d.length;++c){a()!=d.charAt(c)&&m("Expected '"+d.charAt(c)+"' found '"+a()+"'");e()}}function j(){b();for(var c=[];/\w/.exec(a());c.push(e()));return c.join("")}function s(){b();for(var c=[];/\d/.exec(a());c.push(e()));return parseInt(c.join(""))}function t(){b();var f=[],d=a();/[^\'\"]/.exec(d)&&m("String expected");e();while(a()!=d){a()=="\\"&&f.eat();f.push(e())}c(d);return f.join("")}function u(){b();for(var c=[];/[^;}]/.exec(a());c.push(e()));return c.join("")}function o(){b();return/\d/.exec(a())?s():/['"]/.exec(a())?t():u()}function v(){c("{");b();var d={};while(a()!="}"){var e=j();c(":");d[e]=o();b();if(a()=="}")break;c(";")}c("}");return d}function h(){var c=j();b();opts=a()=="{"?v():{};return l(c,opts)}function p(){c("[");b();var e=[];while(a()!="]"){e.push(h());b()}c("]");return d(e)}function r(){b();return a()=="["?p():h()}function q(){var d;b();if(a()=="("){e();d=i();c(")")}else d=h();return d}function n(){var a=r();c("=>");var b=q();a.setAction(b);return a}function i(){var d=[];while(true){d.push(n());b();if(a()!=",")break;c(",")}return k(d)}return i()}function g(d,k){var e=a(d),g=e.data("liquid-canvas");if(!g)return;var c=g.canvas,j=a(c),i=e.outerWidth(),h=e.outerHeight();if(k||c.width!=i||c.height!=h||c.offsetTop!=d.offsetTop||c.offsetLeft!=d.offsetLeft){b=100;j.css({left:d.offsetLeft+"px",top:d.offsetTop+"px"});c.width=i;c.height=h;var f=new n(c);f.save();g.paint(f);f.restore()}}function f(b){a.each(e,function(){g(this,b)})}function c(){f();b--;if(b<0){b=0;setTimeout(c,1e3)}else setTimeout(c,1e3/60)}jQuery.fn.extend({liquidCanvas:function(b){this.each(function(){var c;if(window.G_vmlCanvasManager){a(this).before('<div width="0" height="0" style="position:absolute; top:0px; left:0px;"></div>');c=G_vmlCanvasManager.initElement(a(this).prev("div").get(0))}else{a(this).before('<canvas width="0" height="0" style="position:absolute; top:0px; left:0px;"></canvas>');c=a(this).prev("canvas").get(0)}var d;if(a.isFunction(b))d=b;else{var f=m(b);d=function(a){f.paint(a)}}a(this).data("liquid-canvas",{canvas:c,paint:d});a(this).css({background:"transparent"});a(this).css("position")!="absolute"&&a(this).css({position:"relative"});e.push(this);g(this,true)})}});jQuery.extend({registerLiquidCanvasPlugin:function(b){i[b.name]=a.extend({},j,b)}});a(document).ready(f);c()})(jQuery)
