﻿//document.domain = "hanbiton.com";

// 이미지 사이즈 조정하기
function ResizeImage(id) {
	var img = document.getElementById("UserImage" + id);
	
	if (img.width > 680) {
		img.width = 680;
	} else if (img.width == 0) {
		setTimeout("ResizeImage('" + id + "')", 200);
	}
}

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_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

var isVistar = false;
var ls = null;
var ts = null;

/*
 * Browser type
 */
var isOpera = navigator.userAgent.indexOf("Opera") > -1; 
var isIE = navigator.userAgent.indexOf("MSIE") > 1 && !isOpera; 
var isMoz = navigator.userAgent.indexOf("Mozilla/5.") == 0 && !isOpera; 

/*
	Title 및 상태바 링크 숨기기
*/
document.title = "행복한 게임커뮤니티 한빛온  Hanbit ON!!";

if (document.layers) {
	document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT);
}

document.onmouseover = hidestatus;
document.onmouseout = hidestatus;

function hidestatus(){
	window.status = '행복한 게임커뮤니티 한빛온';
	return true;
}

/*
 * document event
 */
//document.oncontextmenu = new Function("return false");
document.onclick = MouseDown;
document.onkeydown = processKey;

/*
 * String object prototype functions
 */
// length
String.prototype.getAsciiLength = function() {
	var len = 0;
	for (i = 0; i < this.length; i++) {
		if (this.charCodeAt(i) < 255) {
			len++;
		} else {
			len+=2;
		}
	}
	return len;
}

// trim
String.prototype.trim = function() {
	var retValue = this;

	var ch = retValue.substring(0, 1);
	while (ch == " ") {
		retValue = retValue.substring(1, retValue.length);
		ch = retValue.substring(0, 1);
	}
	
	ch = retValue.substring(retValue.length - 1, retValue.length);
	while (ch == " ") {
		retValue = retValue.substring(0, retValue.length - 1);
		ch = retValue.substring(retValue.length - 1, retValue.length);
	}
	
	return retValue;
}

// replace
/*String.prototype.replace = function(source, copy) {
  var str = this;
	while (str.indexOf(source) != -1) {
		str = str.substring(0, str.indexOf(source)) + copy + str.substring(str.indexOf(source) + source.length);
	}
	return str;
}*/


//Client Windows Version Check
function CheckOS() {

	if(navigator.userAgent.indexOf('Win') != -1)
	{ 
		var Version;
		var temp = navigator.userAgent.split(";");
		
		for(i=0;i<temp.length;i++)
		{
			if(temp[i].indexOf('Win') != -1)
			{
				Version = temp[i];
			}
		}
		
		if(Version.indexOf('6.0') != -1)
		{
			var OpSys = "Vistar"; 			
			isVistar = true; 
		} else {
			var OpSys = "Windows Me or NT or 2000"; 
			isVistar = false;
		}
	}	
	
	return OpSys;
}

/*
 * utility functions
 */
//아스키코드값 173 입력 불가 처리 
function CheckNullChar(input)
{
  for (i=0; i<input.length; i++)
  {
    if(input.charCodeAt(i) == 173)
      return false;
  }
  return true;
} 
function CheckSpecialChar(input)
{
  var ret = false;
  ret = CheckNullChar(input);
  if(ret)
  {
    for (i=0; i<input.length; i++)
    {
      if(input.charCodeAt(i) == 8 || input.charCodeAt(i) == 92)
      {
        ret = false;
        break;
      }
    }
    ret = true;
  }
  return ret;
}
// trim
function trim(input) {
	if (typeof input != "string") return input;
	
	var retValue = input;

	var ch = retValue.substring(0, 1);
	while (ch == " ") {
		retValue = retValue.substring(1, retValue.length);
		ch = retValue.substring(0, 1);
	}
	
	ch = retValue.substring(retValue.length - 1, retValue.length);
	while (ch == " ") {
		retValue = retValue.substring(0, retValue.length - 1);
		ch = retValue.substring(retValue.length - 1, retValue.length);
	}
	
	return retValue;
}

// replace string
function replace(str, source, copy) {
	while (str.indexOf(source) != -1) {
		str = str.substring(0, str.indexOf(source)) + copy + str.substring(str.indexOf(source) + source.length);
	}
	return str;
}

// IsNumeric
function IsNumeric(str) {
	var r = new RegExp("^[0-9]*$");
	if (document.all) {
		return r.exec(str) != null;
	} else {
		return r(str) != null;
	}
}

// ASCII only
function URLEncode(plaintext) {
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
		if (ch == " ") {
			encoded += "%20";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
			encoded += ch;
		} else {
			var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
				// encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for

	return encoded;
}

function URLDecode(encoded) {
	// Replace + with ' '
	// Replace %xx with equivalent character
	// Put [ERROR] in output if %xx is invalid.
	var HEXCHARS = "0123456789ABCDEFabcdef"; 
	var plaintext = "";
	var i = 0;
	while (i < encoded.length) {
		var ch = encoded.charAt(i);
		if (ch == "+") {
			plaintext += " ";
			i++;
		} else if (ch == "%") {
			if (i < (encoded.length-2) 
				&& HEXCHARS.indexOf(encoded.charAt(i+1)) != -1 
				&& HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 ) {
				plaintext += unescape( encoded.substr(i,3) );
				i += 3;
			} else {
				alert( 'Bad escape combination near ...' + encoded.substr(i) );
				plaintext += "%[ERROR]";
				i++;
			}
		} else {
			plaintext += ch;
			i++;
		}
	} // while
	return plaintext;
}

// 이미지 미리 로딩
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];}}
}

