// Core object
if (typeof window != "undefined" && typeof window.whois == "undefined") {
	window.whois = new Object;
}

if (typeof window != "undefined") {
	window.whois = {};
} else {
	whois = {};
}

var _dir = '';
if(1) {
	var scripts = document.getElementsByTagName('script');
	var existsBase64 = false;
	for(var i=0; i<scripts.length; i++) {
		var _src = scripts[i].getAttribute('src');
		if(!_src) continue;

		if (_src.indexOf("whois.ssl.js") != -1) {
			_dir = _src.split("whois.ssl.js")[0];
			document.write('<script type="text/javascript" src="'+_dir+'lib/assl/lib/jsbn/jsbn.js"></script>'+
			'<script type="text/javascript" src="'+_dir+'lib/assl/lib/jsbn/prng4.js"></script>'+
			'<script type="text/javascript" src="'+_dir+'lib/assl/lib/jsbn/rng.js"></script>'+
			'<script type="text/javascript" src="'+_dir+'lib/assl/lib/jsbn/rsa.js"></script>'+
			'<script type="text/javascript" src="'+_dir+'lib/assl/lib/aes.js"></script>'+
			'<script type="text/javascript" src="'+_dir+'lib/assl/assl_.js"></script>');
		}

		// base64.js ¶óÀÌºê·¯¸® Æ÷ÇÔ ¿©ºÎ È®ÀÎ
		if(_src.indexOf("base64.js") != -1) existsBase64 = true;
	}

	// jQuery Æ÷ÇÔ¿©ºÎ È®ÀÎ
	if(typeof jQuery == 'undefined' || typeof window.jQuery == "undefined") {
		document.write('<script type="text/javascript" src="'+_dir+'lib/jquery/js/jquery-1.4.2.min.js"></script>');
		document.write('<script type="text/javascript" src="'+_dir+'lib/jquery/js/jquery-ui-1.8.2.custom.min.js"></script>');
	}

	if(!existsBase64) {
		document.write('<script type="text/javascript" src="'+_dir+'lib/base64.js"></script>');
	}
}

/**
 * @brief string prototypeÀ¸·Î trim ÇÔ¼ö Ãß°¡
 **/
if(typeof String.prototype.trim == 'undefined') {
	String.prototype.trim = function() {
		return this.replace(/(^\s*)|(\s*$)/g, "");
	}
}

