/*
 * @title		아이템매니아 JS프레임
 * @author		이주원
 * @date		2007. 9.12
 * @update		2007. 9.20(이주원)<prototype기능추가>
				2007.10.20(이주원)<selectbox추가>
				2007.10.30(이주원)<suggest추가>
				2007.11. 3(이주원)<xhr추가>
				2007.11. 7(이주원)<form추가>
				2007.11. 8(이주원)<debug추가>
 * @description	JS공통파일(모든 페이지에 포함시켜야함)
 */

var _DEBUG = false;			// 디버그 사용유무

/* ▼ 브라우저 정보 */
var _BROWSER = {
	name: (navigator.appName.indexOf('Explorer')!=-1) ? 'explorer' : navigator.appName.toLowerCase(),
	version: parseInt((navigator.appName.indexOf('Explorer')!=-1) ? navigator.appVersion.split(';')[1].replace('MSIE','') : navigator.appVersion.substr(0,navigator.appVersion.indexOf('(')))
};
/* ▲ 브라우저 정보 */

/* ▼ 클래스 및 확장 */
var Class = {
	create: function(parent, methods) 
	{
		if (arguments.length == 1 && !Object.isFunction(parent)) 
		{
			methods = parent, parent = null 
		}
		var method = function() 
		{
			if (!Class.extending) this.initialize.apply(this, arguments);
		};

		method.superclass = parent;
		method.subclasses = [];

		if (Object.isFunction(parent)) 
		{
			Class.extending = true;
			method.prototype = new parent();
			parent.subclasses.push(method);
			delete Class.extending;
		}

		if (methods) Class.extend(method, methods);
		method.prototype.constructor = method;
	    return method;
	},
	extend: function(destination, source) 
	{
		for (var name in source) Class.inherit(destination, source, name);
		return destination;
	},
	inherit: function(destination, source, name) 
	{
		var prototype = destination.prototype, ancestor = prototype[name],
		descendant = source[name];
		if (ancestor && Object.isFunction(descendant) && descendant.argumentNames().first() == "$super") 
		{
			var method = descendant, descendant = ancestor.wrap(method);
			Object.extend(descendant, {
				valueOf:  function() { return method },
				toString: function() { return method.toString() }
			});
		}
		prototype[name] = descendant;

		if (destination.subclasses && destination.subclasses.length > 0) 
		{
			for (var i = 0, subclass; subclass = destination.subclasses[i]; i++) 
			{
				Class.extending = true;
				Object.extend(subclass.prototype, new destination());
				subclass.prototype.constructor = subclass;
				delete Class.extending;
				Class.inherit(subclass, destination.prototype, name);
			}
		}
	},
	mixin: function(destination, source) 
	{
		return Object.extend(destination, source);
	}
};

// 클래스 상속
Object.extend = function(destination, source)
{	
	for(var property in source)	
		destination[property] = source[property];

	return destination;
};

// Object확장
Object.extend(Object, {
	inspect: function(object) 
	{
		try {
			if (object === undefined)	{ return 'undefined'; }
			if (object === null)		{ return 'null'; }
			return object.inspect ? object.inspect() : object.toString();
		} 
		catch (e) {
			if (e instanceof RangeError) return '...';
			throw e;
		}
	},
	toJSON: function(object) 
	{
		var type = typeof object;
		switch (type) 
		{
		  case 'undefined':
		  case 'function':
		  case 'unknown': return;
		  case 'boolean': return object.toString();
		}

		if (object === null) return 'null'; 
		if (object.toJSON) return object.toJSON();
		if (Object.isElement(object)) return;
		var results = [];
		for (var property in object) 
		{
			var value = Object.toJSON(object[property]);
			if (value !== undefined)
			results.push(property.toJSON() + ': ' + value);
		}

		return '{' + results.join(', ') + '}';
	},
	clone: function(object)		{ return Object.extend({ }, object) },
	isElement: function(object)	{ return object && object.nodeType == 1 },
	isArray: function(object)	{ return object && object.constructor === Array },
	isFunction: function(object){ return typeof object == "function" },
	isString: function(object)	{ return typeof object == "string" },
	isNumber: function(object)	{ return typeof object == "number" },
	isUndefined: function(object){return typeof object == "undefined" }
});

// Function확장
Object.extend(Function.prototype, {
	argumentNames: function() 
	{
		var names = this.toString().match(/^[\s\(]*function\s*\((.*?)\)/)[1].split(",").invoke("trim");
		return names.length == 1 && !names[0] ? [] : names;
	},
	bind: function() 
	{
		if (arguments.length < 2 && arguments[0] === undefined) return this;
		var __method = this, args = $A(arguments), object = args.shift();

		return function() {
			return __method.apply(object, args.concat($A(arguments)));
		}
	},
	bindAsEventListener: function() {
		var __method = this, args = $A(arguments), object = args.shift();

		return function(event) {
			return __method.apply(object, [event || window.event].concat(args));
		}
	},
	curry: function() 
	{
		if (!arguments.length) return this;
		var __method = this, args = $A(arguments);
		return function() {
			return __method.apply(this, args.concat($A(arguments)));
		}
	},
	delay: function() 
	{
		var __method = this, args = $A(arguments), timeout = args.shift() * 1000;
		return window.setTimeout(function() {
			return __method.apply(__method, args);
		}, timeout);
	},
	wrap: function(wrapper) 
	{
		var __method = this;
		return function() {
			return wrapper.apply(this, [__method.bind(this)].concat($A(arguments)));
		}
	},
	methodize: function() {
		if (this._methodized) return this._methodized;
		var __method = this;
		return this._methodized = function() {
			return __method.apply(null, [this].concat($A(arguments)));
		};
	}
});
if(_BROWSER.name=='opera'){
  Array.prototype.concat = function() {
    var array = [];
    for (var i = 0, length = this.length; i < length; i++) array.push(this[i]);
    for (var i = 0, length = arguments.length; i < length; i++) {
      if (Object.isArray(arguments[i])) {
        for (var j = 0, arrayLength = arguments[i].length; j < arrayLength; j++)
          array.push(arguments[i][j]);
      } else {
        array.push(arguments[i]);
      }
    }

	try { return array; }
	finally { array=null; }
  };
}

// Array확장
var $break = { };
Object.extend(Array.prototype, {
	_each: function(iterator)
	{
		for (var i = 0, length = this.length; i < length; i++)
			iterator(this[i]);
	},
	clear: function()
	{
		this.length = 0;
		return this;
	},
	first: function()	{ return this[0] },
	last: function()	{ return this[this.length - 1] },
	clone: function()	{ return [].concat(this) },
	size: function()	{ return this.length },
	toJSON: function()
	{
		var results = [];
		this.each(function(object) {
			var value = Object.toJSON(object);
			if (value !== undefined) results.push(value);
		});
		return '[' + results.join(', ') + ']';
	},
	each: function(iterator, context) {
		var index = 0;
		iterator = iterator.bind(context);
		try {
			this._each(function(value) {
				iterator(value, index++);
			});
		} catch (e) {
			if (e != $break) throw e;
		}
		return this;
	},
	inject: function(memo, iterator, context) {
		iterator = iterator.bind(context);
		this.each(function(value, index) {
			memo = iterator(memo, value, index);
		});
		return memo;
	}
});
Array.prototype.toArray = Array.prototype.clone;

// Event객체
var _event = { };
Object.extend(_event, {
	KEY_BACKSPACE: 8,
	KEY_TAB:       9,
	KEY_RETURN:   13,
	KEY_ESC:      27,
	KEY_LEFT:     37,
	KEY_UP:       38,
	KEY_RIGHT:    39,
	KEY_DOWN:     40,
	KEY_DELETE:   46,
	KEY_HOME:     36,
	KEY_END:      35,
	KEY_PAGEUP:   33,
	KEY_PAGEDOWN: 34,
	KEY_INSERT:   45,

	DOMEvents: ['click', 'dblclick', 'mousedown', 'mouseup', 'mouseover',
			  'mousemove', 'mouseout', 'keypress', 'keydown', 'keyup',
			  'load', 'unload', 'abort', 'error', 'resize', 'scroll',
			  'select', 'change', 'submit', 'reset', 'focus', 'blur'],

	cache: { },

	relatedTarget: function(event) {
		event = this.event(event);
		var element;
		switch(event.type) {
		  case 'mouseover': element = event.fromElement; break;
		  case 'mouseout':  element = event.toElement;   break;
		  default: return null;
		}
		return element;
	},

	isLeftClick: function(event) {
		event = this.event(event);
		return (((event.which) && (event.which == 1)) || ((event.button) && (event.button == 1)));
	},
	pointer: function(event) {
		event = this.event(event);
		return {
			x: event.pageX || (event.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft)),
			y: event.pageY || (event.clientY + (document.documentElement.scrollTop || document.body.scrollTop))
		};
	},
	pointerX: function(event) { event = this.event(event); return _event.pointer(event).x },
	pointerY: function(event) { event = this.event(event); return _event.pointer(event).y },

	stopPropagation: function(event)
	{
		event = this.event(event);
		if(event.stopPropagation)	{ event.stopPropagation() }
		else						{ event.cancelBubble = true }
	},
	preventDefault: function(event)
	{
		event = this.event(event);
		try { (event.which) ? event.which : event.keyCode = 0; }
		catch(e) {}
		if(event.preventDefault)	{ event.preventDefault() }
		else						{ event.returnValue = false }
	},
	keycode: function(event)
	{
		event = this.event(event);
		if(!event) { return -1; }
		return (event.which) ? event.which : event.keyCode;
	},
	stop: function(event) {
		_event.preventDefault(event);
		_event.stopPropagation(event);
	},
	event: function(event)
	{
		return window.event || event;
	}
});

