var RT_ERROR = "ERROR";
var RT_FAIL = "FAIL";
var RT_OK = "SUCCESS";
var RT_WARNING = "WARNING";

var NEWHID = "1";
var NEWhid = "2";
var hid2HID = "3";
var HID2HID = "4";
var HID2hid = "5";
var hid2hid = "6";
var NEWkid = "7";

var UPDATE_USER_INFO = "40";
var REQUEST_SMS_COUNT = "10";
var REQUEST_SHARED_MAIL = "20";
var REQUEST_SHARED_PERMISSION = "21";
var REQEUST_BILL_PERMISSION = "30";
var REQUEST_ETC = "999";
var REQUEST_ORG_BOARD_CREATE = "60";
var REQUEST_GROUP_BOARD_CREATE = "61";
var REQUEST_BOARD_PERMISSION = "62";

var CHANGE_MAIL_SIZE = "70";
var CHANGE_HARD_SIZE = "80";
var CANCEL_HID_LINK = "99";

var BASIC_WEBHARD_SIZE = 100;
var BASIC_WEBMAIL_SIZE = 1000;
var DOMAIN_MINLEN = 2;
var GROUP_MINLEN = 6;

var WEBHARD_READ = 2;
var WEBHARD_WRITE = 4;
var WEBHARD_DELETE = 1;


function saveCaret(elem)
{
        if(document.selection)
                elem.caretPos = document.selection.createRange();

        else
        {
            var oldSelectionStart = elem.selectionStart;
            var oldSelectionEnd = elem.selectionEnd;
            var selectedText = elem.value.substring(oldSelectionStart, oldSelectionEnd);

            var str1 = elem.value.substring(0, oldSelectionStart);
            var sym = str1.substring(str1.length - 1);
        }
}

function insertAtCaret(textElement, newText)
{
  if ( textElement.isTextEdit )
  {
    if ( !textElement.caretPos )
    {
       saveCaret(textElement);
    }

    var caretPos = textElement.caretPos;
    caretPos.text = newText;
    caretPos.select();
  }
}


function fromSpecial(textElement, cInput )
{
        if( document.selection )
        {
                insertAtCaret( textElement, cInput );
        }
        else
        {
                var oldSelectionStart = textElement.selectionStart;
                var oldSelectionEnd = textElement.selectionEnd;
                var selectedText = textElement.value.substring(oldSelectionStart, oldSelectionEnd);

                var scrollTop, scrollLeft;

                if (textElement.type == 'textarea' && typeof textElement.scrollTop != 'undefined')
                {
                        scrollTop  = textElement.scrollTop;
                        scrollLeft = textElement.scrollLeft;
                }

                textElement.value =
                  textElement.value.substring(0, oldSelectionStart) +
                  cInput +
                  textElement.value.substring(oldSelectionEnd);

                if (typeof scrollTop != 'undefined')
                {
                        textElement.scrollTop  = scrollTop;
                        textElement.scrollLeft = scrollLeft;
                }

                textElement.setSelectionRange(oldSelectionStart + cInput.length,
                                      oldSelectionStart + cInput.length);
        }

}