// windowsopen
function openWindow(loc, name, opt) {
	var win = window.open(loc, name, opt);
	if (win == null) {
		alert("한빛온을 원활하게 이용하시려면 먼저 팝업차단설정을 꺼주세요");
	}
	return win;
}

function GetDownload(filename, postid)
{
  var idown = document.getElementById("downloadframe" + postid);
  if(idown == null)
  {
    var tmp = document.createElement("iframe");
    tmp.setAttribute("src", "about:blank");
    tmp.setAttribute("id", "downloadframe" + postid);
    tmp.setAttribute("name", "downloadframe" + postid);
    tmp.setAttribute("style", "display:none;");
    document.body.appendChild(tmp);
    
    idown = tmp;
  }
  idown.src = "/popup/AttachDownload.aspx?dbfilename=" + escape(filename);
}
// get cookie expire day
function getexpirydate(mins){
	var Today = new Date();
	var nomilli = Date.parse(Today);
	Today.setTime(nomilli + mins * 60 * 1000);
	return Today.toUTCString();
}

// get cookie value
function getcookie(cookiename) {
	var cookiestring = "" + document.cookie;

	// cookie first
	var index1 = cookiestring.indexOf(cookiename);
	if (index1 == -1 || cookiename == "") {
		return "";
	}

	// cookie end
	var index2 = cookiestring.indexOf(';',index1);
	if (index2 == -1) {
		index2 = cookiestring.length; 
	}

	return unescape(cookiestring.substring(index1+cookiename.length+1, index2));
}

// set cookie
function setcookie(name, value, mins){
	// make cookie string
	cookiestring = name + "=" + escape(value) + ";expires=" + getexpirydate(mins) + ";domain=hanbiton.com;path=/;";

	// write!
	document.cookie = cookiestring;
	if (!getcookie(name)){
		return false;
	} else {
		return true;
	}
}

/*
 * usage
 *
 * var cookie = new MCookie();
 * for (i = 0; i < 10; i++) {
 *   AppendMCookie(cookie, "name_" + i, "value_" + i);
 * }
 * SetMCookie(cookie, "sample_cookie", 10); // 10 minutes
 *
 *
 * var cookie = GetMCookie("sample_cookie");
 */

// multi name-value cookie container
function MCookie() {
	this.names = new Array();
	this.values = new Array();
	this.count = 0;

	return this;
}

// append multi name-value cookie
function AppendMCookie(cookie, name, value) {
	var index = cookie.count;
	// if exists cookie, update that
	for (i = 0; i < cookie.count; i++) {
		if (cookie.names[i] == name) {
			index = i;
			break;
		}
	}

	cookie.names[index] = name;
	cookie.values[index] = value;
	cookie.count++;
}

// delete one cookie in multi name-value cookie
function DeleteMCookie(cookie, index) {
	for (i = index + 1; i < cookie.count; i++) {
		cookie.names[i - 1] = cookie.names[i];
		cookie.values[i - 1] = cookie.values[i];
	}

	cookie.count--;
}

// multi name-value cookie seperator
var s1 = "||";
var s2 = "|||";

// set multi name-value cookie
function SetMCookie(cookie, name, mins) {
	var value = "";

	for (i = 0; i < cookie.count; i++) {
		value += escape(cookie.names[i]) + s1 + escape(cookie.values[i]);
		if (i + 1 < cookie.count) {
			value += s2;
		}
	}

	setcookie(name, value, mins);
}

// get multi name-value cookie
function GetMCookie(name) {
	var str = getcookie(name);
	var cookie = new MCookie();

	if (str != "") {
		var array = str.split(s2);

		for (i = 0; i < array.length; i++) {
			tmp = array[i].split(s1);
			AppendMCookie(cookie, tmp[0], tmp[1]);
		}

		cookie.count = array.length;

		return cookie;
	} else {
		return new MCookie();
	}
}

// add get variable
function AddGetVariable(url, name, value) {
	url = url + "";

	var index0 = url.indexOf("?" + name + "=");

	if (index0 == -1) {
		var index1 = url.indexOf("&" + name + "=");

		if (index1 == -1) {
			if (url.indexOf("?") == -1) {
				url = url + "?" + name + "=" + value;
			} else {
				url = url + "&" + name + "=" + value;
			}	
		} else {
			var index2 = url.substr(index1 + 1).indexOf("&");
			if (index2 == -1) {
				url = url.substr(0, index1) + "&" + name + "=" + value;
			} else {
				url = url.substr(0, index1) + url.substr(index1 + index2 + 1, url.length) + "&" + name + "=" + value;
			}
		}
	} else {
		var index3 = url.substr(index0 + 1).indexOf("&");
		if (index3 == -1) {
			url = url.substr(0, index0) + "?" + name + "=" + value;
		} else {
			url = url.substr(0, index0) + "?" + name + "=" + value + url.substr(index0 + index3 + 1, url.length);
		}
	}	

	return url;
}