whois.SSL = {
	_isConn:false,

	initialize:function(connUrl, opts) 
	{
		if(!connUrl || connUrl == '' || typeof connUrl == 'undefined') {
			alert('°ø°³Å° ¼ö½ÅURLÀ» ÁöÁ¤ÇØ ÁÖ½Ê½Ã¿À.');
			return false;
		}
		if(!opts || typeof opts == 'undefined') opts = {}
		var _showInd = (typeof opts.indicator != 'undefined')? opts.indicator : true;
		var _msgIndex = -1;
		if(_showInd) _msgIndex = this.showIndicator(30000, null);

		if(!this._isConn) {
			this._isConn = true;
			var currKey = (opts.conn) ? opts.conn : '0';
			// aSSL ¿¬°á(°ø°³Å° ¼ö½Å)
			aSSL.connect(connUrl, function(response){
				if(response) {
					if(opts.callback) opts.callback(response);
				} else {
					if(_msgIndex > -1) this.hideIndicator(_msgIndex);
					whois.SSL._isConn = false;
					alert('SSL ÀÎÁõ¿¡ ½ÇÆÐÇß½À´Ï´Ù. Àá½Ã ÈÄ ´Ù½Ã ½ÃµµÇØ ÁÖ½Ã±â ¹Ù¶ø´Ï´Ù.');
					return false;
				}
			}, currKey);
		}

		return this._isConn;
	}, 

	isConnected:function() 
	{
		return this._isConn;
	}, 

	/**
	 * whois.SSL.initializeÀÇ º°Äª(±¸¹öÀü È£È¯¿ë)
	 */
	init:function(connUrl, cb, opts) 
	{
		if(!opts || typeof opts == 'undefined') opts = {}
		var _opts = opts;
		if(cb) _opts.callback = cb;
		this.initialize(connUrl, _opts);
	},

	/**
	 * whois.SSL.Request.sendÀÇ º°Äª(±¸¹öÀü È£È¯¿ë)
	 */
	send:function(oForm, opts, callback) 
	{
		this.Request.send(oForm, opts, callback);
	}, 

	/**
	 * whois.SSL.Request.getEncryptData º°Äª(±¸¹öÀü È£È¯¿ë)
	 */
	getEncryptData:function(pageUrl) {
		this.Response.getEncryptData(pageUrl);
	}, 

	mbDecode:function(str)
	{
		if (str != '') {
			var qs = '';
			var flag = '';
			var arrUrl = str.split('&');
			if (arrUrl.length > 1) {
				for (i=0; i<arrUrl.length; i++) {
					// url À» °¢°¢ÀÇ ÆÄ¶ó¹ÌÅÍ
					var arrUrl_token = arrUrl[i].split('=');
					// ÆÄ¶ó¹ÌÅÍ °¢°¢À» key ¿Í value ·Î ±¸ºÐ
					var arrUrl_key = arrUrl_token[0];
					var arrUrl_val = arrUrl[i].replace(arrUrl_token[0]+'=', '');
					// ¾ÏÈ£È­µÈ µ¥ÀÌÅ¸ÀÎ °æ¿ì
					if (arrUrl_val.substr(0, 7) == '@_ENC_@') {
						arrUrl_val = arrUrl_val.substr(7);
						// µ¥ÀÌÅ¸°¡ Å« °æ¿ì ÀÏÁ¤±æÀÌ·Î ³ª´² ¾ÏÈ£È­ ÇÔ(±¸ºÐÀÚ´Â ||^||)
						arrUrl_val_token = arrUrl_val.split('||^||');
						arrUrl_val = '';
						// IE ¿¡¼­ ¹®Á¦°¡ µÉ ¼ö ÀÖÀ½
						if (arrUrl_val_token.length > 12) {
							alert('Àü¼ÛÇÒ µ¥ÀÌÅ¸·®ÀÌ ¸¹À» °æ¿ì, ½ºÅ©¸³Æ® ½ÇÇàÀ» ¸ØÃâ°ÍÀÎÁö È®ÀÎÇÏ´Â Ã¢ÀÌ ³ª¿Ã ¼ö ÀÖ½À´Ï´Ù.\n\r\n\r±×·± °æ¿ì ¹Ýµå½Ã \'¾Æ´Ï¿À\' ¸¦ ¼±ÅÃÇØ ÁÖ½Ê½Ã¿À.');
						}
						for (j=0; j<arrUrl_val_token.length; j++) {
							arrUrl_val = arrUrl_val + aSSL.decrypt(arrUrl_val_token[j], aSSL._current);
						}
					}
					qs = qs + flag + arrUrl_key+'='+Base64.decode(decodeURIComponent(arrUrl_val));
					flag = '&';
				}
			}
			else {
				// ¾ÏÈ£È­µÈ µ¥ÀÌÅ¸ÀÎ °æ¿ì
				if (str.substr(0, 7) == '@_ENC_@') {
					// µ¥ÀÌÅ¸°¡ Å« °æ¿ì ÀÏÁ¤±æÀÌ·Î ³ª´² ¾ÏÈ£È­ ÇÔ(±¸ºÐÀÚ´Â ||^||)
					str_token = str.split('||^||');
					str = '';
					// IE ¿¡¼­ ¹®Á¦°¡ µÉ ¼ö ÀÖÀ½
					if (str_token.length > 12) {
						alert('Àü¼ÛÇÒ µ¥ÀÌÅ¸·®ÀÌ ¸¹À» °æ¿ì, ½ºÅ©¸³Æ® ½ÇÇàÀ» ¸ØÃâ°ÍÀÎÁö È®ÀÎÇÏ´Â Ã¢ÀÌ ³ª¿Ã ¼ö ÀÖ½À´Ï´Ù.\n\r\n\r±×·± °æ¿ì ¹Ýµå½Ã \'¾Æ´Ï¿À\' ¸¦ ¼±ÅÃÇØ ÁÖ½Ê½Ã¿À.');
					}
					for (j=0; j<str_token.length; j++) {
						str = str + aSSL.decrypt(str_token[j], aSSL._current);
					}
				}
				qs = str;
			}
		}
		else {
			qs = str;
		}
		return qs;
	},

	mbEncode:function(_en, str)
	{		
		// ÇÑ±Û ¹®Á¦·Î ÀÎÇØ ¸ðµç µ¥ÀÌÅ¸´Â base64 Ã³¸® ÈÄ encodeURIComponent Ã³¸® ÇØÁÜ
		var qs = encodeURIComponent(Base64.encode(str));

		// ¾ÏÈ£È­¸¦ ¿øÇÏ´Â Ç×¸ñ(encrypt_target ¹è¿­·Î ÁöÁ¤)ÀÌ ¾øÀÌ¸é ¸ðµç Ç×¸ñÀ» ´Ù ¾ÏÈ£È­ ÇÔ
		// whois.SSL.encrypt_target = Array('user_id', 'user_passwd', 'jumin_num'); ·Î ÁöÁ¤
		// whois.SSL.encrypt_target ¹è¿­À» ¼±¾ðÇÏÁö ¾ÊÀº °æ¿ì¿¡´Â ¸ðµç µ¥ÀÌÅ¸¸¦ ¾ÏÈ£È­
		var is_encrypt = false;
		if (typeof whois.SSL.encrypt_target != 'undefined') {
			for (i=0; i<whois.SSL.encrypt_target.length; i++) {
				if (_en == whois.SSL.encrypt_target[i]) {
					is_encrypt = true;
					break;
				}
			}
		}
		else {
			is_encrypt = true;
		}
		if (is_encrypt == false) {
			return qs;
		}

		// ¾ÏÈ£È­.  aSSL ÇÑ°è ¶§¹®¿¡ 2048 ÀÚ ´ÜÀ§·Î Àß¶ó¼­ °¢°¢À» ¾ÏÈ£È­.  ¾ÏÈ£È­µÈ °¢°¢ÀÇ µ¥ÀÌÅ¸´Â ±¸ºÐÀÚ(||^||)·Î ±¸ºÐÇØ ºÙÀÓ
		// ¾ÏÈ£È­ µ¥ÀÌÅ¸ÀÇ ¸Ç ¾Õ¿¡´Â ½Äº°ÀÚ(@_ENC_@)¸¦ ºÙ¿©Áà¼­ ¼­¹öÂÊ ÇÁ·Î±×·¥¿¡¼­ ¾ÏÈ£È­µÈ µ¥ÀÌÅ¸ÀÓÀ» ÀÎÁöÇÏµµ·Ï ÇÔ
		var src_length = qs.length;
		var cnt = parseInt(src_length / 2048);
		var mod = src_length % 2048;
		var send_str = '';
		var send_str_token = '';
		// IE ¿¡¼­ ¹®Á¦°¡ µÉ ¼ö ÀÖÀ½
		if (cnt > 12) {
			alert('Àü¼ÛÇÒ µ¥ÀÌÅ¸·®ÀÌ ¸¹À» °æ¿ì, ½ºÅ©¸³Æ® ½ÇÇàÀ» ¸ØÃâ°ÍÀÎÁö È®ÀÎÇÏ´Â Ã¢ÀÌ ³ª¿Ã ¼ö ÀÖ½À´Ï´Ù.\n\r\n\r±×·± °æ¿ì ¹Ýµå½Ã \'¾Æ´Ï¿À\' ¸¦ ¼±ÅÃÇØ ÁÖ½Ê½Ã¿À.');
		}
		for (var i=0; i<cnt; i++) {
			send_str_token = qs.substr((i * 2048), 2048);
			send_str_token = aSSL.encrypt(send_str_token, aSSL._current);

			if (send_str == '') {
				send_str = send_str_token;
			}
			else {
				send_str = send_str + '||^||' + send_str_token;
			}
		}
		send_str_token = qs.substr((src_length-mod), mod);
		send_str_token = aSSL.encrypt(send_str_token, aSSL._current);		
		if (send_str == '') {
			send_str = send_str_token;
		}
		else {
			send_str = send_str + '||^||' + send_str_token;
		}
		qs = '@_ENC_@'+send_str;
	
		return qs;
	},

	showIndicator:function(duration, callback) {
		var _id = 'whoisssl-alarm-box';
		var _id2 = "#" + _id;
		if(!duration) duration = 30000;
		if(jQuery(_id2).length > 0) return;

		var _msgIndex = whois.Message.create({id:_id, title:'¾ÏÈ£È­¸ðµâ ÀÛµ¿ Áß...', helper:'30ÃÊÈÄ¿¡ ´ÝÈü´Ï´Ù(Å¬¸¯ÇÏ¸é ¹Ù·Î ´ÝÈû)'});

		var msgWidth = jQuery(_id2).outerWidth();
		var msgHeight = jQuery(_id2).outerHeight() + 5;
		jQuery(_id2).css("left", (jQuery(window).width() + jQuery(document).scrollLeft() - msgWidth) + 'px');
		jQuery(_id2).css("top", (jQuery(window).height() + jQuery(document).scrollTop() - msgHeight) + 'px');
		
		jQuery(window).scroll(function () { 
			jQuery(_id2).css("left", (jQuery(window).width() + jQuery(document).scrollLeft() - msgWidth) + 'px');
			jQuery(_id2).css("top", (jQuery(window).height() + jQuery(document).scrollTop() - msgHeight) + 'px');
		});

		jQuery(window).bind("resize", function(){
			jQuery(_id2).css("left", (jQuery(window).width() + jQuery(document).scrollLeft() - msgWidth) + 'px');
			jQuery(_id2).css("top", (jQuery(window).height() + jQuery(document).scrollTop() - msgHeight) + 'px');
		});

		jQuery(_id2).show();

		jQuery(_id2).click(function() {
			clearTimeout();
			jQuery(this).fadeOut(1000);
		});

		setTimeout(function(){
			jQuery(_id2).fadeOut(1000);
		}, duration);

		if(callback) callback();

		return _msgIndex;
	}, 

	hideIndicator:function(msgIndex) {
		whois.Message.hide(msgIndex);
	}, 

	showProgressBox:function(isModal)
	{
		if(typeof isModal == 'undefined') isModal=false;
		var _id = 'whoisssl-progress-box';
		var _id2 = "#" + _id;

		var _msgIndex = whois.Message.create({id:_id, title:'¾ÏÈ£È­ µ¥ÀÌÅÍ Àü¼Û Áß...', modal:isModal});

		jQuery(_id2).css("left", parseInt((jQuery(window).width() / 2) - (jQuery(_id2).width() / 2), 10) + 'px');
		jQuery(_id2).css("top", parseInt((jQuery(window).height() / 2) - (jQuery(_id2).height() / 2), 10) + 'px');

		jQuery(window).bind("resize", function(){
			jQuery(_id2).css("left", parseInt((jQuery(window).width() / 2) - (jQuery(_id2).width() / 2), 10) + 'px');
			jQuery(_id2).css("top", parseInt((jQuery(window).height() / 2) - (jQuery(_id2).height() / 2), 10) + 'px');
		});

		whois.Message.show(_msgIndex);
		return _msgIndex;
	}, 

	hideProgressBox:function(msgIndex) {
		whois.Message.hideModalBg();
		whois.Message.hide(msgIndex);
	}
}

