(function(){var a={_listeners:[]};$.chug.events={windows:[window],fire:function(){var f={},e=arguments.length;if(arguments.length){var d=arguments[arguments.length-1];if(typeof(d)=="object"&&!(d instanceof String)){f=d;e--}}var g=[];for(var c=0;c<e;c++){g[c]=arguments[c]}for(var c=0;c<this.windows.length;c++){if(this.windows[c]){if(this.windows[c].closed){this.windows[c]=null}else{this.windows[c].$.chug.events._fire(g,f)}}}},_fire:function(g,f){var e=a;for(var c=0;c<e._listeners.length;c++){if(e._listeners[c]){e._listeners[c](f,g)}}for(var d=0;d<g.length;d++){if(!a[g[d]]){break}e=a[g[d]];for(var c=0;c<e._listeners.length;c++){if(e._listeners[c]){e._listeners[c](f,g)}}}},addListener:function(){var d=a;for(var c=0;c<arguments.length-1;c++){if(!d[arguments[c]]){d[arguments[c]]={_listeners:[]}}d=d[arguments[c]]}var e=arguments[c];d._listeners.push(e);e.remove=function(){for(var f=0;f<d._listeners.length;f++){if(d._listeners[f]==this){d._listeners[f]=null}}}}};if(window.opener&&!window.opener.closed){function b(){try{if(!window.opener.$.chug.events.windows){throw"not ready"}}catch(f){window.setTimeout(function(){b()},500);return}var d=$.chug.events.windows;$.chug.events.windows=window.opener.$.chug.events.windows;for(var c=0;c<d.length;c++){$.chug.events.windows.push(d[c])}}b()}$(window).unload(function(){var d=$.chug.events.windows;for(var c=0;c<d.length;c++){if(d[c]==window){d[c]=null}}})})();