function GetGetVariable(url, name) {
	url = url + "";

	var index0 = url.indexOf("?" + name + "=");

	if (index0 == -1) {
		var index1 = url.indexOf("&" + name + "=");

		if (index1 == -1) {
			return "";
		} else {
			var index2 = url.substr(index1 + name.length + 2).indexOf("&");
			if (index2 == -1) {
				return url.substr(index1 + name.length + 2);
			} else {
				return url.substr(index1 + name.length + 2, index2);
			}
		}
	} else {
		var index3 = url.substr(index0 + name.length + 2).indexOf("&");
		if (index3 == -1) {
			return url.substr(index0 + name.length + 2);
		} else {
			return url.substr(index0 + name.length + 2, index3);
		}
	}
}

function DeleteGetVariable(url, name) {
	url = url + "";

	var index0 = url.indexOf("?" + name + "=");

	if (index0 == -1) {
		var index1 = url.indexOf("&" + name + "=");

		if (index1 != -1) {
			var index2 = url.substr(index1 + 1).indexOf("&");
			if (index2 == -1) {
				url = url.substr(0, index1);
			} else {
				url = url.substr(0, index1) + url.substr(index1 + index2 + 1, url.length);
			}
		}
	} else {
		var index3 = url.substr(index0 + 1).indexOf("&");
		if (index3 == -1) {
			url = url.substr(0, index0);
		} else {
			url = url.substr(0, index0) + "?" + url.substr(index0 + index3 + 2, url.length);
		}
	}	

	return url;
}

// is xp sp2?
function IsNaviXp2() {
	var strMatch = window.navigator.appVersion;
	
	if( strMatch.match("SV1") == "SV1" && strMatch.match("Windows NT 5.1") == "Windows NT 5.1" )
		return true;
	else
		return false;
}

// form submit with disabled viewstate
function FormSubmit(form, action) {
	for (i = 0; (e = document.getElementsByTagName("input")[i]); i++) {
		if (e.getAttribute("type").indexOf("hidden") != -1) {
			if (e.getAttribute("name") == "__VIEWSTATE") {
				e.disabled = true;
				break;
			}
		}
	}

	form.action = action;
	form.submit();
}

// ajax
// XMLHTTP object
var objHttp;

function ActionWindow(flag) {
	flag = flag + "";
	if (flag.length == 4) {
		actionWindow(opener, flag.substr(0, 1));
		actionWindow(top, flag.substr(1, 1));
		actionWindow(parent, flag.substr(2, 1));
		actionWindow(self, flag.substr(3, 1));
	}
}

function actionWindow(o, action) {
	if (o != null) {
		switch (action) {
			case "1": o.location.reload(); break;
			case "2": o.close(); break;
			case "3":
				var ret = GetGetVariable(window.location, "ReturnUrl");
				if (ret != null && ret != "") {
					ret = unescape(ret);
					o.location = ret;
				} else {
					o.location = "/home/default.aspx";
				}
				break;
		}
	}
}

// select color pallete
function SelectColorInPallete(szFunction) {
	window.open("/popup/selectcolor.html?o=" + szFunction, "HanbitON_Pallete", "width=300,height=190,status=no,scrollbars=no");
}


/*
 * gogogo functions
 */
/* 
 * Layer Function
 */
// 소망상자 보기
function GoWishList(id) {
	openWindow("/miniblblog/admin/main.aspx?id=" + id + "&menu=hope", "blogwindow", "");
}

function GoGiftList(id) {
	openWindow("/miniblblog/admin/main.aspx?id=" + id + "&menu=gift", "blogwindow", "");
}
// 내 미니블 가기 
function goMyMinibl(id, mode) {
	
	if (mode == "undefined" || mode == null) 
	{
		openWindow("http://www.hanbiton.com/miniblblog/default.aspx?id=" + id,  "blogwindow", "");
	} 
	else 
	{
		openWindow("http://www.hanbiton.com/miniblblog/default.aspx?id=" + id + "&mode=" + mode,  "blogwindow", "");
	}
}

function goMyMiniblGame(id, mode) {
	openWindow("/miniblblog/default.aspx?pagetype=game&id=" + id + "&mode=" + mode,  "blogwindow", "");
}


/******************************************************************************************************************/

// 이웃 미니블 바로가기
function goMiniblShortCut(id,gametype) {
	openWindow("/miniblblog/default.aspx?id=" + id +"&GameType="+gametype+"&FirstView=true", "blogwindow", "") ;
}


function goMiniblShortCut(id) {
	openWindow("/miniblblog/default.aspx?id=" + id +"&FirstView=true", "blogwindow", "");
}

// 내 미니블 포스트 가기
function goMyMiniblPost(id, no) {
	openWindow("/miniblblog/default.aspx?pagetype=blog&id=" + id + "&postid=" + no, "blogwindow", "");
}

// 내 블로그 가기
function goMyBlog(id) {
	openWindow("/miniblblog/default.aspx?id=" + id, "blogwindow", "");
}

// 내 미니블 인사게시판 가기
function goMyGuestBook(id) {
	openWindow("/miniblblog/default.aspx?pagetype=guest&id=" + id, "blogwindow", "");
}

