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