var Common = {

	getBounds : function(tag)
	{
		var ret = new Object();

		if(tag.getBoundingClientRect)
		{
			var rect = tag.getBoundingClientRect();
			ret.left =
			rect.left + (document.documentElement.scrollLeft || document.body.scrollLeft);
			ret.top =
			rect.top + (document.documentElement.scrollTop || document.body.scrollTop);
			ret.width = rect.right - rect.left;
			ret.height = rect.bottom - rect.top;
		}
		else
		{
			var box = document.getBoxObjectFor(tag);
			ret.left = box.x;
			ret.top = box.y;
			ret.width = box.width;
			ret.height = box.height;
		}
		return ret;
	},
	expandLinkArea : function()
	{
		if ($("topLinkFrame").style.height == "48px")
		{
			$("fav_expand_img").src = "/assets/images/common/icon/icon_favorite.gif"
			$("topLinkFrame").style.height = $("topLinkTable").style.height = "28px";
			$("topLinkView").style.height = "17px";
			$("topLinkView").style.overflowY = "hidden";	// ie6에서는 스크롤바가 안사라진다.-_-
			$("topLinkView").style.overflow = "hidden";
		}
		else
		{
			$("fav_expand_img").src = "/assets/images/common/icon/icon_favorite_up.gif"
			$("topLinkFrame").style.height = "48px";
			$("topLinkTable").style.height = $("topLinkView").style.height = "38px";
			$("topLinkView").style.overflowY = "auto";
		}
	},

	trim : function (str)
	{
		if (str == null || str == "") return ""
		var o = new String(str);
		o = o.replace(/^\s*/,'').replace(/\s*$/, '');

		return o;
	},
	Link : function(pMenu)
	{
		switch(pMenu)
		{
			case "join" : location.href="join";
				break;
			default : location.href="/";
		}
	},
	funcCheckEmail : function (email)
	{
		var supported = 0;
		if (window.RegExp)
		{
			var tempStr = "a";
			var tempReg = new RegExp(tempStr);
			if (tempReg.test(tempStr)) supported = 1;
		}
		if (!supported) return (email.indexOf(".") > 2) && (email.indexOf("@") > 0);

		var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
		var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$");

		return (!r1.test(email) && r2.test(email));
	},

	funcCheckPhoneNo : function(number)
	{
		var patten = /\d{2,3}-\d{3,4}-\d{4}$/;
		if (!patten.test(number)) return false;

		return true;
	},

	funcCheckJumin : function(number)
	{
		var patten = /\d{6}-\d{7}$/;
		if (!patten.test(number)) return false;

		return true;
	},

	funcValidCheckJumin: function(pValue) {
		pIdno = Common.trim(pValue.replace(/-/g, ''));
		if (pIdno == null || pIdno == "") return false;

		var sum = 0;
		var odd = 0;

		buf = new Array(13);
		for (i = 0; i < 13; i++) buf[i] = parseInt(pIdno.charAt(i));

		odd = buf[7]*10 + buf[8];

		if (odd%2 != 0) return false;

		if ((buf[11] != 6)&&(buf[11] != 7)&&(buf[11] != 8)&&(buf[11] != 9))
			return false;

		var multipliers = [2,3,4,5,6,7,8,9,2,3,4,5];
		for (i = 0, sum = 0; i < 12; i++) sum += (buf[i] *= multipliers[i]);

		sum=11-(sum%11);

		if (sum>=10) sum-=10;

		sum += 2;

		if (sum>=10) sum-=10;

		if ( sum != buf[12]) return false;
		else return true;
	},

	/*
	Creator : shj at xenosi.de

	if(false == (birth = checkPersonalNo(주민번호))) 틀렸어요;
	년 = birth[0];
	월 = birth[1];
	일 = birth[2];
	if(birth[3]) 외국인;
	*/
	checkPersonalNo : function(personal_no) {
		personal_no = personal_no.replace(/[^\d]+/g, '');
		pattern = /^[0-9]{6}[1-8][0-9]{6}$/;

		if(!pattern.test(personal_no)) {
			return false;
		}
		var birth = new Array();
		birth[0] = personal_no.substr(0, 2);
		switch(personal_no.charAt(6)) {
			case '1':
			case '2':
				birth[0] = ('19' + birth[0]) * 1;
				birth[3] = false;
			break;
			case '3':
			case '4':
				birth[0] = ('20' + birth[0]) * 1;
				birth[3] = false;
			break;
			case '5':
			case '6':
				birth[0] = ('19' + birth[0]) * 1;
				birth[3] = true;
			break;
			case '7':
			case '8':
				birth[0] = ('20' + birth[0]) * 1;
				birth[3] = true;
			break;
			/*case '9': // 이렇게 늙은 사람은 있어도 안받아요. 위의 정규식에서 안받음.
			case '0':
				birth[0] = ('18' + birth[0]) * 1;
				birth[3] = true;
			break;*/
		}

		birth[1] = personal_no.substr(2, 2) * 1;
		birth[2] = personal_no.substr(4, 2) * 1;

		if(birth[1] < 1 || birth[1] > 12) {
			return false;
		}
		if(birth[2] < 1 || birth[2] > 31) {
			return false;
		}
		var check = 0;
		var mul = 2;

		if(birth[3]) {
			if(((personal_no.charAt(7) * 10 + personal_no.charAt(8)) % 2) != 0) {
				return false;
			}
		}
		for(i = 0; i < 12; i ++) {
			check += personal_no.charAt(i) * mul;
			mul ++;
			if(mul > 9) {
				mul = 2;
			}
		}

		check = 11 - (check % 11);

		if(check > 9) {
			check %= 10;
		}
		if(birth[3]) {
			check += 2;
			if(check > 9) {
				check %= 10;
			}
		}
		if(check != personal_no.charAt(12)) {
			return false;
		}
		return birth;
	},

	funcCheckCompanyNo : function(number)
	{
		var patten = /\d{3}-\d{2}-\d{5}$/;
		if (!patten.test(number)) return false;
		return true;
	},

	funcValidCheckCompanyNo : function(number) {
		number = Common.trim(number.replace(/-/g, ''));

		if(number.length == 0) {
			return false;
		}

		var sum = 0;
		var getlist =new Array(10);
		var chkvalue =new Array("1","3","7","1","3","7","1","3","5");

		for(var i=0; i<10; i++) {
			getlist[i] = number.substring(i, i+1);
		}

		for(var i=0; i<9; i++) {
			sum += getlist[i]*chkvalue[i];
		}

		sum = sum + parseInt((getlist[8]*5)/10);
		var sidliy = sum % 10;
		var sidchk = 0;

		if(sidliy != 0) {
			sidchk = 10 - sidliy;
		} else {
			sidchk = 0;
		}

		if(sidchk != getlist[9]) { return false; }

		return true;
	},

	getDomain : function()
	{
		return pathHelper.getInfo("DOMAIN");
	},

	getGroupID : function()
	{
		var currentUrl = document.location.href.replace("http://", "").split("/");

		var pattern = /^([a-zA-Z0-9\-]*)\.hiworks.co.kr/i;

		if (pattern.test(currentUrl[0])) return currentUrl[1];
		else return "";
	},

	getRoot : function()
	{
		var g = Common.getGroupID();

		if (g == "") return "/";
		else return "/" + g + "/";
	},

	Logout : function()
	{
		var wmsg = new validateMessage("error");

		if (confirm(wmsg.getMessage("LOGOUT_CONFIRM")))
		{
			getAjaxData(Common.getRoot() + 'home/Logout', "", Common.goHome);
		}
	},

	goHome : function()
	{
		document.location.href = Common.getRoot();
	},

	getImagePath : function()
	{
		return (Common.getImageRoot() + Common.getLanguage() + "/");
		//return pathHelper.getInfo("IMAGEPATH");
	},

	getLanguage : function()
	{
		return getCookie("LANGUAGE");
	},

	getImageRoot : function()
	{
		return "/assets/images/";
		//return pathHelper.getInfo("IMAGEROOT");
	},

	goAdmin : function()
	{
		document.location.href = Common.getRoot() + "admin/adminmain";
	},

	getRealOffsetTop : function(o)
	{
		return o ? o.offsetTop + this.getRealOffsetTop(o.offsetParent) : 0;
	},

	getRealOffsetLeft : function(o)
	{
		return o ? o.offsetLeft + this.getRealOffsetLeft(o.offsetParent) : 0;
	},

	selectAll : function(obj) {
		if (document.getElementsByName('chkMemoList')[0].checked == true)
		{
			for(var i=0;i<document.getElementsByName('chkMemoList').length;i++)
			{
				document.getElementsByName('chkMemoList')[i].checked = false;
			}
		}else
		{
			for(var i=0;i<document.getElementsByName('chkMemoList').length;i++)
			{
				document.getElementsByName('chkMemoList')[i].checked = true;
			}
		}
	},
	viewPopup: function(viewLayerId, backLayerId) // Main.viewPopup
	{
		$(viewLayerId).show();

		if(typeof(backLayerId) != "string"){
			// 인자값이 없으면 디폴트 레이어 사용
			backLayerId = "backLayer";
		}

		//가운데 상하 스크롤 반영
		$(viewLayerId).toCenter();
		//$(viewLayerId).style.left = (document.body.clientWidth - $(viewLayerId).clientWidth) /2 + "px";
		//$(viewLayerId).style.top = (document.body.clientHeight - $(viewLayerId).clientHeight) /2 + document.body.scrollTop + "px";
		$(viewLayerId).style.filter = "alpha(opacity:100)";

		if(!$(backLayerId)){
			var ifmObj = document.createElement("iframe");

			ifmObj.id = backLayerId;
			ifmObj.src = Common.getRoot() + "addr/backLayer";
			ifmObj.style.width = "100%";
			ifmObj.style.height = "100%";
			ifmObj.scrolling = "no";
			ifmObj.frameBorder = "0";
			ifmObj.style.position = "absolute";
			ifmObj.style.display = "none";
			ifmObj.style.opacity = "60";
			ifmObj.style.MozOpacity = "0.6";
			ifmObj.style.filter = "alpha(opacity=60)";
			document.body.appendChild(ifmObj);
		}

		var ifmRef = document.getElementById(backLayerId);
		ifmRef.style.width = document.body.clientWidth;
		ifmRef.style.height = document.body.scrollHeight;
		ifmRef.style.top = "0px";
		ifmRef.style.left = "0px";
		ifmRef.style.zIndex = "1";
		ifmRef.style.display = "block";
	},
	closePopup: function(closeLayerId, backLayerId) // Main.closePopup
	{
		if(typeof(backLayerId) != "string"){
			// 인자값이 없으면 디폴트 레이어 사용
			backLayerId = "backLayer";
		}

		document.body.style.filter = "";
		$(closeLayerId).hide();

		if($(backLayerId)){
			$(backLayerId).hide();
		}
	},
	_createBackGround : function()
	{
		try
		{
			if ($("alphaDiv"))
			{
				$("alphaDiv").style.display = "block";
				return;
			}
			var oAlphaDiv = document.createElement("iframe");
			oAlphaDiv.setAttribute("id", "alphaDiv");

			oAlphaDiv.style.height = document.body.clientHeight + "px";
			oAlphaDiv.style.width = "100%";
			oAlphaDiv.style.display = "inline";
			oAlphaDiv.style.opacity = "0.6";
			document.getElementById("outline").appendChild(oAlphaDiv);

			$("alphaDiv").setStyle({filter:'alpha(opacity=100)','-moz-opacity':'60%','opacity':'0.6'});
		}
		catch(E)
		{
			alert(E);
		}
	},

	_closeBackGround : function()
	{
		if ($("progressDiv"))
		{
			if ($("progressDiv").style.display == "")
				$("progressDiv").style.display = "none";
		}

		if ($("alphaDiv"))
		{
			if ($("alphaDiv").style.display != "none")
				$("alphaDiv").style.display = "none";

			return;
		}
	},

	_closeProgress : function()
	{
		if ($("progressDiv"))
		{
			if ($("progressDiv").style.display == "")
				$("progressDiv").style.display = "none";
		}
	},

	_createProgress : function()
	{
		try
		{
			if ($("progressDiv"))
			{
				$("progressDiv").style.display = "";
				return;
			}
			var oProgressDiv = document.createElement("div");
			oProgressDiv.setAttribute("id", "progressDiv");

			oProgressDiv.innerHTML = "<img src=\"/assets/images/common/icon/progress_big.gif\" alt=\"progress..\" title=\"progress..\" />";
			document.getElementById("outline").appendChild(oProgressDiv);
		}
		catch(E)
		{
			alert(E);
		}
	},

	byte_check : function(pValue)
	{
		var str = "";
		var str_count = 0;
		var cut_count = 0;
		var inputLength = pValue.length;

		var newline=(document.all)?'%0A':'%0D%0A';

		for(var i=0 ; i < inputLength ; ++i)
		{
			str = pValue.charAt(i);
			// 네이버 문자 카운트 방법....빠르다..Orz..
			var ascii = str.charCodeAt();
			if (ascii > 127 && escape(str) != newline) str_count += 2;
			else if (escape(str) == newline) str_count += 0;
			else ++str_count;
		}

		return str_count;
	},
	cut_str: function(str,limit, tail) {
		var tmpStr = str;
		var byte_count = 0;
		var len = str.length;
		var dot = "";
		if(tail == undefined) {
			tail = '';
		}

		for(i=0; i<len; i++) {
			byte_count += Common.chr_byte(str.charAt(i));
			if(byte_count == limit-1) {
				if(Common.chr_byte(str.charAt(i+1)) == 2) {
					tmpStr = str.substring(0,i+1);
					dot = tail;
				} else {
					if(i+2 != len) dot = tail;
					tmpStr = str.substring(0,i+2);
				}
				break;
			} else if(byte_count == limit) {
				if(i+1 != len) dot = tail;
				tmpStr = str.substring(0,i+1);
				break;
			}
		}
		return tmpStr+dot;
	},
	chr_byte: function(chr) {
		if(escape(chr).length > 4) {
			return 2;
		} else if(chr == "\n") {
			return 0;
		} else {
			return 1;
		}
	},

	getIEVersion : function()
	{
		var v = navigator.appVersion;
		if (v.indexOf("MSIE") > -1)
		{
			if (v.indexOf("MSIE 6") > -1) return 6;
			else if (v.indexOf("MSIE 7") > -1) return 7;
			else if (v.indexOf("MSIE 8") > -1) return 8;
			else if (v.indexOf("MSIE 9") > -1) return 9;
			else return 5;
		}

		return false;
	},

	initTopPreview : function()
	{
		if ($("EXT"))
			Event.observe($("EXT"), "click", Common.viewMore, false);

		if ($("PAID"))
			Event.observe($("PAID"), "click", Common.viewPaid, false);
	},

	viewMore : function(el)
	{
		var t = Common.getBounds($("EXT"));
		var currentUrl = document.location.href.replace("http://", "");

		$("morePreview").style.left = t.left + "px";

		if ($('morePreview').visible())
		{
			$('morePreview').hide();
		}
		else
		{
			Effect.BlindDown('morePreview', { duration: 0.2 });
			offset = Element.cumulativeOffset(el);

			if (currentUrl.indexOf("/admin") > 0)
				$('morePreview').style.top = (offset[1] + 237) + "px";
			else
				$('morePreview').style.top = (offset[1] + 90) + "px";
		}
	},

	viewPaid : function(el)
	{
		var t = Common.getBounds($("PAID"));
		var currentUrl = document.location.href.replace("http://", "");

		$("paidPreview").style.left = t.left + "px";

		if ($('paidPreview').visible())
		{
			$('paidPreview').hide();
		}
		else
		{
			Effect.BlindDown('paidPreview', { duration: 0.2 });
			offset = Element.cumulativeOffset(el);

			if (currentUrl.indexOf("/admin") > 0)
				$('paidPreview').style.top = (offset[1] + 237) + "px";
			else
				$('paidPreview').style.top = (offset[1] + 90) + "px";
		}
	},

	hideMore : function()
	{
		if ($("morePreview"))
		{
			if ($("morePreview").style.display != "none")
				$("morePreview").style.display = "none";
		}

	},

	hidePaid : function()
	{
		if ($("paidPreview"))
		{
			if ($("paidPreview").style.display != "none")
				$("paidPreview").style.display = "none";
		}

	}
}