// 내 미니블 관리 가기
function goMyMiniblAdmin(id, menu) {
	openWindow("/miniblblog/default.aspx?pagetype=admin&id=" + id + "&menu=" + menu, "blogwindow", "");
}


// 미니블 가기
function goMinibl(id) {
	openWindow("/miniblblog/default.aspx?id=" + id+"&FirstView=true", "blogwindow", "");
}

// 미니블 포스트 가기
function goMiniblPost(id, no) {
	openWindow("/miniblblog/default.aspx?pagetype=blog&id=" + id + "&postid=" + no+"&FirstView=true", "blogwindow", "");
}
// 미니블 블로그탭으로 가기
function goBlog(id) {
  openWindow("/miniblblog/default.aspx?id=" + id+"&FirstView=true", "blogwindow", "");
}

// 미니블 블로그탭 카테고리로 가기
function GoMiniblCategory(id, cid) {
	openWindow("/miniblblog/default.aspx?pagetype=blog&id=" + id + "&cid=" + cid+"&FirstView=true", "blogwindow", "");
}

// 미니블 관심게임 설정 바로가기
function GoMiniblFavorgame(id) {
	openWindow("/miniblblog/default.aspx?pagetype=admin&id=" + id + "&menu=favorgame", "blogwindow", "");
}

// 사용자 미니블의 캐라콘 백 바로 가기
function GoUserCharaconBag(id)
{
	openWindow("/miniblblog/admin/main.aspx?menu=characon&id="+id+"&FirstView=true", "blogwindow", "");
}

// 발직한 미니블 포스트 가기
function goMySearchMiniblPost(id, SearchWord) {
	openWindow("/miniblblog/default.aspx?pagetype=blog&mode=write&id="+id+"&SearchWord="+SearchWord, "blogwindow", "");
}

// 사용자 미니블의 캐라콘 백 바로 가기
function GoSelfCharaconBag(id)
{
	openWindow("/miniblblog/admin/main.aspx?id=" + id + "&menu=characon", "blogwindow", "");
}

// 길드/파티 바로가기
function goshortcut(loc) {
	setcookie("hanbiton_visit", "", -100);
	if (loc) location.href = loc;
}

// 창닫기
function closeWindow() {
	if (top != self) {
		top.closeWindow();
	} else {
		self.opener = self;
		self.close();
	}
}

// 인사말 수정
function GreetingPopup(id) {
	window.open("/popup/minibl/EditGreeting.aspx?id=" + id, "HanbitOn_EditGreeting", "width=350,height=300,status=no,scrollbars=no");
}

// 스크랩
function ScrapPost(from, id, no) {
	window.open("/popup/scrappost.aspx?from=" + from + "&id=" + id + "&no=" + no, "HanbitOn_Scrap", "width=400,height=300,status=no,scrollbars=no");
}
function ScrapPost(from, id, no, ds_photo) {
	window.open("/popup/scrappost.aspx?from=" + from + "&id=" + id + "&no=" + no+ "&ds_photo=" + ds_photo, "HanbitOn_Scrap", "width=400,height=300,status=no,scrollbars=no");
}

function ViewScrap(from, id, no) {
	window.open("http://www.hanbiton.com/popup/scraplist.aspx?from=" + from + "&id=" + id + "&no=" + no, "HanbitOn_ScrapList", "width=520,height=509,status=no,scrollbars=yes");
}

//약관동의 창
function openArticle(userid) {
	window.open("http://member.hanbiton.com/h_realname/default.aspx?userid=" + userid + "&gm=WHN", "HanbitOn_Article", "width=800,height=550,status=no,scrollbars=no");
}


// 회원가입
function GoJoinMember() {
	top.location.href="https://members.hanbiton.com:8080/register/default.aspx?regsite=hanbiton";
}

// 회원수정
function GoEditMember() {
	top.location.href="https://members.hanbiton.com:8080/myinfo/default.aspx?menu=MyInfoModify&regsite=hanbiton";
}

// 회원탈퇴
function GoOutMember() {
	top.location.href="https://members.hanbiton.com:8080/myinfo/default.aspx?menu=InfoOut&regsite=hanbiton";
}

//내캐시내역
function GoCashMember() {
	top.location.href="https://members.hanbiton.com:8080/MyInfo/Default.aspx?menu=CashInfo";
}

// 쪽지리스트
function GoPaperList() {
	top.location.href="https://members.hanbiton.com:8080/Paper/ReceiveList.aspx?menu=PaperInfo";
}

// 새 쪽지
function GoPaperView() {
	window.open("https://members.hanbiton.com:8080/Paper/Popup/View.aspx", "HanbitPaper", "width=350px height=315");
}

// 아이디/패스워드 찾기
function GoSearchIdPass() {
    if (opener != null)
    {
        opener.location.href = "https://webservice.hanbiton.com/Info/AccountSearch.aspx?regsite=hanbiton";
    }
    else
    {
        top.location.href = "https://webservice.hanbiton.com/Info/AccountSearch.aspx?regsite=hanbiton";
    }
}

// 멤버쉽 페이지로
function GoMembership() {
	window.open("http://member.hanbiton.com/h_member/ms_main.aspx", "HanbitMemberShip", "left=10,top=10,width=997,height=600,status=no,scrollbars=yes");
}