whois.SSL.Request = {
	_defaultOpt:{
		mode:'ajax',
		method:'post',
		async:false, 
		dataType:'json',
		timeout:60
	},

	/**
	 * Àü¼Û °ü·Ã ÇÔ¼öµé...
	 */
	send:function(oForm, opts, callback) 
	{
		if(!opts) opts = {}
		if(!whois.SSL.isConnected()) {
			alert('whois.aSSL °´Ã¼ ÃÊ±âÈ­ ÇÊ¿ä!!');
			return false;
		}

		var _url = oForm.action;
		if(!_url) {
			alert('form °´Ã¼ÀÇ action°ªÀ» ÁöÁ¤ÇØÁÖ½Ê½Ã¿À.');
			return false;
		}

		var qs = this._createQueryString(oForm);
//alert(qs);
//var qs2 = whois.SSL.mbDecode(qs);
//alert(qs2);
//alert(qs2.substr((qs2.length-3), 3));
		var _mode = (opts.mode)?opts.mode:this._defaultOpt.mode;
		var _method = (opts.method)?opts.method:this._defaultOpt.method;
		var _async = (opts.async)?opts.async:this._defaultOpt.async;

		switch(_mode) {
			case 'plain':
				oForm.onsubmit = function() { return false; }
				var pForm = this._createPlainForm(qs, aSSL._current);
				pForm.action = oForm.action;
				if(oForm.method) pForm.method = oForm.method;
				if(oForm.target) pForm.target = oForm.target;
				pForm.submit();
				break;
			case 'ajax':
			default:
				var _msgIndex = whois.SSL.showProgressBox(true);
				var _timeout = (opts.timeout)?opts.timeout:this._defaultOpt.timeout;
				var _dataType = (opts.dataType)?opts.dataType:this._defaultOpt.dataType;
				var _meta = 'is_ssl=Y&dataType=' + _dataType + '&ssl_conn=' + aSSL._current;

				jQuery.ajax({
					url:_url, 
					type:_method, 
					async:_async, 
					data:_meta + "&encdata=" + encodeURIComponent(qs), 
					timeout:_timeout, 
					dataType:_dataType,
					complete:function(xhr, text) {
						try	{
							callback(xhr, text);
						} catch(e) {
							alert('[µ¥ÀÌÅÍ Ã³¸® ¿À·ù]\nµ¥ÀÌÅÍ Ã³¸® Áß ¿À·ù°¡ ¹ß»ýÇß½À´Ï´Ù.\n(' + e.name + ':' + e.message + ')');
							return;
						} finally {

							whois.SSL.hideProgressBox(_msgIndex);
						}
					}
				});
				break;	
		}

		return false;
	}, 

	setMode:function(mode)
	{
		switch(mode.toLowerCase()) {
			case 'plain': case 'ajax': this.Request._defaultOpt.mode = mode; break;
			default: break;
		}

		return this;
	},

	setMethod:function(method)
	{
		switch(method.toLowerCase()) {
			case 'post': case 'get': this.Request._defaultOpt.method = mode; break;
			default: break;
		}

		return this;
	},

	setDataType:function(dataType)
	{
		switch(dataType.toLowerCase()) {
			case 'json': case 'xml': case 'text': this.Request._defaultOpt.dataType = dataType; break;
			default: break;
		}

		return this;
	}, 

	setAsync:function(async)
	{
		switch(async) {
			case true: case false: this.Request._defaultOpt.async = async; break;
		}

		return this;
	}, 
	
	setTimeout:function(timeout)
	{
		timeout = parseInt(timeout, 10);
		if(time > 0) this.Request._defaultOpt.timeout = timeout;

		return this;
	},

	_createQueryString:function(form) 
	{
		var fe = form.elements;
		var buff = new Array();

		buff.push('validate_start='+this.mbEncode('validate_start', 'ok'));
		for(var i=0; i<fe.length; i++) {
			var _ce = fe[i];

			if(jQuery(_ce).attr('disabled')) continue;

			var _en = _ce.name;
			if(!_en) continue;

			var _ev = '';
			switch(_ce.nodeName.toLowerCase()) {
				case 'input':
					var _et = _ce.getAttribute('type').toLowerCase();
					switch(_et) {
						case 'radio':
						case 'checkbox':
							if(_ce.checked) buff.push(_en + '=' + this.mbEncode(_en, _ce.value.trim()));
							break;
						case 'file': 
						case 'button':
						case 'submit':
						case 'cancel':
							continue;
							break;
						case 'text':
						case 'hidden':
						default:
							// fix:¸î¸î ¹®ÀÚÀÇ °æ¿ì ¹®ÀÚ°¡ Àß¸®´Â ¹®Á¦ ¹ß»ý(PHP iconv½Ã utf-8=>euc-kr·Î º¯°æ½Ã...)
							buff.push(_en + '=' + this.mbEncode(_en, _ce.value.trim())); 
							break;
					}
					break;

				case 'select':
					if(_ce.options && _ce.options.length > 0) {
						buff.push(_en + '=' + this.mbEncode(_en, _ce.options[_ce.selectedIndex].value.trim()));
					} 
					break;

				case 'textarea':
					buff.push(_en + '=' + this.mbEncode(_en, jQuery(_ce).html()));
					break;
			}
			
		}
		buff.push('validate_end='+this.mbEncode('validate_end', 'ok'));

		return buff.join('&');
	}, 
	
	_editForm:function(oForm) 
	{
		var fe = oForm.elements;
		for(var i=0; i<fe.length; i++) {
			var _ce = fe[i];
			if(_ce.nodeName.toLowerCase() == 'input' && _ce.type.toLowerCase() == 'file') continue;
			_ce.name = '';
			if(_ce.value) _ce.value = '';
		}

		var _oI1 = document.createElement('input');
		_oI1.setAttribute('type', 'hidden');
		_oI1.setAttribute('name', 'encdata');
		_oI1.setAttribute('value', '');
		oForm.appendChild(_oI1);

		var _oI2 = document.createElement('input');
		_oI2.setAttribute('type', 'hidden');
		_oI2.setAttribute('name', 'is_ssl');
		_oI2.setAttribute('value', 'Y');
		oForm.appendChild(_oI2);
	}, 

	_createPlainForm:function(qs, conn) 
	{
		if(!document.forms['__sys_form_whoisssl_plain']) {
			var _html = '<form name="__sys_form_whoisssl_plain" method="post" action="">';
			_html += '<input type="hidden" name="encdata" value="'+qs+'" />';
			_html += '<input type="hidden" name="is_ssl" value="Y" />';
			_html += '<input type="hidden" name="ssl_conn" value="'+conn+'" />';
			_html += '</form>';
			jQuery(document.body).append(_html);
		} else {
			document.forms['__sys_form_whoisssl_plain'].elements['encdata'].value = qs;
		}
		return document.forms['__sys_form_whoisssl_plain'];
	},

	mbEncode:function(_en, str)
	{
		return whois.SSL.mbEncode(_en, str);
	}
}