var topMenuSetting = {
	m_CurrentItem : null,

	getMenuConfigDiv : function()
	{
		getAjaxData(Common.getRoot() + "main_ajax/getMenuConfig" , null, topMenuSetting.resultMenuConfigDiv);
	},

	resultMenuConfigDiv : function(pData)
	{
		if (pData.resultCode == RT_OK)
		{
			Common._createBackGround();
			if ($("popupBaseA"))
				$("popupBaseA").parentNode.removeChild($("popupBaseA"));

			var oPopupbase = document.createElement("div");
			oPopupbase.setAttribute("id", "popupBaseA");

			oPopupbase.style.width = "520px";
			oPopupbase.style.color = "#444444";
			oPopupbase.style.height = "470px";
			oPopupbase.innerHTML = pData.result;

			document.getElementById("outline").appendChild(oPopupbase);
			$("popupBaseA").toCenter();

		}
		else
			alert(pData.message);
	},

	setCurrentMenu : function(pRow)
	{
		try {
			var oTr = $("menuOrderTable").getElementsByTagName("tr");

			for(i=0 ; i<oTr.length ; ++i)
			{
				oTr[i].cells[0].firstChild.style.backgroundColor = "white";
				oTr[i].cells[0].firstChild.style.color = "#444444";
			}

			for(i=0 ; i<oTr.length ; ++i)
				if (oTr[i].cells[0] == pRow.parentNode) this.m_CurrentItem = i;

			//this.m_CurrentItem = pRow;
			pRow.style.backgroundColor = "#0E84E4";
			pRow.style.color = "white";

		} catch(E)
		{
			alert(E);
		}
	},

	setMenuFirst : function()
	{
		try {
			if (this.m_CurrentItem)
			{
				if (this.m_CurrentItem == 0)
				{
					alert("더이상 올릴 수 없습니다.");
					return;
				}
				var oTr = $("menuOrderTable").getElementsByTagName("tr");
				$("menuOrderTable").tBodies[0].insertBefore(oTr[this.m_CurrentItem], oTr[0]);

				this.m_CurrentItem = 0;
			}
			else
			{
				alert("메뉴를 먼저 선택해주세요");
				return;
			}
		} catch(E)
		{
			alert(E);
		}
	},

	setMenuLast : function()
	{
		try
		{
			if (this.m_CurrentItem)
			{
				var nLastIndex = $("userMenuCount").value-1;

				if (this.m_CurrentItem == nLastIndex)
				{
					alert("더 이상 내릴 수 없습니다.");
					return;
				}

				var oTr = $("menuOrderTable").getElementsByTagName("tr");
				$("menuOrderTable").tBodies[0].appendChild(oTr[this.m_CurrentItem]);
				this.m_CurrentItem = nLastIndex;
			}
			else
			{
				alert("메뉴를 먼저 선택해주세요");
				return;
			}
		} catch(E)
		{
			alert(E);
		}
	},

	setMenuOrder : function(pFlag)
	{
		try {
			if (pFlag == "U")
			{
				if (this.m_CurrentItem == 0)
				{
					alert("더 이상 올릴 수 없습니다.");
					return;
				}

				var oTr = $("menuOrderTable").getElementsByTagName("tr");
				$("menuOrderTable").tBodies[0].insertBefore(oTr[this.m_CurrentItem], oTr[this.m_CurrentItem-1]);
				--this.m_CurrentItem;
			}
			else
			{
				if (this.m_CurrentItem == ($("userMenuCount").value-1))
				{
					alert("더 이상 내릴 수 없습니다.");
					return;
				}

				var oTr = $("menuOrderTable").getElementsByTagName("tr");

				$("menuOrderTable").tBodies[0].insertBefore(oTr[this.m_CurrentItem+1], oTr[this.m_CurrentItem]);
				++this.m_CurrentItem;
			}
		} catch(E)
		{
			alert(E);
		}
	},

	deleteMenu : function()
	{
		if (this.m_CurrentItem)
		{
			var oTr = $("menuOrderTable").getElementsByTagName("tr");
			var oCurrent = oTr[this.m_CurrentItem];

			$("enable_" + oCurrent.cells[0].id.replace("ordertd_", "")).checked = false;
			oCurrent.parentNode.removeChild(oCurrent);

			$("userMenuCount").value = oTr.length;
			if (this.m_CurrentItem >= oTr.length)
				this.m_CurrentItem =oTr.length;
		}
		else
		{
			alert("메뉴를 선택해주세요.");
			return;
		}
	},

	closePopup : function()
	{
		if ($("popupBaseA"))
		{
			$("popupBaseA").style.display = "none";
			$("popupBaseA").parentNode.removeChild($("popupBaseA"));
			Common._closeBackGround();
		}
	},

	saveMenu : function()
	{
try {
		var oTr = $("menuOrderTable").getElementsByTagName("tr");
		var oCode = Array();
		var oUse = Array();
		var oFlag = Array();

		for(i=0 ; i<oTr.length ; ++i)
			oCode[i] = oTr[i].cells[0].id.replace("ordertd_", "");

		$$("table.menuSetting input").each(function(value, index) {
			if (value.id.indexOf("op_enable_") == 0)
			{
				oUse[oUse.length] = value.id.replace("op_enable_", "");
				oFlag[oFlag.length] = (value.checked)?"Y" : "N";
			}
		});

		var param = $H({"pCode[]" : oCode, "pUse[]" : oUse, "pFlag[]" : oFlag});
		getAjaxData(Common.getRoot() + "main_ajax/saveTopMenuConfig" , param, topMenuSetting.resultSaveMenu);
} catch(E)
{
	alert(E);
}
	},

	resultSaveMenu : function(pData)
	{
		alert(pData.message);
		if (pData.resultCode == RT_OK)
			document.location.reload();
	},

	initMenuSetting : function()
	{
		if (confirm("초기화 하시겠습니까?"))
			getAjaxData(Common.getRoot() + "main_ajax/initTopMenuConfig" , null, topMenuSetting.resultInitMenuSetting);
	},

	resultInitMenuSetting : function(pData)
	{
		alert(pData.message);

		if (pData.resultCode == RT_OK)
			document.location.reload();
	}
}