//조르기
function openPress(userid) {
	window.open("http://member.hanbiton.com/h_realname/Press.aspx?userid=" + userid + "&gm=WHN", "HanbitOn_Press", "width=800,height=550,status=no,scrollbars=no");
}


/* 
 * popup functions
 */

// 이미지 팝업
function popview(url) {
	openWindow("/popup/ViewImage.aspx?url=" + url, "HanbitOnpopview", "width=100,height=100,status=no,scrollbars=yes,resizable=yes");
}

// 로그인 창 열기
function openLogin() {
	openWindow("/popup/login.aspx", "HanbitOnLogin", "width=350,height=300,status=no,scrollbars=no");
}

// 로그인이 필요합니다
function NeedLogin() {
	alert("먼저 로그인해주세요");
	//openWindow("/popup/login.aspx", "HanbitOnLogin", "width=350,height=300,status=no,scrollbars=no");
}

// 프레임으로 쌓여있는 곳에서의 로그인
function NeedLoginFrame() {
	alert("먼저 로그인해주세요");
}

// 바로가기
function goUrl(url) {
	if (url != "") {
		if (url.substring(0, 7) == 'http://') {
			openWindow(url, "", "");
		} else {
			location.href = url;
		}
	}
}

// 로그인
function Login() {
	
	var preurl = escape(window.location.href);
	
	while(preurl.search(/%3A/i) > 0)
	{
		preurl = preurl.replace(/%3A/i,":");
	}
	
	while(preurl.search(/%3F/i) > 0)
	{
		preurl = preurl.replace(/%3F/i,"?");
	}
	
	while(preurl.search(/%3D/i) > 0)
	{
		preurl = preurl.replace(/%3D/i,"=");
	}
	
	while(preurl.search(/%23/i) > 0)
	{
		preurl = preurl.replace(/%23/i,"#");
	}
	
	//top.location.href = "/h_help/h_space/member05.aspx?ReturnUrl="+preurl;
	top.location.href = "http://help.hanbitOn.com/login/member05.aspx?ReturnUrl="+preurl;
	
}

function StaticLogin(returnUrl)
{
	//top.location.href = "/h_help/h_space/member05.aspx?ReturnUrl="+returnUrl;
	top.location.href = "http://help.hanbitOn.com/login/member05.aspx?ReturnUrl="+preurl;
}

/*
 * frame resize functions
 */
// ifrmae 리사이즈
function resizeIframe(name) {
	if (name == null || name == "") {
		return;
	}
	
	try {
	  // iframe object
	  var oIFrame = document.getElementById(name);

	  // resize
		oIFrame.style.height = oIFrame.contentWindow.document.body.scrollHeight;
	} catch (e) {
	}
}

// 부모쪽 리사이즈 함수 호출
function parentResizeIframe(name) {
	if (parent && parent != this && parent.resizeIframe != null) {
		parent.resizeIframe(name);
	}
}

/*
 * navi table
 */
var navi = new Array();
navi[0] = "/home/default.aspx";
navi[1] = "/h_guild/h_space/guild_main.aspx";
navi[2] = "/h_parti/h_space/main.aspx";
navi[3] = "/h_minibl/h_space/main.aspx";
navi[4] = "/h_ongisik/knowMain.aspx";
navi[5] = "/h_shop/default.aspx";

/*
 * hanbiton key shortcut
 */
function processKey(event) {
	var e;

	if (isIE) {
		e = window.event;
	} else {
		e = event;
	}
  
	// alt + number
	if (e.altKey && e.keyCode > 47 && e.keyCode < 54) {
		if (window == top && opener == null) {
			window.location = navi[e.keyCode - 48];
		}
	}
}

/*
 * hanbiton ui functions
 * 
 */
var status_over = false;
var menu_name = "ui_menu";

var minibl_id = "";
var game_id = "";

// var menuover_bgcolor = "#e4ff75";
var menuover_bgcolor = "#eeeeee";
var default_menuover_bgcolor = "#ffffff";

// admin id array
var adminIdList = ["hanbiton", "hanbitonshop", "hanbiton_stars", "hanbit_game", "hanbiton_ge"];


// mouse down event
function MouseDown(e) {
	if (event.button == 2 || event.button == 3) {
		return false;
	}
	event_check = false;
	event_target = event.srcElement;

	// 이미지에 링크가 걸리는 경우
	if (event_target.tagName.toString().toLowerCase() == "img") {
		if (event_target.parentElement.tagName.toString().toLowerCase() == "a") {
			event_target = event_target.parentElement.toString();
			event_check = event_target.indexOf("javascript:HOPopup(");
		} else {
			return;
		}
	} else {
		event_target = event_target.toString();
		event_check = event_target.indexOf("javascript:HOPopup(");
	}
	
	if (!status_over) hideMenu();
	if (!event_check) {
		viewMenu(event, menu_name);
	} else {
		if (!status_over) hideMenu();
		return;
	}
}

