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