var ServiceLink = {
	get_service_link: function()
	{
		var param = $H();
		getAjaxData(Common.getRoot() + 'main_ajax/get_service_link', param, ServiceLink.view_service_link.bind(ServiceLink));
	},
	view_service_link: function(rtnData)
	{
		var returnArr = rtnData.result.evalJSON();

		$('id_top_service_link').options.length = 1;
		$('id_top_service_link').options[0].text = ":::내 서비스 바로가기:::";
		$('id_top_service_link').options[0].value = "";

		if(returnArr == null || returnArr.length < 1){
			$('id_top_service_link').hide();
		}else{
			for(var i = 0; i < returnArr.length; i++){
					row = returnArr[i];

					$('id_top_service_link').options.length++;
					$('id_top_service_link').options[i+1].text = row.link_name;
					$('id_top_service_link').options[i+1].value = row.no + '#' + row.domain_group + '#' + row.link_url;
			}
		}

/*
		var line = [];

		for(var i =0; i < returnArr.length; i++){
			row = returnArr[i];
			line[i] = "'" + row.no + '_' + row.domain_group + "':'" + row.link_name + "'\n";
		}

		var lines = '__service_another__ = {' + line.join(',')+'};';
		eval(lines);

		var title = ':::내 서비스 바로가기:::';
		ServiceLink.select_another_service('id_top_service_link',  title, __service_another__, 180);
	},
	select_another_service: function(id, title, obj, width, func)
	{
		var X = {'id':id, 'title':title, 'data':obj, 'width':width};
		var O = new SelectBox(X);
		O.Change = ServiceLink.another_on_change();
*/
	},
	another_on_change: function(id)
	{
		if(id.value.length > 0){
			var tmp = id.value.split('#');
/*
			if (Common.getGroupID() != "") document.location.href = tmp[2];
			else
			{
				if (tmp[2].indexOf("group.hiworks.co.kr") > 0 || tmp[2].indexOf("office.hiworks.co.kr") > 0)
					var href = tmp[2] + '/home/service_link/'+tmp[0]+'/'+tmp[1];
				else
					var href = Common.getRoot() + 'main_ajax/service_link/'+tmp[0]+'/'+tmp[1];

				document.location.href = href;
			}
			*/
			document.location.href = Common.getRoot() + 'main_ajax/service_link/'+tmp[0]+'/'+tmp[1];
		}
/*
		window.alert(id.value);
		function X(k, v)
		{
			var tmp = k.split('_');

			var href = Common.getRoot() + 'home/service_link/'+tmp[0]+'/'+tmp[1];
			document.location.href = href;
		}

		return X;
*/
	}
}

