/**
 * ¹÷½º °ø¿ë ½ºÅ©¸³Æ®
 *
 * @author °æ½ÂÈ£ <daygoods@einsdigital.com>
 * @date 2008-05-20
 */


// Check Const Variables
try {
	Const.nullTmp;
}
catch (e) {
	var Const =
	{
		isLogged		: false,
		isDevMachine	: false,
		isHttps			: false,
		Domain			: { 'Pay' : 'https://pay.bugs.co.kr', 'Reg' : 'https://secure.bugs.co.kr' },
		ImgUrl			: 'http://file.bugsm.co.kr',
		Message			: '1.0',
		nullTmp			: {}
	}
}


var $C = function()
{
	var rElem = document.createElement(arguments[0]);
	if (arguments[1]) rElem.id = arguments[1];
	return rElem;
}


var $RF = function (el, radioGroup)
{
	if($(el).type && $(el).type.toLowerCase() == 'radio')
	{
		var radioGroup = $(el).name;
		var el = $(el).form;
	}
	else if ($(el).tagName.toLowerCase() != 'form')
	{
		return false;
	}

	try
	{
		var checked = $(el).getInputs('radio', radioGroup).find(
			function(re) {return re.checked;}
		);
	}
	catch (e)
	{
		var checked = $$('input[type=radio][name=' + radioGroup + ']').find(
			function(re) {return re.checked;}
		);
	}

	return (checked) ? $F(checked) : null;
}


var $XML = function()
{
	return Try.these
	(
		function() {return new DOMParser()},
		function() {return new ActiveXObject('MSXML2.DOMDocument.6.0')},
		function() {return new ActiveXObject('MSXML2.DOMDocument.5.0')},
		function() {return new ActiveXObject('MSXML2.DOMDocument.4.0')},
		function() {return new ActiveXObject('MSXML2.DOMDocument.3.0')},
		function() {return new ActiveXObject('MSXML2.DOMDocument')},
		function() {return new ActiveXObject('Microsoft.XmlDom')}
	) || false;
}


var XML = 
{
	nodeText : function(objNode)
	{
		if (typeof objNode.text != 'undefined')
		{
			return objNode.text;
		}
		else if (typeof objNode.textContent != 'undefined')
		{
			return objNode.textContent;
		}
		else if (typeof objNode.innerText != 'undefined')
		{
			return objNode.innerText;
		}
		else
		{
			return '';
		}
	}
}


String.prototype.getByte = function()
{
	var tcount = 0;

	for (i=0; i< this.length ;i++)
	{
		if(this.substr(i,1).charCodeAt(0) < 128){
			tcount += 1 ;
		}else{
			tcount += 2 ;
		}
	}

	return tcount;
}


String.prototype.trim = function()
{
	return this.replace(/(^\s*)|(\s*$)/gi, '');
}


Array.prototype.remove=function(s)
{
	if( isNaN(s) || s > this.length ) return false;
	for( var i=0,n=0; i<this.length; i++ ) {
		if( i != s ) this[n++]=this[i];
	}
	this.length-=1;
}


