/*
 * Rich JavaScript framework, version 1.5
 * Copyright (c) 2006-2008 Lee Won-Gyoon <mail.kido@gmail.com>
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * For details, see the RichScript web site: http://www.richScript.net/
 * 
*******************************************************************************/

var richScript = {
	Version : "1.5"
}

var browser = {
	isIE : (navigator.userAgent.toUpperCase().indexOf('MSIE')>-1),
	isIE6 : (navigator.userAgent.toUpperCase().indexOf('MSIE 6')>-1),
	isIE7 : (navigator.userAgent.toUpperCase().indexOf('MSIE 7')>-1),
	isFF : (navigator.userAgent.toUpperCase().indexOf('FIREFOX')>-1),
	isSF : (navigator.userAgent.toUpperCase().indexOf('SAFARI')>-1&&navigator.userAgent.toUpperCase().indexOf('CHROME')==-1),
	isCR : (navigator.userAgent.toUpperCase().indexOf('CHROME')>-1),
	getW : function() {
		return document.documentElement.clientWidth;
	},
	getH : function() {
		return document.documentElement.clientHeight;
	}
}


/**
 String
*****************************/
String.prototype.trim = function () {
	var s = (this!=null) ? this : "";
	s = s.replace(/^\s+/g,"");
	s = s.replace(/\s+$/g,"");
	return s;
};