function viewMenu(e, name) {
	if (name == "none") return;

	b = window.document.body;
	x_pos = b.scrollLeft + event.clientX;
	y_pos = event.clientY + b.scrollTop;
	// screen_height = window.document.body.offsetHeight;
	// screen_width = window.document.body.offsetWidth;
	// mouse_top = e.y;
	// mouse_left = e.x;

	eval(name + ".style.pixelTop = " + y_pos);
	eval(name + ".style.pixelLeft = " + x_pos);
	eval(name + ".style.display = \"\"");
}

function hideMenu() {
	eval(menu_name + ".style.display = \"none\"");
}

function menuOut(ar_obj) {
	status_over = false;
	changeColor(ar_obj);
}

function menuOver(ar_obj, ar_id) {
	status_over = true;
	changeColor(ar_obj);
}

function changeColor(ar_obj) {
	if (ar_obj.style.background == menuover_bgcolor) {
		ar_obj.style.background = default_menuover_bgcolor;
	} else {
		ar_obj.style.background = menuover_bgcolor;
	}
}

function exec_menuitem(key) {
	switch(key) {
		case "HOEVENT1":
			goMinibl(minibl_id);
			break;
		case "HOEVENT2":
		  ho_SendNote(minibl_id);
		  break;
		case "HOEVENT3":
		  GoWishList(minibl_id);
		  break;
		case "HOEVENT4":
		  ho_AddNeighbor(minibl_id);
		  break;
	}
}

//
// 실제 호출할 때 사용
//
function HOPopup(m_nick) {
	minibl_id = m_nick;

	var chk = false;
	for (i = 0; i < adminIdList.length; i++) {
		if (minibl_id == adminIdList[i]) {
			chk = true;
			break;
		}
	}

	if (chk) 
	{
		document.getElementById("ui_menu").innerHTML = half_ui_menu;
	} else 
	{
	    var loc = window.location + "";
        if (!(loc.indexOf('/guild/') > -1 || loc.indexOf('/parti/') > -1))
        {   
            // 신규 길드 추가 (10.06.22)
            if(loc.indexOf('guild.hanbiton.com') > -1 ) {
                document.getElementById("ui_menu").innerHTML = new_guild_ui_menu;
            } else {
	            document.getElementById("ui_menu").innerHTML = full_ui_menu;
	        }
        }
        else
        {    
		    document.getElementById("ui_menu").innerHTML = guild_ui_menu;
		}     
	}
}
var scrapType = "";
var communityid = "";
var communityPostId = "";
function HOPopup(userid, game, num) {
//function HOPopup(userid, game) {
  if(userid == "minibl" || userid == "guild"|| userid == "know"){
    scrapType = userid
    communityid = game;
    communityPostId = num;
    document.getElementById("ui_menu").innerHTML = scrap_ui_menu;
    return;
  }
	minibl_id = userid;
	game_id = game;

	var chk = false;
	for (i = 0; i < adminIdList.length; i++) {
		if (minibl_id == adminIdList[i]) {
			chk = true;
			break;
		}
	}

	if (chk) 
	{
		document.getElementById("ui_menu").innerHTML = half_ui_menu;
	} else 
	{
    switch(game_id){
      case "34": //미소스
          document.getElementById("ui_menu").innerHTML = new_guild_ui_menu_game;
          break;
      default:
          document.getElementById("ui_menu").innerHTML = new_guild_ui_menu;      
          break;
    }	  
	}
}

var loc = window.location + "";
if (!(loc.indexOf('/guild/') > -1 || loc.indexOf('/parti/') > -1)) {
	setcookie('hanbiton_visit', '', -10);
}

//
// 지식 신뢰지수 레벨 이미지 레이어 보이기
//
function trustDescShow(nLevel)
{
	b = window.document.body;
	x_pos = b.scrollLeft + event.clientX;
	y_pos = event.clientY + b.scrollTop;
	
	x_pos -= event.offsetX;
	y_pos -= event.offsetY;
	
	if(document.all.TrustLevelImage != null)
	{
		document.all.TrustLevelImage.src = "/images/gisik_alt_0"+ nLevel +".gif";
		
		if(document.all.TrustDescription != null)
		{
			document.all.TrustDescription.style.top = y_pos - 4;
			document.all.TrustDescription.style.left = x_pos + 35;
			document.all.TrustDescription.style.display = "";
		}
	}
}

//
// 지식 신뢰지수 레벨 이미지 레이어 감추기
//
function trustDescHide()
{
	if(document.all.TrustDescription != null)
	{
		document.all.TrustDescription.style.display = "none";
	}
}	

//
// 키보드 해킹 방지 Ax Loading
//
/*
var keyClsID = 'clsid:2CDD22B9-FC0F-46B9-A2FA-BCCFFA7F87F3';
var keyCodeBase = 'http://www.wyd2.co.kr/JKeySecret/ActiveJoyP.cab#version=1,0,0,13';
var jkey = '<OBJECT classid="'+ keyClsID +'" codebase="'+ keyCodeBase +'" width=0 height=0></OBJECT>';

document.write(jkey);
*/