// 2009-08-18 °æ½ÂÈ£ : Object ÇÁ·ÎÅä Å¸ÀÔ È®Àå
Object.extend(Object,
{
	isObject : function(object)
	{
		return object && object.constructor === Object;
	},

	constructorName : function(object)
	{
		if (object.constructor)
		{
			var code = object.constructor.toString();
			match = code.match(/function ([^\(]*)/);

			return (match && match[1]) || null;
		}

		return null;
	},

	merge: function(dest, source)
	{
		for (var x in source)
		{
			if (Object.isObject(source[x]))
			{
				if (!dest[x]){ dest[x] = {}; }
				Object.merge(dest[x],source[x]);
			}
			else
			{
				dest[x] = source[x]; 
			}
		}
		return dest;
	},

	deepClone : function(object)
	{
		var constructor, dst;

		if ((typeof object == "object") && (constructor = Object.constructorName(object)))
		{
			dst = eval("new " + constructor + "()");

			if (object.prototype)
			{
				for (var key in object.prototype)
					dst.prototype[key] = Object.deepClone(object.prototype[key]);
			}

			for (var key in object)
				dst[key] = Object.deepClone(object[key]);

			return dst;
		}
		else
		{
			dst = object;
			return dst; 
		}
	}
}); 


var App =
{
	// App È®ÀÎ
	isIE		: (navigator.appVersion.indexOf('MSIE') != -1)				? true : false,
	isWin		: (navigator.appVersion.toLowerCase().indexOf('win') != -1)	? true : false,
	isOpera		: (navigator.userAgent.indexOf('Opera') != -1)				? true : false,
	nullTmp		: {}
}


var Common =
{
	// Null È®ÀÎ
	isNull : function(argV)
	{
		return (argV == null || argV == '' || argV == '<undefined>' || argV == 'undefined') ? true : false;
	},

	// Cookie ÀúÀå
	setCookie : function(cookieName, cookieValue, expires, path, domain, secure)
	{	
		document.cookie =
			escape(cookieName) + '=' + escape(cookieValue)
			+ (expires ? '; expires=' + expires.toGMTString() : '')
			+ (path    ? '; path=' + path : '')
			+ (domain  ? '; domain=' + domain : '')
			+ (secure  ? '; secure' : '');
	},

	// Cookie °ª ¾ò±â
	getCookie : function(cookieName)
	{
		var cookieValue = '';
		var posName = document.cookie.indexOf(escape(cookieName) + '=');

		if (posName != -1)
		{	
			var posValue = posName + (escape(cookieName) + '=').length;
			var endPos = document.cookie.indexOf(';', posValue);

			if (endPos != -1) cookieValue = unescape(document.cookie.substring(posValue, endPos));
			else cookieValue = unescape(document.cookie.substring(posValue));
		}
		return (cookieValue);
	},

	// Cookie »èÁ¦
	deleteCookie : function()
	{
		var oDate = new Date();
		oDate.setTime(oDate.getTime() - (1000*60*60*24));

		for (var i=0; i<arguments.length; i++)
		{
			this.setCookie(arguments[i], 'cookieValue', oDate, '/', 'bugs.co.kr');
		}
	},

	// »ç¿ëÀÚ È¯°æ ¾ò±â
	Agent : function()
	{
		var isOpera = !!(window.opera);
		var nu = navigator.userAgent;
		var isIE = !isOpera && /MSIE/.test(nu), ie5=false, ie55=false, ie6=false, ie7=false, ie8=false, macIE=false;

		if (isIE) {
			/MSIE ([0-9\.]+)/.exec(nu);
			var ver = parseFloat(RegExp.$1);
			switch (ver) {
				case 5   : ie5 = true; break;
				case 5.5 : ie55= true; break;
				case 6   : ie6 = true; break;
				case 7   : ie7 = true; break;
				case 8   : ie8 = true; break;
				default  :
			}
		}

		return {
			IE     : isIE,
			IE5    : isIE && ie5,
			IE55   : isIE && ie55,
			IE6    : isIE && ie6,
			IE7    : isIE && ie7,
			IE8    : isIE && ie8,
			macIE  : isIE && macIE,
			Gecko  : /Gecko/.test(nu),
			Opera  : isOpera,
			Safari : /WebKit/.test(nu),
			KHTML  : /KHTML/.test(nu)
		}
	},

	// Flash UI
	ShowFL : function()
	{
		var strURL, strID, nWidth, nHeight, strFlashVars, strWmode, strBgColor, strReturn, strHtml

		strURL			= arguments[0] || '';
		strID			= arguments[1] || 'CommonFL';
		nWidth			= arguments[2] || 0;
		nHeight			= arguments[3] || 0;
		strFlashVars	= arguments[4] || '';
		strWmode		= arguments[5] || 'transparent'; // window, opaque, transparent
		strBgColor		= arguments[6] || '';
		strReturn		= arguments[7] || false;
		strHtml			= ''

		// 2009-09-14 °æ½ÂÈ£ : https º¸¾È ÇÁ·ÎÅäÄÝ¿¡¼­ÀÇ codebase,pluginspage https ÇÁ·ÎÅäÄÝ ¼³Á¤
		var strHttp = (Const.isHttps) ? "https://" : "http://";

		if(App.isIE && App.isWin && !App.isOpera)
		{
			strHtml  = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="'+strHttp+'download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'+nWidth+'" height="'+nHeight+'" id="'+strID+'" name="'+strID+'" align="middle">';
			strHtml += '	<param name="quality"				value="high" />';
			strHtml += '	<param name="allowScriptAccess"		value="always" />';
			strHtml += '	<param name="showLiveConnect"		value="true" />';
			strHtml += '	<param name="movie"					value="'+strURL+'" />';
			strHtml += '	<param name="wmode"					value="'+strWmode+'" />';
			strHtml += '	<param name="bgcolor"				value="'+strBgColor+'" />';
			strHtml += '	<param name="FlashVars"				value="'+strFlashVars+'">';
			strHtml += '</object>';
		}
		else
		{
			strHtml += '<embed width="'+nWidth+'" height="'+nHeight+'" id="'+strID+'" name="'+strID+'" quality="high" allowScriptAccess="always" showLiveConnect="true" src="'+strURL+'"  wmode="'+strWmode+'" bgcolor="'+strBgColor+'" FlashVars="'+strFlashVars+'" align="middle" type="application/x-shockwave-flash" pluginspage="'+strHttp+'www.macromedia.com/go/getflashplayer" />';
		}

		if(strReturn)	{ return strHtml; }
		else			{ document.write(strHtml); }
	},


	// À©µµ¿ì Å©±â º¯°æ
	resizeWindow : function()
	{
		try	{
			var tStep = new Array(200, 500, 1500, 3500, 7000, 12000, 20000);
			for(var i=0; i < tStep.length; i++)
			{
				window.setTimeout(this.doResizeWindow.bind(this), tStep[i]);
			}
		}
		catch(e) { }
	},

	doResizeWindow : function(argObj)
	{
		try {
			if(Common.isNull(argObj)) argObj = $('__RESIZE_AREA__');
			window.resizeBy(argObj.clientWidth-document.body.clientWidth, argObj.clientHeight-document.body.clientHeight);
		}
		catch (e) {}
	},


	// ÇÁ·¹ÀÓ Å©±â º¯°æ
	resizeFrame : function()
	{
		try	{
			var tStep = new Array(200, 500, 1500, 3500, 7000, 12000, 20000);
			for(var i=0; i < tStep.length; i++)
			{
				window.setTimeout(this.doResizeFrame.bind(this), tStep[i]);
			}
		}
		catch(e) { }
	},

	doResizeFrame : function()
	{
		try {
			window.resizeTo(document.body.scrollWidth, document.body.scrollHeight);
			document.body.style.height = document.body.scrollHeight;
		}
		catch(e) { }
	},

	doResizeFrmContent : function()
	{
		var size = arguments[0] || 0;
		try {
			var objFrm = document.getElementById("frmContent");

		    if(size!=0)
		    {
		   		objFrm.style.height=size;
		    }
		}
		catch(e) { }
	},

	/*
	// 2008-06-25 : °æ½ÂÈ£ :=> ÀÓ½Ãº¸·ù

	// À©µµ¿ì¿¡¼­ body ÀÌ¿ÜÀÇ Å©±â °è»ê
	windowMargin :
	{
		width	: 0,
		height	: 0,
		isSet	: false,

		setValue: function()
		{
			if (!this.isSet)
			{
				curWidth	= document.body.clientWidth;
				curHeight	= document.body.clientHeight;
				window.resizeTo(250, 150);

				this.width	= 250 - document.body.clientWidth;
				this.height	= 150 - document.body.clientHeight;
				window.resizeTo(this.width+curWidth, this.height+curHeight);

				this.isSet = true;
			}
		}
	},

	// À©µµ¿ì Å©±â º¯°æ
	resizeWindow : function()
	{
		var SetWidth  = 0;
		var SetHeight = 0;

		SetWidth  = (!arguments[0]) ? document.body.scrollWidth  : arguments[0];
		SetHeight = (!arguments[1]) ? document.body.scrollHeight : arguments[1];

		try {
			Common.windowMargin.setValue();
			window.resizeTo(Common.windowMargin.width+SetWidth, Common.windowMargin.height+SetHeight);
		} catch(e) {}
	},

	// ÇÁ·¹ÀÓ Å©±â º¯°æ
	resizeFrame : function()
	{
		var SetWidth  = 0;
		var SetHeight = 0;

		SetWidth  = (!arguments[0]) ? document.body.scrollWidth  : arguments[0];
		SetHeight = (!arguments[1]) ? document.body.scrollHeight : arguments[1];

		try {
			window.resizeTo(SetWidth, SetHeight);
		} catch(e) {}
	},
	*/

	nullTmp : {}
}


var LF =
{
	// ÀüÃ¼ ¼±ÅÃ, ÇØÁ¦
	doSelectCheck : function()
	{
		var objCheck = arguments[0] || null;

		if (Common.isNull(objCheck.isCheck))
		{
			this.doSelectCheckAll(arguments[1]);
			objCheck.isCheck = true;
		}
		else
		{
			this.doSelectCheckCancel(arguments[1]);
			objCheck.isCheck = false;
		}

		/*
		var objFrm;
		if (arguments.length > 0)	objFrm = arguments[0] || document.all;
		else						objFrm = document.all;

		if (!objFrm.SelectCheckBox) return;

		if (objFrm.SelectCheckBox.length > 0)
		{
			for (i=0;i<objFrm.SelectCheckBox.length;i++)
			{
				objFrm.SelectCheckBox[i].checked = !objFrm.SelectCheckBox[i].checked;
			}
		}
		else
		{
			objFrm.SelectCheckBox.checked = !objFrm.SelectCheckBox.checked;
		}
		*/
	},


	// ÀüÃ¼ ¼±ÅÃ
	doSelectCheckAll : function()
	{
		var objFrm;
		if (arguments.length > 0)	objFrm = arguments[0] || document.all;
		else						objFrm = document.all;

		if (!objFrm.SelectCheckBox) return;

		if (objFrm.SelectCheckBox.length > 0)
		{
			for (i=0;i<objFrm.SelectCheckBox.length;i++)
			{
				if(!objFrm.SelectCheckBox[i].disabled){
					objFrm.SelectCheckBox[i].checked = true;
				}
			}
		}
		else
		{
			objFrm.SelectCheckBox.checked = true;
		}
	},


	// ÀüÃ¼ ¼±ÅÃ ÇØÁ¦
	doSelectCheckCancel : function()
	{
		var objFrm;
		if (arguments.length > 0)	objFrm = arguments[0] || document.all;
		else						objFrm = document.all;

		if (!objFrm.SelectCheckBox) return;

		if (objFrm.SelectCheckBox.length > 0)
		{
			for (i=0;i<objFrm.SelectCheckBox.length;i++)
			{
				objFrm.SelectCheckBox[i].checked = false;
			}
		}
		else
		{
			objFrm.SelectCheckBox.checked = false;
		}
	},


	// ¼±ÅÃ°ª ¾ò±â
	getSelectCheckValue : function()
	{
		var objFrm, chkLen;
		var nCnt=0, tmpVal = '', SelectVal = '';

		if (arguments.length > 0)
		{
			objFrm = arguments[0] || document.all;
			chkLen = (!Common.isNull(objFrm.SelectCheckBox)) ? (objFrm.SelectCheckBox.length || 1) : 0;
		}
		else
		{
			objFrm = document.all;
			chkLen = document.getElementsByName('SelectCheckBox').length;
		}

		if (!chkLen) return;

		if (chkLen > 1)
		{
			for (i=0;i<objFrm.SelectCheckBox.length;i++)
			{
				if (objFrm.SelectCheckBox[i].checked && !objFrm.SelectCheckBox[i].disabled)
				{
					if (objFrm.SelectCheckBox[i].value)
					{
						tmpVal = tmpVal+objFrm.SelectCheckBox[i].value+',';
						nCnt++;
					}
				}
			}
			SelectVal = tmpVal.substr(0,tmpVal.length - 1);
		}
		else
		{
			if (objFrm.SelectCheckBox.checked && !objFrm.SelectCheckBox.disabled)
			{
				if (objFrm.SelectCheckBox.value)
				{
					SelectVal = objFrm.SelectCheckBox.value;
					nCnt++;
				}
			}
		}
		return SelectVal;
	},

	//¼±ÅÃ°¹¼ö ¾ò±â
	getSelectCheckCount : function()
	{
		var objBox, chkLen;
		var nCnt=0;

		objBox = document.getElementsByName('SelectCheckBox');
		chkLen = objBox.length;

		if (!chkLen) return;

		if (chkLen > 0)
		{
			for (var i=0; i < chkLen; i++)
			{
				if (objBox[i].checked && !objBox[i].disabled)
				{
					nCnt++;
				}
			}
		}
		return nCnt;
	},

	nullTmp : {}
}


var FN =
{
	imgSrcRegex		: /(_(?:o|on|off|over|down))?\.([0-9a-z]+)$/gi,
	lineFlatRegex	: /<br\s*\/?>|\n|\r|&nbsp;/gi,
	emailRegex		: /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i,

	// ·¥´ý ¹è¿­
	randArray : function()
	{
		var SourceArray = ($A(arguments[0]) || new Array()).compact();
		var ResultArray = new Array();

		while(0 < SourceArray.length)
		{
			var index = parseInt(Math.random() * SourceArray.length);
			ResultArray.push(SourceArray[index]);
			SourceArray.splice(index, 1);
		}

		return ResultArray;
	},

	// ¶óµð¿À ¹öÆ° ¼±ÅÃ
	setRadioValue : function(elementName, value)
	{
		var elements = document.getElementsByName(elementName);
		for (var i=0; i<elements.length; i++)
		{
			if (elements[i].value == value) {
				elements[i].checked = true;
				return;
			}
		}
	},

	// ÀÌ¹ÌÁö ÇÊÅÍ
	imgSrcChange : function(originalText, changeString)
	{
		return originalText.replace(this.imgSrcRegex, changeString);
	},

	// ¶óÀÎ ÅØ½ºÆ® ÇÊÅÍ
	changeLineFlat : function(originalText)
	{
		return originalText.replace(this.lineFlatRegex, '');
	},

	// ÆÄÀÏ È®ÀåÀÚ
	getFileExtension : function(strFileName)
	{
		return (strFileName.indexOf('.') < 0) ? '' : strFileName.substring(strFileName.lastIndexOf('.') + 1, strFileName.length);
	},

	// ±ÛÀÚ ¼ö È®ÀÎ
	getStringByte : function(strText)
	{
		var nLen = 0, strChar = '';

		for(var i=0; i<strText.length; i++)
		{
			strChar = strText.charAt(i);

			if(escape(strChar).length >4)	nLen += 2;
			else							nLen++;
		}

		return nLen;
	},

	// ±ÛÀÚ ¼ö Á¦ÇÑ
	getStringCut : function(strText, nLimit)
	{
		var nLen = 0, strChar = '', rChar = '';

		for(var i=0; i<strText.length; i++)
		{
			strChar = strText.charAt(i);

			if(escape(strChar).length >4)	nLen += 2;
			else							nLen++;

			if(nLen > nLimit) break;
			rChar += strChar;
		}

		return rChar;
	},

	// ÀÌ¸ÞÀÏ ÁÖ¼Ò °Ë»ç
	isEmailCheck : function(strEmail)
	{
		return this.emailRegex.test(strEmail);
	},

	// ÁÖ¹Î¹øÈ£ È®ÀÎ
	isSsnCheck : function(strSsn)
	{
		var isForeigner = false;
		switch (strSsn.substr(6,1))
		{
			case '5'	:
			case '6'	:
			case '7'	:
			case '8'	: isForeigner = true;	break;
			default		: isForeigner = false;	break;
		}

		// ¿Ü±¹ÀÎ È®ÀÎ
		if (isForeigner)
		{
			return this.isFgnSsnCheck(strSsn);
		}
		else
		{
			var strCheckKey = '234567892345';
			var nCheckNo = 0, nCheckVal= 0, rVal;

			for (var i=0;i<strCheckKey.length;i++)
			{
				nCheckNo += strSsn.charAt(i) * strCheckKey.charAt(i);
			}
			nCheckVal = strSsn.charAt(i);

			rVal = 11 - (nCheckNo % 11)
			if (rVal > 9) rVal = (rVal % 10);

			return (nCheckVal == rVal) ? true : false;
		}
	},

	// ÁÖ¹Î¹øÈ£ È®ÀÎ - ¿Ü±¹ÀÎ
	isFgnSsnCheck : function(strSsn)
	{
		var strCheckKey = '234567892345';
		var nCheckNo = 0, nCheckVal= 0, rVal;
		var nList = new Array(13);

		for (var i=0;i<13;i++)
		{
			nList[i] = strSsn.charAt(i);
		}

		if(nList[11] < 6) return false;
		if((nList[7]*10 + nList[8])&1) return false;

		for (var i=0;i<strCheckKey.length;i++)
		{
			nCheckVal += nList[i] * strCheckKey.charAt(i);
		}

		if ((nCheckVal  = 11 - (nCheckVal%11)) >= 10) nCheckVal -= 10;
		if ((nCheckVal += 2) >= 10) nCheckVal -= 10;

		return (nCheckVal != nList[12]) ? false : true;
	},

	// Caps Lock Ã¼Å©
	isCapsLock : function (e)
	{
		nKeyCode	= (e.keyCode) ? e.keyCode : e.which;
		bShiftKey	= (e.shiftKey) ? e.shiftKey : ((nKeyCode == 16) ? true : false);

		if ( ((nKeyCode >= 65 && nKeyCode <= 90) && !bShiftKey) || ((nKeyCode >= 97 && nKeyCode <= 122) && bShiftKey) )
		{
			return true;
		}
		else
		{
			return false;
		}
	},

	// ³¯Â¥ Ã¼Å©
	isValidDate : function(argYear, argMonth, argDay)
	{
		var nYear	= parseInt(argYear, 10);
		var nMonth	= parseInt(argMonth, 10) - 1;
		var nDay	= parseInt(argDay, 10);

		var oDate = new Date();

		oDate.setFullYear(nYear);
		oDate.setMonth(nMonth);
		oDate.setDate(nDay);

		if (oDate.getFullYear()	!= nYear ||
			oDate.getMonth()	!= nMonth ||
			oDate.getDate()		!= nDay)
		{
			return false;
		}
		else
		{
			return true;
		}
	},

	// ¼ýÀÚ ÀÚ¸´¼ö ÄÞ¸¶
	doNumberFormat : function(argNum)
	{
		var aValue  = String(argNum).split(".");
		var nRegExp = /(-?[0-9]+)([0-9]{3})/;

		while (nRegExp.test(aValue[0])) 
		{
			aValue[0] = aValue[0].replace(nRegExp, "$1,$2");
		}

		return aValue.join('.');
	},

	nullTmp : {}
}


var Util =
{
	doBuildBlock : function()
	{
		var theDiv	= arguments[0] || document.body;
		var theHtml	= '<div id="__PrintBlock__" style="display: none; position: absolute; background-color: #000000; '
					+ '		width: 100%; height: 100%; left: 0px; top: 0px; z-index: 50000; opacity:0.3; filter:alpha(opacity=30);" '
					+ '		onclick="return false" onmousedown="return false" onmousemove="return false" onmouseup="return false" ondblclick="return false">'
					+ '&nbsp;'
					+ '</div>';
		new Insertion.Top(theDiv, theHtml);

		$('__PrintBlock__').setStyle({ width : theDiv.scrollWidth + 'px', height : theDiv.scrollHeight + 'px' });
		Event.observe(window, 'scroll', this.doSizeCheck.bindAsEventListener(this, theDiv));

		return $('__PrintBlock__');
	},

	doSizeCheck : function(e, argElement)
	{
		if (!Common.isNull(e))
		{
			$('__PrintBlock__').setStyle({ width : argElement.scrollWidth + 'px', height : argElement.scrollHeight + 'px' });
		}
	},

	Block:function()
	{
		try
		{
			var boolFlag  = arguments[0] || false;
			var strTarget = arguments[1] || null;
			var DivPrintBlock = $('__PrintBlock__') || this.doBuildBlock(strTarget);

			if(!Common.isNull(strTarget))
			{
				$(strTarget).makePositioned();
				DivPrintBlock.setStyle({ backgroundColor : '#ffffff' });
			}

			(boolFlag) ? DivPrintBlock.show() : DivPrintBlock.hide();
		}
		catch (e) {}
	},

	doBuildLoading : function()
	{
		var theDiv	= arguments[0] || document.body;
		var theHtml	= '<div id="__PrintLoading__" style="display: none; position: absolute; width: 100%; height: 100%; left: 0px; top: 0px; z-index: 60000;">'
					+ '<table border="0" width="100%" height="100%" cellpadding="0" cellspacing="0"><tr><td align="center" valign="middle">'
					+  Common.ShowFL(Const.ImgUrl+'/bugs/flash/common/Loading.swf', 'Loading', '80', '80', '', 'transparent', '', true)
					+ '</td></tr></table>'
					+ '</div>';
		new Insertion.Top(theDiv, theHtml);
		return $('__PrintLoading__');
	},

	doBuildLoading2 : function()
	{
		var theDiv	= arguments[0] || document.body;
		var theHtml	= '<div id="__PrintLoading__" style="display: none; position: absolute; width: 100%; height: 100%; left: 0px; top: 0px; z-index: 60000;">'
					+ '<table border="0" width="100%" height="100%" cellpadding="0" cellspacing="0"><tr><td align="center" valign="middle">'
					+ '<img src="http://file.bugsm.co.kr/bugs/images/common/ani/inprogress.gif" width="220" height="19" alt="Loading...">'
					+ '</td></tr></table>'
					+ '</div>';
		new Insertion.Top(theDiv, theHtml);
		return $('__PrintLoading__');
	},

	Loading : function(boolFlag)
	{
		try
		{
			var boolFlag  = arguments[0] || false;
			var strTarget = arguments[1] || null;
			var DivPrintLoading = $('__PrintLoading__') || this.doBuildLoading(strTarget);

			(boolFlag) ? DivPrintLoading.show() : DivPrintLoading.hide();
		}
		catch (e) {}
	},

	Loading2 : function(boolFlag)
	{
		try
		{
			var boolFlag  = arguments[0] || false;
			var strTarget = arguments[1] || null;
			var DivPrintLoading = $('__PrintLoading__') || this.doBuildLoading2(strTarget);

			(boolFlag) ? DivPrintLoading.show() : DivPrintLoading.hide();
		}
		catch (e) {}
	},

	// Block & Loading
	doBlockAndLoading : function ()
	{
		var boolFlag  = arguments[0] || false;
		var strTarget = arguments[1] || null;

		if (!Common.isNull(arguments[2]))
		{
			this.Block(boolFlag, strTarget);
			this.Loading2(boolFlag, strTarget);
		}
		else
		{
			this.Block(boolFlag, strTarget);
			this.Loading(boolFlag, strTarget);
		}
	},

	doMessageShow : function()
	{
		var oTarget		= $(arguments[0]) || null;
		var oMessage	= $(arguments[1]) || null;
		var oOption		= Object.extend({
			left		: 0,
			top			: 1
		}, arguments[2] || {});

		if (!Common.isNull(oTarget))
		{
			var nPosi = Position.cumulativeOffset(oTarget); // 0 : left, 1 : top
			var nSize = oTarget.getDimensions();

			oMessage.setStyle({
					'top'		: (nPosi[1] + nSize.height + oOption.top) + 'px',
					'left'		: (nPosi[0] + oOption.left) + 'px',
					'display'	: ''
				});
		}
	},

	doMessageHide : function()
	{
		var oMessage = $(arguments[0]) || null;

		if (!Common.isNull(oMessage))
		{
			oMessage.hide();
		}
	},

	nullTmp : {}
}


// Sliding
Util.Sliding = new Class.create();
Util.Sliding.prototype =
{
	initialize : function()
	{
		if(arguments.length < 1) return false;

		this.element	= $(arguments[0]);
		this.timer		= null;
		this.running	= false;
		this.isOpen		= false;
		this.options	=
		{
			type		: 'left', // left, top
			step		: 10,
			offset		: 0
		};
		Object.extend(this.options, arguments[1] || {});

		var aPosi		= Position.cumulativeOffset(this.element);
		this.value		=
		{
			nCurLeft	: aPosi[0],
			nCurTop		: aPosi[1],
			nLimitLeft	: aPosi[0] + this.options.offset || 0,
			nLimitTop	: aPosi[1] + this.options.offset || 0
		};
	},

	Doing : function()
	{
		if (!this.isOpen)
		{
			this.Open();
			this.isOpen = true;
		}
		else
		{
			this.Close();
			this.isOpen = false;
		}
	},

	Open : function()
	{
		//alert(Debug.dump(this.value))
		this.element.setStyle({ display: 'inline' });
		switch (this.options.type)
		{
			case 'left' :
				if (this.value.nLimitLeft - this.value.nCurLeft > 1)
				{
					this.value.nCurLeft	= this.value.nCurLeft+(this.value.nLimitLeft-this.value.nCurLeft)/this.options.step;

					this.element.setStyle({ left: this.value.nCurLeft + 'px' });
					this.timer = setTimeout(this.Open.bind(this), 10);
				}
				else
				{
					this.value.nCurLeft	= this.value.nLimitLeft;

					this.element.setStyle({ left: this.value.nCurLeft + 'px' });
					clearTimeout(this.timer);
				}
			break;

			case 'top' :
				if (this.value.nLimitTop - this.value.nCurTop > 1)
				{
					this.value.nCurTop = this.value.nCurTop+(this.value.nLimitTop-this.value.nCurTop)/this.options.step;

					this.element.setStyle({ top: this.value.nCurTop + 'px' });
					this.timer = setTimeout(this.Open.bind(this), 10);
				}
				else
				{
					this.value.nCurTop = this.value.nLimitTop;

					this.element.setStyle({ top: this.value.nCurTop + 'px' });
					clearTimeout(this.timer);
				}
			break;

			default :
				return;
		}
	},

	Close : function()
	{
		//top.document.title = (this.value.nCurLeft) +'/'+ (this.value.nLimitLeft -this.options.offset + this.options.step);
		//alert(Debug.dump(this.value))
		switch (this.options.type)
		{
			case 'left' :
				if (this.value.nCurLeft >= (this.value.nLimitLeft -this.options.offset + this.options.step))
				{
					this.value.nCurLeft = this.value.nCurLeft-(Math.abs(this.value.nLimitLeft)/this.options.step);

					this.element.setStyle({ left: this.value.nCurLeft + 'px' });
					this.timer = setTimeout(this.Close.bind(this), 10);
				}
				else
				{
					this.value.nCurLeft = this.value.nLimitLeft -this.options.offset;

					this.element.setStyle({ left: this.value.nCurLeft + 'px' });
					clearTimeout(this.timer);
				}
			break;

			case 'top' :
				if (this.value.nCurTop >= (this.value.nLimitTop -this.options.offset + this.options.step))
				{
					this.value.nCurTop = this.value.nCurTop-(Math.abs(this.value.nLimitTop)/this.options.step);

					this.element.setStyle({ top: this.value.nCurTop + 'px' });
					this.timer = setTimeout(this.Close.bind(this), 10);
				}
				else
				{
					this.value.nCurTop = this.value.nLimitTop -this.options.offset;

					this.element.setStyle({ top: this.value.nCurTop + 'px' });
					clearTimeout(this.timer);
				}
			break;

			default		:
				return;
		}
	},

	End : function()
	{
	},

	nullTmp : {}
}


// Slide Class
Util.Slide = new Class.create();
Util.Slide.prototype =
{
	initialize : function()
	{
		this.handleElement	= ($(arguments[0]) || null);
		this.trackElement	= ($(arguments[1]) || null);
		this.fillElement	= ($(arguments[2]) || null);

		this.running		= false;
		this.value			= 0;
		this.options = {
			axis	: 'horizontal',
			max		: null,
			min		: null,
			offset	: 0
		};
		Object.extend(this.options, arguments[3] || {});

		var trackPos	= Position.cumulativeOffset(this.trackElement);
		if(this.options.axis == 'horizontal') {
			this.options.min	= 0;
			this.options.max	= this.options.min + Element.getWidth(this.trackElement) - Element.getWidth(this.handleElement);
			this.options.offset	= (Element.getWidth(this.handleElement) / 2) + trackPos[0];
		} else {
			this.options.min	= 0;
			this.options.max	= this.options.min + Element.getHeight(this.trackElement) - Element.getHeight(this.handleElement);
			this.options.offset	= (Element.getHeight(this.handleElement) / 2) + trackPos[1];
		}

		Position.absolutize(this.handleElement);

		this.eventDragStart	= this.startDrag.bindAsEventListener(this);
		this.eventDragMove	= this.moveDrag.bindAsEventListener(this);
		this.eventDragEnd	= this.endDrag.bindAsEventListener(this);

		Event.observe(this.trackElement,	'mousedown',	this.eventDragStart);
	},

	startDrag : function(event)
	{
		this.running		= true;

		Event.observe(document.body,	'mousemove',	this.eventDragMove);
		Event.observe(document.body,	'mouseup',		this.eventDragEnd);

		this.onDragStart();
		this.moveDrag(event);

		Event.stop(event);
	},

	moveDrag : function(event)
	{
		var movePos	= 0;
		if(this.options.axis == 'horizontal') {
			movePos	= Event.pointerX(event) - this.options.offset;
			movePos	= Math.min(movePos, this.options.max);
			movePos	= Math.max(movePos, this.options.min);
			Element.setStyle(this.handleElement, { 'left' : movePos +'px' });
			if(this.fillElement != null) {
				Element.setStyle(this.fillElement, { 'width' : movePos +'px' });
			}
		} else {
			movePos	= Event.pointerY(event) - this.options.offset;
			movePos	= Math.min(movePos, this.options.max);
			movePos	= Math.max(movePos, this.options.min);
			Element.setStyle(this.handleElement, { 'top' : movePos +'px' });
			if(this.fillElement != null) {
				Element.setStyle(this.fillElement, { 'height' : movePos +'px' });
			}
		}

		this.value	= movePos / this.options.max * 100;

		this.onDragMove();

		Event.stop(event);
	},

	endDrag : function(event)
	{
		Event.stopObserving(document.body,	'mousemove',	this.eventDragMove);
		Event.stopObserving(document.body,	'mouseup',		this.eventDragEnd);

		this.onDragEnd();

		this.running		= false;

		Event.stop(event);
	},

	setValue : function()
	{
		if(arguments.length > 0) {
			var changeValue	= (parseInt(arguments[0]) || 0);
			var movePos		= this.options.max / 100 * changeValue;

			if(this.options.axis == 'horizontal') {
				Element.setStyle(this.handleElement, { 'left' : movePos +'px' });
				if(this.fillElement != null) {
					Element.setStyle(this.fillElement, { 'width' : movePos +'px' });
				}
			} else {
				Element.setStyle(this.handleElement, { 'top' : movePos +'px' });
				if(this.fillElement != null) {
					Element.setStyle(this.fillElement, { 'height' : movePos +'px' });
				}
			}
		}
	},

	onDragStart		: function()	{},
	onDragMove		: function()	{},
	onDragEnd		: function()	{}
}


// Shift Class
Util.Shift = new Class.create();
Util.Shift.prototype =
{
	initialize : function()
	{
		this.pElements		= arguments[0] || null;
		this.isListPrefix	= arguments[1] || null;
		this.isListObject	= null;
		this.isListHeight	= 25;
	},

	// ¸®½ºÆ® Á¤º¸
	getListObject : function()
	{
		return $(this.pElements).childElements();
	},

	// ¸®½ºÆ® Á¤º¸ ¼³Á¤
	setListObject : function()
	{
		this.isListObject = $(this.pElements).childElements();
	},

	// ÇöÀç ¸ñ·Ï ¾ò±â (Key)
	getCurrentAllList : function()
	{
		if (Common.isNull(this.isListObject)) this.isListObject = this.getListObject();

		var rtnVal = new Array();
		for (var i=0; i<this.isListObject.length; i++)
		{
			rtnVal.push(this.isListObject[i].nodeKey);
		}

		return rtnVal.join(',');
	},

	// ÇöÀç ¸ñ·Ï ½ÃÀÛ Á¤·Ä¹øÈ£ ¾ò±â
	getCurrentStartNo : function()
	{
		if (Common.isNull(this.isListObject)) this.isListObject = this.getListObject();
		return (this.isListObject.length > 0) ? this.isListObject[0].nodeSNo : null;
	},

	// ¸®½ºÆ® ³ëµå Á¤º¸
	getListNodeNo : function()
	{
		return parseInt($(this.isListPrefix+arguments[0]).nodeNo) || 0;
	},

	// ÀüÃ¼ ¸®½ºÆ® Àç ¼³Á¤
	setListHeightReset : function()
	{
		if (Common.isNull(this.isListObject)) this.isListObject = this.getListObject();
		$(this.pElements).setStyle({ 'height' : (this.isListObject.length*this.isListHeight)+'px' });
	},

	// ¸®½ºÆ® ¼ø¼­ º¯°æ
	doMoveListChange : function(argObjList,argSKey,argTKey)
	{
		var tmpValue = argObjList[argSKey];

		argObjList[argSKey] = argObjList[argTKey];
		argObjList[argTKey] = tmpValue;
	},

	// ¸®½ºÆ® ¼ø¼­ À§·Î
	doMoveListUp : function()
	{
		var mSeq = this.getListNodeNo(arguments[0]) || 0;
		if (Common.isNull(this.isListObject)) this.isListObject = this.getListObject();

		if(mSeq == '0')
		{
			alert('´õ ÀÌ»ó À§·Î ÀÌµ¿ÇÒ ¼ö ¾ø½À´Ï´Ù.');
			return;
		}
		else
		{
			var objSelect = this.isListObject[mSeq];
			var objTarget = this.isListObject[mSeq-1];

			var S_Top = objTarget.getStyle('top'), S_Left = objTarget.getStyle('left');
			var T_Top = objSelect.getStyle('top'), T_Left = objSelect.getStyle('left');

			objSelect.setStyle({
					'top'		: S_Top,
					'left'		: S_Left
				});

			objTarget.setStyle({
					'top'		: T_Top,
					'left'		: T_Left
				});

			objSelect.nodeNo = mSeq-1;
			objTarget.nodeNo = mSeq;

			this.doMoveListChange(this.isListObject,mSeq,mSeq-1);
		}
	},

	// ¸®½ºÆ® ¼ø¼­ ¾Æ·¡·Î
	doMoveListDn : function()
	{
		var mSeq = this.getListNodeNo(arguments[0]) || 0;
		if (Common.isNull(this.isListObject)) this.isListObject = this.getListObject();

		if (mSeq == (this.isListObject.length-1))
		{
			alert('´õ ÀÌ»ó ¾Æ·¡·Î ÀÌµ¿ÇÒ ¼ö ¾ø½À´Ï´Ù.');
			return;
		}
		else
		{
			var objSelect = this.isListObject[mSeq];
			var objTarget = this.isListObject[mSeq+1];

			var S_Top = objTarget.getStyle('top'), S_Left = objTarget.getStyle('left');
			var T_Top = objSelect.getStyle('top'), T_Left = objSelect.getStyle('left');

			objSelect.setStyle({
					'top'		: S_Top,
					'left'		: S_Left
				});

			objTarget.setStyle({
					'top'		: T_Top,
					'left'		: T_Left
				});

			objSelect.nodeNo = mSeq+1;
			objTarget.nodeNo = mSeq;

			this.doMoveListChange(this.isListObject,mSeq,mSeq+1);
		}
	},

	nullTmp : {}
}


// Bugs Flash Utils
// Flash 10.x Debugs Editing...
var BFU =
{
	sModuleId : null,
	sModulePath : null,

	doConstruct : function()
	{
		/*
		if (Common.isNull(this.sModuleId))
		{
			this.sModuleId		= 'BugsFlashUtil'+(new Date).getMilliseconds()+Math.floor(Math.random()*100000);
			this.sModulePath	= '/global/common/general/BugsFlashUtil.swf';

			var theHtml			= '<div style="position:absolute; left:-1000px; top:-1000px">'
								+ Common.ShowFL(this.sModulePath, this.sModuleId, '0', '0', null, null, true)
								+ '</div>';
			new Insertion.Top(document.body, theHtml);
		}
		*/
	},

	setClipboard : function(sString, sMessage)
	{
		if(sString) bResult = window.clipboardData.setData('Text', sString);
		if(sMessage && bResult) window.alert(sMessage);

		return true;
		/*
		var bResult = false;
		try
		{
			var oBugsFlashUtil = $(this.sModuleId) || null;
			if(oBugsFlashUtil)
			{
				if(sString) bResult = oBugsFlashUtil.setClipboard(sString);
				if(sMessage && bResult) alert(sMessage);
			}
			return bResult;
		}
		catch(e)
		{
			if(sString) bResult = window.clipboardData.setData('Text', sString);
			if(sMessage && bResult) window.alert(sMessage);
			return bResult;
		}
		*/
	},

	nullTmp : {}
}


// ·Î±×ÀÎ Á¤º¸
var Login =
{
	// Do not used!
	getLogged : function()
	{
		var doSuccessProc = function(Request)
		{
			Const.isLogged = (Request.responseText.trim() == '1') ? true : false;
		}

		var doFailureProc = function(Request)
		{
			Const.isLogged = false;
		}

		new Ajax.Request(
			'/global/common/general/isLogged.php',
			{
				method			: 'get',
				onSuccess		: doSuccessProc.bind(this),
				onFailure		: doFailureProc.bind(this)
			}
		);
	},

	doPopLogin : function()
	{
		var _parameter = Array();

		if (arguments[0] == 'ND')
		{
			_parameter.push('SetDomainYN=N');
			_parameter.push('rUrl='+Base64.encode(location.href));
		}
		else
		{
			if (!Common.isNull(arguments[0])) _parameter.push('opener='+arguments[0]);
			if (!Common.isNull(arguments[1])) _parameter.push('rUrl='+arguments[1]);
			if (!Common.isNull(arguments[2])) _parameter.push('reLogin='+arguments[2]);
		}

		var log_win = window.open(Const.Domain.Reg+'/member/login/form/?'+_parameter.join('&'), 'PopLogin', 'width=361, height=288, scrollbars=no');
        if(log_win == null){
        	alert("ÇöÀç È¸¿ø´ÔÀº ÆË¾÷Â÷´Ü ¼³Á¤À¸·Î ¼­ºñ½º ÀÌ¿ëÀÌ ºÒ°¡ÇÏ¿À´Ï\n"+
            	  "Internet Explorer ¸Þ´º µµ±¸>ÆË¾÷Â÷´Ü>ÆË¾÷Â÷´Ü ¼³Á¤¿¡¼­\n"+
            	  "ÆË¾÷Â÷´Ü ÇØÁ¦ ÈÄ ÀÌ¿ëÇØ ÁÖ½Ã±â ¹Ù¶ø´Ï´Ù.");
        }

	},

	doLogout : function()
	{
		var rUrl = Base64.encode(location.href) || null;
		location.href = Const.Domain.Reg+'/member/logout/?rUrl='+rUrl
	},

	doLoginPage : function()
	{
		var _parameter = '';

		if (!Common.isNull(arguments[0])) _parameter = '&rUrl='+arguments[0];
		
		location.href = Const.Domain.Reg+'/member/login/form/?opener=self'+_parameter;
	},

	nullTmp : {}
}


// ·Î±× ³²±â±â
var Log =
{
	setPageViewLog : function()
	{
		if (Common.isNull(arguments[0]) ||
			Common.isNull(arguments[1]) ||
			Common.isNull(arguments[2]) ||
			Common.isNull(arguments[3]))
		{
			return;
		}

		var SetParameter = {
			PageDomain		: arguments[0],
			PageModule		: arguments[1],
			PageController	: arguments[2],
			PageAction		: arguments[3]
		};

		new Ajax.Request(
			'/global/common/general/PageView.php',
			{
				method			: 'post',
				parameters		: SetParameter
			}
		);
	},

	nullTmp : {}
}


// UI Á¤º¸
var UI =
{
	mSearchBarImg	: '',


	// °Ë»ö ¹Ù Á¤¸®
	doClearSearchBar : function()
	{
		var pTarget = arguments[0] || null;
		if (!Common.isNull(pTarget))
		{
			$(pTarget).setStyle({ background : 'url()' });
		}
	},


	// °Ë»ö ¹Ù ÃÊ±âÈ­
	doResetSearchBar : function()
	{
		var pTarget = arguments[0] || null;

		if (Common.isNull($F(pTarget).trim()))
		{
			$(pTarget).setStyle({ background : 'url('+this.mSearchBarImg+')' });
		}
	},


	// ¾Ù¹ü Á¤º¸ º¸±â
	doListenAlbumView : function(argTrackID, argAlbumID, argOpen)
	{
		if (!Common.isNull(argTrackID))
		{
			if (!Common.isNull(argOpen)) {
				void(window.open('http://music.bugs.co.kr/index/listenalbum/track_id/' + argTrackID + '/album_id/' + argAlbumID));
			}
			else {
				location.href='http://music.bugs.co.kr/index/listenalbum/track_id/' + argTrackID + '/album_id/' + argAlbumID;
			}
		}
		else
		{
			alert('°î ¾ÆÀÌµð°¡ ¾ø½À´Ï´Ù.');
		}
		return;
	},


	// ¾Ù¹ü Á¤º¸ º¸±â
	doAlbumView : function(argAlbumID, argOpen)
	{
		if (!Common.isNull(argAlbumID))
		{
			if (!Common.isNull(argOpen)) {
				void(window.open('http://music.bugs.co.kr/album/'+argAlbumID));
			}
			else {
				location.href='http://music.bugs.co.kr/album/'+argAlbumID;
			}
		}
		else
		{
			alert('¾Ù¹ü ¾ÆÀÌµð°¡ ¾ø½À´Ï´Ù.');
		}
		return;
	},


	// ¾ÆÆ¼½ºÆ® Á¤º¸ º¸±â
	doArtistView : function(argArtistID, argOpen)
	{
		if (!Common.isNull(argArtistID))
		{
			if (!Common.isNull(argOpen)) {
				void(window.open('http://music.bugs.co.kr/artist/'+argArtistID));
			}
			else {
				location.href='http://music.bugs.co.kr/artist/'+argArtistID;
			}

		}
		else
		{
			alert('¾ÆÆ¼½ºÆ® ¾ÆÀÌµð°¡ ¾ø½À´Ï´Ù.');
		}
		return;
	},


	// ¸¶ÀÌÆäÀÌÁö º¸±â
	doMypageView : function()
	{
		var mGubun = arguments[0] || '';

		var theURL = 'http://mypage.bugs.co.kr/service/';
		if (Const.isLogged)
		{
			location.href = theURL;
		}
		else
		{
			if (mGubun == 'Home')
			{
				alert('·Î±×ÀÎ ÈÄ ÀÌ¿ëÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù.');
				$('USER_ID').focus();
			}
			else
			{
				var rUrl = Base64.encode(theURL) || null;
				Login.doPopLogin('opener', rUrl);
			}
		}
	},


	// ³ª¸¸ÀÇ¾Ù¹ü º¸±â
	doMyAlbumView : function()
	{
		var mType  = arguments[0] || '';
		var mGubun = arguments[1] || '';
		var theURL = '';

		switch (mType)
		{
			case 'aod'	:	// À½¾Ç
			case 'vod'	:	// ¹Âºñ
			case 'mpm'	:	// ±¸¸ÅÇÑ MP3º¸°üÇÔ
			case 'art'	:	// ¾ÆÆ¼½ºÆ®
			case 'lod'	:	// À½¾Ç¾Ù¹ü
			case 'olb'	:	// °ø°³¾Ù¹ü
				theURL = 'http://myalbum.bugs.co.kr/index/'+mType;
				break;

			default		:
				theURL = 'http://myalbum.bugs.co.kr/';
		}

		if (Const.isLogged)
		{
			SetWin = window.open(theURL, 'myalbum', 'width=250,height=250,resizable=no,scrollbars=0');
			SetWin.focus();
		}
		else
		{
			if (mGubun == 'Home')
			{
				alert('·Î±×ÀÎ ÈÄ ÀÌ¿ëÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù.');
				$('USER_ID').focus();
			}
			else
			{
				var rUrl = Base64.encode(theURL) || null;
				Login.doPopLogin('self', rUrl);
			}
		}
	},


	// ³ª¸¸ÀÇ¾Ù¹ü ´ã±â
	doOpenMyAlbum : function()
	{
		var mType  = arguments[0] || '';
		var mList  = arguments[1] || '';
		var mGubun = arguments[2] || '';
		var theURL = '';
		var popupName = ''

		switch (mType)
		{
			case 'aod'	:	// À½¾Ç
			case 'vod'	:	// ¹Âºñ
			case 'art'	:	// ¾ÆÆ¼½ºÆ®
			case 'lod'	:	// À½¾Ç¾Ù¹ü
			case 'olb'	:	// °ø°³¾Ù¹ü
				theURL = 'http://myalbum.bugs.co.kr/popup/myalbum?atype='+mType+'&clist='+mList;
				popupName = 'plusmyalbum';
				break;

			default		:
				theURL = 'http://myalbum.bugs.co.kr/';
				popupName = 'myalbum';
		}

		if (Const.isLogged)
		{
			SetWin = window.open(theURL, popupName, 'width=250,height=250,resizable=no,scrollbars=0');
			SetWin.focus();
		}
		else
		{
			if (mGubun == 'Home')
			{
				alert('·Î±×ÀÎ ÈÄ ÀÌ¿ëÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù.');
				$('USER_ID').focus();
			}
			else
			{
				var rUrl = Base64.encode(theURL) || null;
				Login.doPopLogin('self', rUrl);
			}
		}
	},


	// Àå¹Ù±¸´Ï ¿­±â
	doOpenCart : function()
	{
		var theURL = 'http://mypage.bugs.co.kr/service/cart/';
		if (Const.isLogged)
		{
			SetWin = window.open(theURL, 'Cart', 'width=594,height=355,resizable=no,scrollbars=0');
			SetWin.focus();
		}
		else
		{
			var rUrl = Base64.encode(theURL) || null;
			Login.doPopLogin('self', rUrl);
		}
	},


	// Àå¹Ù±¸´Ï ´ã±â
	doOpenCartAdd : function(tp, tids)
	{
		var theURL = 'http://mypage.bugs.co.kr/service/cart/add/tp/'+tp+'/ids/'+tids;
		if (Const.isLogged)
		{
			SetWin = window.open(theURL, 'CartAddList', 'width=594,height=355,resizable=no,scrollbars=0');
			SetWin.focus();
		}
		else
		{
			var rUrl = Base64.encode(theURL) || null;
			Login.doPopLogin('self', rUrl);
		}
	},


	// ±¸¸ÅÃ¢ ¿­±â
	doOpenBuy : function()
	{
		var mType  = arguments[0] || '';
		var mList  = arguments[1] || '';
		var mGubun = arguments[2] || '';
		var theURL = '';

		switch (mType.toLowerCase())
		{
			case 'mp3'	:	// Mp3
				theURL = Const.Domain.Pay+'/pay/down/getBillDownLoad?buyTp=mp3&downId='+mList;
				break;
			case 'mv'	:	// ¹Âºñ
				theURL = Const.Domain.Pay+'/Mp3mv/mvbuy/mv_ids/'+mList;
				break;
			default		:
				theURL = Const.Domain.Pay+'/pay/down/getBillDownLoad?buyTp=mp3&downId='+mList;
		}

		if (Const.isLogged)
		{
			SetWin = window.open(theURL, 'Mp3mv', 'width=530,height=400,left=30,top=30,resizable=no,scrollbars=1');
			SetWin.focus();
		}
		else
		{
			if (mGubun == 'Home')
			{
				alert('·Î±×ÀÎ ÈÄ ÀÌ¿ëÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù.');
				$('USER_ID').focus();
			}
			else
			{
				var rUrl = Base64.encode(theURL) || null;
				Login.doPopLogin('self', rUrl);
			}
		}

		return true;
	},


	// ¼±¹°Ã¢ ¿­±â
	doOpenGift : function()
	{
		var mType = arguments[0] || '';
		var mList = arguments[1] || '';
		var theURL = '';

		switch (mType.toLowerCase())
		{
			case 'mp3'	:	// Mp3
				theURL = Const.Domain.Pay+'/Mp3mv/mp3gift/track_ids/'+mList;
				break;
			case 'mv'	:	// ¹Âºñ
				theURL = Const.Domain.Pay+'/Mp3mv/mvgift/mv_ids/'+mList;
				break;
			default		:
				theURL = Const.Domain.Pay+'/Mp3mv/mp3gift/track_ids/'+mList;
		}

		if (Const.isLogged)
		{
			SetWin = window.open(theURL, 'Mp3mv', 'width=611,height=720,left=30,top=30,resizable=no,scrollbars=1');
			SetWin.focus();
		}
		else
		{
			var rUrl = Base64.encode(theURL) || null;
			Login.doPopLogin('self', rUrl);
		}

		return true;
	},


	// MP3 ÇÃ·¹¸®¾î µî·Ï Ã¢
	doOpenMp3ListInfo : function()
	{
		var cUrl   = Base64.encode(location.href) || '';
		var theURL = arguments[0] || 'http://mypage.bugs.co.kr/service/player/manage/?cUrl=' + cUrl;
		if (Const.isLogged)
		{
			SetWin = window.open(theURL, 'mange', 'width=536,height=648,top=50,left=50,resizable=no,scrollbars=no');
			SetWin.focus();
		}
		else
		{
			var rUrl = Base64.encode(theURL) || null;
			Login.doPopLogin('self', rUrl);
		}
	},


	// ¶óÀÌºêº§
	doOpenLivebell : function()
	{
		var nTrackID   = arguments[0] || '';
		var strAdultYN = arguments[1] || 'N';
		var strMode    = arguments[2] || 'ME'; // ME=¼³Á¤, TO=¼±¹°
		var theURL     = "http://livebell.bugs.co.kr/player/playeruser?track_id="+ nTrackID +"&adult_yn="+ strAdultYN +"&mode="+ strMode;

		if (!Common.isNull(nTrackID))
		{
			// ¼ºÀÎ È®ÀÎ
			if (strAdultYN == 'Y')
			{
				if (Const.isLogged)
				{
					this.doOpenCp('Livebell', nTrackID, strMode);
				}
				else
				{
					theURL = Const.Domain.Reg+'/member/login/adult/?opener=self&rUrl='+Base64.encode(theURL);
					void(window.open(theURL, 'PopLogin', 'width=361, height=332, scrollbars=no'));
				}
			}
			else
			{
				this.doOpenCp('Livebell', nTrackID, strMode);
			}
		}
	},


	// ÄÃ·¯¸µ
	doOpenColoring : function()
	{
		var nTrackID   = arguments[0] || '';
		var strAdultYN = arguments[1] || 'N';
		var strMode    = arguments[2] || 'ME'; // ME=¼³Á¤, TO=¼±¹°
		var theURL     = "http://coloring.bugs.co.kr/player/playeruser?track_id="+ nTrackID +"&adult_yn="+ strAdultYN +"&mode="+ strMode;

		if (!Common.isNull(nTrackID))
		{
			// ¼ºÀÎ È®ÀÎ
			if (strAdultYN == 'Y')
			{
				if (Const.isLogged)
				{
					this.doOpenCp('Coloring', nTrackID, strMode);
				}
				else
				{
					theURL = Const.Domain.Reg+'/member/login/adult/?opener=self&rUrl='+Base64.encode(theURL);
					void(window.open(theURL, 'PopLogin', 'width=361, height=332, scrollbars=no'));
				}
			}
			else
			{
				this.doOpenCp('Coloring', nTrackID, strMode);
			}
		}
	},



	// Cp ±¸ºÐ ¿­±â
	doOpenCp : function()
	{
		var mType = arguments[0] || '';
		var mList = arguments[1] || '';
		var mMode = arguments[2] || '';

		switch (mType.toLowerCase())
		{
			case 'livebell'		:	// ¶óÀÌºêº§
				void(window.open('http://livebell.bugs.co.kr/player/playeruser?track_id='+mList+'&mode='+mMode, 'Livebell', 'width=350,height=495,resizable=no,scrollbars=0'));
				break;

			case 'coloring'		:	// ÄÃ·¯¸µ
				void(window.open('http://coloring.bugs.co.kr/player/playeruser?track_id='+mList+'&mode='+mMode, 'Coloring', 'width=350,height=473,resizable=no,scrollbars=0'));
				break;

			case 'ring'			:	// ÅëÈ­¿¬°áÀ½
				void(window.open('http://ring.bugs.co.kr/POP4/PopSet.asp?C_IDX='+mList+'&dType=1', 'MusicRing', 'width=250,height=250,resizable=no,scrollbars=0'));
				break;

			case 'ringgift'		:	// ÅëÈ­¿¬°áÀ½ - ¼±¹°
				void(window.open('http://ring.bugs.co.kr/POP4/PopSet.asp?C_IDX='+mList+'&dType=2', 'MusicRing', 'width=250,height=250,resizable=no,scrollbars=0'));
				break;

			case 'bell'			:	// º§¼Ò¸®
				void(window.open('http://bell.bugs.co.kr/popup2/PopupBuy.asp?ptype=listen&mcode='+mList+'&stype=', 'MusicBell', 'width=250,height=250,resizable=no,scrollbars=0'));
				break;

			case 'bellgift'		:	// º§¼Ò¸® - ¼±¹°
				void(window.open('http://bell.bugs.co.kr/popup2/PopupBuy.asp?ptype=gift&mcode='+mList+'&stype=', 'MusicBell', 'width=250,height=250,resizable=no,scrollbars=0'));
				break;

			case 'mscore'		:	// ¾Çº¸
				UI.doMscorePopup();
				//alert("¼­ºñ½º Á¡°Ë ÁßÀÔ´Ï´Ù.");
				//void(window.open('http://mscore.bugs.co.kr/bugs/score/gayo/scorepresell.asp?s_idx='+mList, 'Score'));
				break;

			case 'cdmall'		:	// À½¹Ý¸ô
				void(window.open('http://cdmall.bugs.co.kr/shop/mall_pcode.php?gcode='+mList, 'CDMall'));
				break;
		}
	},


	// ÃæÀüÃ¢ ¿­±â
	doOpenCashCharge : function()
	{
		var theURL = Const.Domain.Pay+'/index/cell1/pay_type/charge/';
		if (Const.isLogged)
		{
			SetWin = window.open(theURL, 'charge', 'width=536,height=600,resizable=no,scrollbars=0');
			SetWin.focus();
		}
		else
		{
			var rUrl = Base64.encode(theURL) || null;
			Login.doPopLogin('self', rUrl);
		}
	},


	// ¾ÆÀÌµð, ºñ¹Ð¹øÈ£ Ã£±â
	doOpenFindIdPass : function()
	{
		var theURL = Const.Domain.Reg+'/member/find/jointype/';

		SetWin = window.open(theURL, 'OpenFindIdPass', 'width=494, height=477,resizable=no,scrollbars=0');
		SetWin.focus();
	},


	// GNB °Ë»ö º¸³»±â
	doSearchSubmit : function(argForm, argSelect)
	{
		// ±âº»°ª È®ÀÎ
		if (Common.isNull(argForm.name)) return false;

		// °Ë»ö Á¾·ù
		var strSearchKind = $(argForm.name)[argSelect].value || 'total';

		// °Ë»ö URL
		var strActionUrl  = '';
		switch (strSearchKind)
		{
			case 'song'		: strActionUrl = 'music/trackall';			break;
			case 'text'		: strActionUrl = 'music/lyrics';			break;
			case 'album'	:
			case 'artist'	:
			case 'webzine'	: strActionUrl = 'music/' + strSearchKind;	break;
			default			: strActionUrl = strSearchKind;				break;
		}

		// °Ë»ö ¹è³Ê À¯¹«
		if (/http\:\/\//.test($(argForm.name)['keyword'].style.background) && !Common.isNull($(argForm.name)['s_banner'].value.trim()))
		{
			location.href = Base64.decode($F('s_banner'));
			return false;
		}
		else
		{
			if (Common.isNull($(argForm.name)['keyword'].value.trim()))
			{
				alert("°Ë»ö¾î¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä.");
				return false;
			}
			else
			{
				// 2010-01-06 °æ½ÂÈ£ : ½Å±Ô °Ë»ö ÀÎÄÚµù ¹®Á¦
				location.href = 'http://search.bugs.co.kr/search/' + strActionUrl + '/?s_kind=' + strSearchKind + '&keyword=' + Url.encode($(argForm.name)['keyword'].value.trim());
				return false;

				//$(argForm.name).s_kind.value	= strSearchKind;
				//$(argForm.name).s_banner.value	= '';
				//$(argForm.name).action			= 'http://search.bugs.co.kr/search/'+strActionUrl+'/';
				//return true;
			}
		}
	},


	// ÀÎµ¦½º °Ë»ö
	doSearchIndex : function(argKeyword)
	{
		location.href = 'http://search.bugs.co.kr/index/index/?idx_key='+argKeyword;
	},


	// ´Ù¿î·Îµå ¸Å´ÏÀú È£ÃâºÎ.
	PCDownload : function (mp3Idx, mvIdx, utype)
	{
		var width = 750;
		var height = 530;
		var left = screen.width/2 - width/2;
		var top = screen.height/2 - height/2;

		url = 'http://myalbum.bugs.co.kr/down';
		url += '?defBitRate=128&mp3Idx=' + mp3Idx + '&mvIdx=' + mvIdx + '&utype=' + utype;
		//win = window.open(url, 'PcDownLoad', 'left='+left+',top='+top+',width='+width+',height='+height+',toolbar=no,menubar=no,status=no,scrollbars=no,resizable=no');
		//win.focus();

		var win = window.open('', 'PcDownLoad', 'left='+left+',top='+top+',width='+width+',height='+height+',toolbar=no,menubar=no,status=no,scrollbars=no,resizable=no');
		win.focus();
		
		try {
			var isDown = win.DataManage.getCheck();
			if(isDown)
			{
				raise();
			} else
			{
				alert("Áö±Ý ÁøÇà ÁßÀÎ ´Ù¿î·Îµå°¡ Á¾·á\nµÈ ÈÄ¿¡ ´Ù½Ã ½ÃµµÇØ ÁÖ¼¼¿ä.");
			}
		} catch (e) {
			win = window.open(url, 'PcDownLoad', 'left='+left+',top='+top+',width='+width+',height='+height+',toolbar=no,menubar=no,status=no,scrollbars=no,resizable=no');
		}
	},


	// ±¤°í Á¦ÈÞ¹®ÀÇ
	doOpenAdInfo : function()
	{
		var theURL = 'http://www.bugs.co.kr/common/addinfo/';
		void(window.open(theURL, 'OpenAdInfo', 'width=1000, height=748, resizable=no,scrollbars=0'));
	},


	// ÀÌ¸ÞÀÏ ¹«´Ü ¼öÁý°ÅºÎ
	doOpenEmreject : function()
	{
		var theURL = 'http://www.bugs.co.kr/common/emreject/';
		void(window.open(theURL, 'OpenAdInfo', 'width=536, height=303, left=100, top=100, resizable=no,scrollbars=0'));
	},


	// ÅëÇÕ ·Î±×ÀÎ È®ÀÎ (È®ÀÎÈÄ ÆäÀÌÁö ³Ñ±è)
	doChkLogin : function(theURL)
	{
		var mGubun = arguments[1] || '';

		if (Const.isLogged)
		{
			location.href = theURL;
		}
		else
		{
			if (mGubun == 'Home')
			{
				alert('·Î±×ÀÎ ÈÄ ÀÌ¿ëÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù.');
				$('USER_ID').focus();
			}
			else
			{
				var rUrl = Base64.encode(theURL) || null;
				Login.doPopLogin('opener', rUrl);
			}
		}
	},
	

	// ¾Çº¸¼­ºñ½º Á¾·á popup 5/13ÀÏ ÀÌÈÄ »èÁ¦
	doMscorePopup : function()
	{
		var theURL = 'http://www.bugs.co.kr/popup/mscorepopup';
		
		if(Common.getCookie('mscorePopup') != 'mscoreClose')
		{
			void(window.open(theURL, 'mscorePopup', 'width=510, height=425, resizable=no,scrollbars=0'));
		}
	},


	// UpSelling
	doUpSellingBanner : function()
	{
		var tElem = arguments[0] || null;
		var bOpen = arguments[1] || false;
		var oDate = new Date();

		if (!Common.isNull(tElem))
		{
			if (bOpen)
			{
				if (Common.isNull(Common.getCookie(tElem)))
				{
					$(tElem).show();
				}
			}
			else
			{
				oDate.setDate(oDate.getDate() + 30);
				Common.setCookie(tElem, 'Hide', oDate, '/', '.bugs.co.kr');

				$(tElem).hide();
			}
		}
	},

	nullTmp : {}
}


// Base64
var Base64 =
{
	keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",

	encode : function(strText)
	{
		var output = "";
		var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
		var i = 0;

		strText = Utf8.encode(strText);

		while (i < strText.length)
		{
			chr1 = strText.charCodeAt(i++);
			chr2 = strText.charCodeAt(i++);
			chr3 = strText.charCodeAt(i++);

			enc1 = chr1 >> 2;
			enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
			enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
			enc4 = chr3 & 63;

			if (isNaN(chr2))		{ enc3 = enc4 = 64;	}
			else if (isNaN(chr3))	{ enc4 = 64;		}

			output = output + this.keyStr.charAt(enc1) + this.keyStr.charAt(enc2) + this.keyStr.charAt(enc3) + this.keyStr.charAt(enc4);
		}

		return output;
	},

	decode : function(strText)
	{
		var output = "";
		var chr1, chr2, chr3;
		var enc1, enc2, enc3, enc4;
		var i = 0;

		// remove all characters that are not A-Z, a-z, 0-9, +, /, or =
		strText = strText.replace(/[^A-Za-z0-9\+\/\=]/g, "");

		while (i < strText.length)
		{
			enc1 = this.keyStr.indexOf(strText.charAt(i++));
			enc2 = this.keyStr.indexOf(strText.charAt(i++));
			enc3 = this.keyStr.indexOf(strText.charAt(i++));
			enc4 = this.keyStr.indexOf(strText.charAt(i++));

			chr1 = (enc1 << 2) | (enc2 >> 4);
			chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
			chr3 = ((enc3 & 3) << 6) | enc4;

			output = output + String.fromCharCode(chr1);

			if (enc3 != 64) { output = output + String.fromCharCode(chr2);	}
			if (enc4 != 64) { output = output + String.fromCharCode(chr3);	}
		}

		output = Utf8.decode(output);

		return output;
	},

	nullTmp : {}
}


// Url
var Url = {
 
	// public method for url encoding
	encode : function (string) {
		return escape(Utf8.encode(string));
	},
 
	// public method for url decoding
	decode : function (string) {
		return Utf8.decode(unescape(string));
	},
	
	urlencode : function urlencode (str) {
	    // URL-encodes string  
	    // 
	    // version: 1004.2314
	    // discuss at: http://phpjs.org/functions/urlencode
	    // +   original by: Philip Peterson
	    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	    // +      input by: AJ
	    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	    // +   improved by: Brett Zamir (http://brett-zamir.me)
	    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	    // +      input by: travc
	    // +      input by: Brett Zamir (http://brett-zamir.me)
	    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	    // +   improved by: Lars Fischer
	    // +      input by: Ratheous
	    // +      reimplemented by: Brett Zamir (http://brett-zamir.me)
	    // +   bugfixed by: Joris
	    // +      reimplemented by: Brett Zamir (http://brett-zamir.me)
	    // %          note 1: This reflects PHP 5.3/6.0+ behavior
	    // %        note 2: Please be aware that this function expects to encode into UTF-8 encoded strings, as found on
	    // %        note 2: pages served as UTF-8
	    // *     example 1: urlencode('Kevin van Zonneveld!');
	    // *     returns 1: 'Kevin+van+Zonneveld%21'
	    // *     example 2: urlencode('http://kevin.vanzonneveld.net/');
	    // *     returns 2: 'http%3A%2F%2Fkevin.vanzonneveld.net%2F'
	    // *     example 3: urlencode('http://www.google.nl/search?q=php.js&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:unofficial&client=firefox-a');
	    // *     returns 3: 'http%3A%2F%2Fwww.google.nl%2Fsearch%3Fq%3Dphp.js%26ie%3Dutf-8%26oe%3Dutf-8%26aq%3Dt%26rls%3Dcom.ubuntu%3Aen-US%3Aunofficial%26client%3Dfirefox-a'
	    str = (str+'').toString();
	    
	    // Tilde should be allowed unescaped in future versions of PHP (as reflected below), but if you want to reflect current
	    // PHP behavior, you would need to add ".replace(/~/g, '%7E');" to the following.
	    return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/\*/g, '%2A').replace(/%20/g, '+');
	},
	nullTmp : {}
}

// Utf8
var Utf8 =
{
	encode : function (strText)
	{
		strText = strText.replace(/\r\n/g,"\n");
		var output = "";

		for (var n = 0; n < strText.length; n++)
		{
			var c = strText.charCodeAt(n);

			if (c < 128)
			{
				output += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048))
			{
				output += String.fromCharCode((c >> 6) | 192);
				output += String.fromCharCode((c & 63) | 128);
			}
			else
			{
				output += String.fromCharCode((c >> 12) | 224);
				output += String.fromCharCode(((c >> 6) & 63) | 128);
				output += String.fromCharCode((c & 63) | 128);
			}
		}

		return output;
	},

	decode : function (strText)
	{
		var output = "";
		var i = 0;
		var c = c1 = c2 = 0;

		while ( i < strText.length )
		{
			c = strText.charCodeAt(i);

			if (c < 128)
			{
				output += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224))
			{
				c2 = strText.charCodeAt(i+1);
				output += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else
			{
				c2 = strText.charCodeAt(i+1);
				c3 = strText.charCodeAt(i+2);
				output += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}
		}

		return output;
	},

	nullTmp : {}
}