// String확장
Object.extend(String.prototype, {
	trim :	function()	{ return this.replace(/(^\s*)|(\s*$)/g, ''); },
	alltrim:	function()	{ return this.replace(/\s*/g, ''); },
	ltrim:	function()	{ return this.replace(/^\s*/g, ''); },
	rtrim:	function()	{ return this.replace(/\s*$/g, ''); },
	isEmpty:function()	{ return (this==null || this.trim()=='') ? true : false; },
	isHangul:function()	{
		var iCode=0, cChar="";
		var length = this.length;
		for (var i=0; i<length; i++)
		{
			iCode = parseInt(this.charCodeAt(i));
			cChar = this.substr(i,1).toUpperCase();
			if((cChar<"0" || cChar>"9") && (cChar<"A" || cChar>"Z") && ((iCode>255) || (iCode<0)))
				return true;
		}
		return false;
	},
	isDate: function() {
		var date = this.replace(/[^0-9]/,'');
		if(date.length==8)
		{
			var year = Number(date.substring(0,4));
			var month= Number(date.substring(4,6));
			var day	 = Number(date.substring(6,8));
		}
		else if(date.length==6)
		{
			var year = Number('19'+date.substring(0,2));
			var month= Number(date.substring(2,4));
			var day	 = Number(date.substring(4,6));
		}
		else { return false }

		var rgMaxDay = new Array(31, ((((year%4==0) && (year%100!=0)) || (year%400==0)) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
		if(month<1 || month>12)				{ return false }
		if(day<1 || day>rgMaxDay[month-1])	{ return false }
		return true;
	},
	getWidth: function() {
		var ascii_code, string_value_length = this.length;
		var character, character_width, total_width=0, total_length=0;
		var special_char_size=6, multibyte_char_size=12, base_char_start=32, base_char_end=127;
		var ascii_char_size = Array(4,4,4,6,6,10,8,4,5,5,6,6,4,6,4,6,6,6,6,6,6,6,6,6,6,6,4,4,8,6,8,6,12,8,8,9,8,8,7,9,8,3,6,8,7,11,9,9,8,9,8,8,8,8,8,10,8,8,8,6,11,6,6,6,4,7,7,7,7,7,3,7,7,3,3,6,3,11,7,7,7,7,4,7,3,7,6,10,7,7,7,6,6,6,9,6);

		for(i=0; i<string_value_length; i++)
		{
			character = this.substring(i,(i+1));
			ascii_code = character.charCodeAt(0);

			if(ascii_code < base_char_start)	
			{ 
				character_width = special_char_size;
			}
			else if(ascii_code <= base_char_end)
			{
				idx = ascii_code - base_char_start;
				character_width = ascii_char_size[idx];
			}
			else if(ascii_code > base_char_end)
			{
				character_width = multibyte_char_size;
			}

			total_width += character_width;
		}

		return total_width;
	},
	getByte: function() {
		if(this.isEmpty())	{ return 0 }
		var count	= 0;
		var tmp		= new String(this);
		var length	= tmp.length;
		for(var i=0; i<length; i++) { count += (escape(tmp.charAt(i)).length>4) ? 2 : 1 }
		return count;
	},
	subbyte: function(len) {
		if(this.isEmpty())	{ return '' }
		var count	= 0;
		var tmpCount= 0;
		var tmp		= new String(this);
		var length	= tmp.length;
		for(var i=0; i<length; i++)
		{
			tmpCount= (escape(tmp.charAt(i)).length>4) ? 2 : 1;
			if((count+tmpCount)>len) { return this.substring(0,i) }
			count += tmpCount;
		}
		return this;
	},
	toQueryParams: function(separator) {
		var match = this.trim().match(/([^?#]*)(#.*)?$/);
		if (!match) return { };

		return match[1].split(separator || '&').inject({ }, function(hash, pair) {
		  if ((pair = pair.split('='))[0]) {
			var key = decodeURIComponent(pair.shift());
			var value = pair.length > 1 ? pair.join('=') : pair[0];
			if (value != undefined) value = decodeURIComponent(value);

			if (key in hash) {
			  if (!Object.isArray(hash[key])) hash[key] = [hash[key]];
			  hash[key].push(value);
			}
			else hash[key] = value;
		  }
		  return hash;
		});
	}
});

// Number확장
Object.extend(Number.prototype, {
	currency: function(cipher) {
		number = String(this).trim();
		cipher = (cipher) ? cipher : 3;
		var result	= '';
		var length = number.length, index = (length%cipher), max = (length-cipher+1);
		index = (index==0) ? cipher : index;
		if(length<=cipher || cipher<1)	return number;
		result = number.substring(0,index);
		while(index<=max)
		{
			result	+= ',' + number.substring(index,index+3);
			index	+= cipher;
		}
		return result;
	},
	korean: function()
	{
		var rgNumber	= new Array('','일','이','삼','사','오','육','칠','팔','구');
		var rgRepeat	= new Array('','십','백','천');
		var rgUnit		= new Array('','만','억','조','경','해','자','양','구','간','정재극');

		var strNumber	= String(this).trim();
		var iUnitIndex	= Math.floor(strNumber.length/4);
		var iIndex		= (strNumber.length%4)-1;
		var iNumberIndex=0, iTmp=0;
		var strResult	= '';

		for(;iUnitIndex>=0; iUnitIndex--)
		{
			for(;iIndex>=0; iIndex--)
			{
				iTmp		=  Number(strNumber.charAt(iNumberIndex));
				strResult	+= (iTmp==1 && iIndex!=0) ? '' : rgNumber[iTmp];
				strResult	+= (iTmp==0) ? '' : rgRepeat[iIndex];
				iNumberIndex++;
			}
			iIndex=3;
			strResult += (iTmp==0 && Number(strNumber.substring(iNumberIndex-4,iNumberIndex))==0) ? '' : rgUnit[iUnitIndex] + ' ';
		}
		if(strResult.substring(strResult.length-1,strResult.length)==' ')
			strResult = strResult.substring(0,strResult.length-1);

		return strResult;
	}
});

// Date확장
Object.extend(Date.prototype,{
	getDayName: function(nIndex)
	{
		var rgDay= new Array('일','월','화','수','목','금','토');
		var day	 = (arguments.length==1) ? nIndex : this.getDay();
		return rgDay[day];
	},
	getTotalDay: function()
	{
		var year = this.getFullYear();
		var days = new Array(31, ((((year%4==0) && (year%100!=0)) || (year%400==0)) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
		return days[this.getMonth()];
	}
});

// Error확장
Object.extend(Error.prototype,{
	print: function()
	{
		alert('에러가 발생하였습니다!!\n이 페이지는 디버그 모드입니다.\n서비스중 이 경고창이 뜬다면 관리자에게 문의하세요.\n\n에러 : ' + this.toString() + '\n\n코드 : ' + ((_BROWSER.name=='explorer') ? (this.number & 0xFFFF) : (this.code) ? this.code : '없음') + '\n\n유형 : ' + this.name + '\n\n메세지 : ' + this.message);
	},
	exceptionToString : function(indent)
	{
		var frames, stacktrace, pos, i, msg, tmp;
		indent = indent || "";
		if(this instanceof Components.interfaces.nsIException)
		{
			stacktrace = "";
			frames = this.location;
			while (frames && frames.caller) 
			{
				stacktrace += indent+"  "+frames.name+"(<unknown>) at "+(frames.filename||"<unknown>")+":"+(frames.lineNumber||"<unknown>")+"\n";
				frames = frames.caller;
			}
			msg = this.filename+":"+this.lineNumber+"\n";
			if (this.inner)
			msg += indent+"Caused by:\n" + this.exceptionToString(this.inner, indent+"  ");
			return msg+indent+"Stacktrace:\n"+stacktrace;
		} 
		else if(this instanceof Error) 
		{
			tmp = this.stack.split("\n");
			frames = [];
			for (i = 0; i < tmp. length; i++) 
			{
				var m = tmp[i].lastIndexOf("@");
				frames[i] = [tmp[i].slice(0, m), tmp[i].slice(m+1)];
			}
			stacktrace = "";
			pos = this.fileName+":"+this.lineNumber;
			for (i = 0; i < frames.length && frames[i][1] != pos; i++);
			for (; i < frames.length-2; i++) { stacktrace += indent+"  "+frames[i][0] + " at "+frames[i][1]+"\n" }
			msg = indent+this.fileName+":"+this.lineNumber +"\n";
			if (this.reason) { msg += indent+"Caused by:\n" + this.exceptionToString(this.reason, indent+"  ") }
			return msg+indent+"Stacktrace:\n"+stacktrace;
		} 
		else if (this.code)
		{
			return indent+"Exception code: "+this.code+"\n"+(this.reason ? indent+"Caused by:\n" +			this.exceptionToString(this.reason,indent+"  ")+"\n":"");
		}
		else
		{	
			return indent+uneval(this);
		}
	},
	toString: function() { return _BROWSER.name=='explorer' ? this : this.exceptionToString('') }
});
if('Components' in window)	Components.interfaces.nsIException.toString = this.toString();
/* ▲ 클래스 및 확장 */


/* ▼ 전역 함수  */
function $(element)
{
	if(arguments.length > 1)
	{
		for (var i = 0, elements = [], length = arguments.length; i < length; i++)
			elements.push($(arguments[i]));
		return elements;
	}
	if(typeof element=='string')	{ element = document.getElementById(element) }
	if(element)
	{
		if('addEvent' in element)	{ return element }
		else						{ Object.extend(element,_item.event) }
	}	
	return element;
}

// 하나의 인자를 Array객체로 변환
function $A(iterable) 
{
	if (!iterable)			{ return [] }
	if (iterable.toArray)	{ return iterable.toArray() }
	else 
	{
		var results = [];
		for (var i = 0, length = iterable.length; i < length; i++)
			results.push(iterable[i]);
		return results;
	}
}

// 주기적 실행
var _PeriodicalExecuter = Class.create({
  initialize: function(callback, frequency) {
	this.callback = callback;
	this.frequency = frequency;
	this.currentlyExecuting = false;

	this.registerCallback();
  },
  registerCallback: function() {
	this.timer = setInterval(this.onTimerEvent.bind(this), this.frequency * 1000);
  },
  stop: function() {
	if (!this.timer) return;
	clearInterval(this.timer);
	this.timer = null;
  },
  onTimerEvent: function() {
	if (!this.currentlyExecuting) {
	  try {
		this.currentlyExecuting = true;
		this.callback(this);
	  } finally {
		this.currentlyExecuting = false;
	  }
	}
  }
});

// 순차적 실행
var _Try = {
  these: function() {
	var returnValue;
	for (var i = 0, length = arguments.length; i < length; i++) {
	  var lambda = arguments[i];
	  try {
		returnValue = lambda();
		if(!returnValue) break;
	  } catch (e) { returnValue=false; break; }
	}

	return returnValue;
  }
};

var _ENABLE	= function() { return true };
var _DISABLE= function() { return false };
/* ▲ 전역 함수 */ 


// 윈도우 관련
var _window = {};
Object.extend(_window,{
	open: function(name,url,width,height,policy,info)
	{
		name = name.replace(/[^a-zA-Z0-9_]/g,'');
		var strPolicy = 'height='+height+',width='+width;
		strPolicy += (!policy) ? 'status=no,toolbar=no,menubar=no,location=no,fullscreen=no,scrollbars=no,resizable=no,titlebar=no' : (','+policy);

		var popup = window.open(url,name,strPolicy);
		if(popup)
		{
			this.center(popup,width,height);
			popup.focus();
			if(info) { return popup }
		}
	},
	close: function(wnd)
	{
		if(!wnd) { wnd = window }
		wnd.close();
	},
	resize: function(width,height,wnd)
	{
		if(!wnd) { wnd = window }
		wnd.resizeTo(width,height);
	},
	move: function(x,y,wnd)
	{
		try
		{
			if(!wnd) { wnd = window }
			wnd.moveTo(x,y);			
		}
		catch(err)
		{
		}
	},
	moveresize: function(location,width,height,wnd)
	{
		if(!wnd) { wnd = window }
		wnd.location.href = location;
		this.resize(width,height,wnd);
	},
	moveclose: function(wnd,location,wnd_close)
	{
		if(!wnd)		{ wnd = window }
		if(!wnd_close)	{ wnd_close = window }

		wnd.location.href = location;
		wnd.focus();
		this.close(wnd_close);
	},
	center: function(wnd,width,height)
	{
		if(!wnd) { wnd = window }

		if(_BROWSER.name=='explorer')
		{
			var size = { width:width, height:height };
			var x = (screen.availWidth/2) - (size.width/2);
			var y = (screen.availHeight/2) - (size.height/2);
		}
		else
		{
			var size = { width:0, height:0 };
			size.width = wnd.outerWidth;
			size.height= wnd.outerHeight;
			var x = (screen.width - size.width) / 2; 
			var y = (screen.height - size.height) / 2;
		}

		this.move(x,y,wnd);
	}
});

// 다이얼로그 관련
var _dialog = {};
Object.extend(_dialog,{
	open: function(name,url,width,height,policy)
	{
		var strPolicy = 'dialogWidth:'+width+'px; dialogHeight:'+height+'px;';
		strPolicy += (!policy) ? 'help:No; resizable:No; status:No; scroll:No, center:Yes' : policy;
		return window.showModalDialog(url,name,strPolicy);
	}
});

// 오브젝트 관련
var _object = {};
Object.extend(_object,{
	count: 0,
	find: function(id) { return (_BROWSER.name=='explorer') ? document[id] : window[id] },
	flash: function(id,url,width,height,opt)
	{
		var item	= null;
		var params	= { wmode:"opaque", bgcolor:"#FFFFFF" };
		opt = (arguments[4]) ? opt.toQueryParams() : {};
		for(item in opt)
		{
			params[item] = opt[item];
		}

		if(_BROWSER.name=="explorer")
		{
			document.writeln("<object id=\""+id+"\"");
			document.writeln(" type=\"application/x-shockwave-flash\"");
			document.writeln(" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"");
			document.writeln(" codebase=\"http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab\"");
			document.writeln(" width=\""+width+"\" height=\""+height+"\">");
			document.writeln("<param name=\"movie\" value=\"" + url + "\" />"); 
			document.writeln("<param name=\"quality\" value=\"high\" />");
			document.writeln("<param name=\"menu\" value=\"false\" />");
			document.writeln("<param name=\"allowScriptAccess\" value=\"sameDomain\" />");
			document.writeln("<param name=\"allowscale\" value=\"false\" />");
			document.writeln("<param name=\"swliveconnect\" value=\"false\" />");
			document.writeln("<param name=\"wmode\" value=\""+params.wmode+"\" />");
			document.writeln("<param name=\"bgcolor\" value=\""+params.bgcolor+"\" />");
			for(item in params)
			{
				document.writeln("<param name=\""+item+"\" value=\""+params+"\" />");
			}
			document.writeln("</object>");
		}
		else
		{
			document.writeln("<embed src=\"" + url + "\" id=\""+id+"\"");
			document.writeln(" type=\"application/x-shockwave-flash\"");
			document.writeln(" pluginspage=\"http://www.macromedia.com/go/getflashplayer\"");		
			document.writeln(" menu=\"false\" width=\"" + width + "\" height=\"" + height + "\"");
			document.writeln(" quality=\"high\" allowScriptAccess=\"sameDomain\"");
			document.writeln(" swliveconnect=\"false\" allowscale=\"false\"");
			document.writeln(" wmode=\""+params.wmode+"\"");
			document.writeln(" bgcolor=\""+params.bgcolor+"\"");
			for(item in params)
			{
				document.writeln(" "+item+"=\""+params[item]+"\"");
			}
			document.writeln(" />");
			window[id] = document.getElementById(id);
		}
		_object.count++;

		if(_object.count==1)
		{
			if(typeof window.onbeforeunload=="function")
			{
				var oldBeforeUnload = window.onbeforeunload;
				window.onbeforeunload = function()
				{
					_object.prepunload.call(_object);
					oldBeforeUnload();
				}
			}
			else
			{
				window.onbeforeunload = _object.prepunload.bind(_object);
			}
		}
	},
	prepunload: function()
	{
		if(typeof window.onunload=="function")
		{
			var oldUnload = window.onunload;
			window.onunload = function() 
			{
				_object.clean();
				oldUnload();
			}
		}
		else
		{
			window.onunload = this.clean;
		}
	},
	clean: function()
	{
		if (window.opera || !document.all) return;
		var objects = document.getElementsByTagName("OBJECT");
		for (var i=0; i<objects.length; i++) 
		{
			objects[i].style.display = "none";
			for (var x in objects[i]) 
			{
				if (typeof objects[i][x]=="function")
				{
					objects[i][x] = function(){};
				}
			}
		}
	}
});


/* ▼ HTTP */
var _http = {};
Object.extend(_http,{
	encodeURI: function(data)
	{
		var url = data.substring(0,data.indexOf('?'));
		var get = data.substring(data.indexOf('?')+1,data.length);
		var strResult='';
		var rgData = get.toQueryParams();

		for(var item in rgData)
		{
			rgData[item]= encodeURIComponent(rgData[item]);
			strResult	+=item + "=" + rgData[item] + "&";
		}
		if(!strResult.isEmpty()) { strResult = strResult.substring(0,strResult.length-1) }
		if(!url.isEmpty()) { url += '?' }
		return url + strResult;
	},
	decodeURI: function(data)
	{
		var url = data.substring(0,data.indexOf('?'));
		var get = data.substring(data.indexOf('?')+1,data.length);
		var strResult ='';
		var rgData = get.toQueryParams();

		for(var item in rgData)
		{
			rgData[item]= decodeURIComponent(rgData[item]);
			strResult	+=item + "=" + rgData[item] + "&";
		}
		if(!strResult.isEmpty()) { strResult = strResult.substring(0,strResult.length-1) }
		if(!url.isEmpty()) { url += '?' }
		return url + strResult;
	}
});
_http.data = Class.create({
	address: '',
	data: {},
	initialize: function(url)
	{
		if(url.indexOf('?')!=-1)
		{
			this.address= url.substring(0,url.indexOf('?'));
			var get		= url.substring(url.indexOf('?')+1,url.length);
			this.data	= get.toQueryParams();
		}
		else { this.address = url }
	},
	push: function(data)
	{
		Object.extend(this.data,data.toQueryParams());
	},
	pop: function(search)
	{
		if(search in this.data) { delete this.data[search] }
	},
	get: function(search)
	{
		return (search in this.data) ? this.data[search] : '';
	},
	setURL: function(url)	{ this.address = url },
	getURL: function()		{ return this.address },
	getData: function()
	{
		var rgData		= {};
		Object.extend(rgData,this.data);
		var strResult	= '';
		for(var item in rgData)
		{
			rgData[item]= encodeURIComponent(rgData[item]);
			strResult	+=item + "=" + rgData[item] + "&";
		}
		if(!strResult.isEmpty()) { strResult = strResult.substring(0,strResult.length-1) }
		return strResult;
	},
	getAll: function()
	{
		var url=this.address;
		var get=this.getData();
		if(!get.isEmpty())	{ url += '?' }
		else				{ return url }
		return url + get;
	},
	getDomain: function()
	{
		var nFind	= this.address.substring(this.address.indexOf("://")+3,this.address.length);
		var nGap	= this.address.length-nFind.length;
		return (nFind.indexOf("/")<0) ? this.address : this.address.substring(0,nFind.indexOf("/")+nGap);
	}
});
/* ▲ HTTP */


/* ▼ 쿠키 */
var _cookie = {};
Object.extend(_cookie,{
	add: function(name,value)
	{
		// 쿠키이름, 쿠키값, 유효시간, 경로, 도메인, 보안
		var argv	= arguments;
		var argc	= arguments.length;
		var expires = (2<argc) ? argv[2] : null;
		var path	= (3<argc) ? argv[3] : null;
		var domain	= (4<argc) ? argv[4] : null;
		var secure	= (5<argc) ? argv[5] : false;
		if(expires)
		{
			var now		= new Date();
			now.setDate(now.getDate() + parseInt(expires));
		}
		document.cookie =	name + '=' + escape(value) +
							((expires == null)	? '' : ('; expires=' + now.toGMTString())) +
							((path == null)		? '' : ('; path=' + path)) +
							((domain == null)	? '' : ('; domain=' + domain)) +
							((secure == true)	? '; secure' : '');
	},
	remove: function(name)
	{
		var expDate = new Date();
		expDate.setDate(expDate.getDate()-1);
		document.cookie = name + '=; expires=' + expDate.toGMTString() + ';';
	},
	get: function(name)
	{
		name += "=";
		var iStart=0, iFind, iEnd;
		while (iStart<=document.cookie.length)
		{
			iFind = iStart + name.length;
			if(document.cookie.substring(iStart,iFind)==name)
			{
				if((iEnd=document.cookie.indexOf(';',iFind))==-1) { iEnd = document.cookie.length }
				return unescape(document.cookie.substring(iFind, iEnd));
			}
			iStart = document.cookie.indexOf(' ',iStart)+1;
			if(iStart==0) { break }
		}
		return '';
	},
	getNames: function()
	{
		var rgName = Array();
		var rgCookies = document.cookie.split(';');
		var rgField;
		var iIndex = 0;
		for(var i=0; i<rgCookies.length; i++)
		{
			if(rgCookies[i]=='') { continue }
			rgField = rgCookies[i].split('=');
			if(rgField[0]!='')
			{
				rgName[iIndex++] = rgField[0];
			}
		}
		return rgName;
	},
	free: function()
	{
		var expDate = new Date();
		expDate.setDate(expDate.getDate()-1);
		var rgCookies = document.cookie.split(';');
		var rgField;		
		for(var i=0; i<rgCookies.length; i++)
		{
			if(rgCookies[i]=='') { continue }
			rgField = rgCookies[i].split('=');
			if(rgField[0]!='')
			{
				document.cookie = rgField[0] + '=; expires=' + expDate.toGMTString() + ';';
			}
		}
	},
	isEnable: function() { return navigator.cookieEnabled }
});
/* ▲ 쿠키 */


/* ▼ XMLHttpRequest */
/*
 *  data[type,params]		type:(POST or GET), params:id=looche3&pw=1234
 *  callback[self, overall, prepare, loading, loaded, interactive, complete, error]
 *	config[autorun,language,charset,contentType]	language:ko, charset:UTF-8, contentType:application/x-www-form-urlencoded
 */
var _xhr = Class.create({
	initialize: function(url,data,config,callback)
	{
		this.objRequest	= null;
		this.config		= {autorun:true, language:'ko', charset:'UTF-8', contentType:'application/x-www-form-urlencoded'};
		this.setConfig(url,data,config,callback);
	},
	setConfig: function(url,data,config,callback)
	{
		this.url		= url;
		this.data		= {type:'GET', params:''};
		this.callback	= {self:null};
		if(data)
		{
			if('type' in data)	{ this.data.type = data.type }
			if('params' in data){ this.data.params= data.params }
		}
		if(config)
		{
			if('autorun' in config)		{ this.config.autorun	= config.autorun }
			if('language' in config)	{ this.config.language	= config.language}
			if('charset' in config)		{ this.config.charset	= config.charset }
			if('contentType' in config)	{ this.config.contentType = config.contentType}
		}
		if(callback)
		{
			if('self' in callback)	{ this.callback.self = callback.self }
			if('error' in callback)	{ this.callback.error= callback.error}
			if('overall' in callback)
			{
				this.callback.prepare	= callback.overall;
				this.callback.loading	= callback.overall;
				this.callback.loaded	= callback.overall;
				this.callback.interactive=callback.overall;
				this.callback.complete	= callback.overall;
			}
			else
			{
				if('prepare' in callback)	{ this.callback.prepare	= callback.prepare	}
				if('loading' in callback)	{ this.callback.loading	= callback.loading	}
				if('loaded' in callback)	{ this.callback.loaded	= callback.loaded	}
				if('interactive' in callback){this.callback.interactive = callback.interactive }
				if('complete' in callback)	{ this.callback.complete= callback.complete }
			}
		}
		if(this.config.autorun) { this.send() }
	},
	getXMLHttpRequest: function() 				// XMLHTTP객체 리턴
	{
		if (window.ActiveXObject) {
			try { return new ActiveXObject("Msxml2.XMLHTTP") } 
			catch(e) {
				try { return new ActiveXObject("Microsoft.XMLHTTP") } 
				catch(e1) { return false }
			}
		} 
		else if (window.XMLHttpRequest)	{ return new XMLHttpRequest() }
		else							{ return false }
	},
	send: function()
	{
		if(!this.objReqeust)
		{
			this.objRequest = this.getXMLHttpRequest();
		}
		else if(this.objRequest.readyState)
		{
			this.objRequest.abort();
		}

		var url = this.url;
		if(this.data.type=='GET' && !this.data.params.isEmpty())
			url += '?' + _http.encodeURI(this.data.params);

		this.objRequest.open(this.data.type, url, true);
		this.objRequest.setRequestHeader("Accept-Language",this.config.language);
		this.objRequest.setRequestHeader("Content-Encoding",this.config.charset);
		this.objRequest.setRequestHeader('Content-Type', this.config.contentType);	
		this.objRequest.onreadystatechange = this.OnStatechange.bind(this);
		this.objRequest.send((this.data.type=="POST")?this.data.params:null);

		//this.tmWait = window.setTimeout(this.OnError.bind(this,null),4000);
	},
	tmWait: null,
	OnError: function(request)
	{
		if(request && request.status==200)	{ return; }
		if('error' in this.callback)
		{
			if(!request) { request={status:"000"} }
			if(this.callback.self)	{ this.callback.error.call(this.callback.self,request.status); }
			else					{ this.callback.error(request.status); }
		}
		else { alert('페이지를 열수 없습니다.\n\n잠시 후 이용하시기 바랍니다.') }
		this.objRequest.abort();
	},
	OnStatechange: function()
	{
		var request = this.objRequest;
		switch(request.readyState)
		{
			case 0:
				if('prepare' in this.callback)
				{
					if(this.callback.self)	{ this.callback.prepare.call(this.callback.self,request) }
					else					{ this.callback.prepare(request) }
				}
				break;
			case 1:
				if('loading' in this.callback)
				{
					if(this.callback.self)	{ this.callback.loading.call(this.callback.self,request) }
					else					{ this.callback.loading(this.objRequest) }
				}
				break;
			case 2:
				if('loaded' in this.callback)
				{
					if(this.callback.self)	{ this.callback.loaded.call(this.callback.self,request) }
					else					{ this.callback.loaded(this.objRequest) }
				}
				break;
			case 3:
				if('interactive' in this.callback)
				{
					if(this.callback.self)	{ this.callback.interactive.call(this.callback.self,request) }
					else					{ this.callback.interactive(this.objRequest) }
				}
				break;
			case 4:
				//window.clearTimeout(this.tmWait);
				//this.tmWait = null;
				if(this.objRequest.status==200)
				{
					if('complete' in this.callback)
					{
						if(this.callback.self)	{ this.callback.complete.call(this.callback.self,request) }
						else					{ this.callback.complete(this.objRequest) }
					}
				}
				else { this.OnError(request) }
				break;
		}
	}
});
/* ▲ XMLHttpRequest */


/* ▼ XML,XSLT */
var _xml = {};
Object.extend(_xml,{
	getElement: function(node,element,index)
	{
		var item = null;
		if(!(item=node.getElementsByTagName(element).item(index)))
		{
			element	= element.replace('xsl:','');
			item	= node.getElementsByTagName(element)[index];
		}

		try { return item; }
		finally { item=null; }
	},
	getElements: function(node,element)
	{
		var item=null;
		if(!(item=node.getElementsByTagName(element).item(0)))
		{
			element	= element.replace('xsl:','');
			return node.getElementsByTagName(element);
		}
		return node.getElementsByTagName(element);
	}
});

var _xslt = {};
Object.extend(_xslt,{
	parseXML: function(obj, xml, xsl)
	{
		try { obj.innerHTML = xml.transformNode(xsl) }
		catch (e)
		{
			obj.innerHTML = '';
			var xsltProc = new XSLTProcessor();
			xsltProc.importStylesheet(xsl);
			var fragment = xsltProc.transformToFragment(xml, document);
			obj.appendChild(fragment);
		}
		return obj.childNodes.length;
	}
});
/* ▲ XML,XSLT */


/* ▼ ITEM Framework */
var _item = {};

	// 최상위 노드
	_item.root = null;

	/* ▼ 테이블 롤오버 */
	_item.table_rollover = function(table,outColor,overColor)
	{
		var nodeTable = Object.extend(table,_item.dom);
		var rgTR	= nodeTable.getElements('TR');
		var iLength	= rgTR.length;
		var color	= {out:(outColor) ? outColor : '#FFF', over:(overColor) ? overColor : '#F4F4F4'};
		for(var i=1; i<iLength; i++)
		{
			Object.extend(rgTR[i],_item.dom);
			rgTR[i].onmouseover = function()
			{
				if(_BROWSER.name=='explorer')
				{
					var rgTD	= this.getElements('TD');
					var iLength	= rgTD.length;
					for(var i=0; i<iLength; i++) { rgTD[i].style.backgroundColor = color.over }
				}
				else { this.style.backgroundColor = color.over }
			}
			rgTR[i].onmouseout = function()
			{
				if(_BROWSER.name=='explorer')
				{
					var rgTD	= this.getElements('TD');
					var iLength	= rgTD.length;
					for(var i=0; i<iLength; i++) { rgTD[i].style.backgroundColor = color.out }
				}
				else { this.style.backgroundColor = color.out }
			}
		}
	}
	/* ▲ 테이블 롤오버 */

	/* ▼ 이미지 롤오버 */
	_item.rollover = {};
	Object.extend(_item.rollover,{
		over: function()
		{
			var info = _item.rollover.getInfo.call(this);
			if(info.position<0)
			{
				this.src = this.src.substring(0,(this.src.lastIndexOf('/')+1)) + info.name +'_on' + this.src.substring(this.src.lastIndexOf('.'));
			}
		},
		out: function()
		{
			var info = _item.rollover.getInfo.call(this);	
			if(info.position>-1)
			{
				this.src = this.src.substring(0,(this.src.lastIndexOf('/')+1)) + info.name.replace('_on','') + this.src.substring(this.src.lastIndexOf('.'));
			}
		},
		getInfo: function()
		{
			var name= this.src.substring((this.src.lastIndexOf('/')+1),this.src.lastIndexOf('.'));
			return {name:name, position:name.lastIndexOf('_on')};
		}
	});
	var _out = function(obj) { _item.rollover.out.call(obj) };
	var _over= function(obj) { _item.rollover.over.call(obj); if(!obj.onmouseout) { obj.onmouseout=_item.rollover.out.bind(obj) } };
	/* ▲ 이미지 롤오버 */

	/* ▼ 이벤트 */
	_item.event = {
		addEvent : function(eventType)
		{		
			if(this.attachEvent)
			{
				eventType = 'on' + eventType;
				for(var i=1; i<arguments.length; i++) { this.attachEvent(eventType,arguments[i]) }
			}
			else
			{
				for(var i=1; i<arguments.length; i++) { this.addEventListener(eventType,arguments[i],true) }
			}
		},
		removeEvent : function(eventType)
		{
			if(this.detachEvent)
			{
				eventType = 'on' + eventType;
				for(var i=1; i<arguments.length; i++) { this.detachEvent(eventType,arguments[i]) }
			}
			else
			{
				for(var i=1; i<arguments.length; i++) { this.removeEventListener(eventType,arguments[i],true) }
			}				
		}
	}
	Object.extend(window,_item.event);
	Object.extend(document,_item.event);
	/* ▲ 이벤트 */

	/* ▼ DOM */
	_item.dom = {
		addElement : function(node,position,compNode)
		{
			switch (position)
			{
				case -1:
					if(compNode) { this.insertBefore(node,compNode) }
					else
					{
						if(this.childNodes.length<1)	{ this.appendChild(node) }
						else							{ this.insertBefore(node,this.firstChild) }
					}
					break;
				case 1:
					if(compNode)
					{
						if(compNode==this.lastChild)	{ this.appendChild(node) }
						else							{ this.insertBefore(node,compNode.nextSibling) }
					}
					else { this.appendChild(node) }
					break;
			}
			return node;
		},
		createElement : function(element,position)
		{
			switch (position)
			{
				case -1:
				{
					if(this.childNodes.length<1)	{ this.appendChild(document.createElement(element)) }
					else							{ this.insertBefore(document.createElement(element),this.firstChild) }
				}
				case 1:
				{
					this.appendChild(document.createElement(element));
				}
			}
			return element;
		},
		getElements : function(element)
		{
			var rgItem	= this.getElementsByTagName(element);
			var rgResult= Array();
			var pos=null, element=null;

			for(var i=0; i<rgItem.length; i++)
			{
				if(!(element=rgItem.item(i)))
				{
					pos = element.indexOf(':');
					if(pos>-1) { element = element.substring(pos+1,pos.length) }
					element = rgItem(element)[i];
				}
				rgResult.push(element);
			}

			try { return rgResult; }
			finally { rgResult=null; }
		},
		getElement : function(element, index)
		{
			if(!(objItem=this.getElementsByTagName(element).item(index)))
			{
				var pos = element.indexOf(':');
				if(pos>-1) { element = element.substring(pos+1,pos.length) }
				objItem = this.getElementsByTagName(element)[index];
			}

			try { return objItem; }
			finally { objItem=null; }
		},
		remove : function() { return this.parentNode.removeChild(this) },
		removeChildAll : function()
		{
			if(this.childNodes.length<1) { return }
			for(var i=0; i<this.childNodes.length; i++)
			{
				this.removeChild(this.childNodes[i]);
				i--;
			}
		},
		removeGarbage : function()
		{
			for(var i=0; i<this.childNodes.length; i++)
			{
				if(this.childNodes[i].tagName==null || this.childNodes[i].tagName==undefined)
				{
					this.removeChild(this.childNodes[i]);
					i--;
				}
			}
		}
	}
	/* ▲ DOM */

	/* ▼ GUI */
	_item.gui = {
		getStyle : function(property)
		{
			var value	= null;
			var dv		= document.defaultView;
			
			if(property=='opacity' && this.filters)
			{
				value = 1;
				try {
					value = this.filters.item('alpha').opacity/100;	
				} catch(e) {}
			}
			else if(this.style[property])	{ value = this.style[property] }
			else if(this.currentStyle && this.currentStyle[property])	{ value = this.currentStyle[property] }
			else if(dv && dv.getComputedStyle)
			{
				var converted = '';
				for(var i=0, len=property.length; i<len; ++i)
				{
					converted+= (property.charAt(i)==property.charAt(i).toUpperCase()) ? ('-' + property.charAt(i).toLowerCase()) : property.charAt(i);
				}
				if(dv.getComputedStyle(this,'').getPropertyValue(converted))
				{
					value = dv.getComputedStyle(this,'').getPropertyValue(converted);
				}
			}
			if(property.indexOf('border')>-1 && value=='medium')	{ value = '1px' }

			return value;
		},
		getXY : function()
		{
			if(this.parentNode==null || this.style.display=='none')	{ return false }

			var parent=null, pos=[], box;
			if(document.getBoxObjectFor)		// gecko엔진 기반
			{
				box = document.getBoxObjectFor(this);
				pos = [box.x, box.y];				
			}
			else								// 그 외 브라우저
			{
				pos		= [this.offsetLeft, this.offsetTop];
				parent	= this.offsetParent;
				if(parent!=this)
				{
					while(parent)
					{
						pos[0]	+= parent.offsetLeft;
						pos[1]	+= parent.offsetTop;
						parent	 = parent.offsetParent;
					}
				}
				// 오페라와 사파리의 'absolute' position의 경우
				// body의 offsetTop을 잘못 계산하므로 보정
				if(_BROWSER.name.indexOf('opera')!=-1 || _BROWSER.name.indexOf('safari')!=-1 && this.getStyle('position')=='absolute') { pos[1]	-= document.body.offsetTop }
			}
			parent = (this.parentNode) ? this.parentNode : null;
			while(parent && parent.tagName!='BODY' && parent.tagName!='HTML')
			{
				pos[0]	-= parent.scrollLeft;
				pos[1]	-= parent.scrollTop;
				parent = (parent.parentNode) ? parent.parentNode : null;
			}
			
			return {x: pos[0], y: pos[1]};
		},
		getX : function() { return this.getXY().x },
		getY : function() { return this.getXY().y },
		getBound : function()
		{
			var pos = this.getXY();
			return { x: pos.x, y: pos.y, width: this.offsetWidth, height:this.offsetHeight }
		},
		setXY : function(x, y)
		{
			var pos = this.getXY();
			if(!pos) { return false }
			var position = this.getStyle('position');
			if(!position || position=='static') { this.style.position = 'relative' }
			var delta = { x: parseInt(this.getStyle('left'),10), y: parseInt(this.getStyle('top'),10) }
			if(isNaN(delta.x)) delta.x = 0;
			if(isNaN(delta.y)) delta.y = 0;
			if(x!=null) this.style.left = (x-pos.x+delta.x)+'px';
			if(y!=null) this.style.top = (y-pos.y+delta.y)+'px';
			return true;
		},
		getBugSize : function()
		{
			var rgBound = this.getBound();
			var size = { width: 0, height:0 }
			size.width	+= parseInt(this.getStyle('paddingLeft'));
			size.width	+= parseInt(this.getStyle('paddingRight'));
			size.width	+= parseInt(this.getStyle('borderLeftWidth'));
			size.width 	+= parseInt(this.getStyle('borderRightWidth'));
			size.height += parseInt(this.getStyle('paddingTop'));
			size.height += parseInt(this.getStyle('paddingBottom'));
			size.height += parseInt(this.getStyle('borderTopWidth'));
			size.height += parseInt(this.getStyle('borderBottomWidth'));
			return size;
		}
	}
	/* ▲ GUI */

	/* ▼ Layer */
	_item.layer = {};
	Object.extend(_item.layer,_item.gui);
	Object.extend(_item.layer,{
		move : function(x,y){ return this.setXY(x,y) },
		resize: function(width, height)
		{
			if(width!=null)	{ this.style.width = width + 'px' }
			if(height!=null){ this.style.height	= height + 'px' }
		},
		show : function()	{ this.style.display = 'block'	},
		//hidden : function()	{ this.style.display = 'none'	},
		behind : function()	{ this.style.display = 'none'	},
		toggle : function() { this.style.display = (this.getStyle('display').indexOf('none')>-1) ? 'block' : 'none' },
		opacity : function(fNumber)
		{
			if(this.filters)	{ this.style.filter = 'alpha(opacity=' + (fNumber*100).toString() + ')' }
			else				{ this.style.opacity = fNumber }
		}
	});
	/* ▲ Layer */

	/* ▼ Selectbox */
	_item.selectbox_convertAll = function(node)
	{
		if(arguments.length<1) { var node = document.body }
		var DIV		= null;
		Object.extend(node,_item.dom);
		var rgSelect= node.getElements('SELECT');
		for(var i=0; i<rgSelect.length; i++)
		{
			if(rgSelect[i].className!='g_hidden') { continue }
			DIV = document.createElement('DIV');
			DIV.setAttribute('id',rgSelect[i].getAttribute('id'));
			rgSelect[i].parentNode.insertBefore(DIV,rgSelect[i]);
			Object.extend(DIV,_item.selectbox);
			DIV.initialize(rgSelect[i]);
		}
	}
	_item.selectbox_converts = function()
	{
		if(arguments.length<1) { return }
		var DIV = null;
		for(var i=0; i<arguments.length; i++)
		{
			if(arguments[i].className!='g_hidden') { continue }
			DIV = document.createElement('DIV');
			DIV.setAttribute('id',arguments[i].getAttribute('id'));
			arguments[i].parentNode.insertBefore(DIV,arguments[i]);
			Object.extend(DIV,_item.selectbox);
			DIV.initialize(arguments[i]);
		}
	}
	_item.selectbox = {};
	Object.extend(_item.selectbox,{
		initialize: function(selectbox)
		{
			if(selectbox.tagName!='SELECT') { return }
			var obj = this;
			Object.extend(this,_item.event);
			Object.extend(this,_item.layer);
			this.className	= 'g_selectbox';
			this.setAttribute('id',selectbox.getAttribute('id'));

			var INPUT = document.createElement('INPUT');
			INPUT.setAttribute('type','hidden');
			INPUT.setAttribute('name',selectbox.getAttribute('name'));
			this.nodeInput	= this.appendChild(INPUT);

			this.nodeText	= this.appendChild(document.createElement('DIV'));
			this.nodeText.className	= 'value';

			this.nodeList	= Object.extend(_item.root.insertBefore(document.createElement('DIV'),_item.root.lastChild),_item.layer);
			Object.extend(this.nodeList,_item.dom).removeGarbage();
			this.nodeList.className	= 'g_selectbox_list';
			this.nodeList.parent = this;

			Object.extend(selectbox,_item.dom);
			selectbox.removeGarbage();
			var text	= '';
			var rgOption= selectbox.getElements('OPTION');
			for(var i=0; i<rgOption.length; i++)
			{
				text = (rgOption[i].childNodes.length>0) ? rgOption[i].childNodes[0].nodeValue : '';
				var selected = rgOption[i].getAttribute('selected');
				if(selected==true || selected=='selected')
				{
					this.selected = this.addOption(null,rgOption[i].getAttribute('value'),text);
				}
				else
				{
					this.addOption(null,rgOption[i].getAttribute('value'),text);
				}
			}

			this.nodeButton	= this.appendChild(document.createElement('DIV'));			

			if(this.selected) { this.setText(this.selected.text) }
			else if(this.nodeList.childNodes.length>0)
			{
				this.selected = this.nodeList.firstChild;
				this.setText(this.selected.text);
			}

			if(this.selected) { this.setValue(this.selected.value) }
			if('onchange' in selectbox) { this.OnUpdate = selectbox.onchange; selectbox.onchange=null }
			selectbox.parentNode.removeChild(selectbox);

			var rgBound		= this.getBound();
			var rgBound_list= this.nodeList.getBound();
			if((_item.root.scrollTop+_item.root.getBound().height-(rgBound.height+rgBound_list.height+100))>rgBound.y)
			{
				this.flow = 'down';
				this.nodeButton.className = 'open';
			}
			else
			{
				this.flow = 'up';
				this.nodeButton.className = 'close';
			}

			this.close();
		},
		selected: null,
		width: 0,
		widthMargin: 0,
		flow: 'down',
		view_count: 8,
		zIndex: null,
		setText: function(text) { this.nodeText.innerHTML = text },
		getText: function() { return this.nodeText.innerHTML },
		setValue: function(value)
		{
			this.nodeInput.setAttribute('value',value);
			if('OnUpdate' in this && this.OnUpdate) { this.OnUpdate(value) }
		},
		getValue: function() 
		{ 
			if(this.nodeInput.getAttribute('value')==null){	return '';	}
			return this.nodeInput.getAttribute('value'); 	
		},
		getLength: function(){ return this.nodeList.childNodes.length },
		addOption: function(pos,value,text)
		{
			var width	= text.getWidth();
			if(this.width<width)
			{
				this.width = width+this.widthMargin;
				this.style.width = (this.width+27).toString() + 'px';
				this.nodeList.style.width = (this.width+27).toString() + 'px';
			}

			var node = Object.extend(document.createElement('DIV'),_item.option);
			node.appendChild(document.createTextNode(text));
			node.text = text;
			node.value= value;

			if(pos==null || this.nodeList.childNodes.length<1 || this.nodeList.childNodes.length<pos)	
			{ this.nodeList.appendChild(node) }
			else if(pos==0)	{ this.nodeList.insertBefore(node,this.nodeList.firstChild) }
			else			{ this.nodeList.insertBefore(node,this.nodeList.childNodes[(pos+1)]) }

			if(this.mode=="open" && this.getLength()==this.view_count)
			{
				this.nodeList.style.height	= (Object.extend(this.nodeList.childNodes[0],_item.gui).getBound().height*this.view_count+9) + 'px';
				this.nodeList.style.overflow= 'auto';
			}

			try { return node; }
			finally { node=null; }
		},
		removeOption: function() {},
		removeOptionAll: function() 
		{
			this.nodeList.removeChildAll();
			this.nodeInput.setAttribute("value","");
			this.setText("");
		},
		select: function(id)
		{
			var rgList	= this.nodeList.getElements("DIV");
			var length	= rgList.length;
			for(var i=0; i<length; i++)
			{
				if(rgList[i].value==id)
				{
					rgList[i].onclick();
					return;
				}
			}
		},
		onclick: function()
		{
			if(this.mode=='open')	{ this.close()	}
			else					{ this.open()	}
		},
		open: function(params)
		{
			if(this.mode!='open')
			{
				this.mode = 'open';
				this.nodeList.show();

				if(this.getLength()>this.view_count)
				{
					this.nodeList.style.height	= (Object.extend(this.nodeList.childNodes[0],_item.gui).getBound().height*this.view_count+9) + 'px';
					this.nodeList.style.overflow= 'auto';
				}

				var rgBound		= this.getBound();
				this.flow = 'down';
				this.nodeList.move(rgBound.x,(rgBound.y+rgBound.height));
				this.nodeList.className		= 'g_selectbox_list';
				this.nodeButton.className	= 'open';
			}
			if(this.zIndex && _item.root==this.nodeList.parentNode)
			{
				_item.root.parentNode.appendChild(this.nodeList);
				this.nodeList.style.zIndex = this.zIndex;
			}

			if(!('tmpBind' in this))
				this.tmpBind = this._blur.bindAsEventListener(this);

			document.addEvent('click',this.tmpBind);
			window.addEvent('resize',this.tmpBind);

			if('OnOpen' in this)	this.OnOpen(params);
		},
		close: function(type)
		{
			if(this.mode!='close')
			{
				this.nodeButton.className = (this.flow=='down') ? 'close' : 'open';
				this.mode = 'close';
				this.nodeList.behind();
			}

			if(!('tmpBind' in this))
				this.tmpBind = this._blur.bindAsEventListener(this);

			document.removeEvent('click',this.tmpBind);
			window.removeEvent('resize',this.tmpBind);

			if('OnClose' in this && type!='default') { this.OnClose(); }
		},
		_blur: function(Event)
		{
			if(this.mode=='close') { return }

			var rgPointer	= _event.pointer(Event);
			var rgBound		= this.getBound();
			var rgBound_list= this.nodeList.getBound();

			if((rgPointer.x>=rgBound.x && rgPointer.x<=(rgBound.x+rgBound.width) && rgPointer.y>=rgBound.y && rgPointer.y<=(rgBound.y+rgBound.height)) || (rgPointer.x>=rgBound_list.x && rgPointer.x<=(rgBound_list.x+rgBound_list.width) && rgPointer.y>=rgBound_list.y && rgPointer.y<=(rgBound_list.y+rgBound_list.height)))
				return;

			this.close();
		}
	});
	_item.option = {};
	Object.extend(_item.option,{
		value:	'',
		text:	'',
		onclick: function(event)
		{
			var parent = this.parentNode.parent;
			if(parent)
			{
				parent.selected = this;
				if('setText' in parent)		parent.setText(this.text);
				parent.setValue(this.value);
				if('OnChange' in parent)	parent.OnChange(this);
				parent.close();
			}
		},
		onmouseover: function(event)
		{
			var parent = this.parentNode.parent;
			this.className = 'select';
			if(parent) { if('OnMouseOver' in parent) { parent.OnMouseOver(event,this)} }
		},
		onmouseout: function() { this.className = '' }
	});
	/* ▲ Selectbox */

	/* ▼ Suggest */
	_item.suggest = {};
	Object.extend(_item.suggest,_item.selectbox);
	Object.extend(_item.suggest,{
		initialize: function(nodeList)
		{
			var obj = this;
			
			Object.extend(this,_item.event);
			Object.extend(this,_item.layer);
			this.className	= 'g_selectbox';
			var nodeSelected = Object.extend(this,_item.dom).getElement('INPUT',0);
	
			if('onchange' in this) { this.OnUpdate = function(value) { eval(this.onchange) } }

			var INPUT = document.createElement('INPUT');
			INPUT.setAttribute('type','hidden');
			INPUT.setAttribute('name',this.getAttribute('name'));
			this.setAttribute('name','');
			this.nodeInput	= this.appendChild(INPUT);

			var INPUT = document.createElement('INPUT');
			INPUT.setAttribute('type','text');
			INPUT.setAttribute('name',this.nodeInput.getAttribute('name')+'_text');
			if('OnKeyDown' in this)	INPUT.onkeydown	= this.OnKeyDown.bindAsEventListener(this);
			if('OnKeyUp' in this)	INPUT.onkeyup	= this.OnKeyUp.bindAsEventListener(this);
			if('OnFocus' in this)	INPUT.onfocus	= this.OnFocus.bindAsEventListener(this);
			if('OnBlur' in this)	INPUT.onblur	= this.OnBlur.bindAsEventListener(this);
			this.nodeSearch = this.appendChild(INPUT);
			this.nodeSearch.className = 'g_selectbox_input';

			if(nodeList)
			{
				this.modeView	= 'fix';
				this.nodeList	= Object.extend(nodeList,_item.layer);
				this.nodeList.className	= 'g_selectbox_list';
				this.nodeList.parent = this;

				this.open = function(params) { if('OnOpen' in this)	this.OnOpen(params) };
				this.close= function(type) { if('OnClose' in this && type!='default')	this.OnClose() };
			}
			else
			{
				this.nodeList	= Object.extend(_item.root.insertBefore(document.createElement('DIV'),_item.root.lastChild),_item.layer);
				this.nodeList.className	= 'g_selectbox_list';
				this.nodeList.style.overflow = 'auto';
				this.nodeList.parent = this;

				this.nodeButton	= this.appendChild(document.createElement('DIV'));
				this.nodeButton.onclick = function()
				{
					if(obj.mode=='open')	{ obj.close()	}
					else					{ obj.open()	}
				}

				var rgBound		= this.getBound();
				var rgBound_list= this.nodeList.getBound();

				this.nodeList.style.width = ((!(_BROWSER.name=='explorer' && _BROWSER.version<7)) ? (rgBound.width-2) : rgBound.width) + 'px';

				if((_item.root.scrollTop+_item.root.getBound().height-(rgBound.height+rgBound_list.height+100))>rgBound.y)
				{
					this.flow = 'down';
					this.nodeButton.className = 'open';
				}
				else
				{
					this.flow = 'up';
					this.nodeButton.className = 'close';
				}
				this.close();
			}
			Object.extend(this.nodeList,_item.dom).removeGarbage();

			if(this.modeView=="fix" && this.type=="gamelist")
			{
				if(nodeSelected && nodeSelected.getAttribute('name')=='selected' && !nodeSelected.value.isEmpty() && ('applyDefault' in this))
				{
					this.status = {type:'sub', where:nodeSelected.value, duplicate:true, selected:nodeSelected.value};
				}
				this.open();					
			}
			else if("status" in this && this.id!="g_SEARCHBAR_GAME" && this.id!="dvGame")
			{
				this.status = {active:true, type:'all', where:null, duplicate:false};	
			}

			if(nodeSelected && nodeSelected.getAttribute('name')=='selected' && !nodeSelected.value.isEmpty() && ('applyDefault' in this))
			{
				if(this.type=="gamelist")
				{
					this.applyDefault(nodeSelected.value);
				}
				else if(this.type=="itemlist")
				{
					this.applyDefault(nodeSelected.value);
				}
				this.selectedValue = nodeSelected.value;
				this.removeChild(nodeSelected);
			}
			else
			{
				if(this.type=='gamelist')		{ this.nodeSearch.value = '게임검색'; }
				else if(this.type=='serverlist'){ this.nodeSearch.value = '서버검색'; }
				else if(this.type=='itemlist'){ this.nodeSearch.value = '아이템검색'; }
			}

			if(this.type=="serverlist")
			{
				this.applyDefault();
			}
		},
		modeView: 'slide',
		view_count: 20,
		setText: _DISABLE,
		getText: function() { return this.nodeSearch.value },
		onclick : _DISABLE,
		select: function(id)
		{
			var rgList	= this.nodeList.getElements("DIV");
			var length	= rgList.length;
			if(length<2)
			{
				if(length==1 && this.modeView=="fix")
				{
					rgList[0].onclick();
				}
				return;
			}

			for(var i=0; i<length; i++)
			{
				if(_xml.getElement(rgList[i],"INPUT",0).value==id)
				{
					rgList[i].onclick();
					return;
				}
			}
		},
		addOption: function(pos,rgValue,text)
		{
			var node = Object.extend(document.createElement('DIV'),_item.option2);
			
			node.appendChild(document.createTextNode(text));

			var item = null;
			var input= document.createElement("INPUT");
			input.setAttribute("type","hidden");
			var nCount = (Object.isArray(rgValue)) ? rgValue.length : 0;
			/*
			 *	objValue[0] = {name:'', value''}
			 */
			for(var i=0; i<nCount; i++)
			{
				item = input.cloneNode;
				item.setAttribute("name",rgValue[i].name);
				item.setAttribute("value",rgValue[i].value);
				node.appendChild(item);
			}

			if(pos==null || this.nodeList.childNodes.length<1 || this.nodeList.childNodes.length<pos)
			{ this.nodeList.appendChild(node) }
			else if(pos==0)	{ this.nodeList.insertBefore(node,this.nodeList.firstChild) }
			else			{ this.nodeList.insertBefore(node,this.nodeList.childNodes[(pos+1)]) }

			try { return node; }
			finally { node=null; }
		},
		hangul: {
			cho : Array('ㄱ', 'ㄲ', 'ㄴ', 'ㄷ', 'ㄸ','ㄹ', 'ㅁ', 'ㅂ', 'ㅃ', 'ㅅ', 'ㅆ','ㅇ', 'ㅈ', 'ㅉ', 'ㅊ', 'ㅋ','ㅌ', 'ㅍ', 'ㅎ' ),
			jung: Array('ㅏ', 'ㅐ', 'ㅑ', 'ㅒ', 'ㅓ','ㅔ', 'ㅕ', 'ㅖ', 'ㅗ', 'ㅘ', 'ㅙ','ㅚ', 'ㅛ', 'ㅜ', 'ㅝ', 'ㅞ','ㅟ','ㅠ', 'ㅡ', 'ㅢ', 'ㅣ' ),
			jong: Array('', 'ㄱ', 'ㄲ', 'ㄳ', 'ㄴ', 'ㄵ', 'ㄶ', 'ㄷ', 'ㄹ','ㄺ', 'ㄻ', 'ㄼ', 'ㄽ', 'ㄾ', 'ㄿ', 'ㅀ','ㅁ','ㅂ', 'ㅄ', 'ㅅ', 'ㅆ', 'ㅇ', 'ㅈ', 'ㅊ', 'ㅋ', 'ㅌ', 'ㅍ', 'ㅎ' ),
			_jung:Array('ㅏ', '', '', '', 'ㅓ','ㅔ', '', '', 'ㅗ', '', '','', '', 'ㅜ', '', '','','', 'ㅡ', 'ㅢ', 'ㅣ'),
			_jong:Array('', 'ㄱ', '', '', 'ㄴ', '', '', 'ㅁ', 'ㄹ','', '', '', '', '', '', '','','ㅂ', '', '', 'ㅆ', 'ㅇ', '', '', '', '', '', '' )
		},
		getHangulList : function(word)
		{
			var chrSearch, iSearch, xUni, iCho, iJung, iJong, bCheck=false, iIndex=0;
			var strNot		= word.substring(0,word.length-1);
			var rgResult	= Array();
			if(!String(word.charAt(word.length-1)).isHangul())		// 마지막 단어가 한글이 아니면 검색할 필요없음
			{
				rgResult[0] = word;
				return rgResult;
			}
			chrSearch = word.charAt(word.length-1);
			iSearch	= chrSearch.charCodeAt(0);
			xUni		= iSearch - 0xAC00;
			iJong		= xUni % 0x1C;
			iJung		= ((xUni-iJong)/0x1C)%0x15;
			iCho		= parseInt(((xUni-iJong)/0x1C)/0x15);
			if(iCho<0)												// 한글 완성이 안되었을 경우
			{
				var cho_length	= this.hangul.cho.length;
				var _jung_length= this.hangul._jung.length;
				var _jong_length= this.hangul._jong.length;
				for(var j=0; j<cho_length; j++)
				{
					if(this.hangul.cho[j]==chrSearch)
					{
						bCheck = true;
						for(var jung=0; jung<_jung_length; jung++)
						{
							if(this.hangul.jung[jung]=='') { continue }
							for(var jong=0; jong<_jong_length; jong++)
							{
								if(jong!=0 && this.hangul._jong[jong]=='') { continue }
								rgResult[iIndex++] = strNot + String.fromCharCode(0xAC00 + j * 0x24C + jung * 0x1C + jong);
							}
						}
					}
				}
				if(!bCheck)	rgResult[0] = strNot;

				try { return rgResult; }
				finally { rgResult=null; }
			}
			rgResult[0] = strNot + String.fromCharCode(0xAC00 + iCho * 0x24C + iJung * 0x1C + iJong);
			var jong_length = this.hangul.jong.length;
			for(var i=1; i<jong_length && iJong==0; i++)
				rgResult[i] = strNot + String.fromCharCode(0xAC00 + iCho * 0x24C + iJung * 0x1C + i);

			try { return rgResult; }
			finally { rgResult=null; }
		}
	});
	_item.option2 = {};
	Object.extend(_item.option2,_item.option);
	Object.extend(_item.option2,{
		onclick: function(event)
		{
			var parent = this.parentNode.parent;
			if(parent)
			{
				parent.selected = this;
				var item = this.getElementsByTagName("INPUT");
				if('setText' in parent)		parent.setText(item[1].value);
				parent.setValue(item[0].value);
				if('OnChange' in parent)	parent.OnChange(this);
				parent.close();
			}
		}
	});
	/* ▲ Suggest */
/* ▲ ITEM Framework */


/* ▼ 폼객체 */
var _form = {};
_form.checker = Class.create({
	form: null,
	item: null,
	initialize: function(frm)
	{
		this.item = new Array();
		this.form = frm;
		this.form.checker = this;
		this.form.onsubmit= this.send.bind(this);
		//Object.extend(this.form,_item.event).addEvent("submit",this.send.bind(this));
	},
	send: function()
	{
		var result	= this.check();
		if(!result) { return false; }
		if('OnSubmit' in this && this.OnSubmit) 
		{
			result = this.OnSubmit.call(this.form);
			if(!result) { return false; }
		}

		return true;
	},
	send_manual: function()
	{
		var result	= this.check();
		if(!result) { return; }
		if('OnSubmit' in this && this.OnSubmit) 
		{
			result = this.OnSubmit.call(this.form);
			if(!result) { return; }
		}

		this.form.submit();
	},
	check: function()
	{
		if(this.item.length<1) return true;
		var result = true, type='', value='', length=this.item.length;
		for(var i=0; i<length; i++)
		{
			if('input' in this.item[i])
			{
				tag	= this.item[i].input.tagName.toUpperCase();
				type= this.item[i].input.getAttribute('type');
				value=(tag=='TEXTAREA') ? this.item[i].input.innerHTML.trim() : this.item[i].input.value.trim();
			}
			try
			{
				if('custom' in this.item[i])
				{
					var obj = ('input' in this.item[i]) ? this.item[i].input : this.form;
					if(!this.item[i].custom.call(obj,value))
					{
						result = false;
						break;
					}
				}
				else
				{
					var fnValidator = eval('_form.validator.'+this.item[i].type);
					var min=null, max=null;
					if('range' in this.item[i])
					{
						min = ('min' in this.item[i].range) ? this.item[i].range.min : 0.1;
						max = ('max' in this.item[i].range) ? this.item[i].range.max : null;
					}
					else { min = 0.1 }
					if(!fnValidator.call(_form.validator,value,min,max))
					{
						result = false;
						break;
					}
				}				
			}
			catch (error)
			{
				if(_DEBUG==true) { error.print() };
				result = false;
				break;
			}
		}
		
		if(!result)
		{
			if('message' in this.item[i])	alert(this.item[i].message);
			if(('input' in this.item[i]) && (type=='text' || type=='password' || tag=='TEXTAREA'))
			{
				this.item[i].input.value = '';
				this.item[i].input.focus();
			}
			return false;
		}
		return true;
	},
	add: function(item)
	{
		/*
		 *	입력 항목의 구조
		 *	custom	: 사용자 정의 함수 추가(반드시 결과를 return(true,false)해야 함)
		 *  input	: 해당 컨트롤
		 *	type	: 타입(number,price,string,date)
		 *  range	: number일 경우 범위설정({min:0, max:100}
		 *	message	: 조건실패시 메세지
		 */
		if(!('custom' in item) && (!item.input || !item.type)) { return }
		this.item.push(item);
		if(('protect' in item) && item.protect && (item.type in _form.protect))
		{ eval('_form.protect.'+item.type).call(_form.protect,(item.input)) }
	},
	free: function()
	{
		this.item.clear();
	}
});

_form.validator = {};
Object.extend(_form.validator,{
	number: function(value,min,max)
	{
		if(value.isEmpty())		{ return false }
		value = Number(value);
		if(isNaN(value))		{ return false }
		if((min && isNaN(min)) || (max && isNaN(max)))	{ return false }
		if(min && (value<min))	{ return false }
		if(max && (value>max))	{ return false }
		return true;
	},
	price: function(value,min,max)
	{
		value = value.replace(/[^0-9]/g,'');
		return this.number(value,min,max);
	},
	string: function(value,min,max)
	{
		if(value.isEmpty())				{ return false }
		if(min && (value.length<min))	{ return false }
		if(max && (value.length>max))	{ return false }
		return true;
	},
	hangul: function(value,min,max)
	{
		if(!this.string(value,min,max))	{ return false }
		return value.isHangul();
	},
	domain: function(value)
	{
		var regular = (/^(http\:\/\/)?((\w+)[.])+(asia|biz|cc|cn|com|de|eu|in|info|jobs|jp|kr|mobi|mx|name|net|nz|org|travel|tv|tw|uk|us)(\/(\w*))*$/i);
		return regular.test(value);
	},
	url: function(value)
	{
		if(this.domain(value)) { return true }
		var nIndex = value.lastIndexOf("/");
		if(nIndex>-1) { return this.domain(value.substring(0,nIndex)); }
		return false;				
	},
	userid: function(value)
	{
		value = value.replace(/[^a-zA-Z0-9]/g,'');
		if(!isNaN(value.substring(0,1)))	{ return false }
		if(!isNaN(value))					{ return false }
		return this.string(value,4,12);
	}
});

_form.protect = {};
Object.extend(_form.protect,{
	functionkey: Array(8,9,13,16,17,18,20,21,22,25,27,32,33,34,35,36,37,38,39,40,45,46),
	functioncheck: function(keycode)
	{
		var length = this.functionkey.length;
		for(var i=0; i<length; i++) { if(this.functionkey[i]==keycode) { return true } }
		return false;
	},
	set: function(input,fnKey,fnKeyup,fnBlur)
	{
		if(!fnBlur)	fnBlur = fnKeyup;
		input = Object.extend(input,_item.event);
		if(fnKey)	{ input.addEvent('keydown',fnKey.bind(input)) }
		if(fnKeyup)	{ input.addEvent('keyup',fnKeyup.bind(input))}
		if(fnBlur)	{ input.addEvent('blur',fnBlur.bind(input))	 }
	},
	number: function(input)
	{
		this.set(input,function(Event) {
			var keycode = _event.keycode(Event);
			if(_form.protect.functioncheck(keycode)) { return true }
			if((keycode>=48 && keycode<=57) || (keycode>=96 && keycode<=105)) { return true }
			_event.stop(Event);
			return false;
		},function(Event) {
			var value = this.value.replace(/[^0-9]/g,'');
			this.value = (value.isEmpty()) ? '' : value;
		});
	},
	price: function(input)
	{
		this.set(input,function(Event) {
			var keycode = _event.keycode(Event);
			if(_form.protect.functioncheck(keycode)) { return true }
			if((keycode>=48 && keycode<=57) || (keycode>=96 && keycode<=105)) { return true }
			_event.stop();
			return false;
		},function(Event) {
			var value = this.value.replace(/[^0-9]/g,'');
			value = Number(value).currency();
			if(this.getAttribute('maxLength') && value.length>this.getAttribute('maxLength'))
			{
				var gap = value.length-parseInt(this.getAttribute('maxLength'))-1;
				value = value.replace(/[^0-9]/g,'');
				value = value.substring(0,value.length-gap);
				value = Number(value).currency();
			}
			this.value = (value=="0") ? "" : value;
		});
	},
	hangul: function(input)
	{
		this.set(input,function(Event) {
			var keycode = _event.keycode(Event);
			if(_form.protect.functioncheck(keycode)){ return true }
			if(keycode==229)						{ return true }
			_event.stop(Event);
			return false;
		},
		null,
		function(Event) {
			var value	= this.value.replace(/[^가-힣]/g,'');
			this.value	= value;
		});
	},
	userid: function(input)
	{
		this.set(input,function(Event) {
			/*
			var keycode = _event.keycode(Event);
			if(_form.protect.functioncheck(keycode)){ return true }
			if((keycode>=48 && keycode<=57) || (keycode>=65 && keycode<=90) || (keycode>=97 && keycode<=122))	{ return true }
			_event.stop(Event);
			return false;
			*/
		},
		function(Event) {
			var value	= this.value.replace(/[^a-zA-Z0-9]/g,'');
			this.value	= value;
		});
	}
});
_form.addValues = function(form,params)
{
	if(!form || !params) { return }
	var input = null;
	for(var item in params)
	{
		input = document.createElement('INPUT');
		input.setAttribute('type','hidden');
		input.setAttribute('name',item);
		input.setAttribute('value',params[item]);
		form.appendChild(input);
	}
}
/* ▲ 폼객체 */


/* ▼ 모든 포커스 제거 */
function g_fnBLUR()
{
	var rgTags = null;
	var rgTagFocus = Array('A','IMG','AREA','INPUT');
	for(var i=0; i<rgTagFocus.length; i++)
	{
		rgTags = document.getElementsByTagName(rgTagFocus[i]);
		for(var j=0; j<rgTags.length; j++)
		{
			if(rgTagFocus[i]=="INPUT" && (rgTags[j].getAttribute('type')=='text' || rgTags[j].getAttribute('type')=='password' ||  rgTags[j].getAttribute('type')=='file')) { continue }
			rgTags[j].onfocus = function() { this.blur() }
		}
	}
}
/* ▲ 모든 포커스 제거 */


/* ▼ 보안설정 */
function g_fnSECURITY()
{
	document.oncontextmenu	= _DISABLE;
	document.ondragstart	= _DISABLE;
	document.onselectstart	= _DISABLE;
	document.addEvent('mousedown',function(event){
		event = _event.event(event);
		if(event.button!=2) { return true }
		_event.stop(event);
		return false;
	});
	document.addEvent('keydown',function(event){
		event = _event.event(event);
		var code = _event.keycode(event);
		code = parseInt(code);
		var rgTaboo = new Array(114,115,116,117,118,121,122,8);	/* F3, F4, F5, F6, F7, F10, F11 , <- */
		if(event.altKey || event.altLeft || event.ctrlKey || event.ctrlLeft)
		{
			try { event.keyCode = 0 }
			catch(e) {}
			_event.stop(event);
			return false;
		}
		for(var i=0; i<rgTaboo.length; i++)
			if(rgTaboo[i]==code)
			{
				try
				{ event.keyCode = 0; }
				catch(e) {}
				_event.stop(event);
				return false;
			}			
		return true;
	});
}

function g_fnSECURITY2()			/* input내용 입력시 백스페이스 사용 하려고 생성함*/
{
	document.oncontextmenu	= _DISABLE;
	document.ondragstart	= _DISABLE;
	document.onselectstart	= _DISABLE;
	document.addEvent('mousedown',function(event){
		event = _event.event(event);
		if(event.button!=2) { return true }
		_event.stop(event);
		return false;
	});
	document.addEvent('keydown',function(event){
		event = _event.event(event);
		var code = _event.keycode(event);
		code = parseInt(code);
		var rgTaboo = new Array(114,115,116,117,118,121,122);	/* F3, F4, F5, F6, F7, F10, F11 */
		if(event.altKey || event.altLeft || event.ctrlKey || event.ctrlLeft)
		{
			try { event.keyCode = 0 }
			catch(e) {}
			_event.stop(event);
			return false;
		}
		for(var i=0; i<rgTaboo.length; i++)
			if(rgTaboo[i]==code)
			{
				try
				{ event.keyCode = 0; }
				catch(e) {}
				_event.stop(event);
				return false;
			}			
		return true;
	});
}
/* ▲ 보안설정 */


/* ▼ 초기화 */
function _initialize()
{
	_item.root = Object.extend($('g_BODY'),_item.gui);

	// SLEEP설정
	var nodeSleep = Object.extend($('g_SLEEP'),_item.layer);
	if(nodeSleep)
	{
		Object.extend(nodeSleep,_item.dom);
		Object.extend(nodeSleep,{
			parent : null,
			node : null,
			mask : null,
			setSleep: function(node,enable)
			{
				this.freeSleep();
				this.parent	= node.parentNode;
				this.node	= Object.extend(node,_item.layer);

				this.parentNode.insertBefore(this.node,this);
				this.node.style.position	= 'absolute';
				this.node.style.zIndex		= '98';
				this.node.style.top			= '50%';
				this.node.style.left		= '50%';

				if(!this.mask)
				{
					var ifrm = document.createElement("IFRAME");
					ifrm.frameBorder	= "no";
					ifrm.style.position	= "absolute";
					ifrm.style.border	= "0px";
					ifrm.style.zIndex	= "97";
					ifrm.style.top		= "50%";
					ifrm.style.left		= "50%";
					this.mask = Object.extend(ifrm,_item.layer);
					this.mask.behind();
					this.parentNode.insertBefore(this.mask,this);
				}

				var rgDiv = Object.extend(this.node,_item.dom).getElements('DIV');
				var length= rgDiv.length;
				for(var i=0; i<length; i++) 
				{ 
					if(rgDiv[i].className=="g_selectbox")
					{
						rgDiv[i].nodeList.style.zIndex = "99";
						document.body.appendChild(rgDiv[i].nodeList);
					} 
				}
				if(enable) { this.enable() }
			},
			freeSleep: function()
			{
				this.disable();
				if(this.node)
				{
					if(this.parent) { this.parent.appendChild(this.node) }
					this.parent	= null;
					this.node	= null;
				}
				if(this.mask)
				{
					this.parentNode.removeChild(this.mask);
					this.mask = null;
				}
			},
			enable: function()
			{
				this.show();
				this.node.show();
				var rgBound = this.node.getBound();
				this.node.style.marginTop	= '-'+(rgBound.height/2)+'px';
				this.node.style.marginLeft = '-'+(rgBound.width/2)+'px';

				if(this.mask)
				{
					this.mask.style.width		= rgBound.width + "px";
					this.mask.style.height		= rgBound.height+ "px";
					this.mask.style.marginTop	= "-"+(rgBound.height/2)+"px";
					this.mask.style.marginLeft	= "-"+(rgBound.width/2)+"px";
					this.mask.show();
				}

				if("_accelerate" in this && this._accelerate)
				{
					document.addEvent('keydown',this._accelerate.bindAsEventListener(this));
				}
				if('OnOpen' in this) { this.OnOpen.call(this) }
			},
			disable: function()
			{
				if(this.node) { this.node.behind() }
				if(this.mask) { this.mask.behind(); this.mask=null; }
				this.behind();

				if("_accelerate" in this && this._accelerate)
				{
					document.removeEvent('keydown',this._accelerate.bindAsEventListener(this));
				}
				if('OnClose' in this) { this.OnClose.call(this) }
			},
			_accelerate: function(Event) {
				switch(_event.keycode(Event))
				{
					case _event.KEY_ESC:
						this.disable();
						break;
					case _event.KEY_SPACE:
						_event.stop(Event);
						return false;
						break;
				}
			}
		});
	}
	try
	{
		//g_fnSECURITY();
		g_fnBLUR();		
	}
	catch(error) { if(_DEBUG) { error.print(); } }
	try
	{
		if('_header' in window)	{ _header() }
		if('_init' in window)	{ _init()	}
		if('__init' in window)	{ __init()	}
		if('___init' in window)	{ ___init() }
		//window.onerror = _DISABLE;
	}
	catch(error) { if(_DEBUG) { error.print(); return false; } }
	return true;
}
/* ▲ 초기화 */


// 게임데이터
var _gamedata	= {xml:null, xsl:null};
var _serverdata	= {xml:null, xsl:null};

// 게임리스트
var _gamelist = {};
Object.extend(_gamelist,_item.suggest);
Object.extend(_gamelist,{
	type: 'gamelist',
	xhr: null,
	xml: _gamedata.xml,
	xsl: _gamedata.xsl,
	bind: null,
	nodeMove: null,
	nodeTmp: null,
	template: "",
	status: {active:true, type:'all', where:null, duplicate:false, selected:""},
	applyDefault: function(value)
	{
		this.open({type:"sub", where:value});
		this.close();
	},
	OnOpen: function(params)
	{
		if(this.nodeSearch.value=="게임검색" || this.nodeSearch.value=='서버검색')
		{
			this.nodeSearch.value = "";
		}
		if(!this.status.active && !(this.bind && this.bind.status.type=="sub"))
		{
			return;
		}
		if(this.bind && this.bind.mode=="open")
		{
			this.bind.close();
		}
		this.nodeMove = null;

		if(params)
		{
			if(this.status.type==params.type && this.status.where==params.where) { return; }
			else
			{
				this.status.type = params.type;
				this.status.where= params.where;
			}
			if("selected" in params && !params.selected.isEmpty())
			{
				this.status.selected = params.selected;
			}
		}
		else
		{
			this.status = {active:true, type:'all', where:null, duplicate:false};
		}

		this.nodeList.innerHTML = "";
		var loading = this.addOption(null,null,'검색중입니다...');
		loading.onclick		= _DISABLE;
		loading.onmouseover	= _DISABLE;
		loading.onmouseout	= _DISABLE;

//		if(this.xml)	{ this.OnLoadXML.bind(this).delay(0.1) }
//		else			{ this.loadXML()	}
		this.loadXML();
	},
	loadXML: function()
	{
		if(!this.xhr)
		{
			this.xhr = new _xhr('/_xml/gamelist.xml',{params:'key='+encodeURIComponent(Date().toString())},null,{self:this, complete:this.OnLoadXML,error:this.OnError});
		}
		else
		{
			this.xhr.setConfig('/_xml/gamelist.xml',{params:'key='+encodeURIComponent(Date().toString())},null,{self:this, complete:this.OnLoadXML,error:this.OnError});
		}
	},
	OnLoadXML: function(request)
	{
		if(this.xml && this.xsl)
		{
			this.setMode();
			this.print.bind(this).delay(0.1);
		}
		else
		{
			this.xml = new Object(request.responseXML);
			if(!this.xhr)
			{
				this.xhr = new _xhr('/_xslt/gamelist'+this.template+'.xsl',{params:'key=200804141'},null,{self:this, complete:this.OnLoadXSLT,error:this.OnError});
			}
			else
			{
				this.xhr.setConfig('/_xslt/gamelist'+this.template+'.xsl',{params:'key=200804141'},null,{self:this, complete:this.OnLoadXSLT,error:this.OnError});
			}
		}
	},
	OnLoadXSLT : function(request)
	{
		this.xsl = new Object(request.responseXML);
		this.setMode();
		this.print();
	},
	OnError: function()
	{
		this.close();
		this.nodeList.innerHTML = '';

		var qa = confirm('목록을 받아오지 못했습니다.\n\n재시도 하시겠습니까?');
		if(qa)	{ this.open(this.status)	}
		else	{ window.location.reload()	}
	},
	OnChange: function(option)
	{
		var rgInfo = option.getElementsByTagName("INPUT");

		this.status = {type:'search', where:rgInfo[0].value};
		option.onmouseover();
		this.nodeSearch.value = rgInfo[1].value;

		if(this.bind)
		{
			this.bind.setValue('');
			this.bind.selected = null;
			this.bind.nodeSearch.value = '';
			this.bind.status.active = true;
			this.bind.status.duplicate = false;
			this.bind.open({type:'sub',where:rgInfo[0].value });
			this.bind.nodeSearch.focus();
		}

		this.nodeSearch.blur();
	},
	OnFocus: function()
	{
		if(this.nodeSearch.value=='게임검색') { this.nodeSearch.value='' }
		this.status.active = true;
		if(this.bind)
		{
			if(this.modeView=="fix")
			{
				this.bind.nodeList.innerHTML = '';
			}
			this.bind.selected = null;
			this.bind.setValue('');
			this.bind.nodeSearch.value='';
			this.bind.close();
		}
		this.OnKeyUp();
	},
	OnBlur: function()
	{
		if(!this.nodeSearch.value.isEmpty())
		{
			var selected= null;
			var text	= this.nodeSearch.value;
			var length	= this.nodeList.childNodes.length;
			var item	= null;

			for(var i=0; i<length; i++)
			{
				var rgInfo = this.nodeList.childNodes[i].getElementsByTagName("INPUT");
				if(this.nodeList.childNodes[i].tagName!="DIV" || rgInfo.length<3)
					continue;

				item = this.nodeList.childNodes[i].getElementsByTagName("INPUT")[1].value;
				if(item && item.toUpperCase()==text.toUpperCase())
					selected = this.nodeList.childNodes[i];
			}
			this.selected = selected;
			if(this.selected && this.bind)
			{
				var value = this.selected.getElementsByTagName("INPUT")[0].value;
				this.setValue(value);
				this.bind.status.active = true;
				this.bind.status.duplicate = false;
				this.bind.open({type:'sub', where:value});
			}
		}
	},
	OnClose: function()
	{
		if(!this.nodeSearch.value.isEmpty())
		{
			var selected= null;
			var text	= this.nodeSearch.value;
			var length	= this.nodeList.childNodes.length;
			var item	= null;

			for(var i=0; i<length; i++)
			{
				var rgInfo = this.nodeList.childNodes[i].getElementsByTagName("INPUT");
				if(this.nodeList.childNodes[i].tagName!="DIV" || rgInfo.length<3)
					continue;

				item = this.nodeList.childNodes[i].getElementsByTagName("INPUT")[1].value;
				if(item && item.toUpperCase()==text.toUpperCase())
					selected = this.nodeList.childNodes[i];
			}
			if(selected)
			{
				this.selected = selected;
				var value = this.selected.getElementsByTagName("INPUT")[0].value;
				this.setValue(value);
				this.nodeSearch.value = this.selected.getElementsByTagName("INPUT")[1].value;
				if(this.bind)
					this.bind.open({type:'sub',where:value});
				return;
			}
		}
		this.setValue('');
		this.selected = null;
		this.nodeSearch.value = '';
		if(this.bind)
		{
			if(this.bind.mode=='open')	this.bind.close();
			this.bind.selected = null;
		}
	},
	OnMouseOver: function(Event, option) { this.nodeMove = option },
	OnKeyUp: function(Event)
	{
		var keycode = _event.keycode(Event);
		if(keycode==_event.KEY_RETURN || this.status.where==this.nodeSearch.value) { return }
		if(keycode==_event.KEY_UP || keycode==_event.KEY_PAGEUP || keycode==_event.KEY_DOWN || keycode==_event.KEY_PAGEDOWN)
		{ return }

		if(this.status.type!='sub' && this.nodeSearch.value.isEmpty())
		{
			this.status		= {active:true, type:'all', where:null};
			this.close();
			if(this.modeView=='fix' && this.type=='gamelist')
			{
				this.open();
			}
			if(this.bind)	{ this.bind.status={active:true, type:'all', where:null} }
		}
		else
		{
			if(this.type=="serverlist") 
			{ 
				this.open({type:'sub', where:this.nodeSearch.value, duplicate:true});
			}
			else { this.open({type:'search', where:this.nodeSearch.value}) }
		}
	},
	OnKeyDown: function(Event)
	{
		var keycode = _event.keycode(Event);
		if(keycode==_event.KEY_RETURN)
		{
			if(this.nodeMove) { this.nodeMove.onclick(Event); }
			_event.stop(Event);
			if(this.type=="serverlist" && this.modeView=="slide")
			{  
				if(this.getAttribute("id")=="g_SEARCHBAR_SERVER")
				{
					(function() { $("g_SEARCHBAR_FORM").search_word.focus(); }).bind(this).delay(0.1);
					(function() { this.close(); }).bind(this).delay(0.2);
				}
				else
				{
					(function() { this.nodeSearch.blur(); this.close(); }).bind(this).delay(0.1);
				}
			}
			return false;
		}
		else if(keycode==_event.KEY_UP || keycode==_event.KEY_PAGEUP || keycode==_event.KEY_DOWN || keycode==_event.KEY_PAGEDOWN)
		{
			if(this.nodeList.childNodes.length<1) { return }
			var flow = (keycode==_event.KEY_UP || keycode==_event.KEY_PAGEUP) ? 'up' : 'down';
			if(flow=='up')
			{
				if(!this.nodeMove)
				{
					_event.stop(Event);
					return;
				}
				else if(this.nodeList.firstChild==this.nodeMove)
				{
					if(keycode==_event.KEY_PAGEUP)	return;
					this.nodeMove.onmouseout();
					this.nodeMove = null;
					this.nodeList.scrollTop = '0px';
					return;
				}

				this.nodeMove.onmouseout();
				if(keycode==_event.KEY_UP) { this.nodeMove = this.nodeMove.previousSibling }
				else
				{
					var node = this.nodeMove;
					for(var i=0; i<this.view_count; i++)
					{
						if('previousSibling' in node)
						{
							node = node.previousSibling;
							if(node==this.nodeList.firstChild) { break }
						}
						else { break }
					}
					this.nodeMove = node;
				}
				this.nodeMove.onmouseover();

				if(this.nodeList.scrollTop>this.nodeMove.offsetTop)
				{ this.nodeList.scrollTop = this.nodeMove.offsetTop-3 }
			}
			else
			{
				
				if(!this.nodeMove)
				{
					this.nodeMove = this.nodeList.firstChild;
					this.nodeMove.onmouseover();
					this.status.active = false;
					return;
				}
				else if(this.nodeMove==this.nodeList.lastChild)
				{
					_event.stop(Event);
					return;
				}

				this.nodeMove.onmouseout();
				if(keycode==_event.KEY_DOWN) { this.nodeMove = this.nodeMove.nextSibling }
				else
				{
					var node = this.nodeMove;
					for(var i=0; i<this.view_count; i++)
					{
						if('nextSibling' in node)
						{
							node = node.nextSibling;
							if(node==this.nodeList.lastChild) { break }
						}
						else { break }
					}
					this.nodeMove = node;
				}
				this.nodeMove.onmouseover();

				var height = this.nodeList.getBound().height;
				if((this.nodeList.scrollTop+height-20)<this.nodeMove.offsetTop)
				{ this.nodeList.scrollTop = this.nodeMove.offsetTop-height+27 }
			}
		}
		else
		{
			if(this.type=='serverlist' && this.status.type=='sub') { this.status.duplicate = true }
			this.status.active = true;
			return true;
		}
	},
	setMode: function()
	{
		var tagFor = _xml.getElement(this.xsl,'xsl:for-each',0);
		var tagVar = _xml.getElement(this.xsl,'xsl:variable',0);
		tagVar.setAttribute('select',0);

		if(this.status.type=='all')			{ tagFor.setAttribute("select","/gamelist/game") }
		else if(this.status.type=='sub')	{ tagFor.setAttribute("select","/gamelist/game[@id='"+this.status.where+"']") }
		else if(this.status.type=='search')
		{
			var rgWord	= this.getHangulList(this.status.where);
			//alert(rgWord);
			var length	= rgWord.length;
			var query	= '/gamelist/game[';
			for(var i=0; i<length; i++)
			{
				if(i!=0)	query += " or ";
				query += "starts-with(@name,'"+rgWord[i].toUpperCase()+"')";	// 대문자 -> 대문자, 소문자 -> 대문자 변환
				// query += "starts-with(@name,'"+rgWord[i]+"')"; 대소문자 구분
			}
			query += ']';
			// 검색어에 해당하는 목록 문자열의 위치를 잡아낸다
			var rgLast	= Array(2);
			var len		= this.status.where.length;
			rgLast[0] = this.status.where.substring(len-1, len);
			rgLast[1] = rgWord[0].substring(rgWord[0].length-1, rgWord[0].length);
			if(rgLast[0]!=rgLast[1])
				len--;
			tagFor.setAttribute('select',query);
			tagVar.setAttribute('select',len);
		}
	},
	print: function()
	{
		_xslt.parseXML(this.nodeList,this.xml,this.xsl);	

		if(this.nodeList.childNodes.length<1)
		{
			var result = this.addOption(null,null,'검색결과가 없습니다.');
			result.onclick		= _DISABLE;
			result.onmouseover	= _DISABLE;
			result.onmouseout	= _DISABLE;
		}
		else if((!this.bind || (this.bind && this.bind.type=='serverlist')) && this.status.type=='sub')
		{
			this.selected = this.nodeList.firstChild;
			var rgInfo = this.selected.getElementsByTagName("INPUT");

			this.setValue(rgInfo[0].value);
			this.nodeSearch.value = rgInfo[1].value;
		}
		if("selected" in this.status && !this.status.selected.isEmpty())
		{
			this.select(this.status.selected);
		}

		if(this.modeView=='fix') { }
		else if(this.nodeList.childNodes.length>this.view_count)
		{
			this.nodeList.style.height	= (Object.extend(this.nodeList.childNodes[0],_item.gui).getBound().height*this.view_count+9) + 'px';
			this.nodeList.style.overflow = 'auto';
		}
		else { this.nodeList.style.height = 'auto' }

		if("selectedValue" in this && this.selectedValue.isEmpty()==false)
		{
			if(this.type=="gamelist")
			{
				if(this.bind && "useDefault" in this.bind && Object.isFunction(this.bind.useDefault)==true)
				{
					this.bind.useDefault(this.selectedValue);
					this.bind.useDefault = null;
				}
			}
			else if(this.type=="serverlist")
			{
				this.select(this.selectedValue);
			}
			this.selectedValue = "";
		}
	},
	getUnit: function()
	{
		if(this.selected)
		{
			try { return this.selected.getElementsByTagName("INPUT")[2].value }
			catch(Err) { return "" }
		}
		return "";
	}
});

// 서버리스트
var _serverlist = {};
Object.extend(_serverlist,_gamelist);
Object.extend(_serverlist,{
	type: 'serverlist',
	xhr: null,
	xml: _serverdata.xml,
	xsl: _serverdata.xsl,
	status: {active:true, type:'sub', where:null, duplicate:false, selected:""},
	applyDefault: function()
	{		
		this.useDefault = function(value)
		{
			this.open({type:"sub", where:value});
			this.close();
		}
	},
	OnOpen: function(params)
	{
		if(!this.status.active)
		{
			return;
		}
		if(this.bind && this.bind.getValue().isEmpty())
		{
			this.close();
			alert('게임을 선택해 주세요.');
			this.bind.nodeSearch.focus();
			return;
		}
		this.nodeMove = null;

		if(params)
		{
			this.status.type = params.type;
			this.status.where= params.where;
		}

		this.nodeList.innerHTML = "";
		var loading = this.addOption(null,null,'검색중입니다...');
		loading.onclick		= _DISABLE;
		loading.onmouseover	= _DISABLE;
		loading.onmouseout	= _DISABLE;

		this.loadXML();
	},
	loadXML: function()
	{
		if(this.status.type=="search" || this.status.type=="sub" && this.status.duplicate==true)
		{
			this.setMode();
			this.print.bind(this).delay(0.1);
			return;
		}

		if(!this.xhr)
		{
			this.xhr = new _xhr('/_xml/serverlist.php',{params:'game='+this.status.where+'&key='+encodeURIComponent(Date().toString())},null,{self:this, complete:this.OnLoadXML,error:this.OnError});
		}
		else
		{
			this.xhr.setConfig('/_xml/serverlist.php',{params:'game='+this.status.where+'&key='+encodeURIComponent(Date().toString())},null,{self:this, complete:this.OnLoadXML,error:this.OnError});
		}
	},
	OnLoadXML: function(request)
	{
		this.xml = new Object(request.responseXML);
		if(this.xsl)
		{
			this.setMode();
			this.print.bind(this).delay(0.1);
		}
		else
		{
			if(!this.xhr)
			{
				this.xhr = new _xhr('/_xslt/serverlist.xsl',{params:'key=200804141'},null,{self:this, complete:this.OnLoadXSLT,error:this.OnError});
			}
			else
			{
				this.xhr.setConfig('/_xslt/serverlist.xsl',{params:'key=200804141'},null,{self:this, complete:this.OnLoadXSLT,error:this.OnError});
			}
		}
	},
	OnChange: function(option)
	{
		var rgInfo = option.getElementsByTagName("INPUT");
		this.nodeSearch.value = rgInfo[1].value;

		if(this.status.type!='sub')
		{
			this.status = {type:'search', where:rgInfo[0].value};
			if(this.bind)
			{
				this.bind.status.active = true;
				this.bind.open({type:'sub',where:rgInfo[2].value });
				this.bind.close();
				this.bind.status.active = false;
				this.status.active = true;
				this.open({type:'sub',where:rgInfo[2].value });
				this.status.active = false;
				this.close();
			}
		}
		else
		{
			if(!this.bind.selected || this.bind.selected.getElementsByTagName("INPUT")[0].value!=rgInfo[2].value)
			{
				this.bind.status.active = true;
				this.bind.open({type:'sub',where:rgInfo[2].value });
				this.bind.close();
				this.bind.status.active = false;
			}
			this.status.active = false;
			this.close();
		}
	},
	OnFocus: function()
	{
		if(this.nodeSearch.value=='서버검색') { this.nodeSearch.value='' }
		if(this.bind && this.bind.getValue().isEmpty())
		{
			this.close();
			alert('게임을 선택해 주세요.');
			this.bind.nodeSearch.focus();
			return;
		}
		if(this.bind && this.bind.mode=='open') { this.bind.close() }
		if(this.status.type=='sub')
		{
			this.status.active = false;
			if(this.mode!='open')
				this.open();
		}
	},
	OnClose: _ENABLE,
	OnBlur: function()
	{
		var selected= null;
		var text	= this.nodeSearch.value;
		var length	= this.nodeList.childNodes.length;
		var item	= null;

		for(var i=0; i<length; i++)
		{
			var rgInfo = this.nodeList.childNodes[i].getElementsByTagName("INPUT");
			if(this.nodeList.childNodes[i].tagName!="DIV" || rgInfo.length<6)
				continue;

			item = this.nodeList.childNodes[i].getElementsByTagName("INPUT")[1].value;
			if(item && item.toUpperCase()==text.toUpperCase())
				selected = this.nodeList.childNodes[i];
		}
		this.selected = selected;
		if(!this.selected)
		{
			this.setValue('');
			this.selected = null;
			this.nodeSearch.value = '';
			this.status.active = true;
		}
	},
	setMode: function()
	{
		var tagFor = _xml.getElement(this.xsl,'xsl:for-each',0);
		var tagVar = _xml.getElement(this.xsl,'xsl:variable',0);
		tagVar.setAttribute('select',0);

		if(this.status.type=='sub')	{ 
			if(!this.status.duplicate)
			{
				var query = "/SERVERLIST/SERVER";
				query+= (this.modeView=='fix') ? "[not(@TYPE) or @TYPE!='all']" : "";
				tagFor.setAttribute("select",query);
			}
			else
			{
				var text	= this.nodeSearch.value;
				var rgWord	= this.getHangulList(text);
				var length	= rgWord.length;
				var query	= "/SERVERLIST/SERVER[";
				for(var i=0; i<length; i++)
				{
					if(i!=0)	query += " or ";
					query += "starts-with(@NAME,'"+rgWord[i]+"')";
				}
				query+=(this.modeView=='fix')?" and (not(@TYPE) or @TYPE!='all')":"";
				query+= "]";

				// 검색어에 해당하는 목록 문자열의 위치를 잡아낸다
				var rgLast	= Array(2);
				var len		= text.length;
				rgLast[0] = text.substring(len-1, len);
				rgLast[1] = rgWord[0].substring(rgWord[0].length-1, rgWord[0].length);
				if(rgLast[0]!=rgLast[1])
				{
					len--;
				}
				tagFor.setAttribute('select',query);
				tagVar.setAttribute('select',len);
			}
		}
		else if(this.status.type=='search')
		{
			var rgWord	= this.getHangulList(this.status.where);
			var length	= rgWord.length;
			var query	= "/SERVERLIST/SERVER[not(@TYPE) and (";
			for(var i=0; i<length; i++)
			{
				if(i!=0)	query += " or ";
				query += "starts-with(@NAME,'"+rgWord[i]+"')";
			}
			query += ")]";

			// 검색어에 해당하는 목록 문자열의 위치를 잡아낸다
			var rgLast	= Array(2);
			var len		= this.status.where.length;
			rgLast[0] = this.status.where.substring(len-1, len);
			rgLast[1] = rgWord[0].substring(rgWord[0].length-1, rgWord[0].length);
			if(rgLast[0]!=rgLast[1])
				len--;
			tagFor.setAttribute('select',query);
			tagVar.setAttribute('select',len);
		}
		else { return }
	},
	getMoney: function()
	{
		if(this.selected) 
		{ 
			try { return this.selected.getElementsByTagName("INPUT")[3].value }
			catch(Err) { return "" }
		}
		return "";
	},
	getMoneyUnit: function()
	{
		if(this.selected) 
		{ 
			try { return this.selected.getElementsByTagName("INPUT")[4].value }
			catch(Err) { return "" }
		}
		return "";
	},
	getUnit: function()
	{
		if(this.selected) 
		{
			try { return this.selected.getElementsByTagName("INPUT")[5].value }
			catch(Err) { return "" }
		}
		return "";
	}
});
/* ▼  삽니다, 팝니다 도움말 레이어 */
function sellHelp()
{
        Object.extend($('sell_help'),_item.layer).show();
        make_newBox('sell_help','판매 등록된 물품 리스트로<br />구매 신청으로 구매할 수 있<br />습니다.','0','35','','1','140');
}

function buyHelp()
{
        Object.extend($('buy_help'),_item.layer).show();
        make_newBox('buy_help','구매 등록된 물품 리스트로<br />판매 신청으로 판매할 수 있<br />습니다.','90','35','','1','140');
}

function layerOff()
{
        Object.extend($('sell_help'),_item.layer).behind();
        Object.extend($('buy_help'),_item.layer).behind();
}
/* ▲  삽니다, 팝니다 도움말 레이어 */


/* ▼  새 공통 말풍선 */
function make_newBox(id, comment, left, top, direction, width_yn, width, arrow_left, arrow_top, arrow_pad_left)
{
	var image;
	var width_string;

	if(arrow_left == "" || arrow_left == null) arrow_left = "-3";
	if(arrow_top == "" || arrow_top == null) arrow_top = "1";
	if(arrow_pad_left == "" || arrow_pad_left == null) arrow_pad_left = "0";
	if(direction == "" || direction == null) image = "";
	else image = "<img src=\"/images/common/balloon/arrow_"+direction+".gif\"/>";
	if(width_yn == "" || direction == null) width_string = "";
	else width_string = "style=\"width: "+width+"px;\"";

	$(id).innerHTML = "<div style=\"left: "+left+"px; top: "+top+"px;\" class=\"g_balloons\"> <div class=\"square\" "+width_string+"> <div class=\"comment\">"+comment+" </div></div> <span  class=\"pointer_arrow\" style=\"left: "+arrow_left+"px; top: "+arrow_top+"px; margin-left: "+arrow_pad_left+"px;\"> "+image+" </span> </div> ";
}

function make_caps_newBox(id, comment, width, left, top, direction, arrow_left, arrow_top, arrow_pad_left)
{
	var image;

	if(arrow_left == "" || arrow_left == null) arrow_left = "-3";
	if(arrow_top == "" || arrow_top == null) arrow_top = "1";
	if(arrow_pad_left == "" || arrow_pad_left == null) arrow_pad_left = "0";
	if(direction == "" || direction == null) image = "";
	else image = "<img src=\"/images/common/balloon/arrow_"+direction+".gif\"/>";

	$(id).innerHTML = "<div style=\"left: "+left+"px; top: "+top+"px;\" class=\"g_balloons\"> <div style=\"width: "+width+"px; \" class=\"square\"> <div class=\"comment\">"+comment+" <div class=\"capslock\"> 키보드에 <span class=\"bold\">Caps Lock</span>이 켜져 있습니다.  </div></div> </div><span class=\"pointer_arrow\" style=\"left: "+arrow_left+"px; top: "+arrow_top+"px; padding-left: "+arrow_pad_left+"px;\"> "+image+" </span> </div> ";
}

function make_caps_login(id, comment, type)
{
	if (type == "kr")
	{
		$(id).innerHTML = "<div class=\"g_balloons\"> <div class=\"comment\"><img src=\"/images/user/"+comment+".gif\"/></div></div> ";
	}
	else
	{
		$(id).innerHTML = "<div class=\"g_balloons2\"> <div class=\"comment\"><img src=\"/images/user/"+comment+".gif\"/></div></div> ";
	}
}
/* ▲  새 공통 말풍선 */

