(function(a){function b(b,c,d,e){a.fn["old_"+b]=a.fn[b],a.fn[b]=function(){var f=arguments,g=a(this),h=g.parent(),i=a.fn["old_"+b].apply(this,arguments);if(!a(this).length)return i;arguments.length>=d&&(!e||e.call(this,f))&&(b==="remove"?h.trigger(c):g[0].nodeName.toLowerCase()!=="body"&&g.trigger(c));return i}}a.fx.prototype.oldUpdate=a.fx.prototype.update,a.fx.prototype.update=function(){var b=this.oldUpdate.apply(this,arguments);a(this.elem).trigger("cssupdate");return b},a.fn.tie=function(b,c,d,e){e=a.extend({globalListener:!1,onImgLoad:!1,onResize:!1,onScroll:!1,proxyListener:!1},e),d||(d=b),c=a(c);var f=a(e.proxyListener);e.globalListener?f=a("body"):f||(f=c.parent());return a(this).each(function(){function k(){f.unbind("cssupdate",i),f.unbind("domupdate",i),c.unbind("cssupdate",i),c.unbind("domupdate",i),g.unbind("destroy.tie",k),a(window).unbind("resize",i),a(window).unbind("scroll",i),a("img").unbind("load",j)}function j(){a(this).trigger("cssupdate")}function i(f){g.old_css(b,a.isFunction(d)?d.call(c):c.old_css(d)),!h&&!e.globalListener&&!e.proxyListener&&g.trigger("cssupdate")}var g=a(this),h=g[0]===c[0];g.parents().each(function(){this===c[0]&&(h=!0)}),i(),h||e.globalListener||e.proxyListener?(f.bind("cssupdate",i),f.bind("domupdate",i)):(c.bind("cssupdate",i),c.bind("domupdate",i)),e.globalListener&&e.onImgLoad?a("img").bind("load",j):e.onImgLoad&&c.find("img").bind("load",j),g.bind("destroy.tie",k),e.onResize&&a(window).bind("resize",i),e.onScroll&&a(window).bind("scroll",i)})},a.fn.untie=function(){return a(this).trigger("destroy")},a.fn.cssupdate=function(b){var c=a(this);b?c.bind("cssupdate",b):c.trigger("cssupdate");return c},a.fn.domupdate=function(b){var c=a(this);b?c.bind("domupdate",b):c.trigger("domupdate");return c},b("css","cssupdate",1,function(a){return a.length>=2||typeof a[0]=="object"}),b("attr","domupdate",2,function(a){return a.length===2}),b("append","domupdate",1),b("prepend","domupdate",1),b("before","domupdate",1),b("after","domupdate",1),b("text","domupdate",1),b("html","domupdate",1),b("empty","domupdate",0),b("remove","domupdate",0),b("removeAttr","domupdate",1)})(jQuery)