var adminTop = {
	mouseFlag : false,
	timer : null,

	showSub : function(pMenu)
	{
		adminTop.clearSub();

		if ($(pMenu)) $(pMenu).style.display = "";
	},

	clearSub : function()
	{
		if ($("org_sub")) $("org_sub").style.display = "none";
		if ($("bbs_sub")) $("bbs_sub").style.display = "none";
		if ($("stat_sub")) $("stat_sub").style.display = "none";
		if ($("conf_sub")) $("conf_sub").style.display = "none";
	},

	frontAdminSubOn : function()
	{
		if ($("frontAdminMenu"))
		{
			$("frontAdminMenu").style.display = "block";
		}
	},

	frontAdminSubOff : function(event)
	{
		if ($("frontAdminMenu"))
		{
			$("frontAdminMenu").style.display = "none";
		}
	},

	initMouse : function()
	{
		if ($("adminButtonLI"))
		{
			$("adminButtonLI").onmouseover = function() { adminTop.mouseFlag = true; }
			$("adminButtonLI").onmouseout = function() { adminTop.mouseFlag = false; }
			adminTop.timer = window.setInterval("adminTop.checkMouseOver()", 3);
		}
	},

	checkMouseOver : function()
	{
		if (!adminTop.mouseFlag)
		{
			adminTop.frontAdminSubOff();
		}
		else
		{
			if ($("frontAdminMenu").style.display == "none")
			{
				adminTop.frontAdminSubOn();
				//window.clearInterval(adminTop.timer);
			}
		}
	}
}

/// 스트링 객체에 메소드 추가 ///
String.prototype.isEmail = function()
{
	return (/\w+([-+.]\w+)*@\w+([-.]\w+)*\.[a-zA-Z]{2,4}$/).test(this.trim());
}

String.prototype.isDomain = function()
{
	return (/^[A-Za-z0-9.-]+\.[A-Za-z]{2,6}$/).test(this.trim());
}

String.prototype.pad = function(c, n)
{
	var result=this;
	while(result.length<n)
	{
		result=c+result;
	}
	return result;
}

String.prototype.trim = function(str)
{
	str = this != window ? this : str;
	return str.replace(/^\s+/g,'').replace(/\s+$/g,'');
}

//javascript function added, tetsu
String.prototype.br2nl = function()
{
    return this.replace(/<br\s*\/?>/img,"\n");
}

String.prototype.p2nl = function()
{
    return this.replace(/<p\s*\/?>/img,"\n");
}

String.prototype.ext = function()
{
	 var arr = this.split(".");
	return arr[arr.length-1].toLowerCase();
}

String.prototype.img_ext = function()
{
	 var str = this.ext();
	 var arr_good = new Array("ai", "arj","avi","bat","bmp","com","doc","exe","gif","gz","hwp","jpg","jpeg","lha","mov","mp3","mpeg","mpg","pcx","pdf","ppt","ra","ram","rar","rm","zip","tar","txt","wav","xls","xlsx","pptx","docx");

	 if(arr_good.indexOf(str)<0)	return "unknown.gif";
	 else return str + ".gif";
}

//element align center
Element.addMethods({   clearTable: function(table_element, size) {
	if(!size) size = 0;
	while(table_element.rows[size])
	{
		table_element.deleteRow(size);
	}
	return table_element;
}});

var swapMethod = {
	swap: function(element, el, popupFlag)
	{
		// 조직 관리 화면에서 사용을위한 편법.
		if (popupFlag)
		{
			elementTemp = Array();

			$$("#userListDiv li").each(function(v, index) {

				if (v.id == element.id)
				{
					elementTemp[elementTemp.length] = v;
				}
				else if (v.id == el.id)
				{
					elementTemp[elementTemp.length] = v;
				}
				else return null;
			});

			element = elementTemp[0];
			el = elementTemp[1];

			if (element == el) return element;

			var clone = el.cloneNode(false); // no need to clone deep
			Element.replace(element, clone);
			Element.replace(el, element);
			Element.replace(clone, el); // make sure references (like event observers) are kept

			return element;
		}
		else
		{
			element = $(element);
			el = $(el);

			if (element == el) return element;

			var clone = el.cloneNode(false); // no need to clone deep
			Element.replace(element, clone);
			Element.replace(el, element);
			Element.replace(clone, el); // make sure references (like event observers) are kept
			return element;
		}
	}
}
Element.addMethods(swapMethod);

//element align center
Element.addMethods({   toCenter: function(element) {
	var scTop = document.documentElement.scrollTop || document.body.scrollTop;
	element.style.left = ((document.viewport.getWidth() - element.getWidth()) /2) + "px";
	element.style.top = ((document.viewport.getHeight() - element.getHeight()) /2 + scTop) + "px";

	if(document.viewport.getHeight() < element.getHeight()) {
		element.style.top = (scTop+100) + 'px';
	}
	return element;
}});

Element.addMethods({   toHere: function(element, event) {
	document.body.appendChild(element);
	element.style.left = Event.pointerX(event) + "px";
	element.style.top = Event.pointerY(event)+ "px";
	return element;
}});

Element.addMethods({   closeByEsc: function(element) {
	Event.observe(document,'keydown', function(event){
			if(event.keyCode==27)
			{
				element.hide();
				if($('backLayer'))
				{
					$('backLayer').hide();
				};
			}

		});
	return element;
}});

//show back layer element
Element.addMethods({   backSmallLayerShow: function(element) {
	if(!$(element.id + "layer"))
	{
		var ifObj = document.createElement("iframe");
		ifObj.id = element.id + "layer";
		document.body.appendChild(ifObj);
	}else
	{
		$(element.id + "layer").show();
	}
	$(element.id + "layer").style.position = "absolute";

	//$('backLayer').style.width = document.documentElement.clientWidth;
	//$('backLayer').style.height = document.documentElement.clientHeight;
	$(element.id + "layer").style.opacity = "60";
	$(element.id + "layer").style.MozOpacity = "0.6";
	$(element.id + "layer").style.filter = "alpha(opacity=10)";
	$(element.id + "layer").style.width = element.getWidth() + "px";
	$(element.id + "layer").style.height = element.getHeight() + "px";
	$(element.id + "layer").style.top = element.style.top;
	$(element.id + "layer").style.left = element.style.left;
	$(element.id + "layer").style.zIndex = "1";
	$(element.id + "layer").style.display = "block";
	$(element.id + "layer").border = "0px";

	element.style.zIndex = 2;

	return element;
}});

//hide back layer element
Element.addMethods({   backSmallLayerHide: function(element) {
	if($(element.id + "layer"))
	{
		$(element.id + "layer").hide();
	}

	return element;
}})

//show layer element
Element.addMethods({   openLayer: function(element) {
	element.show();
	element.toCenter();
	return element;
}});

//show back layer element
Element.addMethods({   closeLayer: function(element) {
	element.hide();
	return element;
}});

//show back layer element
Element.addMethods({   backLayerShow: function(element, zindex) {

	if(!zindex)	zindex = 1;

	if(!$('backLayer'))
	{
		var ifObj = document.createElement("iframe");
		ifObj.id = 'backLayer';

		if ($("outline"))
			$("outline").appendChild(ifObj);
		else
			document.body.appendChild(ifObj);

	}else
	{
		$('backLayer').show();
	}
	$('backLayer').style.position = "absolute";

	//$('backLayer').style.width = document.documentElement.clientWidth;
	//$('backLayer').style.height = document.documentElement.clientHeight;
	$('backLayer').frameborder = "0";
	$('backLayer').frameBorder = "0";
	$('backLayer').style.opacity = "60";
	$('backLayer').style.MozOpacity = "0.6";
	$('backLayer').style.filter = "alpha(opacity=60)";
	$('backLayer').style.width = document.body.clientWidth + "px";
	$('backLayer').style.height = document.body.scrollHeight + "px";
	$('backLayer').style.top = "0";
	$('backLayer').style.left = "0";
	$('backLayer').style.zIndex = zindex;
	$('backLayer').style.border = "none";
	$('backLayer').style.display = "block";

	if(!element.style.zIndex)	element.style.zIndex = zindex + 2;

	return element;
}});