whois.SSL.Response = {
	/**
	 * Get encrypt data from server and decrypt data...
	 */
	getEncryptData:function(pageUrl) 
	{
		if(!pageUrl || pageUrl == '' || typeof pageUrl == 'undefined') {
			alert('Page URLÀ» ÁöÁ¤ÇØ ÁÖ½Ê½Ã¿À.');
			return false;
		}
		if(!whois.SSL.isConnected()) {
			alert('whois.aSSL °´Ã¼ ÃÊ±âÈ­ ÇÊ¿ä!!');
			return false;
		}

		var _msgIndex = whois.SSL.showProgressBox(true);

		jQuery.ajax({
			url:pageUrl, 
			type:'post', 
			async:false, 
			data:{ssl_conn:aSSL._current},
			dataType:'json',
			complete:function(xhr, text) {
				try {
					var json = eval('(' + Base64.decode(aSSL.decrypt(decodeURIComponent(xhr.responseText), aSSL._current)) + ')');
					if(parseInt(json.status, 10) != 200) {
						alert('[µ¥ÀÌÅÍ Àü¼Û ¿À·ù]\n¾ÏÈ£È­ µ¥ÀÌÅÍ ¼ö½Å °úÁ¤ Áß ¿À·ù°¡ ¹ß»ýÇß½À´Ï´Ù.\n\nÀá½ÃÈÄ ´Ù½Ã ½ÃµµÇØ ÁÖ½Ã±â ¹Ù¶ø´Ï´Ù.');
						whois.SSL.hideProgressBox(_msgIndex);
						return false;
					}

					var _data = json.encdata;
					var _leng = _data.length;
					for(var i=0; i<_leng; i++) {
						var _decValue = _data[i].value;
						switch(_data[i].type) {
							case 'form':
								var tObj = null;
								if(_data[i].name) {
									tObj = jQuery("*[name=" + _data[i].name + "]");
								} else if(document.getElementById(_data[i].id)) {
									tObj = jQuery(document.getElementById(_data[i].id));
								} else {
									continue;
								}
								
								if(tObj.is('input')) { 
									var _type = tObj.attr('type').toLowerCase();
									switch(_type) {
										case 'text':
										case 'hidden':
											tObj.val(whois.SSL.mbDecode(_decValue)); 
											break;
										case 'checkbox':
										case 'radio':
											tObj.each(function(index){
												if(_type == 'checkbox' && _decValue.length) {
													for(var x=0;x<_decValue.length;x++) {
														if(jQuery(this).val() == whois.SSL.mbDecode(_decValue[x])) jQuery(this).attr("checked", true);
													}
												} else {
													if(jQuery(this).val() == whois.SSL.mbDecode(_decValue)) jQuery(this).attr("checked", true);
												}
											});
											break;
										default:
											continue;
											break;
									}
								}

								if(tObj.is('select')) {
									tObj.find('option').each(function(index){
										if(jQuery(this).val() == whois.SSL.mbDecode(_decValue)) jQuery(this).attr("selected", true);
									});
								}

								if(tObj.is('textarea')) {
									tObj.text(whois.SSL.mbDecode(_decValue));
								}
								break;
							case 'text':
								jQuery("#" + _data[i].id).html(whois.SSL.mbDecode(_decValue));
								break;
						}
					}
				} catch(e) {
					alert('[µ¥ÀÌÅÍ Ã³¸® ¿À·ù]\n' + _data[i].name + ' µ¥ÀÌÅÍ Ã³¸® Áß ¿À·ù°¡ ¹ß»ýÇß½À´Ï´Ù.\n(' + e.name + ':' + e.message + ')');
					return;
				} finally {
					whois.SSL.hideProgressBox(_msgIndex);
				}
			}
		});
	}
}