// µð¹ö±×
var Debug =
{
	doBuildPanel : function()
	{
		var theDiv	= arguments[0] || document.body;
		var theHtml	= '<div style="display:; width:520px; height:170px; margin:10;">'
					+ '<fieldset>'
					+ '		<legend>Debug</legend>'
					+ '		<div id="__PrintDebug__" name="__PrintDebug__" style="background-color:#ffffff; width:500; height:150; text-align:left; overflow-x:scroll; overflow-y:scroll;"></div>'
					+ '	</fieldset>'
					+ '</div>';
		new Insertion.Top(theDiv, theHtml);
		return $('__PrintDebug__');
	},

	setStyle : function()
	{
		$('__PrintDebug__').setStyle(arguments[0])
	},

	dump : function()
	{
		var SHtml='', SValue = arguments[0] || '';

		switch((typeof SValue).toLowerCase())
		{
			case 'object' :
				Object.keys(SValue).each(function(sKey)
				{
					SHtml += (typeof SValue) + '/'+sKey + ' => ' + SValue[sKey] +'\n';
				});
				break;

			case 'string'	:
			default			:
				SHtml += (typeof SValue) + '/' + SValue;
		}
		return SHtml;
	},

	doPrint : function()
	{
		var DivPrintDebug = $('__PrintDebug__') || this.doBuildPanel(arguments[1] || null);
		var SValue = arguments[0] || '';
		var SHtml  = arguments[1] || DivPrintDebug.innerHTML +'</br>';

		switch((typeof SValue).toLowerCase())
		{
			case 'object' :
				Object.keys(SValue).each(function(sKey)
				{
					SHtml += sKey + ' => ' + SValue[sKey] +'</br>';
				});
				break;

			case 'string'	:
			default			:
				SHtml += SValue;
		}

		DivPrintDebug.update(SHtml);
		DivPrintDebug.scrollTop = DivPrintDebug.scrollHeight;
	},

	nullTmp : {}
}