//hide back layer element
Element.addMethods({   backLayerHide: function(element) {
	if($('backLayer'))
	{
		$('backLayer').hide();
	}

	return element;
}})

/* hides <select> and <applet> objects (for IE only) */
var is_ie_all = document.all;
function hideElement( elmID, overDiv ) {
	if( is_ie_all ) {
		for( var i = 0; i < document.all.tags( elmID ).length; i++ ) {
			obj = document.all.tags( elmID )[i];
			if( !obj || !obj.offsetParent ) {
				continue;
			}

			// Find the element's offsetTop and offsetLeft relative to the BODY tag.
			objLeft   = obj.offsetLeft;
			objTop    = obj.offsetTop;
			objParent = obj.offsetParent;

			while( objParent.tagName.toUpperCase() != "BODY" ) {
				objLeft  += objParent.offsetLeft;
				objTop   += objParent.offsetTop;
				objParent = objParent.offsetParent;
			}

			objHeight = obj.offsetHeight;
			objWidth = obj.offsetWidth;

			if(( overDiv.offsetLeft + overDiv.offsetWidth ) <= objLeft );
			else if(( overDiv.offsetTop + overDiv.offsetHeight ) <= objTop );
			else if( overDiv.offsetTop >= ( objTop + objHeight ));
			else if( overDiv.offsetLeft >= ( objLeft + objWidth ));
			else {
				obj.style.visibility = "hidden";
			}
		}
	}
}

/*
* unhides <select> and <applet> objects (for IE only)
*/
function showElement( elmID ) {
	if( is_ie_all )
	{
		for( i = 0; i < document.all.tags( elmID ).length; i++ ) {
			obj = document.all.tags( elmID )[i];

			if( !obj || !obj.offsetParent ) {
				continue;
			}

			obj.style.visibility = "";
		}
	}
}

//COOKIE related
function setCookie(c_name,value,expiredays)
{
	var exdate=new Date();exdate.setDate(exdate.getDate()+expiredays);
	var cookiePath = (Common.getGroupID() == "")?"/" : "/" + Common.getGroupID();
	document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString()) + ";path=" + cookiePath;
}

function getCookie(c_name)
{
	if (document.cookie.length>0)
	{
		var cookiePath = (Common.getGroupID() == "")?"/" : "/" + Common.getGroupID();
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1)
		{
			c_start=c_start + c_name.length+1;
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
		}
	}
	return "";
}