whois.Message = {
	_msgPool:[],
	
	_defaultOpts:{
		width:"250px", 
		border:"5px solid #9933FF", 
		backgroundColor:"white",
		modal:false
	}, 
	
	create:function(opts) {
		if(!opts || typeof opts == 'undefined') opts = {};

		var _id = "whois-msg-indicator-" + this._msgPool.length;
		if(opts.id) _id = opts.id;

		var _pIndex = jQuery.inArray(_id, this._msgPool);

		// ¸Þ½ÃÁö Ç®¿¡ µî·ÏÀÌ µÇ¾î ÀÖÀ¸¸é »ý¼ºÇÏÁö ¾Ê´Â´Ù.
		if(_pIndex != -1) return _pIndex;

		var _title = 'Message Title';
		if(opts.title) _title = opts.title;

		var _html = '<div id="' + _id + '">';
		_html += '<div class="msg-header">' + _title + '</div>';
		_html += '<div class="img-loader">';
		_html += '<img src="' + _dir + '/img/ajax-loader.gif" alt="ÀÛµ¿ Áß...." />';
		_html += '</div>';
		if(opts.helper) {
			_html += '<div class="msg-helper">' + opts.helper + '</div>';
		}
		_html += '</div>';

		jQuery(document.body).append(_html);

		var _width = (opts.width) ? opts.width : this._defaultOpts.width;
		var _border = (opts.border) ? opts.border : this._defaultOpts.border;
		var _bgColor = (opts.backgroundColor) ? opts.backgroundColor : this._defaultOpts.backgroundColor;

		jQuery("#" + _id).css({
			"width":_width, "border":_border, "background-color":_bgColor, "position":"absolute", "display":"none", "z-index":"99999"
		});

		jQuery("#" + _id + " > .msg-header").css({
			"padding":"8px", "text-align":"center", "font-weight":"bold", "font-size":"12px", "border-bottom":"1px solid #CCC", "background-color":"#EFEFEF"
		});

		jQuery("#" + _id + " > .img-loader").css({
			"padding":"5px", "text-align":"center"
		});

		if(opts.helper) {
			jQuery("#" + _id + " > .msg-helper").css({
				"font-size":"11px", "font-family":"µ¸¿ò", "letter-spacing":"-1px", "padding":"3px", "text-align":"center"
			});
		}

		var _modal = (typeof opts.modal == 'undefined') ? this._defaultOpts.modal:opts.modal;
		switch(_modal){ case true: case false: break; default: _modal = false; break; }

		if(_modal) this.createModalBg();

		// ¸Þ½ÃÁö¹Ú½º Ç®¿¡ Ãß°¡
		this._msgPool.push(_id);
		return jQuery.inArray(_id, this._msgPool);
	}, 

	destroy:function(msgIndex) {
		if(!this._msgPool[msgIndex]) return;

		if(jQuery('#' + this._msgPool[msgIndex]).length > 0) {
			jQuery('#' + this._msgPool[msgIndex]).remove();
		}
		this._msgPool[msgIndex] = null;	
	},

	show:function(msgIndex) {
		if(typeof msgIndex == 'undefined') msgIndex = this._msgPool.length + 1;
		var _index = msgIndex;
		if(!this._msgPool[_index]) {
			_index = this.create();
		}
		jQuery('#' + this._msgPool[_index]).show();
	}, 

	hide:function(msgIndex) {
		if(!this._msgPool[msgIndex]) return;
		jQuery('#' + this._msgPool[msgIndex]).hide();
	},

	createModalBg:function() {
		if(jQuery("#whois-msg-modal-bg").length > 0) {
			jQuery("#whois-msg-modal-bg").css({"background-color":"white", "z-index":"99998"});
		} else {
			jQuery(document.body).append('<div id="whois-msg-modal-bg"></div>');
			jQuery("#whois-msg-modal-bg").css({
				"position":"absolute", "top":"0px", "left":"0px", "width":"100%", "background-color":"white", "z-index":"99998"
			});
			jQuery("#whois-msg-modal-bg").height(jQuery(document).height());
		}
		jQuery("#whois-msg-modal-bg").fadeTo("fast", 0.5);
	}, 

	hideModalBg:function() {
		if(jQuery("#whois-msg-modal-bg").length > 0) {
			jQuery("#whois-msg-modal-bg").css("z-index", "-99998");
			jQuery("#whois-msg-modal-bg").hide();
			return null;
		} 
	}
}
