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