var acLink = {
	linkStart : function()
	{
		if (!$("agreement").checked)
		{
			alert("주의 사항에 동의 하셔야 진행이 가능합니다.");
			return;
		}
		var param = $H({"pMenu" : "login"});
		getAjaxData(Common.getRoot() + "account_link" , param, acLink.viewGabiaLoginResult);
	},

	viewGabiaLogin : function()
	{
		var param = $H({"pMenu" : "login"});
		getAjaxData(Common.getRoot() + "account_link" , param, acLink.viewGabiaLoginResult);
	},

	viewGabiaLoginResult : function(pValue)
	{
		if (pValue.resultCode == RT_OK)
		{
			$("accountBase").innerHTML = pValue.result;

			if ($("gabia_id")) $("gabia_id").focus();
		}
		else
		{
			alert(pValue.message);
			return;
		}
	},

	GabiaLogin : function()
	{
		if (Common.trim($("gabia_id").value) == "")
		{
			alert("ID는 입력 해 주셔야 합니다.");
			$("gabia_id").focus();
			return;
		}
		if (Common.trim($("gabia_pass").value) == "")
		{
			alert("비밀번호는 입력 해 주셔야 합니다.");
			$("gabia_pass").focus();
			return;
		}

		this._hiworksLogin($("gabia_id").value, $("gabia_pass").value);
		for(i=0 ; i<100000 ; ++i)	// 하이웍스 로그인 시간을 위한 delay
		{
			i;
		}

		var param = $H({"pMenu" : "loginprocess", "pID" : $("gabia_id").value, "pPass" : $("gabia_pass").value});

		if ($("action_target"))
			getAjaxData(Common.getRoot() + $("action_target").value, param, acLink.registResult);
		else
			getAjaxData(Common.getRoot() + "account_link", param, acLink.registResult);
	},

	_hiworksLogin : function(pID, pPass)
	{
		try
		{
			var loginForm = document.createElement("form");
			var oLoginUrl = document.createElement("input");
			var oLinkUrl = document.createElement("input");
			var oUserID = document.createElement("input");
			var oUserPwd = document.createElement("input");
			var oSaveFlag = document.createElement("input");

			loginForm.setAttribute("id", "frmLogin");
			loginForm.action = "http://www.hiworks.co.kr/login/sol_login";
			loginForm.method = "post";
			loginForm.target = "loginDiv";
			document.getElementById("accountBase").appendChild(loginForm);

			oLoginUrl.type = "hidden";
			oLoginUrl.setAttribute("id", "login_url");
			oLoginUrl.setAttribute("name", "login_url");
			document.getElementById("frmLogin").appendChild(oLoginUrl);

			oLinkUrl.type = "hidden";
			oLinkUrl.setAttribute("id", "link_url");
			oLinkUrl.setAttribute("name", "link_url");
			document.getElementById("frmLogin").appendChild(oLinkUrl);

			oUserID.type = "hidden";
			oUserID.setAttribute("id", "userid");
			oUserID.setAttribute("name", "userid");
			document.getElementById("frmLogin").appendChild(oUserID);

			oUserPwd.type = "hidden";
			oUserPwd.setAttribute("id", "userpwd");
			oUserPwd.setAttribute("name", "userpwd");
			document.getElementById("frmLogin").appendChild(oUserPwd);

			oSaveFlag.type = "hidden";
			oSaveFlag.setAttribute("id", "save_flag");
			oSaveFlag.setAttribute("name", "save_flag");
			document.getElementById("frmLogin").appendChild(oSaveFlag);

			$("login_url").value = "/";
			$("link_url").value = "";
			$("userid").value = pID;
			$("userpwd").value = pPass;
			$("save_flag").value = false;

			$("frmLogin").submit();
		}
		catch (E)
		{
			alert(E);
			return;
		}
	},

	gabiaLoginResult : function(pValue)
	{
		if (pValue.resultCode == RT_OK)
		{
			$("accountBase").innerHTML = pValue.result;
		}
		else
		{
			alert(pValue.message);
			return;
		}
	},

	viewGabiaRegist : function()
	{
		var param = $H({"pMenu" : "regist"});
		getAjaxData(Common.getRoot() + 'account_link', param, acLink.viewGabiaRegistResult);
	},

	viewGabiaRegistResult : function(pValue)
	{
		if (pValue.resultCode == RT_OK)
		{
			$("accountBase").innerHTML = pValue.result;
		}
		else
		{
			alert(pValue.message);
			return;
		}
	},

	_createHiworksLoginFrame : function()
	{
		try
		{
			if ($("loginDiv"))
				return;

			var oLoginDiv = document.createElement("iframe");
			oLoginDiv.setAttribute("id", "loginDiv");
			oLoginDiv.setAttribute("name", "loginDiv");
			oLoginDiv.style.height="0px";
			oLoginDiv.style.width="0px";
			oLoginDiv.style.display="none";

			document.getElementById("outline").appendChild(oLoginDiv);
		}
		catch(E)
		{
			alert(E);
		}
	},

	viewAccountLink : function()
	{
		Common._createBackGround();
		this._createHiworksLoginFrame();

		getAjaxData(Common.getRoot() + 'account_link', "", acLink.viewAccountLinkResult);
	},

	viewGabiaRegist : function()
	{
		Common._createBackGround();
		this._createHiworksLoginFrame();

		getAjaxData(Common.getRoot() + 'account_link/regist', "", acLink.viewAccountLinkResult);
	},

	viewAccountLinkResult : function(pValue)
	{
		if (pValue.resultCode == RT_OK)
		{
			if ($("accountBase"))
				$("accountBase").parentNode.removeChild($("accountBase"));

			var oAccountBase = document.createElement("div");
			oAccountBase.setAttribute("id", "accountBase");
			oAccountBase.style.width = "500px";
			oAccountBase.innerHTML = pValue.result;
			document.getElementById("outline").appendChild(oAccountBase);
			$("accountBase").toCenter();
		}
		else
		{
			alert(pValue.message);
			Common._closeBackGround();
		}
	},

	accountClose : function()
	{
		Common._closeBackGround();

		if ($("loginDiv"))
		{
			$("loginDiv").style.display = "none";
		}
		if ($("backLayer"))
		{
			$("backLayer").style.display = "none";
		}
		if ($("accountBase"))
		{
			if ($("accountBase").style.display == "")
				$("accountBase").style.display = "none";

			return;
		}
	},

	showAgreement : function()
	{
		if ($("accountAgreement"))
		{
			if ($("accountAgreement").style.display == "none" || $("accountAgreement").style.display == "")
				$("accountAgreement").style.display = "block";
			else
				$("accountAgreement").style.display = "none";
		}
	},

	viewHiworksGabiaID : function(pEvent)
	{
		if ($("accountDesc1"))
		{
			if ($("accountDesc1").style.display == "none" || $("accountDesc1").style.display == "")
			{
				$("accountDesc1").style.top = "200px";
				//$("accountDesc1").style.left = (Event.pointerX(pEvent)-15) + "px";
				$("accountDesc1").style.display = "block";
			}
			else
				$("accountDesc1").style.display = "none";

		}
	},

	idDupCheck : function()
	{
		if ($("gabia_id"))
		{
			if (!validCheck.validGabiaID($("gabia_id").value))
			{
				alert("6~16자리의 영문소문자, 숫자만 가능합니다.");
				$("gabia_id").focus();
				return;
			}

			var param = $H({"pMenu" : "idcheck", "pID" : Common.trim($("gabia_id").value)});
			getAjaxData(Common.getRoot() + "account_link", param, acLink.idDupCheckResult);
		}
	},

	idDupCheckResult : function(pValue)
	{
		if (pValue.resultCode == RT_OK)
		{
			alert("사용가능한 ID입니다.");
			$("idcheck").value = "Y";
			$("pass1").focus();
			return;
		}
		else
		{
			alert(pValue.message);
			$("gabia_id").focus();
			$("idcheck").value = "N";
		}
	},

	juminCheck : function()
	{
		var id1 = Common.trim($("idno1").value) + Common.trim($("idno2").value);
		var id2 = Common.trim($("idno1").value) + "-" + Common.trim($("idno2").value);

		if (!validCheck.idno(id1))
		{
			alert("주민번호 형식이 올바르지 않습니다.");
			$("idno1").focus();
			return;
		}

		var param = $H({"pMenu" : "jumincheck", "pNo" : Common.trim(id2)});
		getAjaxData(Common.getRoot() + "account_link", param, acLink.juminCheckResult);
	},

	juminCheckResult : function(pValue)
	{
		alert(pValue.message);
		if (parseInt(pValue.result, 10) == -1)
		{
			$("jumincheck").value = "Y";
			$("email").focus();
		}
		else
		{
			$("jumincheck").value = "N";
			$("idno1").focus();
		}

		return;
	},

	registSubmit : function()
	{
		if ($("idcheck").value == "N")
		{
			alert("ID중복 확인을 해 주셔야 합니다.");
			$("gabia_id").focus();
			return;
		}

		if (Common.trim($("name").value) == "")
		{
			alert("이름은 입력해주셔야 합니다.");
			$("name").focus();
			return;
		}

		var n = $("name").value;

		var newline=(document.all)?'%0A':'%0D%0A';
		var str_count = 0;

		if ($("name").value.indexOf("'") >= 0 || $("name").value.indexOf('"') >= 0)
		{
			alert("이름(필명)에 쌍따옴표, 따옴표는 입력하실 수 없습니다.");
			$("name").focus();
			return false;
		}
		for(i=0 ; i<n.length ; ++i)
		{
			var str = n.charAt(i);
			var ascii = str.charCodeAt();

			if (ascii > 127 && escape(str) != newline) str_count += 2;
			else if (escape(str) == newline) str_count += 0;
			else ++str_count;
		}

		if (str_count < 4 || str_count > 20)
		{
			alert("이름(필명)은 한글 10자, 영문 20자 이하로 입력해 주시기 바랍니다.");
			$("name").focus();
			return;
		}

		if (!validCheck.validGabiaID($("gabia_id").value))
		{
			alert("아이디는 6~16자의 영문 소문자, 숫자 조합이어야 합니다.");
			$("gabia_id").focus();
			return;
		}

		if (!validCheck.valid_email($("email").value))
		{
			alert("올바른 메일 형식이 아닙니다.");
			$("email").focus();
			return;
		}

		if (!validCheck.between_length($("pass1").value, 8, 16))
		{
			alert("비밀번호는 8~16자의 영문 소문자, 숫자 가능하며, 생일, 주민등록번호 앞자리, 전화번호 사용불가 합니다.");
			$("pass1").focus();
			return;
		}

		if ($("pass1").value != $("pass2").value)
		{
			alert("입력된 비밀번호가 같지 않습니다.");
			$("pass2").focus();
			return;
		}

		if (!$("agreement").checked)
		{
			alert("회원약관 및 개인정보 수집 및 이용에 동의 하셔야 합니다.");
			return;
		}

		var param = $H({"pMenu" : "registprocess",
			"pID" : Common.trim($("gabia_id").value),
			"pPass1" : Common.trim($("pass1").value),
			"pPass2" : Common.trim($("pass2").value),
			"pName" : Common.trim($("name").value),
			"pEmail" : Common.trim($("email").value)});

		if ($("action_target"))
			getAjaxData(Common.getRoot() + $("action_target").value, param, acLink.registResult);
		else
			getAjaxData(Common.getRoot() + "account_link", param, acLink.registResult);
	},

	registResult : function(pValue)
	{
		if (pValue.layerID == "self" || pValue.resultCode != RT_OK)
		{
			alert(pValue.message);
			return;
		}
		else
		{
			try {
			if ($("action_target") && $("action_target").value == "hidprocess_ajax/hidlogin")
			{
				if (confirm(pValue.message))
				{
					var param = $H({"pMenu" : "hidregist", "regist_id" : $("gabia_id").value, "passwd" : $("gabia_pass").value});
					getAjaxData(Common.getRoot() + "hidprocess_ajax/officeregist", param, acLink.requestAccountResult);
				}
			}
			else if ($("action_target") && $("action_target").value == "hidprocess_ajax/officeregist")
			{
				acLink.requestAccountResult(pValue);
			}
			else
			{
				var oTemp = pValue.layerID.split("||");
				acLink._hiworksLogin(oTemp[0], oTemp[1]);
				for(i=0 ; i<100000 ; ++i)	// 하이웍스 로그인 시간을 위한 delay
				{
					i;
				}
				$("accountBase").innerHTML = pValue.result;
			}
		} catch(E)
		{
			alert(E);
		}
		}
	},

	requestAccountResult : function(pData)
	{
		alert(pData.message);
try {
		if ($("accountBase"))
		{
			Common._closeBackGround();
			$("accountBase").style.display = "none";
			$("accountBase").parentNode.removeChild($("accountBase"));
		}
} catch(E)
{
	alert(E);
}
		return;
	},

	zipcode : function()
	{
		Zip.searchZipView();

		var scTop = document.documentElement.scrollTop || document.body.scrollTop;
		$("tableZip").style.left = (($("accountBase").getWidth() - $("tableZip").getWidth()) /2) + "px";
		//$("tableZip").style.left = ((document.viewport.getWidth() - $("tableZip").getWidth()) /2) + "px";
		$("tableZip").style.top = ((document.viewport.getHeight() - $("tableZip").getHeight()) /2 + scTop) + "px";

		if(document.viewport.getHeight() < $("tableZip").getHeight())
			$("tableZip").style.top = (scTop+100) + 'px';
	},

	showHiworksAgreement1 : function()
	{
		AgreementWin = window.open("http://www.hiworks.co.kr/popup_agreement/policy_member", "policy_member", "menubar=no,toolbar=no,location=no,directories=no,resizable=no,status=no,width=770, height=470,left=50,top=50");
		AgreementWin.focus();
	},

	showHiworksAgreement2 : function()
	{
		AgreementWin = window.open("http://www.hiworks.co.kr/popup_agreement/policy_personalinfo", "policy_personalinfo", "menubar=no,toolbar=no,location=no,directories=no,resizable=no,status=no,width=770, height=470,left=50,top=50");
		AgreementWin.focus();
	},

	showDesc : function(pEvent)
	{
		if (!$("helpDiv"))
		{
			var oDesc = document.createElement("div");
			oDesc.setAttribute("id", "helpDiv");
			//document.getElementById("alphaDiv").appendChild(oDesc);
			//document.body.appendChild(oDesc);
			document.getElementById("accountBase").appendChild(oDesc);
		}

		if (Common.getIEVersion() == false)
			$("helpDiv").style.top = (Event.pointerY(pEvent)-420) + "px";
		else
			$("helpDiv").style.top = (Event.pointerY(pEvent)-280) + "px";
		$("helpDiv").style.left = (Event.pointerX(pEvent)-500) + "px";
		$("helpDiv").style.width = "400px";

		var szBuffer = "<p class=\"boldStyle\">이메일 로그인 및 관련 정책 안내</p>";
		szBuffer += "<ol style=\"padding:15px; margin:0; list-style:number inside; *list-style:number outside; line-height:15px;\">";
		szBuffer += "<li style=\"padding:0px;\">이메일 인증 안내<br />";
		szBuffer += "이메일 주소는 사용 가능한 유효한 정보를 입력해주세요.<br />";
		szBuffer += "고객님께서 입력한 이메일이 사용 가능한지 확인하기 위해 ‘이메일 인증 단계’를 진행하오니 반드시 5일 이내에 완료하시기 바랍니다(등록하신 이메일로 인증을 위한 이메일을 보내드립니다). 5일 이후에는 하이웍스 이용에 제한이 있사오니 이점 유의하시기 바랍니다.";
		szBuffer += "</li>";
		szBuffer += "<li style=\"padding:0px; margin-top:10px;\">이메일 로그인 안내<br />";
		szBuffer += "이메일 인증을 완료한 고객님께 하이웍스 사이트 로그인 시 ‘회원 아이디’ 대신 등록하신 ‘이메일 주소’로도 로그인 할 수 있는 기능을 제공해드립니다.<br />";
		szBuffer += "사이트마다 다른 아이디 대신 자주 이용하는 이메일로 로그인 할 수 있어 편리합니다.<br /><br />";
		szBuffer += "본 기능은 이메일 인증을 완료한 고객님께만 제공되므로 인증을 완료하시 않으셨다면, 지금 바로 등록하신 메일로 접속한 후 인증 절차를 완료하시기 바랍니다.<br />";
		szBuffer += "단, 본 기능은 하이웍스 사이트에만 제공됩니다(가비아는 불가능).";
		szBuffer += "</li>";
		szBuffer += "</ol>";
		$("helpDiv").innerHTML = szBuffer;

		$("helpDiv").style.display = "";
	},

	hideDesc : function()
	{
		if ($("helpDiv"))
			$("helpDiv").style.display = "none";
	}
}