var full_ui_menu = "<table width=\"80\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\" bgcolor=\"#B6B6B6\"><tr><td> ";
full_ui_menu += "<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\" bgcolor=\"#FFFFFF\">";
full_ui_menu += "<tr><td style=\"padding-left: 7px;\" height=\"20\" onmouseout=\"menuOut(this);\" onmouseover=\"menuOver(this, 'none');\" onclick=\"exec_menuitem('HOEVENT1');\" style=\"cursor:hand\"><font color=#404040>미니블보기</font></td></tr>";
full_ui_menu += "<tr><td height=\"1\" background=\"/images/line_dot_02.gif\"></td></tr>";
full_ui_menu += "<tr><td style=\"padding-left: 7px;\" height=\"20\" onmouseout=\"menuOut(this);\" onmouseover=\"menuOver(this, 'none');\" onclick=\"exec_menuitem('HOEVENT2');\" style=\"cursor:hand\"><font color=#404040>쪽지보내기</font></td></tr>";
//full_ui_menu += "<tr><td height=\"1\" background=\"/images/line_dot_02.gif\"></td></tr>";
//full_ui_menu += "<tr><td style=\"padding-left: 7px;\" height=\"20\" onmouseout=\"menuOut(this);\" onmouseover=\"menuOver(this, 'none');\" onclick=\"exec_menuitem('HOEVENT3');\" style=\"cursor:hand\"><font color=#404040>선물하기</font></td></tr>";
full_ui_menu += "<tr><td height=\"1\" background=\"/images/line_dot_02.gif\"></td></tr>";
full_ui_menu += "<tr><td style=\"padding-left: 7px;\" height=\"20\" onmouseout=\"menuOut(this);\" onmouseover=\"menuOver(this, 'none');\" onclick=\"exec_menuitem('HOEVENT4');\" style=\"cursor:hand\"><font color=#404040>이웃추가</font></td></tr>";
full_ui_menu += "</table>";
full_ui_menu += "</td></tr></table>";

var half_ui_menu = "<table width=\"80\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\" bgcolor=\"#B6B6B6\"><tr><td> ";
half_ui_menu += "<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\" bgcolor=\"#FFFFFF\">";
half_ui_menu += "<tr><td style=\"padding-left: 7px;\" height=\"20\" onmouseout=\"menuOut(this);\" onmouseover=\"menuOver(this, 'none');\" onclick=\"exec_menuitem('HOEVENT1');\" style=\"cursor:hand\"><font color=#404040>미니블보기</font></td></tr>";
half_ui_menu += "<tr><td height=\"1\" background=\"/images/line_dot_02.gif\"></td></tr>";
half_ui_menu += "<tr><td style=\"padding-left: 7px;\" height=\"20\" onmouseout=\"menuOut(this);\" onmouseover=\"menuOver(this, 'none');\" onclick=\"exec_menuitem('HOEVENT4');\" style=\"cursor:hand\"><font color=#404040>이웃추가</font></td></tr>";
half_ui_menu += "</table>";
half_ui_menu += "</td></tr></table>";

var guild_ui_menu = "<table width=\"80\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\" bgcolor=\"#B6B6B6\"><tr><td> ";
guild_ui_menu += "<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\" bgcolor=\"#FFFFFF\">";
guild_ui_menu += "<tr><td style=\"padding-left: 7px;\" height=\"20\" onmouseout=\"menuOut(this);\" onmouseover=\"menuOver(this, 'none');\" onclick=\"exec_menuitem('HOEVENT1');\" style=\"cursor:hand\"><font color=#404040>미니블보기</font></td></tr>";
guild_ui_menu += "<tr><td height=\"1\" background=\"/images/line_dot_02.gif\"></td></tr>";
guild_ui_menu += "<tr><td style=\"padding-left: 7px;\" height=\"20\" onmouseout=\"menuOut(this);\" onmouseover=\"menuOver(this, 'none');\" onclick=\"exec_menuitem('HOEVENT2');\" style=\"cursor:hand\"><font color=#404040>쪽지보내기</font></td></tr>";
guild_ui_menu += "</table>";
guild_ui_menu += "</td></tr></table>";

var new_guild_ui_menu = "<table width=\"80\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\" bgcolor=\"#B6B6B6\"><tr><td> ";
new_guild_ui_menu += "<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\" bgcolor=\"#FFFFFF\">";
new_guild_ui_menu += "<tr><td style=\"padding-left: 7px;\" height=\"20\" onmouseout=\"menuOut(this);\" onmouseover=\"menuOver(this, 'none');\" onclick=\"fnRedirectHOPopup('http://www.hanbiton.com/miniblblog/blog/main.aspx?id=',2,0,0);\" style=\"cursor:hand\"><font color=#404040>미니블보기</font></td></tr>";
new_guild_ui_menu += "<tr><td height=\"1\" background=\"/images/line_dot_02.gif\"></td></tr>";
new_guild_ui_menu += "<tr><td style=\"padding-left: 7px;\" height=\"20\" onmouseout=\"menuOut(this);\" onmouseover=\"menuOver(this, 'none');\" onclick=\"fnRedirectHOPopup('https://members.hanbiton.com:8080/paper/popup/Reply.aspx?bid=',3,350,340);\" style=\"cursor:hand\"><font color=#404040>쪽지보내기</font></td></tr>";
new_guild_ui_menu += "</table>";
new_guild_ui_menu += "</td></tr></table>";

