/**
 * @projectDescription NHN UI Javascript Framework - codename Jindo
 * @copyright NHN corp. <http://www.nhncorp.com>
 * @author AjaxUI Team
 * @version 0.2.9
 * 
 * Get some idea from prototype.js - http://prototype.conio.net
 * and Dean's work, Base.js - http://dean.edwards.name
 *작성자 : NHN
 */

/** @id JINDO */
var JINDO = {
	/** @id JINDO.extend */
	extend : function(source, append) {
		var obj = source;
		for(var x in append) obj[x] = append[x];
		
		return obj;
	}
}

/** @id Class */
var Class = function(){
	var constructor = function() {
		if (this.__init) this.__init.apply(this,arguments);
	}
	if (arguments[0]) constructor.prototype = arguments[0];
	
	return constructor;
}

/** @id Class.extend */
Class.extend = function(superClass) {
	var obj = Class();	
	obj.prototype = new superClass;
	for(var i=1; i < arguments.length; i++) {
		if (arguments[i]) JINDO.extend(obj.prototype, arguments[i]);
	}

	return obj;
}
/**
 * @projectDescription Jindo Ajax Extend
 * @copyright NHN corp. <http://www.nhncorp.com>
 * @author AjaxUI Team
 * @version 0.1
 * @since 0.2.9 <jindo.do.js>
 */



/** Extend Protoype of Array */
JINDO.extend(Array.prototype, {
	/** @id Array.prototype.has */
	has : function(needle) {
		return (this.indexOf(needle) > -1);
	},
	/** @id Array.prototype.load */
	load : function(obj) {
		for(var i=0; i<obj.length; i++) {
			this.push(obj[i]);
		}
		return this;
	},
	/** @id Array.prototype.each */
	each : function(iter) { 
		for(var i=0; i<this.length; i++) {
			iter.call(this, this[i],i);
		}
	},
	/** @id Array.prototype.refuse */
	refuse : function(value) {
		return this.filter(function(v){ return v!=value });
	},
	size : function() {
		return this.length;
	}
});

/** If This Browser Supports "forEach", Replace "each" */
if (Array.prototype.forEach) Array.prototype.each = Array.prototype.forEach;
/**
 * @projectDescription Jindo DOM Extend
 * @copyright NHN corp. <http://www.nhncorp.com>
 * @author AjaxUI Team
 * @version 0.1
 * @since 0.2.9 <jindo.do.js>
 */