// Overriding CSS Selector Engine.
// 이 함수 위로 추가 해주세요.
Sly.handlers = Selector.handlers;
Sly.prototype.findElements = Sly.prototype.search;
Sly.findElement = function(elements, expression, index) {
  if (Object.isNumber(expression)) {
    index = expression; expression = false;
  }
  return Sly(expression || '*').filter(elements)[index || 0];
};
Sly.findChildElements = function(element, expressions) {
  var result = Sly(expressions.join(',')).search(element);
  return Prototype.BrowserFeatures.ElementExtensions ?
    result : result.filter(Element.extend);
};
Selector = Sly;

//플래시
function flash(path, width, height, name){
        document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="'+width+'" height="'+height+'" codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" id="'+name+'" class="toplogo">'
        +'<param name="movie" value="'+path+'">'
        +'<param name="quality" value="high">'
        +'<param name="wmode" value="transparent">'
        +'<param name="allowScriptAccess" value="always">'
        +'<embed src="'+path+'" quality="high" wmode="transparent" pluginspage="https://www.macromedia.com/go/getflashplayer" width="'+width+'" height="'+height+'" type="application/x-shockwave-flash" showLiveConnect="true" name="'+name+'" allowScriptAccess="always"></embed>'
        +'</object>');
}

//롤오버
function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}


// Tip 임시
function tip_openBrWindow(n) {
	//window.open('/main/tip_popup', 'tip_popup', 'width=740,height=650,resizable=1,scrollbars=1' );
   var num = parseInt(n, 10) + 1;
   window.open('http://www.hiworks.co.kr/main/tip_popup/'+num, 'tip_popup', 'width=740,height=650,resizable=1,scrollbars=1' );
}


function html_strip(html_str) {
  return html_str.replace(/(<([^>]+)>)/ig,"").replace("&nbsp;", "");
}

function ea_pro()
{
	window.open('http://office1.hiworks.co.kr/myservice', '', '');
}

function ea_new()
{
	window.open('http://office1.hiworks.co.kr/make/ea', '', '');
}