var new_guild_ui_menu_game = "<table width=\"80\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\" bgcolor=\"#B6B6B6\"><tr><td> ";
new_guild_ui_menu_game += "<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\" bgcolor=\"#FFFFFF\">";
new_guild_ui_menu_game += "<tr><td style=\"padding-left: 7px;\" height=\"20\" onmouseout=\"menuOut(this);\" onmouseover=\"menuOver(this, 'none');\" onclick=\"fnRedirectHOPopup('http://www.hanbiton.com/miniblblog/blog/main.aspx?id=',2,0,0);\" style=\"cursor:hand\"><font color=#404040>미니블보기</font></td></tr>";
new_guild_ui_menu_game += "<tr><td height=\"1\" background=\"/images/line_dot_02.gif\"></td></tr>";
new_guild_ui_menu_game += "<tr><td style=\"padding-left: 7px;\" height=\"20\" onmouseout=\"menuOut(this);\" onmouseover=\"menuOver(this, 'none');\" onclick=\"fnRedirectHOPopup('https://members.hanbiton.com:8080/paper/popup/Reply.aspx?bid=',3,350,340);\" style=\"cursor:hand\"><font color=#404040>쪽지보내기</font></td></tr>";
new_guild_ui_menu_game += "<tr><td style=\"padding-left: 7px;\" height=\"20\" onmouseout=\"menuOut(this);\" onmouseover=\"menuOver(this, 'none');\" onclick=\"fnRedirectHOPopupGameInfo();\" style=\"cursor:hand\"><font color=#404040>캐릭터정보</font></td></tr>";
new_guild_ui_menu_game += "</table>";
new_guild_ui_menu_game += "</td></tr></table>";

var scrap_ui_menu = "<table width=\"65\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\" bgcolor=\"#B6B6B6\"><tr><td> ";
scrap_ui_menu += "<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\" bgcolor=\"#FFFFFF\">";
scrap_ui_menu += "<tr><td style=\"padding-left: 7px;\" height=\"20\" onmouseout=\"menuOut(this);\" onmouseover=\"menuOver(this, 'none');\" onclick=\"fnScrap('minible');\" style=\"cursor:hand\"><font color=#404040>미니블로</font></td></tr>";
scrap_ui_menu += "<tr><td height=\"1\" background=\"/images/line_dot_02.gif\"></td></tr>";
scrap_ui_menu += "<tr><td style=\"padding-left: 7px;\" height=\"20\" onmouseout=\"menuOut(this);\" onmouseover=\"menuOver(this, 'none');\" onclick=\"fnScrap('guild');\" style=\"cursor:hand\"><font color=#404040>길드로</font></td></tr>";
scrap_ui_menu += "<tr><td height=\"1\" background=\"/images/line_dot_02.gif\"></td></tr>";
scrap_ui_menu += "<tr><td style=\"padding-left: 7px;\" height=\"20\" onmouseout=\"menuOut(this);\" onmouseover=\"menuOver(this, 'none');\" onclick=\"fnScrap('twitter');\" style=\"cursor:hand\"><font color=#404040>트위터로</font></td></tr>";
scrap_ui_menu += "</table>";
scrap_ui_menu += "</td></tr></table>";

document.write("<div id=\"ui_menu\" style=\"position:absolute;display:none;top:0;left:0;z-index:9;\">");
document.write("</div>");

//
// 지식 레이어 HTML
//
document.write("<div id=\"TrustDescription\" style=\"RIGHT: expression(document.body.clientWidth/2 - 62);position:absolute; z-index:1;display:none\"><img id=\"TrustLevelImage\"></div>"); 

// 바로가기 URL

function goUrlTarget(url, target, width, height) {
    
    if (url.substring(0, 7) != 'http://') {
	    if(url.indexOf('https://') == -1) {
	        url = 'http://' + url;
	    }	    
	}
	
	
    switch(target)
    {
	    case 0:
	    case 1:
		    window.location.href = url;
		    break;
	    case 2:
		    window.open(url,"_blank","");
		    break;
	    default:
		    window.open(url,"HanbitOnPopUp","width=" + width +",height=" + height + ",scrollbar=no,menubar=no,toolbar=no,resizable=no");
		    break;
    }
}
// 바로가기 URL (길드용도)
function fnRedirectHOPopup(url, target, width, height) {
    var tempUrl = url + minibl_id;
    goUrlTarget(tempUrl, target, width, height);
}

function fnRedirectHOPopupGameInfo(){
  switch(game_id){
    case "34": //미소스
        goUrlTarget("http://mythos.hanbiton.com/Mypage/Mypage.aspx?pageType=GAMEINFO&rtn=" + minibl_id, 3, "680", "584");
        break;
    default:
        break;
  }
}

function fnScrap(target) {
  if(target == "twitter")
	  window.open("http://www.hanbiton.com/popup/scrapouter.aspx?from=" + scrapType + "&id=" + communityid + "&no=" + communityPostId + "&to=" + target, "HanbitOn_Scrap", "width=430,height=447,status=no,scrollbars=no");  
  else
	  window.open("http://www.hanbiton.com/popup/scrap.aspx?from=" + scrapType + "&id=" + communityid + "&no=" + communityPostId + "&to=" + target, "HanbitOn_Scrap", "width=500,height=574,status=no,scrollbars=no");  	
	
}