/** @id Element */
var Element = {
	_blockTags : /^(div|p|ul|ol|li|pre|xmp|hr|blockquote|center|br|h[1-6]|fieldset|dl|dt|dd)$/i,

	/** @id Element.show */
	show : function() {
		[].load(arguments).each(function(v){
			v = $(v);
			if (!Element.visible(v))
				v.style.display = Element._blockTags.test(v.tagName) ? 'block' : 'inline';
		});
	},
	/** @id Element.hide */
	hide : function() {
		[].load(arguments).each(function(v){ $(v).style.display='none'; });
	},
	/** @id Element.toggle */
	toggle : function() {
		[].load(arguments).each(function(v){ Element[Element.visible(v)?'hide':'show'](v) });
	},
	/** @id Element.visible */
	visible : function(oEl) {
		return (this.getCSS($(oEl), 'display')!='none');
	},
	/** @id Element.has */
	has : function(oParent, oChild) {
		for (; oChild; oChild = oChild.parentNode)
			if (oChild == oParent) return true;
			
		return false;
	},
	/** @id Element.realPos */
	realPos : function(oEl) {
		if (oEl.offsetParent) {
			var p = this.realPos(oEl.offsetParent);
			return { top: oEl.offsetTop+p.top, left: oEl.offsetLeft+p.left };
		} else {
			return { top: oEl.offsetTop, left:oEl.offsetLeft };
		}
	},
	/** @id Element.getCSS */
	getCSS : function(oEl, name) {
		var view;

		if (oEl.ownerDocument && (view = oEl.ownerDocument.defaultView)) {
			name = name.replace(/([A-Z])/g, function(s) { return "-" + s.toLowerCase(); });
			return view.getComputedStyle(oEl, null).getPropertyValue(name);
		} else if (oEl.currentStyle)
			return oEl.currentStyle[name];

		return Element.getInlineCSS(oEl, name);
	},
	/** @id Element.setCSS */
	setCSS : function(oEl, css) {
		$H(css).each(function(val, key) {
			oEl.style[key] = val;
		});
	},
	/** @id Element.hasClass */
	hasClass : function(oEl, className) {
		if (!oEl) return false;
		return (" " + oEl.className + " ").indexOf(" " + className + " ") != -1;
	},
	/** @id Element.addClass */
	addClass : function(oEl, className) {
		if (!this.hasClass(oEl, className)) $(oEl).className = ($(oEl).className+' '+className).replace(/^\s+/,'');
	},
	/** @id Element.removeClass */
	removeClass : function(oEl, className) {
		for (var i = 1, className; className = arguments[i]; i++)
			$(oEl).className = $(oEl).className.replace(new RegExp('\\b' + className + '(\\s+|$)', 'g'), '');
	},
	/** @id Element.getInlineCSS */
	getInlineCSS : function(oEl, name) {
		return oEl.style[name];
	},

	/** @id Element.firstChild */
	firstChild : function(oEl) {
		for (oEl = oEl.firstChild; oEl && oEl.nodeType != 1; oEl = oEl.nextSibling);
		return oEl;
	},

	/** @id Element.previousSibling */
	previousSibling : function(oEl) {
		for (oEl = oEl.previousSibling; oEl && oEl.nodeType != 1; oEl = oEl.previousSibling);
		return oEl;
	},
	
	/** @id Element.nextSibling */
	nextSibling : function(oEl) {
		for (oEl = oEl.nextSibling; oEl && oEl.nodeType != 1; oEl = oEl.nextSibling);
		return oEl;
	},
	
	/**
	 * CSS Query Engine
	 * @author Hooriza
	 */
	_cache : {},
	
	_regexp : {
		bparse : /([^>|\+|\s]+)\s*([>|\+]?)\s*/g,
		fparse : /\s*([>|\+]?)\s*([^>|\+|\s]+)/g,
		
		tag : /^([\w-]+)/,
		id : /#([\w-]+)/g,
		cls : /\.([\w-]+)/g,
		
		pseudo : /:([\w-]+(\(.*\))?)/g,
		pseudoparse : /([\w-]+)(\((.*)\))?/,
		
		attr : /\[([^\]]+)]/g,
		attrparse : /^(\[)([\w-]+)([!|\^|\$|\*]?=)(.*)(\])$/
	},
	
	_agent : $Agent(),
	
	_getElementsByTagName : function(oEl, sTagName) {
		if (this._agent.IE55 && sTagName == "*")
			return oEl.all;
			
		return oEl.getElementsByTagName(sTagName);
	},
	
	_previousNode : function(o) {
		while (o && (o = o.previousSibling) && o.nodeType != 1);
		return o;
	},

	_nextNode : function(o) {
		while (o && (o = o.nextSibling) && o.nodeType != 1);
		return o;
	},
	
	_nodeIndex : function(o) {
		var idx = 1;
		for (var child = o.parentNode.firstChild; child && child != o; child = this._nextNode(child), idx++);
		return idx;
	},

	_pseudo : {
	
		/*	
		nth_child : function(o, arg) {
			var idx = this._nodeIndex(o);
			
			if (/^[0-9]+$/.test(arg))
				return (idx == parseInt(arg));
			
			if (arg == "even")
				return (idx % 2 == 0);
			else if (arg == "odd")
				return (idx % 2 == 1);
			
			return false;
		},
		*/
		
		first_child : function(o) {
			return Element._previousNode(o) ? false : true;
		},
		
		last_child : function(o) {
			return Element._nextNode(o) ? false : true;
		},
		
		empty : function(o) {
			return o.firstChild ? false : true;
		},
		
		contains : function(o, arg) {
			return o.innerHTML.indexOf(arg) > -1;
		}
		
	},
	
	_filter : function(selector, backward) {
		
		var filter = {};
		
		var declare = {}, cond = [ 'true' ];
		var varname, func = '';
		
		var id, tag, classes, pseudoes, attres;
		
		// id
		
		if (id = selector.match(this._regexp.id)) {
			if (id[1]) return false;
			filter.id = id[0].substr(1);
		}
		
		// tagName
		tag = selector.match(this._regexp.tag);
		filter.tag = (tag && tag[1]) || '*';

		// class
		if (classes = selector.match(this._regexp.cls)) {
			for (var cls, i = 0; cls = classes[i]; i++)
				cond.push('Element.hasClass(o,"' + cls.substr(1) + '")');
		}

		// pseudo
		if (pseudoes = selector.match(this._regexp.pseudo)) {
			for (var pseudo, i = 0; pseudo = pseudoes[i]; i++) {
				pseudo = pseudo.substr(1).match(this._regexp.pseudoparse);
				cond.push('Element._pseudo.' + pseudo[1].replace('-', '_') + '(o, "' + pseudo[3] + '")');
			}
		}
		
		// attribute
		if (attres = selector.match(this._regexp.attr)) {
			for (var attr, i = 0; attr = attres[i]; i++) {
				
				attr = attr.match(this._regexp.attrparse); // 2, 3, 4
				varname = 'v_' + attr[2];

				if (!declare[attr[2]]) {
					func += 'var ' + varname + ' = o.getAttribute("' + attr[2] + '") || "";\n';
					declare[attr[2]] = true;
				}
				
				switch (attr[3]) {
				case '=':
					cond.push(varname + ' == "' + attr[4] + '"');
					break;
				case '!=':
					cond.push(varname + ' != "' + attr[4] + '"');
					break;
				case '^=':
					cond.push(varname + '.indexOf("' + attr[4] + '") == 0');
					break;
				case '$=':
					cond.push(varname + '.substr(' + varname + '.length - "' + attr[4] + '".length) == "' + attr[4] + '"');
					break;
				case '*=':
					cond.push(varname + '.indexOf("' + attr[4] + '") > -1');
					break;
				default:
					cond.push(varname + ' != null');
				}

			}
		}
		
		if (backward) {
			if (filter.tag && filter.tag != '*')
				cond.push('(casei ? o.tagName.toLowerCase() == "' + filter.tag.toLowerCase() + '" : o.tagName == "' + filter.tag + '")');
			
			if (filter.id) cond.push('o.id == "' + filter.id + '"');
		}
		
		filter.func = new Function('o', 'casei', func + '\nreturn (' + cond.join(" && ") + ')');
		// alert(filter.func);
		
		return filter;
	},
	
	_traceNode : function(root, o, selectors, idx, casei) {
		
		if (idx == -1) return true;
		
		var selector = selectors[idx];
		
		switch (selector.type) {
		case '':
			for (o = o.parentNode; o != root; o = o.parentNode)
				if (selector.filter.func(o, casei))
					if (this._traceNode(root, o, selectors, idx - 1, casei))
						return true;
			
			break;
			
		case '>':
			o = o.parentNode;
			if (o && o != root && selector.filter.func(o, casei))
				if (this._traceNode(root, o, selectors, idx - 1, casei))
					return true;
					
			break;
			
		case '+':
			o = this._previousNode(o);

			if (o && selector.filter.func(o, casei))
				if (this._traceNode(root, o, selectors, idx - 1, casei))
					return true;
			
			break;
			
		}
		
		return false;
		
	},
	
	_compile : function(query, bquery, fquery) {
		
		if (!this._cache[query]) {
			
			var cache = { backward : [], forward : [] };
			var self = this;
			
			bquery.replace(this._regexp.bparse, function(all, selector, type) {
				
				cache.backward.push({
					'type' : type,
					'filter' : self._filter(selector, true)
				});
				
			});
			
			var i = 0, method;
			var code = [];
			
			fquery.replace(this._regexp.fparse, function(all, type, selector) {
				
				cache.forward.push({
					'type' : type,
					'filter' : self._filter(selector)
				});
				
				switch (type) {
				case '>':
					method = "_getChildren";
					break;
				case '':
					method = "_getOffspring";
					break;
				case '+':
					method = "_getBrother";
					break;
				}
				
				code.push('result = Element.' + method + '(result, forward[' + (i++) + '].filter, casei);');
				
			});
			
			code.push('return result;');
			cache.filter = new Function('result', 'forward', 'casei', code.join('\n'));
			
			this._cache[query] = cache;
			
		}
		
		return this._cache[query];
		
	},
	
	_getChildren : function(objs, filter, casei) {
		
		var ret = [];
		var child;
		
		for (var i = 0, obj; obj = objs[i]; i++) {
			
			for (child = obj.firstChild; child; child = this._nextNode(child))
				if (filter.func(child, casei)) ret.push(child);
			
		}
		
		return ret;
		
	},
	
	_getOffspring : function(objs, filter, casei) {
		
		var ret = [];
		var childs;
		
		for (var i = 0, obj; obj = objs[i]; i++) {
			
			childs = this._getElementsByTagName(obj, filter.tag);
			for (var j = 0, child; child = childs[j]; j++)
				if (filter.func(child, casei)) ret.push(child);
			
		}
		
		return ret;
		
	},
	
	_getBrother : function(objs, filter, casei) {
		
		var ret = [];
		var child;
		
		for (var i = 0, obj; obj = objs[i]; i++) {
			
			if (child = this._nextNode(obj))
				if (filter.func(child, casei)) ret.push(child);
			
		}
		
		return ret;
		
	},

	query : function(query, root) {
		
		var agent = $Agent();
		root = root || document;
		
		var parts = query.match(/(.*#[\w]+[^>|\+|\s]*)([>|\+|\s].*)/) || [];
		
		var cache = Element._compile(query, parts[1] || query, parts[2] || '');

		var idx = cache.backward.length - 1;
		var filter = cache.backward[idx].filter;
		
		var sands = [];
		var result = [];
		
		var casei = (root == document || (root.ownerDocument || root.document) == document);

		if (filter.id)
			sands.push(document.getElementById(filter.id));
		else
			sands = Element._getElementsByTagName(root, casei ? filter.tag.toLowerCase() : filter.tag);

		for (var i = 0, sand; sand = sands[i]; i++) {
			
			if (filter.func(sand, casei))
				if (Element._traceNode(root, sand, cache.backward, idx - 1, casei))
					result.push(sand);
			
		}
		
		return cache.filter(result, cache.forward, casei);
		
	}	
	
}

$$ = Element.query;

/**
 * @projectDescription Jindo Event Extend
 * @copyright NHN corp. <http://www.nhncorp.com>
 * @author AjaxUI Team
 * @version 0.1
 * @since 0.2.9 <jindo.do.js>
 */


/** @id Event */
var Event = {
	/** @id Event.register */
	register : function(oEl, sEvent, pFunc) {
		
		oEl = $(oEl);
		if (oEl.addEventListener) {
			if (sEvent == "mousewheel") sEvent = "DOMMouseScroll";
			oEl.addEventListener(sEvent, pFunc, false);
		} else if(oEl.attachEvent) {
			oEl.attachEvent('on'+sEvent, pFunc);
		}
	},
	/** @id Event.unregister */
	unregister : function(oEl, sEvent, pFunc) {
		oEl = $(oEl);
		if (oEl.removeEventListener) {
			if (sEvent == "mousewheel") sEvent = "DOMMouseScroll";
			oEl.removeEventListener(sEvent, pFunc, false);
		} else if(oEl.detachEvent) {
			oEl.detachEvent('on'+sEvent, pFunc);
		}
	},
	/** @id Event.ready */
 	ready : function(evt) {
		var e = evt || window.event;
		var b = document.body;
		
		switch (e.type.toUpperCase()) {
		case "DOMMOUSESCROLL":
			e.delta = -e.detail;
			break;
			
		case "MOUSEWHEEL":
			e.delta = e.wheelDelta / 40;
			break;
		}

		var scrollPos = [
			b.scrollLeft || document.documentElement.scrollLeft,
			b.scrollTop || document.documentElement.scrollTop
		];
		
		/** Extend For Browser Event */
		JINDO.extend(e, {
			element : e.target || e.srcElement,
			related_element : e.relatedTarget || (e.type == "mouseover" ? e.fromElement : e.toElement),
			page_x  : e.pageX || e.clientX+scrollPos[0]-b.clientLeft,
			page_y  : e.pageY || e.clientY+scrollPos[1]-b.clientTop,
			layer_x : e.offsetX || e.layerX - 1,
			layer_y : e.offsetY || e.layerY - 1,
			key     : {
				alt   : e.altKey,
				ctrl  : e.ctrlKey,
				shift : e.shiftKey,
				up    : [38,104].has(e.keyCode),
				down  : [40,98].has(e.keyCode),
				left  : [37,100].has(e.keyCode),
				right : [39,102].has(e.keyCode),
				enter : (e.keyCode==13)
			},
			mouse   : {
				left   : (e.which&&e.button==0)||!!(e.button&1),
				middle : (e.which&&e.button==1)||!!(e.button&4),
				right  : (e.which&&e.button==2)||!!(e.button&2)
			},
			of : function(parent) {
				
				var el;
				var ret = true;
				
				if (el = this.element)
					ret &= Element.has(parent, el);
					
				if (el = this.related_element)
					ret &= Element.has(parent, el);

				return ret;				
			},
			stop : function() { Event.stop(this); 	}
		});

		return e;
	},
	/** @id Event.stop */
	stop : function(e) {
		if (e.preventDefault) e.preventDefault();
		if (e.stopPropagation) e.stopPropagation();
		
		e.returnValue = false;
		e.cancelBubble = true;
	}
}

/** @id Event.stopProc */
Event.stopProc = function(e) {
	Event.stop(e || window.event);
}
/**
 * @projectDescription Jindo Base Extend
 * @copyright NHN corp. <http://www.nhncorp.com>
 * @author AjaxUI Team
 * @version 0.1
 * @since 0.2.9 <jindo.do.js>
 */

/** @id document.getElementByClassName */
document.getElementsByClassName = function(className, oParent) {
	var a = [].load(($(oParent) || document.body).getElementsByTagName('*'));
	var r = new RegExp('(^|\\s)'+className+'($|\\s)','gi');
	return a.filter(function(v){ return r.test(v.className); });
}


/** @id $ */
function $() {
	var ret = [];
	for(var i=0; i < arguments.length; i++) {
		if (typeof arguments[i] == 'string') {
			ret[ret.length] = document.getElementById(arguments[i]);
		} else {
			ret[ret.length] = arguments[i];
		}
	}
	return ret[1]?ret:ret[0];
}

/** @id $A */
function $A(collection) {
	var ret = [];
	for(var i=0; i < collection.length; i++) ret[ret.length] = collection[i];
	return ret; 
}

/** @id $C */
function $C(tag) {
	return document.createElement(tag);
}

/** @id $H */
function $H(obj) {
	var oHash, hashType = function(){};

	JINDO.extend(hashType.prototype, {
		keys : function() {
			var ret = new Array;
			for(var k in this) {
				if (this.propertyIsEnumerable(k) && typeof Object.prototype[k] == 'undefined') ret.push(k); 
			}
			return ret;
		},
		values : function() {
			var ret  = new Array;
			var keys = this.keys();
			for(var i=0; i < keys.length; i++) {
				ret.push(this[keys[i]]);
			}
			return ret;
		},
		each : function(iter) {
			var keys = this.keys();
			for(var i=0; i < keys.length; i++) {
				iter(this[keys[i]], keys[i]);
			}
		},
		size : function() {
			return this.keys().length;
		}
	});

	oHash = new hashType;
	
	try { JINDO.extend(oHash, obj) }catch(e){alert(e)};
	
	return oHash;
}

/** @id $Agent */
function $Agent() {
	var isOpera = !!(window.opera);
	var nu = navigator.userAgent;
	var isIE = !isOpera && /MSIE/.test(nu), ie5=false, ie55=false, ie6=false, ie7=false, macIE=false;
	
	if (isIE) {
		/MSIE ([0-9\.]+)/.exec(nu);
		var ver = parseFloat(RegExp.$1);
		switch (ver) {
			case 5   : ie5 =true; break;
			case 5.5 : ie55=true; break;
			case 6   : ie6=true; break;
			case 7   : ie7=true; break;
			default  :
		}
	}
	
	return {
		IE     : isIE,
		IE5    : isIE && ie5,
		IE55   : isIE && ie55,
		IE6    : isIE && ie6,
		IE7    : isIE && ie7,
		macIE  : isIE && macIE,
		Gecko  : /Gecko/.test(nu),
		Opera  : isOpera,
		Safari : /WebKit/.test(nu),
		KHTML  : /KHTML/.test(nu)
	};
}

/**
 * legacy comportability
 */
(function(){
	var a = {
		push : function() {
			for(var i=0; i < arguments.length; i++) {
				this[this.length] = arguments[i];
			}
			return this.length;
		},
		pop  : function() {
			var el = this[Math.max(this.length-1,0)];
			if (this.length) this.length--;
			return el;
		},
		shift : function() {
			var el = this[0];
			for(var i=0; i < this.length-1; i++) {
				this[i] = this[i+1];
			}
			if (this.length) this.length--;
			return el;
		},
		unshift : function() {
			var a = new Array(arguments.length+this.length);
			for(var i=a.length-1; i > -1; i--) {
				 a[i] = (i < arguments.length)?arguments[i]:this[i-arguments.length];
			}
			for(var i=0; i < a.length; i++) {
				this[i] = a[i];	
			}
		},
		filter : function(func /*, obj*/) {
			var l = this.length, a=[], obj=arguments[1],v;
			for(var i=0; i < l; i++) {
				v = this[i];
				if (obj) { if (func.call(obj,v,i,this)) a.push(v); }
				else { if (func(v,i,this)) a.push(v); }
			}
			return a;
		},
		map : function(func /*, obj*/) {
			var l = this.length, a=new Array(l), obj=arguments[1];
			/* fixed variable name : len -> l By TarauS */
			for (var i = 0; i < l; i++) {
				a[i] = obj?func.call(obj,this[i],i,this):func(this[i],i,this);
			}
			return a;
		},
		indexOf : function(el/*, from*/) {
			var from = arguments[1] || 0;
			if (from < 0) from += this.length;
			for(var i=from; i < this.length; i++) {
				if (this[i] == el) return i;
			}
			return -1;
		},
		lastIndexOf : function(el/*, from*/) {
			var from = (typeof arguments[1] == 'undefined')?this.length:arguments[1];
			if (from < 0) from += this.length;
			for(var i=from; i >= 0; i--) {
				if (this[i] == el) return i;
			}
			return -1;
		}
	};
	var f = {
		call : function(obj) {
			var r,a = [];
			( obj||{} ).prototype['__jindo_call__'] = this;
			
			switch (arguments.length) {
				case 1: return obj.__jindo_call__(); break;
				case 2: return obj.__jindo_call__(arguments[1]); break;
				case 3: return obj.__jindo_call__(arguments[1],arguments[2]); break;
				default:
					for(var i=1;i<arguments.length;i++) a.push('arguments['+i+']');
					return eval('obj.__jindo_call__('+a.join(',')+')');
			}
		},
		apply : function(obj,arg) {
			var r,a = []; arg = arg || [];
			( obj||{} ).prototype['__jindo_apply__'] = this;
			
			switch(arg.length) {
				case 0: return obj.__jindo_apply__();
				case 1: return obj.__jindo_apply__(arg[0]);
				case 2: return obj.__jindo_apply__(arg[0],arg[1]);
				default:
					for(var i=0;i<arg.length;i++) a.push('arg['+i+']');
					return eval('obj.__jindo_apply__('+a.join(',')+')');
			}
		}
	};
	var o = {
		// JScript 5.0 and earlier version can't support this method 
		propertyIsEnumerable : function(k) {
			return (typeof Object[k] == 'undefined') && (typeof Object.prototype[k] == 'undefined');
		}
	};
	for(var x in a) { if (typeof Array.prototype[x] == 'undefined') Array.prototype[x] = a[x] };
	for(var x in f) { if (typeof Function.prototype[x] == 'undefined') Function.prototype[x] = f[x] };
	for(var x in o) { if (typeof Object.prototype[x] == 'undefined') Object.prototype[x] = o[x] };
})();

/** avoid error */
if (typeof window.debugg == 'undefined') {
	(function(){
		window.debugg = {};
		var names = ['log', 'assert', 'time', 'timeEnd'];
		for(var i=0; i < names.length; i++) {
			window.debugg[names[i]] = function(){};
		}
	})();
}
/**
 * @projectDescription Jindo Function Extend
 * @copyright NHN corp. <http://www.nhncorp.com>
 * @author AjaxUI Team
 * @version 0.1
 * @since 0.2.9 <jindo.do.js>
 */

/** Extend Protoype of Function */
JINDO.extend(Function.prototype, {
	/** @id Function.prototype.bind */
	bind : function(obj) {
		var f=this, a=$A(arguments);a.shift();
		return function() {
			return f.apply(obj, a);
		}
	},
	/** @id Function.prototype.bindForEvent */
	bindForEvent : function(obj) {
		var f=this, a=$A(arguments);
		return function(e) {
			a[0] = Event.ready(e);
			return f.apply(obj, a);
		}
	},
	/** @id Function.prototype.owner */
	owner : function(thisobj) {
		var f=this;
		return function() {
			return f.apply(thisobj, $A(arguments));
		}
	}
});


/**
 * @projectDescription NHN Jindo Widget Project - Ku
 * @copyright NHN corp. <http://www.nhncorp.com>
 * @author AjaxUI Team
 * @version 0.2.6
 */

/** @id Ku */
Ku = {};
/**
 * Color picker widget
 *
 * @author gony
 * @version 0.6
 */

function toInt(v){
	var i = parseInt(v);
	if(!i) i=0;

	return i;
}


	/**
	 * @projectDescription Copy string to clipboard component
	 * @copyright NHN corp. <http://www.nhncorp.com>
	 * @author AjaxUI Team <TarauS>
	 */
	
	Ku.SetClipboard = Class({
		/**
		 * 
		 */
		__init : function(){
		},

		/**
		 * 
		 * @return {Object}
		 */
		_getModule : function(){
			return window.document[Ku.SetClipboard._sModuleId];
		},

		/**
		 * setClipboard 
		 * @return {Boolean} 
		 */
		checkFunction : function(){
			var oModule = this._getModule();
			if(oModule)	return typeof(oModule.setClipboard) == 'function' ? true : false;
		},

		/**
		 * sString
		 * @param {String} sString
		 * @param {String} sMessage
		 */
		setClipboard : function(sString, sMessage){
			var bResult;
			try{
				var oModule = this._getModule();
				if(oModule){
					if(sString) bResult = oModule.setClipboard(sString);
					if(sMessage && bResult) alert(sMessage);
				}
				return bResult;
			}catch(e){
				return false;
			}
		}
	});
	
	Ku.SetClipboard.initFlash = function(sSwfPath){
		if(sSwfPath == null) sSwfPath = './clipboard.swf';
		Ku.SetClipboard._sModuleId = 'SetClipboardModule'+(new Date).getMilliseconds()+Math.floor(Math.random()*100000);
		document.write('<object id="'+Ku.SetClipboard._sModuleId+'" width="0" height="0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0">');
		document.write('<param name="movie" value="'+sSwfPath+'">');
		document.write('<param name="allowScriptAccess" value = "always" />');
		document.write('<embed name="'+Ku.SetClipboard._sModuleId+'" src="'+sSwfPath+'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" width="0" height="0" allowScriptAccess="always"></embed></object>');
	}
/**
 * Slider component
 * @author gony
 */
Ku.Slider = Class({
	_applying : false,
	__init : function(id) {
		this.options = JINDO.extend({
			unit       : null, // id of draggable unit
			minValue   : 0,
			maxValue   : 100,
			defValue   : 0, // default value
			step       : 10,
			maxPos     : 86, // position related to parent (px)
			initPos    : {x:1, y:12}, // initial position (minimun value)
			vertical   : false,
			onChange   : function(v){},
			onChanging : function(v){}
		}, arguments[1]); 
		
		var e = this._element = $(id);
		var o = this.options;
		
		this._value = o.minValue;
		
		// event binding
		this.onmousedown = this.onDown.bindForEvent(this);
		this.onmousemove = this.onMove.bindForEvent(this);
		this.onmouseup   = this.onUp.bind(this);
		this.onclick     = this.onClick.bindForEvent(this);

		Event.register(this._element, 'click', this.onclick);

		// positining draggable unit
		var u = this._unit_element = $(o.unit);
		u.ondragstart = u.ondrag = function(){ return false }
		u.onmousedown = this.onmousedown;
		
		Element.setCSS(u, {
			cursor : 'pointer',
			top  : o.initPos.y+'px',
			left : o.initPos.x+'px'
		});
	},
	getValue : function() {
		return this._value;
	},
	setValue : function(v) {
		if (this._applying) return;
		
		var o = this.options; v = Math.min(Math.max(v,o.minValue),o.maxValue);
		var p = this._val2pos(v);

		if (this.options.vertical) {
			this._unit_element.style.top = p+'px';
		} else {
			this._unit_element.style.left = p+'px';
		}
		
		this._value = v;
		this.options.onChange(v);
	},
	setValueBy : function(diff) {
		var o = this.options;
		var v = Math.min(Math.max(this._value+diff,o.minValue),o.maxValue);
		
		this.setValue(v);
	},
	onDown : function(e) {
		var u = this._unit_element;
		if (e.mouse.left) {
			this._moving = true;
			this._startPos = [parseInt(u.style.left), parseInt(u.style.top)];
			this._startXY  = [e.clientX, e.clientY];

			// register event
			Event.register(document, 'mouseup', this.onmouseup);
			Event.register(document, 'mousemove', this.onmousemove);
			Event.register(document, 'keypress', this.onmousemove);
			
			e.stop();
		}
	},
	onMove : function(e) {
		var newX, newY;
		var o = this.options;
		var u = this._unit_element;

		if (!this._moving || !e.mouse.left) return;
		newX = this._startPos[0] + e.clientX - this._startXY[0];
		newY = this._startPos[1] + e.clientY - this._startXY[1];

		if (o.vertical) {
			newY = Math.max(Math.min(newY,o.maxPos),o.initPos.y);
			u.style.top = newY + 'px';
		} else {
			newX = Math.max(Math.min(newX,o.maxPos),o.initPos.x);
			u.style.left = newX + 'px';
		}
		
		this._value = this._pos2val(o.vertical?newY:newX);

		this.options.onChanging(this._value);
	},
	onUp   : function() {
		var t =this;
		
		this._moving = false;

		// unregister event
		Event.unregister(document, 'mouseup', this.onmouseup);
		Event.unregister(document, 'mousemove', this.onmousemove);
		Event.unregister(document, 'keypress', this.onmousemove);
		
		this.options.onChange(this._value);
		
		// prevent onclick event
		this._applying = true;
		setTimeout(function(){t._applying=false}, 50);
	},
	onClick : function(e) {
		var pos = Element.realPos(this._element);
		this.setValue(this._pos2val(e.page_x-pos.left-this._unit_element.offsetWidth/2));
	},
	_pos2val : function(p) {
		var o = this.options,s=o.step;
		var m = o.vertical?o.initPos.y:o.initPos.x;
		var v = (p-m)*(o.maxValue-o.minValue)/(o.maxPos-m);
		var q = Math.floor(v/s), r=v-q*s, v=q*s;

		return Math.max(Math.min(Math.round((v+o.minValue+((s/2)>r?0:s))*100)/100, o.maxValue), o.minValue);
	},
	_val2pos : function(v) {
		var o = this.options;
		var m = o.vertical?o.initPos.y:o.initPos.x;
		var p = (v-o.minValue)*(o.maxPos-m)/(o.maxValue-o.minValue);

		return Math.max(Math.min(Math.round((p+m)*100)/100, o.maxPos), m);
	}
});