String.prototype.replaceQuot = function() {
	var s = (this!=null) ? this : "";
	s = s.replace(/\\/g,"\\\\");
	s = s.replace(/\"/g,"\\\"");
	s = s.replace(/\'/g,"\\\'");
	return s;
};

String.prototype.escapeXml = function() {
	var s = (this!=null) ? this : "";
	s = s.replace(/&/g,"&amp;");
	s = s.replace(/\'/g,"&#039;");
	s = s.replace(/\"/g,"&#34;");
	s = s.replace(/</g,"&lt;");
	s = s.replace(/>/g,"&gt;");
	s = s.replace(/\n/g,"&#10;");
	s = s.replace(/\r/g,"&#13;");
	s = s.replace(/\t/g,"&#9;");
	return s;
};

String.prototype.escapeJavaScript = function() {
	var s = (this!=null) ? this : "";
	s = s.replace(/\\/g,"\\\\");
	s = s.replace(/\//g,"\\/");
	s = s.replace(/\n/g,"\\n");
	s = s.replace(/\r/g,"\\r");
	s = s.replace(/\t/g,"\\t");
	s = s.replace(/\"/g,"\\\"");
	s = s.replace(/\'/g,"\\'");
	return s;
};

String.prototype.removeTag = function() {
	var s = (this!=null) ? this : "";
	s = s.replace(/<\/?[^>]+>/gi,"");
	return s;
};

String.prototype.convertEnterToBr = function() {
	var s = (this!=null) ? this : "";
	s = s.replace(/\n/g,"<br>");
	return s;
};

String.prototype.getBytes = function() {
	var s = (this!=null) ? this : "";
	var bytes = 0;
	var c = "";
	var u = "";
	for (var i=0; i<s.length; i++) {
		c = s.charAt(i);
		u = escape(c);
		if (u.length < 4) { // ¹Ý°¢¹®ÀÚ : ±âº»ÀûÀÎ ¿µ¹®, ¼ýÀÚ, Æ¯¼ö±âÈ£
			bytes++; // + 1byte
		} else {
			var b = parseInt(c.charCodeAt(0));
			if (((b >= 65377)&&(b <= 65500))||((b >= 65512)&&(b <= 65518))) // ¹Ý°¢¹®ÀÚ À¯´ÏÄÚµå 10Áø¼ö ¹üÀ§ : ÇÑ±¹¾î, ÀÏº»¾î, Æ¯¼ö¹®ÀÚ
				bytes++; // + 1byte
			else // Àü°¢¹®ÀÚ : À§ Á¶°ÇÀ» Á¦¿ÜÇÑ ¸ðµç ¹®ÀÚ
				bytes += 2; // + 2byte
		}
	}
	return bytes;
};

String.prototype.encodeUnicode = function(_separator) {
	var s = (this!=null) ? this : "";
	var separator = (_separator==undefined) ? "." : _separator;
	var u = new Array;
	for (var i=0; i<s.length; i++) {
		s.charCodeAt(i);
		u.push(s.charCodeAt(i));
	}
	return u.join(separator);
};

String.prototype.decodeUnicode = function(_separator) {
	var s = (this!=null) ? this : "";
	var separator = (_separator==undefined) ? "." : _separator;
	var u = s.split(separator);
	var dec = "";
	if (u.length>0) {
		try {
			dec = eval("String.fromCharCode("+u.join(",")+")");
		} catch (e) { }
	}
	return dec;
};

String.prototype.appendParameter = function(_param) {
	var s = (this!=null) ? this : "";
	if (_param!=undefined&&_param!="") {
		if (s.indexOf("?")>-1) {
			s += "&";
		} else {
			s += "?";
		}
		s += _param;
	}
	return s;
};

String.prototype.toBold = function() {
	var s = (this!=null) ? this : "";
	return "<strong>"+s+"</strong>";
};


String.prototype.toPng24BgStyle = function() {
	var s = (this!=null) ? this : "";
	if (browser.isIE) s = ' filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='+s+' ,sizingMethod=scale ); ';
	else s = ' background:url('+s+') transparent; ';
	return s;
}


/**
 Math
*****************************/
Math.isInt = function(_s) {
	return (_s!=undefined&&""+parseInt(_s)!="NaN");
};

Math.isFloat = function(_s) {
	return (_s!=undefined&&""+parseFloat(_s)!="NaN");
};


/**
 Array
*****************************/
Array.prototype.index = new Object;

Array.prototype.push = function(_oect, _makeIndex, _primaryKey) {
	var lastIndex = this.length;
	this[lastIndex] = _oect;
	if (_makeIndex==true) {
		if (_primaryKey!=null) {
			this.index[_primaryKey] = lastIndex;
		} else {
			this.index[_oect] = lastIndex;
		}
	}
	return _oect;
};

Array.prototype.remove = function(_oect) {
	for (var i=0; i<this.length; i++) {
		if (this[i]==_oect) {
			this[i] = null;
		}
	}
};

Array.prototype.compact = function() {
	var temp = new Array;
	var j = 0;
	for (var i=0; i<this.length; i++) {
		if (this[i]!=null&&this[i]!=undefined) {
			temp[j++] = this[i];
		}
	}
	return temp;
};

Array.prototype.getIndex = function(_primaryKey) {
	return this.index[_primaryKey];
};

Array.prototype.getValue = function(_primaryKey) {
	if (this.index[_primaryKey]!=undefined) {
		return this[this.index[_primaryKey]];
	} else {
		return null;
	}
};



/**
 Date
*****************************/
Date.prototype.toFormatted = function(_s) {
	if (_s==undefined) _s = "YYYYMMDD";
	
	var _YYYY = this.getYear();
	var _MM = this.getMonth()+1;
	var _DD = this.getDate();
	var _HH = this.getHours();
	var _MI = this.getMinutes();
	var _SS = this.getSeconds();
	if (_YYYY<1000) {
		_YYYY += 1900;
	}
	if (_MM<10) _MM = "0"+_MM;
	if (_DD<10) _DD = "0"+_DD;
	if (_HH<10) _HH = "0"+_HH;
	if (_MI<10) _MI = "0"+_MI;
	if (_SS<10) _SS = "0"+_SS;
	
	_s = _s.replace(/YYYY/gi, _YYYY);
	_s = _s.replace(/MM/gi, _MM);
	_s = _s.replace(/DD/gi, _DD);
	_s = _s.replace(/HH/gi, _HH);
	_s = _s.replace(/MI/gi, _MI);
	_s = _s.replace(/SS/gi, _SS);
	return _s;
};
Date.prototype.addYear = function(_n) {
	this.setYear(this.getYear()+_n);
};
Date.prototype.addMonth = function(_n) {
	this.setMonth(this.getMonth()+_n);
};
Date.prototype.addDate = function(_n) {
	this.setDate(this.getDate()+_n);
};
Date.prototype.addHours = function(_n) {
	this.setHours(this.getHours()+_n);
};
Date.prototype.addMinutes = function(_n) {
	this.setMinutes(this.getMinutes()+_n);
};
Date.prototype.addSeconds = function(_n) {
	this.setSeconds(this.getSeconds()+_n);
};





/**
 Request Object
*****************************/
function Request(_queryString) {
	this.search = (_queryString!=undefined)?""+_queryString:"";
	this.key = {};
	this.keys = [];
	this.values = [];
	this.size = function() {
		return this.values.length;
	};
	this.set = function(_name, _value) {
		if (this.key[_name]==undefined) {
			var index = this.values.length;
			this.key[_name] = index;
			this.keys.push(_name);
			this.values.push(_value);
		}
		this.search = this.search.appendParameter(_name+"="+_value);
	};
	this.get = function(_name) {
		var value = this.values[this.key[_name]];
		if (value==undefined) value = "";
		return value;
	};
	this.getKey = function(_index) {
		return this.keys[_index];
	};
	
	if (this.search.length>1&&this.search.indexOf("?")==0) this.search = this.search.substring(1,this.search.length);
	var param = this.search.split("&");
	var paramValue = "";
	for (var i=0; i<param.length; i++) {
		var index = param[i].indexOf("=");
		if (index>-1) {
			var pName = param[i].split("=")[0];
			var pValue = param[i].substring(index+1, param[i].length).trim();
			if (this.key[pName]==undefined) {
				this.set(pName, pValue);
			}
		}
	}
}

var request = new Request(location.search);
request.host = location.host;
request.pathname = location.pathname;




/**
 out Object
*****************************/
var out = {
	print : function(_s) {
		document.write(_s);
	},
	println : function(_s) {
		document.writeln(_s);
	},
	printBr : function(_s) {
		document.writeln(_s+"<br/>");
	}
};




/**
 Cookie Object
*****************************/
var Cookie = {
	get : function(_cookieName) {
		var cookieList = document.cookie.split(";");
		var cookieValue = "";
		for (i = 0; i < cookieList.length; i++) {
			if (cookieList[i].indexOf(_cookieName+"=") > -1) {
				if (cookieList[i].split("=")[0].replace(/\s/g,"") == _cookieName) {
					cookieValue = decodeURIComponent(cookieList[i].split("=")[1]);
					break;
				}
			}
		}
		return cookieValue;
	},
	set : function(_name, _value, _days, _path, _domain) {
		if (_name!=undefined) {
			if (_value==undefined) _value = "";
			if (_days==undefined) _days = 365;
			if (_path==undefined) _path = "/";
			//try { if (_domain==undefined) _domain = location.hostname; } catch(e) { }
			var d = new Date();
			d.setDate(d.getDate()+_days);
			var s = "";
			s += _name+"="+encodeURIComponent(_value) + ";";
			s += "expires=" + d.toGMTString() + ";";
			s += "path=" + _path + ";";
			if (_domain!=undefined) {
				s += "domain=" + _domain + ";";
			}
			//alert(s);
			document.cookie = s;
		}
	}
}



/**
 Ajax Object
*****************************/
function Ajax(_url, _method, _async) {
	this.request = null;
	this.method = (_method==undefined)?"post":_method;
	this.url = (_url==undefined)?"":_url;
	this.async = (_async==undefined)?true:_async;
	this.parameter = "";
	this.header = {
		contentType : "application/x-www-form-urlencoded; charset=UTF-8"
	};
}
Ajax.prototype.getEncParam = function(_name, _value) {
	return encodeURIComponent(_name) + "=" + encodeURIComponent(_value);
};
Ajax.prototype.getTimeStamp = function() {
	return (new Date()).getTime();
};
Ajax.prototype.getReadyState = function() {
	return this.request.readyState;
};
Ajax.prototype.getStatus = function() {
	return this.request.status;
};
Ajax.prototype.getResponseText = function() {
	return this.request.responseText;
};
Ajax.prototype.getResponseXML = function() {
	return this.request.responseXML;
};
Ajax.prototype.appendParameter = function(_name, _value) {
	this.parameter = this.parameter.appendParameter(this.getEncParam(_name, _value));
};
Ajax.prototype.send = function() {
	this.request = null;
	try { this.request = new XMLHttpRequest(); } catch(e1) {
		try { this.request = new ActiveXObject('Msxml2.XMLHTTP'); } catch(e2) {
			try { this.request = new ActiveXObject('Microsoft.XMLHTTP'); } catch(e3) {
				this.request = null;
			}
		}
	}
	if (this.parameter.indexOf("?")==0) {
		this.parameter = this.parameter.substring(1);
	}
	if (this.parameter!="") {
		this.parameter += "&";
	}
	this.parameter += "__temp="+this.getTimeStamp();
	this.request.open(this.method, (this.method=="post")?this.url:this.url.appendParameter(this.parameter) , this.async);
	this.request.setRequestHeader("Content-Type", this.header.contentType);
	this.request.send((this.method=="post")?this.parameter:"");
	var _onStatus200 = this.onStatus200;
	var _onError = this.onError;
	var _req = this.request;
	this.request.onreadystatechange = function() {
		if (_req.readyState==4) {
			if (_req.status==200) {
				_onStatus200();
			} else {
				_onError();
			}
		}
	};
};
Ajax.prototype.onStatus200 = function() { };
Ajax.prototype.onError = function() { };



/**
 Document Object
*****************************/
function $() {
	var o = null;
	if (typeof arguments[0] == 'string') {
		o = document.getElementById(arguments[0]);
	} else {
		o = arguments[0];
	}
	if (o==null) {
		o = {};
		o.isNull = true;
	} else {
		if (o.isNull!=undefined) {
			return o;
		}
		o.isNull = false;
	}
	
	o.setStyle = function(_name, _value) {
		try {
			if (_name=="display") {
				_value = (""+_value).toLowerCase();
				if (_value=="false"||_value=="none") _value = "none";
				else _value = "";
			} else if (_name=="left"||_name=="top"||_name=="width"||_name=="height") {
				_value = (""+_value).toLowerCase();
				if (_value!=""&&_value.indexOf("px")<0) _value += "px";
			}
			this.style[_name] = _value;
		} catch(e) {
			var s = "";
			s += "RichScript Error Form $().setStyle() : \n";
			s += "- Object ID : " + o.id + "\n";
			s += "- Style Property : " + _name + "\n";
			alert(s);
		}
	};
	
	o.getStyle = function(_name) {
		return this.style[_name];
	};
	
	o.setPosition = function(_x, _y) {
		if (_x!=undefined) this.setStyle("left", _x);
		if (_y!=undefined) this.setStyle("top", _y);
	};
	
	o.getW = function() {
		return this.offsetWidth;
	};
	
	o.getH = function() {
		return this.offsetHeight;
	};
	
	o.getX = function() {
		var posX = this.style.left;
		if (posX=="") {
			posX = 0;
			var tempObj = this;
			if (tempObj.offsetParent) {
				while (tempObj.offsetParent) {
					posX += tempObj.offsetLeft;
					tempObj = tempObj.offsetParent;
				}
			}
			tempObj = null;
		} else {
			posX = parseInt(posX.toLowerCase().replace("px",""));
		}
		return posX;
	};
	
	o.getY = function() {
		var posY = this.style.top;
		if (posY=="") {
			posY = 0;
			var tempObj = this;
			if (tempObj.offsetParent) {
				while (tempObj.offsetParent) {
					posY += tempObj.offsetTop;
					tempObj = tempObj.offsetParent;
				}
			}
			tempObj = null;
		} else {
			posY = parseInt(posY.toLowerCase().replace("px",""));
		}
		return posY;
	};
	
	o.setOpacity = function(_value) {
		if (parseFloat(_value)>1) _value = parseFloat(_value)/100;
		this.setStyle("filter","alpha(opacity=" + (_value*100) + ")");
		this.setStyle("opacity",_value);
		this.setAttribute("opacity",_value);
	};
	
	o.getOpacity = function() {
		var value = this.getAttribute("opacity") || this.getStyle("opacity") || 0;
		if (value==undefined||value=="") value = 0;
		return parseFloat(value);
	};
	
	o.setFadeIn = function(_opacity, _sp, _function, _isReCall) {
		try {
			if (!this.isNull) {
				if (_isReCall!=true&&this.getAttribute("fade.status")=="ing") {
					this.setAttribute("fade.mode","in");
					this.setAttribute("fade.opacity",_opacity);
					this._fade_function = _function;
				} else {
					var mode = "in";
					if (_isReCall!=true) {
						if (!Math.isFloat(_opacity)) _opacity = 1.0;
						if (_opacity>1) _opacity = _opacity/100;
						if (!Math.isInt(_sp)) _sp = 30;
						this.setAttribute("fade.status","ing");
						this.setAttribute("fade.mode",mode);
						this.setAttribute("fade.opacity",_opacity);
						this._fade_function = _function;
					} else {
						mode = this.getAttribute("fade.mode");
						_opacity = parseFloat(this.getAttribute("fade.opacity"));
						_sp = parseInt(this.getAttribute("fade.sp"));
					}
					if (mode=="out") {
						this.setFadeOut(null, null, null, true);
					} else {
						var nowOpacity = this.getOpacity();
						var targetOpacity = nowOpacity + 0.1;
						if (targetOpacity > _opacity) targetOpacity = _opacity;
						this.setOpacity(targetOpacity);
						if (targetOpacity<_opacity) {
							var _id = this.id;
							this.fadeTimer = setTimeout( function() {
								$(_id).setFadeIn(null, null, null, true);
							}, _sp);
						} else {
							this.removeAttribute("fade.status");
							this.removeAttribute("fade.mode");
							this.removeAttribute("fade.opacity");
							_function = this._fade_function;
							this._fade_function = null;
							if (_function==undefined) _function = "";
							try {
								if (typeof(_function)=="function") {
									_function();
								} else {
									eval(_function);
								}
							} catch(e) { }
						}
					}
				}
			}
		}catch(e) {
			alert("RichScript Error Form $().setFadeIn() : " + e);
		}
	};
	
	o.setFadeOut = function(_opacity, _sp, _function, _isReCall) {
		try {
			if (!this.isNull) {
				if (_isReCall!=true&&this.getAttribute("fade.status")=="ing") {
					this.setAttribute("fade.mode","out");
					this.setAttribute("fade.opacity",_opacity);
					this._fade_function = _function;
				} else {
					var mode = "out";
					if (_isReCall!=true) {
						if (!Math.isFloat(_opacity)) _opacity = 1.0;
						if (_opacity>1) _opacity = _opacity/100;
						if (!Math.isInt(_sp)) _sp = 30;
						this.setAttribute("fade.status","ing");
						this.setAttribute("fade.mode",mode);
						this.setAttribute("fade.opacity",_opacity);
						this._fade_function = _function;
					} else {
						mode = this.getAttribute("fade.mode");
						_opacity = parseFloat(this.getAttribute("fade.opacity"));
						_sp = parseInt(this.getAttribute("fade.sp"));
					}
					if (mode=="in") {
						this.setFadeIn(null, null, null, true);
					} else {
						var nowOpacity = this.getOpacity();
						var targetOpacity = nowOpacity - 0.1;
						if (targetOpacity < _opacity) targetOpacity = _opacity;
						this.setOpacity(targetOpacity);
						if (targetOpacity>_opacity) {
							var _id = this.id;
							this.fadeTimer = setTimeout( function() {
								$(_id).setFadeOut(null, null, null, true);
							}, _sp);
						} else {
							this.removeAttribute("fade.status");
							this.removeAttribute("fade.mode");
							this.removeAttribute("fade.opacity");
							_function = this._fade_function;
							this._fade_function = null;
							if (_function==undefined) _function = "";
							try {
								if (typeof(_function)=="function") {
									_function();
								} else {
									eval(_function);
								}
							} catch(e) { }
						}
					}
				}
			}
		}catch(e) {
			alert("RichScript Error Form $().setFadeOut() : " + e);
		}
	};
	
	
	o._getNextPoint = function(_prevPont, _targetPoint, _sp) {
		var point = 0;
		var finishPointChecking = false;
		var checkMode = "";
		if (_targetPoint<0) {
			if (_prevPont<0) {
				if (Math.abs(Math.abs(_targetPoint)-Math.abs(_prevPont))<_sp) {
					point = _targetPoint;
					finishPointChecking = true;
				}
				checkMode = "A";
			} else {
				checkMode = "B";
			}
		} else {
			if (_prevPont>=0) {
				if (Math.abs(Math.abs(_targetPoint)-Math.abs(_prevPont))<_sp) {
					point = _targetPoint;
					finishPointChecking = true;
				}
				checkMode = "C";
			} else {
				checkMode = "D";
			}
		}
		
		if (!finishPointChecking) {
			var setPoint = 0;
			var gapPoint = Math.abs(_prevPont-_targetPoint);
			if (checkMode=="A"||checkMode=="C") {
				gapPoint = Math.abs(_prevPont-_targetPoint);
			} else {
				gapPoint = Math.abs(_prevPont+_targetPoint);
			}
			var minusOption = 1;
			if (_prevPont > _targetPoint) minusOption *= -1;
			if (gapPoint>_sp) setPoint = _sp*minusOption;
			else setPoint = gapPoint*minusOption;
			point = _prevPont+setPoint;
		}
		return point;
	};
	
	
	
	o.resizeToMotionA = function(_w, _h, _function, _sp, _isReCall) {
		if (!this.isNull) {
			var useMultiCommand = (this.getAttribute("resizeTo.useMultiCommand")=="true");
			if (useMultiCommand&&_isReCall!=true&&this.getAttribute("resizeTo.status")=="ing") {
				if (Math.isInt(_w)) this.setAttribute("resizeTo.w",_w);
				if (Math.isInt(_h)) this.setAttribute("resizeTo.h",_h);
				if (Math.isInt(_sp)) this.setAttribute("resizeTo.sp",_sp);
				this._resizeTo_function = _function;
			}
			if (_isReCall==true||this.getAttribute("resizeTo.status")!="ing") {
				try {
					var w = this.getW();
					var h = this.getH();
					if (_isReCall!=true) {
						if (!Math.isInt(_w)) _w = nowW;
						if (!Math.isInt(_h)) _h = nowH;
						if (!Math.isInt(_sp)) _sp = 10;
						else _sp = parseInt(_sp);
						this.setAttribute("resizeTo.status","ing");
						this.setAttribute("resizeTo.w", _w);
						this.setAttribute("resizeTo.h", _h);
						this.setAttribute("resizeTo.sp", _sp);
						this._resizeTo_function = _function;
					} else {
						_w = parseInt(this.getAttribute("resizeTo.w"));
						_h = parseInt(this.getAttribute("resizeTo.h"));
						_sp = parseInt(this.getAttribute("resizeTo.sp"));
					}
					if (_w<1) _w = 1;
					if (_h<1) _h = 1;
					var targetW = this._getNextPoint(w,_w,_sp);
					var targetH = this._getNextPoint(h,_h,_sp);
					this.setStyle("width",targetW);
					this.setStyle("height",targetH);
					
					if (w==_w&&h==_h) {
						this.removeAttribute("resizeTo.status");
						this.removeAttribute("resizeTo.w");
						this.removeAttribute("resizeTo.h");
						this.removeAttribute("resizeTo.sp");
						_function = this._resizeTo_function;
						this._resizeTo_function = null;
						if (_function==undefined) _function = "";
						try {
							if (typeof(_function)=="function") {
								_function();
							} else {
								eval(_function);
							}
						} catch(e) { }
					} else {
						var _id = this.id;
						this.resizeToTimer = setTimeout( function() {
							$(_id).resizeToMotionA(null, null, null, null, true);
						}, 10);
					}
				}catch(e) {
					alert("RichScript Error Form $().resizeToMotionA() : " + e);
				}
			}
		}
	};
	
	
	o.resizeTo = function(_w, _h, _function, _sp, _isReCall) {
		if (!this.isNull) {
			var useMultiCommand = (this.getAttribute("resizeTo.useMultiCommand")=="true");
			if (useMultiCommand&&_isReCall!=true&&this.getAttribute("resizeTo.status")=="ing") {
				if (Math.isInt(_w)) this.setAttribute("resizeTo.w",_w);
				if (Math.isInt(_h)) this.setAttribute("resizeTo.h",_h);
				if (Math.isInt(_sp)) this.setAttribute("resizeTo.sp",_sp);
				this._resizeTo_function = _function;
			}
			if (_isReCall==true||this.getAttribute("resizeTo.status")!="ing") {
				try {
					var nowW = this.getW();
					var nowH = this.getH();
					if (_isReCall!=true) {
						if (!Math.isInt(_w)) _w = nowW;
						if (!Math.isInt(_h)) _h = nowH;
						if (!Math.isInt(_sp)) _sp = 5;
						else _sp = parseInt(_sp);
						this.setAttribute("resizeTo.status","ing");
						this.setAttribute("resizeTo.w", _w);
						this.setAttribute("resizeTo.h", _h);
						this.setAttribute("resizeTo.sp", _sp);
						this._resizeTo_function = _function;
					} else {
						_w = parseInt(this.getAttribute("resizeTo.w"));
						_h = parseInt(this.getAttribute("resizeTo.h"));
						_sp = parseInt(this.getAttribute("resizeTo.sp"));
					}
					var targetW = (_w<1)?1:_w;
					var targetH = (_h<1)?1:_h;
					
					if (targetW==nowW&&targetH==nowH) {
						this.removeAttribute("resizeTo.status");
						this.removeAttribute("resizeTo.w");
						this.removeAttribute("resizeTo.h");
						this.removeAttribute("resizeTo.sp");
						_function = this._resizeTo_function;
						this._resizeTo_function = null;
						if (_function==undefined) _function = "";
						try {
							if (typeof(_function)=="function") {
								_function();
							} else {
								eval(_function);
							}
						} catch(e) { }
					} else {
						var addW = 0;
						var addH = 0;
						if (targetW > nowW) addW = Math.ceil((targetW - nowW) / _sp);
						else                addW = Math.ceil((nowW - targetW) / _sp)*-1;
						if (targetH > nowH) addH = Math.ceil((targetH - nowH) / _sp);
						else                addH = Math.ceil((nowH - targetH) / _sp)*-1;
						var finalW = nowW + addW;
						var finalH = nowH + addH;
						if (finalW<1) finalW = 1;
						if (finalH<1) finalH = 1;
						this.setStyle("width", finalW);
						this.setStyle("height", finalH);
						var _id = this.id;
						this.resizeToTimer = setTimeout( function() {
							$(_id).resizeTo(null, null, null, null, true);
						}, 10);
					}
				}catch(e) {
					alert("RichScript Error Form $().resizeTo() : " + e);
				}
			}
		}
	};
	
	o.moveTo = function(_x, _y, _function, _sp, _isReCall) {
		if (!this.isNull) {
			var useMultiCommand = (this.getAttribute("moveTo.useMultiCommand")=="true");
			if (useMultiCommand&&_isReCall!=true&&this.getAttribute("moveTo.status")=="ing") {
				if (Math.isInt(_x)) this.setAttribute("moveTo.x",_x);
				if (Math.isInt(_y)) this.setAttribute("moveTo.y",_y);
				if (Math.isInt(_sp)) this.setAttribute("moveTo.sp",_sp);
				this._moveTo_function = _function;
			}
			if (_isReCall==true||this.getAttribute("moveTo.status")!="ing") {
				try {
					var nowX = this.getX();
					var nowY = this.getY();
					if (_isReCall!=true) {
						if (!Math.isInt(_x)) _x = nowX;
						if (!Math.isInt(_y)) _y = nowY;
						if (!Math.isInt(_sp)) _sp = 5;
						else _sp = parseInt(_sp);
						this.setAttribute("moveTo.status","ing");
						this.setAttribute("moveTo.x", _x);
						this.setAttribute("moveTo.y", _y);
						this.setAttribute("moveTo.sp", _sp);
						this._moveTo_function = _function;
					} else {
						_x = parseInt(this.getAttribute("moveTo.x"));
						_y = parseInt(this.getAttribute("moveTo.y"));
						_sp = parseInt(this.getAttribute("moveTo.sp"));
					}
					var targetX = _x;
					var targetY = _y;
					
					if (targetX==nowX&&targetY==nowY) {
						this.removeAttribute("moveTo.status");
						this.removeAttribute("moveTo.x");
						this.removeAttribute("moveTo.y");
						this.removeAttribute("moveTo.sp");
						_function = this._moveTo_function;
						this._moveTo_function = null;
						if (_function==undefined) _function = "";
						try {
							if (typeof(_function)=="function") {
								_function();
							} else {
								eval(_function);
							}
						} catch(e) { }
					} else {
						var moveX = 0;
						var moveY = 0;
						var sp = _sp;
						if (Math.abs(targetX - nowX)<=20&&Math.abs(targetY - nowY)<=20) {
							sp = 2;
						}
						if (targetX > nowX) {
							moveX = Math.ceil((targetX - nowX) / sp);
						} else {
							moveX = Math.ceil((nowX - targetX) / sp)*-1;
						}
						if (targetY > nowY) {
							moveY = Math.ceil((targetY - nowY) / sp);
						} else {
							moveY = Math.ceil((nowY - targetY) / sp)*-1;
						}
						this.setStyle("left", nowX + moveX);
						this.setStyle("top", nowY + moveY);
						var _id = this.id;
						this.moveToTimer = setTimeout( function() {
							$(_id).moveTo(null, null, null, null, true);
						}, 10);
					}
				}catch(e) {
					alert("RichScript Error Form $().moveTo() : " + e);
				}
			}
		}
	};
	
	o.moveToMotionA = function(_x, _y, _function, _sp, _isReCall) {
		if (!this.isNull) {
			var useMultiCommand = (this.getAttribute("moveTo.useMultiCommand")=="true");
			if (useMultiCommand&&_isReCall!=true&&this.getAttribute("moveTo.status")=="ing") {
				if (Math.isInt(_x)) this.setAttribute("moveTo.x",_x);
				if (Math.isInt(_y)) this.setAttribute("moveTo.y",_y);
				if (Math.isInt(_sp)) this.setAttribute("moveTo.sp",_sp);
				this._moveTo_function = _function;
			}
			if (_isReCall==true||this.getAttribute("moveTo.status")!="ing") {
				try {
					var x = this.getX();
					var y = this.getY();
					if (_isReCall!=true) {
						if (!Math.isInt(_x)) _x = x;
						if (!Math.isInt(_y)) _y = y;
						if (!Math.isInt(_sp)) _sp = 10;
						else _sp = parseInt(_sp);
						this.setAttribute("moveTo.status","ing");
						this.setAttribute("moveTo.x", _x);
						this.setAttribute("moveTo.y", _y);
						this.setAttribute("moveTo.sp", _sp);
						this._moveTo_function = _function;
					} else {
						_x = parseInt(this.getAttribute("moveTo.x"));
						_y = parseInt(this.getAttribute("moveTo.y"));
						_sp = parseInt(this.getAttribute("moveTo.sp"));
					}
					
					if (x==_x&&x==_x) {
						this.removeAttribute("moveTo.status");
						this.removeAttribute("moveTo.x");
						this.removeAttribute("moveTo.y");
						this.removeAttribute("moveTo.sp");
						_function = this._moveTo_function;
						this._moveTo_function = null;
						if (_function==undefined) _function = "";
						try {
							if (typeof(_function)=="function") {
								_function();
							} else {
								eval(_function);
							}
						} catch(e) { }
					} else {
						var targetX = this._getNextPoint(x,_x,_sp);
						var targetY = this._getNextPoint(y,_y,_sp);
						this.setStyle("left",targetX);
						this.setStyle("top",targetY);
						var _id = this.id;
						this.moveToTimer = setTimeout( function() {
							$(_id).moveToMotionA(null, null, null, null, true);
						}, 10);
					}
				}catch(e) {
					alert("RichScript Error Form $().moveToMotionA() : " + e);
				}
			}
		}
	};
	
	o.moveToTarget = function(_targetId, _function, _sp, _isReCall) {
		if (!this.isNull) {
			var useMultiCommand = (this.getAttribute("moveTo.useMultiCommand")=="true");
			if (useMultiCommand&&_isReCall!=true&&this.getAttribute("moveTo.status")=="ing") {
				if (!$(_targetId).isNull) this.setAttribute("moveTo.targetId",_targetId);
				if (Math.isInt(_sp)) this.setAttribute("moveTo.sp",_sp);
				this._moveTo_function = _function;
			}
			if (_isReCall==true||this.getAttribute("moveTo.status")!="ing") {
				try {
					if (_isReCall!=true) {
						if (!Math.isInt(_sp)) _sp = 5;
						this.setAttribute("moveTo.status","ing");
						this.setAttribute("moveTo.targetId",_targetId);
						this.setAttribute("moveTo.sp",_sp);
						this._moveTo_function = _function;
					} else {
						_targetId = this.getAttribute("moveTo.targetId");
						_sp = this.getAttribute("moveTo.sp");
					}
					if (!$(_targetId).isNull) {
						var targetX = $(_targetId).getX();
						var targetY = $(_targetId).getY();
						var nowX = this.getX();
						var nowY = this.getY();
						
						if (targetX==nowX&&targetY==nowY) {
							this.removeAttribute("moveTo.status");
							this.removeAttribute("moveTo.targetId");
							this.removeAttribute("moveTo.sp");
							_function = this._moveTo_function;
							this._moveTo_function = null;
							if (_function==undefined) _function = "";
							try {
								if (typeof(_function)=="function") {
									_function();
								} else {
									eval(_function);
								}
							} catch(e) { }
						} else {
							var moveX = 0;
							var moveY = 0;
							if (targetX > nowX) moveX = Math.ceil((targetX - nowX) / _sp);
							else                moveX = Math.ceil((nowX - targetX) / _sp)*-1;
							if (targetY > nowY) moveY = Math.ceil((targetY - nowY) / _sp);
							else                moveY = Math.ceil((nowY - targetY) / _sp)*-1;
							this.setStyle("left", nowX + moveX);
							this.setStyle("top", nowY + moveY);
							var _id = this.id;
							this.moveToTimer = setTimeout( function() {
								$(_id).moveToTarget(null, null, null, true);
							}, 10);
						}
					} else {
						this.removeAttribute("moveTo.status");
						this.removeAttribute("moveTo.targetId");
						this.removeAttribute("moveTo.sp");
					}
				}catch(e) {
					alert("RichScript Error Form $().moveToTarget() : " + e);
				}
			}
		}
	};
	
	o.insertAfter = function(_newNode, _beforeNode) {
		if (_beforeNode.parentNode.lastChild==_beforeNode) {
			_beforeNode.parentNode.appendChild(_newNode);
		} else {
			_beforeNode.parentNode.insertBefore(_newNode, _beforeNode.nextSibling);
		}
	};
	
	return o;
}








/**
 Event
*****************************/
var $E = {
	vars : {},
	event : null,
	eventActions : [],
	
	getElement : function() {
		return this.event.target || this.event.srcElement;
	},
	
	getValidElement : function(_attributeName,_attributeValue) {
		var element = this.getElement();
		while(element) {
			if (element.getAttribute(_attributeName)==_attributeValue) {
				break;
			}
			element = element.parentNode;
		}
		return element;
	},
	
	pointerX : function() {
		var x = 0;
		if (this.event!=null) {
			x = this.event.pageX || (this.event.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft));
			//alert("this.event.pageX : " + this.event.pageX + "\n other : " + x);
			//x = (document.documentElement.scrollLeft) ? this.event.clientX : this.event.clientX + document.body.scrollLeft;
		}
		return x;
	},
	
	pointerY : function() {
		var y = 0;
		if (this.event!=null) {
			y = this.event.pageY || (this.event.clientY + (document.documentElement.scrollTop || document.body.scrollTop));
			//y = (document.documentElement.scrollTop) ? this.event.clientY : this.event.clientY + document.body.scrollTop;
		}
		return y;
	},
	
	
	addAction : function(_eventType, _eventGroup, _eventAction) {
		this.eventActions.push(
			{
				  type		: _eventType.trim().toLowerCase()
				, group		: _eventGroup.trim().toLowerCase()
				, action	: _eventAction
			}
		);
	},
	
	removeAction : function(_eventGroup) {
		for (var i=0; i<this.eventActions.length; i++) {
			var eAction = this.eventActions[i];
			if (eAction.group==_eventGroup.trim().toLowerCase()) {
				this.eventActions[i] = null;
			}
		}
		this.eventActions = this.eventActions.compact();
	},
	
	stop : function() {
		if (this.event.preventDefault!=undefined) {
			this.event.preventDefault();
			this.event.stopPropagation();
		} else {
			this.event.returnValue = false;
			this.event.cancelBubble = true;
		}
	},
	
	onEvent : function(_eventType) {
		for (var i=0; i<this.eventActions.length; i++) {
			var eAction = this.eventActions[i];
			if (eAction.type==_eventType.trim().toLowerCase()) {
				try {
					if (typeof(eAction.action)=="function") {
						eAction.action();
					} else {
						eval(eAction.action);
					}
				} catch(e) { }
			}
		}
	}
};

function _EventListener(_event) {
	_event = window.event ? window.event : _event;
	$E.event = _event;
	$E.onEvent("on"+_event.type);
}

document.onmousedown = _EventListener;
document.onmouseup = _EventListener;
document.onmousemove = _EventListener;
document.onmouseover = _EventListener;
document.onselectstart = _EventListener;
document.onclick = _EventListener;
//document.onkeydown = _EventListener;
window.onresize = _EventListener;
window.onscroll = _EventListener;
//window.onload = _EventListener;
//document.onmousewheel = _EventListener;
//document.oncontextmenu = _EventListener;

