/*
 * jQuery UI Widget 1.8.4
 *
 * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * http://docs.jquery.com/UI/Widget
 */
(function(a,c){var b=a.fn.remove;a.fn.remove=function(e,d){return this.each(function(){if(!d){if(!e||a.filter(e,[this]).length){a("*",this).add([this]).each(function(){a(this).triggerHandler("remove")})}}return b.call(a(this),e,d)})};a.widget=function(g,d,i){var h=g.split(".")[0],f;g=g.split(".")[1];f=h+"-"+g;if(!i){i=d;d=a.Widget}a.expr[":"][f]=function(j){return !!a.data(j,g)};a[h]=a[h]||{};a[h][g]=function(k,j){if(arguments.length){this._createWidget(k,j)}};var e=new d();e.options=a.extend(true,{},e.options);a[h][g].prototype=a.extend(true,e,{namespace:h,widgetName:g,widgetEventPrefix:a[h][g].prototype.widgetEventPrefix||g,widgetBaseClass:f},i);a.widget.bridge(g,a[h][g])};a.widget.bridge=function(d,e){a.fn[d]=function(h){var g=typeof h==="string",f=Array.prototype.slice.call(arguments,1),i=this;h=!g&&f.length?a.extend.apply(null,[true,h].concat(f)):h;if(g&&h.substring(0,1)==="_"){return i}if(g){this.each(function(){var j=a.data(this,d),k=j&&a.isFunction(j[h])?j[h].apply(j,f):j;if(k!==j&&k!==c){i=k;return false}})}else{this.each(function(){var j=a.data(this,d);if(j){if(h){j.option(h)}j._init()}else{a.data(this,d,new e(h,this))}})}return i}};a.Widget=function(e,d){if(arguments.length){this._createWidget(e,d)}};a.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:false},_createWidget:function(e,d){a.data(d,this.widgetName,this);this.element=a(d);this.options=a.extend(true,{},this.options,a.metadata&&a.metadata.get(d)[this.widgetName],e);var f=this;this.element.bind("remove."+this.widgetName,function(){f.destroy()});this._create();this._init()},_create:function(){},_init:function(){},destroy:function(){this.element.unbind("."+this.widgetName).removeData(this.widgetName);this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+"-disabled ui-state-disabled")},widget:function(){return this.element},option:function(d,g){var e=d,f=this;if(arguments.length===0){return a.extend({},f.options)}if(typeof d==="string"){if(g===c){return this.options[d]}e={};e[d]=g}a.each(e,function(h,i){f._setOption(h,i)});return f},_setOption:function(d,e){this.options[d]=e;if(d==="disabled"){this.widget()[e?"addClass":"removeClass"](this.widgetBaseClass+"-disabled ui-state-disabled").attr("aria-disabled",e)}return this},enable:function(){return this._setOption("disabled",false)},disable:function(){return this._setOption("disabled",true)},_trigger:function(j,f,e){var d=this.options[j];f=a.Event(f);f.type=(j===this.widgetEventPrefix?j:this.widgetEventPrefix+j).toLowerCase();e=e||{};if(f.originalEvent){for(var g=a.event.props.length,h;g;){h=a.event.props[--g];f[h]=f.originalEvent[h]}}this.element.trigger(f,e);return !(a.isFunction(d)&&d.call(this.element[0],f,e)===false||f.isDefaultPrevented())}}})(jQuery);