// 2009-07-29 °æ½ÂÈ£ : GNB
var GNB =
{
	isSaveID			: 1,

	// GNB Link
	doBugsGnbLink : function()
	{
		var strModule	= arguments[0] || 'newest';
		var nSubtab		= arguments[1] || 0;

		var mUrlInfo	=
		{
			"newmusic"		:
			[
				"http://music.bugs.co.kr/newest/",
				"http://music.bugs.co.kr/newest/index/newmusic/",
				"http://music.bugs.co.kr/newest/index/newmovie/",
				"http://music.bugs.co.kr/newest/index/newupdate/",
				"http://music.bugs.co.kr/newest/index/newkpop/",
				"http://music.bugs.co.kr/newest/index/newpop/",
				"http://music.bugs.co.kr/newest/index/newost/",
				"http://music.bugs.co.kr/newest/index/newjpop/",
				"",
				"http://music.bugs.co.kr/newest/index/newclassic/"
			],

			"chart"			:
			[
				"http://music.bugs.co.kr/chart/",
				"http://music.bugs.co.kr/chart/top100/",
				"http://music.bugs.co.kr/chart/genre/",
				"http://music.bugs.co.kr/chart/period/",
				"http://music.bugs.co.kr/chart/generation/"
			],

			"genre"			:
			[
				"http://music.bugs.co.kr/genre/",
				"http://music.bugs.co.kr/genre/kpop/",
				"http://music.bugs.co.kr/genre/pop/",
				"http://music.bugs.co.kr/genre/ost/",
				"http://music.bugs.co.kr/genre/jpop/",
				"http://music.bugs.co.kr/genre/wpop/",
				"http://music.bugs.co.kr/genre/classic/",
				"http://music.bugs.co.kr/genre/ad/",
				"http://music.bugs.co.kr/genre/children/",
				"http://music.bugs.co.kr/genre/antenatal/",
				"http://music.bugs.co.kr/genre/newage/",
				"http://music.bugs.co.kr/genre/kclassic/",
				"http://music.bugs.co.kr/genre/trot/",
				"http://music.bugs.co.kr/genre/7890/",
				"http://music.bugs.co.kr/genre/ccm/",
				"http://music.bugs.co.kr/genre/club/",
				"http://music.bugs.co.kr/genre/indi/"
			],

			"opentheme"		:
			[
				"http://openalbum.bugs.co.kr/openalbum/theme/new/",
				"http://openalbum.bugs.co.kr/openalbum/theme/new/",
				"http://music.bugs.co.kr/recom/themealbum/",
				"http://music.bugs.co.kr/recom/recomplay/",
				"UI.doChkLogin('http://mmail.bugs.co.kr/index/write/', 'Home')"
			],

			"mv"			:
			[
				"http://music.bugs.co.kr/musicvideo/",
				"http://music.bugs.co.kr/musicvideo/hotmv",
				"http://music.bugs.co.kr/musicvideo/newmv"
			],

			"webzine"		:
			[
				"http://music.bugs.co.kr/webzine/",
				"http://music.bugs.co.kr/webzine/contents/list/?st=496",
				"http://music.bugs.co.kr/webzine/contents/list/?st=497",
				"http://music.bugs.co.kr/webzine/contents/list/?st=498",
				"http://music.bugs.co.kr/webzine/contents/list/?st=499",
				"http://music.bugs.co.kr/webzine/poll/"
			],

			"event"			:
			[
				"http://music.bugs.co.kr/event/",
				"http://music.bugs.co.kr/event/albumevent/",
				"http://music.bugs.co.kr/event/showcase/",
				"http://music.bugs.co.kr/event/bugsevent/",
				"http://music.bugs.co.kr/event/giftzone/"
			],

			"productbuy"	:
			[
				"http://help.bugs.co.kr/index/buy/"
			]
		};


		var theUrl = mUrlInfo[strModule][nSubtab];
		var expUrl = /^http*/i;
		if (!Common.isNull(theUrl))
		{
			if (!expUrl.test(theUrl))
			{
				eval(theUrl);
			}
			else
			{
				location.href = theUrl;
			}
		}
	},


	// GNB °Ë»ö º¸³»±â
	doSearchSubmit : function()
	{
		// °Ë»ö ¹è³Ê À¯¹«
		if (/http\:\/\//.test($('keyword').getStyle('background')) && !Common.isNull($F('s_banner').trim()))
		{
			location.href = Base64.decode($F('s_banner'));
			return false;
		}
		else
		{
			if (Common.isNull($F('keyword').trim()))
			{
				alert("°Ë»ö¾î¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä.");
				return false;
			}
			else
			{
				// 2010-01-06 °æ½ÂÈ£ : ½Å±Ô °Ë»ö ÀÎÄÚµù ¹®Á¦
				location.href = 'http://search.bugs.co.kr/search/?keyword=' + Url.encode($F('keyword'));
				return false;

				$('s_banner').value = '';
				return true;
			}
		}
	},


	// doLoginFocus
	doLoginFocus : function()
	{
		alert('·Î±×ÀÎ ÈÄ ÀÌ¿ëÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù.');
		$('USER_ID').focus();
	},


	// ·Î±×ÀÎ Caps Lock È®ÀÎ
	doCheckCapsLock : function(e)
	{
		if (FN.isCapsLock(e))
		{
			$('CapsLockAlert').removeClassName('none');
		}
		else
		{
			$('CapsLockAlert').addClassName('none');
		}
	},


	// ·Î±×ÀÎ Å¬¸®¾î
	doClearLogin : function()
	{
		var pTarget  = arguments[0] || null;

		if (!Common.isNull(pTarget))
		{
			if ($(pTarget).name == 'USER_ID')
				$(pTarget).removeClassName('showid');
			else
				$(pTarget).removeClassName('showpw');
		}
	},


	// ·Î±×ÀÎ ÃÊ±âÈ­
	doResetLogin : function()
	{
		var pTarget = arguments[0] || null;

		if (Common.isNull($F(pTarget).trim()))
		{
			if ($(pTarget).name == 'USER_ID')
				$(pTarget).addClassName('showid');
			else
				$(pTarget).addClassName('showpw');
		}
	},


	// ¾ÆÀÌµð ÀúÀåÇÏ±â
	doLoginSaveID : function()
	{
		if (this.isSaveID == 1)
		{
			if (confirm("ÇöÀç »ç¿ëÇÏ½Ã´Â PC¿¡ ¾ÆÀÌµð¸¦ ÀúÀåÇÏ½Ã°Ú½À´Ï±î?\n\nPC¹æ µî °ø°øÀå¼Ò¿¡¼­´Â °³ÀÎÁ¤º¸°¡ À¯ÃâµÉ ¼ö ÀÖÀ¸´Ï ÁÖÀÇÇØ ÁÖ½Ã±â ¹Ù¶ø´Ï´Ù."))
			{
				$('CheckSaveUserID').src  = FN.imgSrcChange($('CheckSaveUserID').src, '.$2');
				this.isSaveID = 2;
			}
		}
		else
		{
			$('CheckSaveUserID').src  = FN.imgSrcChange($('CheckSaveUserID').src, '_off.$2');
			this.isSaveID = 1;
		}

		$('chkType').value = this.isSaveID;
	},


	// ·Î±×ÀÎ ÇÏ±â
	doLoginCheckSubmit : function()
	{
		if (Common.isNull($F('USER_ID').trim()))
		{
			alert('¾ÆÀÌµð¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä.');
			$('USER_ID').focus();
			return false;
		}

		if (Common.isNull($F('PASSWD').trim()))
		{
			alert('ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä.');
			$('PASSWD').focus();
			return false;
		}

		// 2009-09-24 °æ½ÂÈ£ : rUrl ¾ø´Â°æ¿ì¸¸
		if (!$F('rUrl').trim())
		{
			// 2009-07-30 °æ½ÂÈ£ : rUrl ¼³Á¤
			var rUrl = Base64.encode(location.href) || '';
			$('rUrl').value = rUrl;
		}

		return true;
	},


	// °³ÀÎÁ¤º¸ ´õº¸±â
	doShowMemberInfo : function()
	{
		var strGubun = arguments[0] || 'Open';

		if (strGubun == 'Open')
			$('ShowMemberInfo').removeClassName('blind');
		else
			$('ShowMemberInfo').addClassName('blind');
	},


	nullTmp : {}
}


// Suggest Class
var Suggest = new Class.create();
Suggest.prototype =
{
	objElem			: {},
	isUse			: true,
	isRunning		: false,
	strKeyword		: '',
	strDesign		: 'Default',
	nItemsSelect	: 0,
	strItemsListID	: '',
	strInstance		: '',
	objTimer		: null,
	nKeyCode		: null,
	nTest			: 1,

	// ÃÊ±âÈ­
	initialize : function()
	{
		if(arguments.length < 1)	{ return; }

		// È¯°æ¼³Á¤
		this.objElem		= Object.extend({
			SearchForm		: arguments[0].SearchForm	|| null,
			Keyword			: arguments[0].Keyword		|| null,
			Suggest			: arguments[0].Suggest		|| null,
			DesignDebug		: arguments[0].DesignDebug	|| null,
			ButtonOn		: arguments[0].ButtonOn		|| null,
			ButtonOff		: arguments[0].ButtonOff	|| null
		}, {});
		this.isUse			= (Common.getCookie('BugsSuggestUse') == 'unuse') ? false : true;
		this.strItemsListID	= arguments[0].ItemsListID;
		this.strInstance	= arguments[0].Instance;

		// Start!
		if (!Common.isNull(this.objElem['SearchForm']) &&
			!Common.isNull(this.objElem['Keyword']) &&
			!Common.isNull(this.objElem['Suggest']) && 
			!Common.isNull(this.strInstance)
			)
		{
			// ÀÌº¥Æ® ¼³Á¤
			Event.observe(document,'click', this.doKeywordSuggestClose.bindAsEventListener(this));
			Event.observe(this.objElem['Keyword'],'keyup', this.doKeywordSuggestStart.bindAsEventListener(this));
			Event.observe(this.objElem['Keyword'],'click', this.doKeywordSuggestStart.bindAsEventListener(this));

			// FF ¹ö±× : ÇÑ±ÛÀÔ·Â½Ã onKeyUp, onKeyDown, onKeyPress ÀÌº¥Æ®°¡ ¸ðµÎ ¹ß»ýÇÏÁö ¾ÊÀ½
			if (!Common.Agent().IE)
			{
				Event.observe(this.objElem['Keyword'],'focus', this.doEventKeyupCapture.bindAsEventListener(this));
				Event.observe(this.objElem['Keyword'],'blur', this.doEventKeyupClear.bindAsEventListener(this));
			}
		}
	},

	// FF ¹ö±× ÀÌº¥Æ® Ä¸ÃÄ
	doEventKeyupCapture : function(e)
	{
		var _root = this;

		this.doEventKeyupClear();
		this.objTimer = setInterval(function() 
		{
			var strCurrKeyword = $F(_root.objElem['Keyword']).trim();
			if (_root.strKeyword != strCurrKeyword)
			{
				//_root.strKeyword = strCurrKeyword;
				_root.doEventKeyupFire();
			}
		}, 500);
	},

	// FF ¹ö±× ÀÌº¥Æ® ÃÊ±âÈ­
	doEventKeyupClear : function()
	{
		if (this.objTimer) clearInterval(this.objTimer);
		this.objTimer = null;
	},

	// FF ¹ö±× ÀÌº¥Æ® ¹ß»ý ½ÃÅ°±â
	doEventKeyupFire : function()
	{
		//window.console.debug('====> : ' + this.nKeyCode);
		if (this.nKeyCode != 13 &&	// enter key
			this.nKeyCode != 27 &&	// esc key
			this.nKeyCode != 40 &&	// down key
			this.nKeyCode != 38 	// up key
		)
		{
			if (document.createEvent)
			{
				var e;
				if (window.KeyEvent)
				{
					e = document.createEvent('KeyEvents');
					e.initKeyEvent('keyup', true, true, window, false, false, false, false, 65, 0);
				}
				else
				{
					e = document.createEvent('UIEvents');
					e.initUIEvent('keyup', true, true, window, 1);
					e.keyCode = 65;
				}

				this.objElem['Keyword'].dispatchEvent(e);
			}
			else
			{
				var e = document.createEventObject();
				e.keyCode = 65;

				this.objElem['Keyword'].fireEvent('onkeyup', e);
			}
		}
	},

	// Å°¿öµå Á¦¾È¾î ½ÃÀÛ
	doKeywordSuggestStart : function(e)
	{
		if (this.isUse)
		{
			this.nKeyCode = (!Common.isNull(e)) ? (e.keyCode || e.which) : null;
			//window.console.debug('doKeywordSuggestStart : ' + this.nKeyCode);

			// enter key
			if (this.nKeyCode == 13)
			{
				this.doKeywordSuggestShowHide('Hide');
			}

			// esc key
			else if (this.isRunning && this.nKeyCode == 27)
			{
				this.objElem['Keyword'].value = '';
				this.objElem['Keyword'].blur();

				this.doKeywordSuggestShowHide('Hide');
			}

			// down key
			else if (this.isRunning && this.nKeyCode == 40)
			{
				this.doKeyboardSelect('Down');
			}

			// up key
			else if (this.isRunning && this.nKeyCode == 38)
			{
				this.doKeyboardSelect('Up');
			}

			else
			{
				var strCurrKeyword = $F(this.objElem['Keyword']).trim();
				if (this.strKeyword != strCurrKeyword)
				{
					this.strKeyword = strCurrKeyword;
					this.doSendKeyword();
				}
			}
		}
	},

	// Å°º¸µå ÀÌµ¿ ¼±ÅÃ
	doKeyboardSelect : function(strGubun)
	{
		var objItems = $(this.strItemsListID);

		if (!Common.isNull(objItems))
		{
			var objItemsList = objItems.childElements();
			var nTotalItems  = objItemsList.length;

			switch (strGubun)
			{
				case 'Down' : 
					if (this.nItemsSelect < nTotalItems) this.nItemsSelect++;
					break;

				case 'Up' :
					if (this.nItemsSelect > 0) this.nItemsSelect--;
					break;
			}

			// ¼±ÅÃ Å°¿öµå
			for (var i=0; i<nTotalItems; i++)
			{
				if ((this.nItemsSelect-1) == i)
				{
					objItemsList[i].addClassName('b');
					this.objElem['Keyword'].value = (Common.Agent().IE) ? objItemsList[i].innerText : objItemsList[i].textContent;
				}
				else
				{
					objItemsList[i].removeClassName('b');
				}
			}

			// ¼±ÅÃ ÃÊ±âÈ­
			if (this.nItemsSelect == 0) this.objElem['Keyword'].value = this.strKeyword;
		}
	},

	// Å°¿öµå Á¦¾È¾î °Ë»ö
	doSendKeyword : function()
	{
		var oParams = { 
			keyword		: (arguments[0]) ? Base64.encode(arguments[0]) : Base64.encode(this.strKeyword),
			design		: this.strDesign,
			instance	: this.strInstance
		};

		var doSuccessProc = function(Request)
		{
			//var rVal = Request.responseText.trim();
			this.nItemsSelect = 0;
			this.doKeywordSuggestShowHide('Show');
		}

		var doFailureProc = function(Request)
		{
			//var rVal = Request.responseText.trim();
			this.nItemsSelect = 0;
			this.doKeywordSuggestShowHide('Hide');
		}

		new Ajax.Updater(
			this.objElem['Suggest'],
			'/global/common/general/Suggest.php',
			{
				parameters		: oParams,
				onSuccess		: doSuccessProc.bind(this),
				onFailure		: doFailureProc.bind(this)
			}
		);
	},

	// ½ÇÇàÁ¾·á
	doKeywordSuggestClose : function(e)
	{
		var isClose = true;
		if (!Common.isNull(e))
		{
			if (e.element() == this.objElem['Keyword'])
			{
				isClose = false;
			}

			if (isClose)
			{
				if (e.element().offsetParent == this.objElem['Suggest'])
				{
					isClose = false;
				}
			}
		}
		//window.console.debug('====> : ' + isClose);
		if (isClose)
		{
			this.doKeywordSuggestShowHide('Hide');
		}
	},

	// Å°¿öµå Á¦¾È¾î º¸ÀÌ±â, ¼û±â±â
	doKeywordSuggestShowHide : function()
	{
		if (arguments[0] == 'Show') 
		{
			this.isRunning = true;

			this.objElem['Suggest'].removeClassName('none');
			if (!Common.isNull(this.objElem['DesignDebug'])) this.objElem['DesignDebug'].removeClassName('none');
			if (!Common.isNull(this.objElem['ButtonOn']))  this.objElem['ButtonOn'].removeClassName('none');
			if (!Common.isNull(this.objElem['ButtonOff'])) this.objElem['ButtonOff'].addClassName('none');
		}
		else
		{
			this.isRunning = false;

			this.objElem['Suggest'].addClassName('none');
			if (!Common.isNull(this.objElem['DesignDebug'])) this.objElem['DesignDebug'].addClassName('none');
			if (!Common.isNull(this.objElem['ButtonOn']))  this.objElem['ButtonOn'].addClassName('none');
			if (!Common.isNull(this.objElem['ButtonOff'])) this.objElem['ButtonOff'].removeClassName('none');
		}
	},

	// Å°¿öµå Á¦¾È¾î ±â´É ÄÑ±â
	doKeywordSuggestOn : function()
	{
		Common.setCookie('BugsSuggestUse', 'use', '', '/', '.bugs.co.kr');

		this.isUse = true;
		this.doKeywordSuggestShowHide('Show');
		this.doSendKeyword($F(this.objElem['Keyword']).trim());
	},

	// Å°¿öµå Á¦¾È¾î ±â´É ²ô±â
	doKeywordSuggestOff : function()
	{
		Common.setCookie('BugsSuggestUse', 'unuse', '', '/', '.bugs.co.kr');

		this.isUse = false;
		this.doKeywordSuggestShowHide('Hide');
	},

	// Å°¿öµå Á¦¾È¾î ¹öÆ° ¿­±â, ´Ý±â
	doSuggestButtonOnOff : function()
	{
		if (arguments[0] == 'On') 
		{
			this.doSendKeyword($F(this.objElem['Keyword']).trim());
		}
		else
		{
			this.doKeywordSuggestShowHide('Hide');
		}
	},

	// Á¦¾È¾î ¼±ÅÃ
	doKeywordSearch : function(strKeyword)
	{
		this.objElem['Keyword'].value = strKeyword;
		//this.objElem['SearchForm'].submit();

		// 2010-01-06 °æ½ÂÈ£ : ½Å±Ô °Ë»ö ÀÎÄÚµù ¹®Á¦
		location.href = 'http://search.bugs.co.kr/search/?keyword=' + Url.encode(strKeyword);
		return false;
	},

	// tmp
	nullTmp : {}
}

