/**
 * MLNUI Core
 * MLNUI 核心类
 * Powered By CandySunPlus (c) 2011 MLN STUDIO
 */
(function(j){function k(a,b,c,f){c=c!=null?c:b;for(var e in a)if(a.hasOwnProperty(e))c[e]=d.rewrite(e,a,b,f);return b}function h(a){return w.call(a)==="[object Function]"}function m(a){throw d.log_prefix+d.errors[a];}var n=false,q="$.Class :: "+(new Date).getTime(),r=/\b_parent\b/.test(function(){this._parent()}),s=r?/\b_parent\b/:/.*/,t=r?/\b_parent\b\./:/.*/,w=Object.prototype.toString,o=function(){function a(b){if(this instanceof a){if(n===false&&h(this.init))this.init.apply(this,typeof b==="object"&&
b!==null&&b.callee?b:arguments)}else return new a(arguments)}a.__is_class__=q;return a},l=o();l.extend=function(a,b){var c=o(),f,e,g=this.prototype||{};if(typeof a!=="boolean")b=a;b=typeof b==="object"&&b!==null?b:{};e=b.prototype;for(f in this)if(this.hasOwnProperty(f))c[f]=this[f];if(a===true||typeof e==="object"&&e!=null){d.validate(b);k(b,this,c,d.initPopulator(this));b=e}c.constructor=c;n=true;e=new this;n=false;b=b||{};d.validate(b);k(b,g,e,d.initPopulator(g));c.prototype=e;return c};l.addMethods=
function(a){return k(a,this.prototype)};l.prototype={addMethods:function(a){return k(a,this)}};var d=function(a,b){return l.extend(a,b)};d.fnSearch=s;d.parentFnSearch=t;d.log_prefix="$.Class :: ";d.errors={logic_parent_call:"Logic error, unable to call the parent function since it isn't defined..",self_in_prop:"'__self__' is a preserved word used in the jQuery.Class plugin, please rename the function",invalid_$:"Invalid data-type of the global '$' property"};d.makeClass=o;d.rewrite=function(a,b,c,
f){return h(b[a])&&(h(c[a])||!(a in c))&&!d.is(b[a])&&s.test(b[a])?function(e,g,u){g=g||function(){m("logic_parent_call")};var v=h(u)&&t.test(e);return function(){var x=this.hasOwnProperty("_parent"),y=this._parent,i;if(v===true){v=false;i=u();for(var p in i)if(i.hasOwnProperty(p))g[p]=i[p]}this._parent=g;this._parent.__self__=this;i=e.apply(this,arguments);if(x)this._parent=y;else try{delete this._parent}catch(z){}return i}}(b[a],c[a],f):b[a]};d.is=function(a){return a.__is_class__===q};d.initPopulator=
function(a){var b;return function(){if(b==null){b={};for(var c in a)if(a.hasOwnProperty(c)&&h(a[c]))b[c]=function(f){return function(){return f.apply(this.__self__,arguments)}}(a[c])}return b}};d.validate=function(a){h(a.__self__)&&m("self_in_prop")};if(!j.$){"$"in j&&m("invalid_$");j.$={}}j.$.Class=d})(this);
(function($){
	$.extend({
		MLNUI:{
			version:"1.00",
			roundedRect: function(ctx, x, y, width, height, radius, rgb, a) {
				ctx.fillStyle = 'rgba(' + rgb.join(',') + ',' + a + ')';
				ctx.beginPath();
				ctx.moveTo(x, y + radius);
				ctx.lineTo(x, y + height - radius);
				ctx.quadraticCurveTo(x, y + height, x + radius, y + height);
				ctx.lineTo(x + width - radius, y + height);
				ctx.quadraticCurveTo(x + width, y + height, x + width, y + height - radius);
				ctx.lineTo(x + width, y + radius);
				ctx.quadraticCurveTo(x + width, y, x + width - radius, y);
				ctx.lineTo(x + radius, y);
				ctx.quadraticCurveTo(x, y, x, y + radius);
				ctx.fill();
			},
			roundedRectLinear: function(ctx, x, y, width, height, radius, beginColor, endColor) {
				this.roundedRect(ctx, x, y, width, height, radius, beginColor, 1);
				var lingrad = ctx.createLinearGradient(0, 0, 0, height);
				lingrad.addColorStop(0, 'rgb(' + beginColor.join(',') + ')');
				lingrad.addColorStop(1, 'rgb(' + endColor.join(',') + ')');
				ctx.fillStyle = lingrad;
				ctx.beginPath();
				ctx.moveTo(x, y + radius);
				ctx.lineTo(x, y + height - radius);
				ctx.quadraticCurveTo(x, y + height, x + radius, y + height);
				ctx.lineTo(x + width - radius, y + height);
				ctx.quadraticCurveTo(x + width, y + height, x + width, y + height - radius);
				ctx.lineTo(x + width, y + radius);
				ctx.quadraticCurveTo(x + width, y, x + width - radius, y);
				ctx.lineTo(x + radius, y);
				ctx.quadraticCurveTo(x, y, x, y + radius);
				ctx.fill();
			},
			triangle: function(ctx, x, y, width, height, rgb, a) {
				ctx.beginPath();
				ctx.moveTo(x + width, y);
				ctx.lineTo(x, y + height);
				ctx.lineTo(x + width, y + height);
				ctx.closePath();
				ctx.fillStyle = 'rgba(' + rgb.join(',') + ',' + a + ')';
				ctx.fill();
			},
			circle: function(ctx, x, y, diameter, rgb, a) {
				ctx.beginPath();
				ctx.arc(x, y, diameter, 0, Math.PI * 2, true);
				ctx.fillStyle = 'rgba(' + rgb.join(',') + ',' + a + ')';
				ctx.fill();
			},
			drawBox: function(ctx, width, height, shadowOffset, isShadows, options) {
				var shadowBlur = options.shadow;
				var shadowBlur2x = shadowBlur * 2;
				var cornerRadius = options.cornerRadius;
				if (isShadows != false) {
					for (var x = 0; x <= shadowBlur; x++) {
						$.MLNUI.roundedRect(
						ctx, shadowOffset.x + x, shadowOffset.y + x, width - (x * 2) - shadowOffset.x, height - (x * 2) - shadowOffset.y, cornerRadius + (shadowBlur - x), [0, 0, 0], x == shadowBlur ? 0.09 : .05 + (x * .01));
					}
				}				
			}
		}
	});
})(jQuery);

