// hexa_array
var HEXA = new Array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');

// dec 2 hex
function hex(input) {
	if (input < 0) return "00";
	else if (input > 255) return "FF";
	else return "" + HEXA[Math.floor(input/16)] + HEXA[input%16];
}

function dec2hex(strin) {
	var i;
	var strout;
	strout = '';

	for(i=0;i<strin.length;i++) {
		strout = strout + hex(strin.charCodeAt(i));
	}

	return strout;
}

function replaceChar(inStr) 
{
	var outStr;
	if(inStr == "‰Ñ") outStr = "µÆ";
	return outStr;
}

// ºê¶ó¿ìÀú ¹öÀü ¹ÝÈ¯
function IE_Ver() {
	if(navigator.appName.match(/Explorer/i)) return navigator.appVersion.match(/MSIE \d+.\d+/)[0].split(" ")[1];
	else return 0;
}

// »õÃ¢¿­±â
function winopen(file,winname,width,height,scroll,resize) {
	var IE = document.all ? true:false;

	var vtop  = (screen.height - height) / 2;
    var vleft = (screen.width - width) / 2;

	var openOpt = "toolbar=no,channelmode=no,location=no,directories=no";
	openOpt += ",resizable=" + resize + ",menubar=no,scrollbars=" + scroll;
	openOpt += ",width=" + width + ",height=" + height + ",left=" + vleft + ",top=" + vtop;

	if(IE && IE_Ver() >= 5.5) {
		var aa = window.open(file,winname,openOpt);
		aa.focus();
	} else {
		window.open(file,winname,openOpt);
	}
}

//¸Ó´Ï¿¡ ÄÞ¸¶ Ç¥½Ã
function addComma(strin) { 
	var strMoney = '' + strin; 
	var rxSplit = new RegExp('([0-9])([0-9][0-9][0-9][,.])'); 
	var array_num = strMoney.split('.'); 
	array_num[0] += '.'; 
		
	do { 
		array_num[0] = array_num[0].replace(rxSplit, '$1,$2'); 
	} while(rxSplit.test(array_num[0])); 
		
	if (array_num.length > 1) { 
		return array_num.join(''); 
	} else { 
		return array_num[0].split('.')[0]; 
	} 
} 

//¹®ÀÚ¿­ ±æÀÌ ±¸ÇÏ±â(ÇÑ±Û 2Byte)
function getLength(cStr) {
	var retCode = 0;
	var currentLen = 0;

	for(i=0; i<cStr.length;i++) {
		var retCode = cStr.charCodeAt(i);
		var retChar = cStr.substr(i,1).toUpperCase();

		retCode = parseInt(retCode);

		if((retChar < '0' || retChar > '9') && (retChar < 'A' || retChar > 'Z') && ((retCode > 255) || (retCode < 0))) {
		   currentLen += 2;
		} else {
			currentLen += 1;
		}
	}

	return currentLen;
}

// °ø¹éÁ¦°Å(Áß°£°ø¹é ¸ðµÎÁ¦°Å)
function delSpace(str) { 
	var index, len;

	while(true) {
		index = str.indexOf(" ");
		if (index == -1) break;
		len = str.length;
		str = str.substring(0, index) + str.substring((index+1),len);
	}

	return str;
}

// ¼ýÀÚÀÔ·Â°ª Ã¼Å©
function chkDigit(str) {
	if(str == "") {
		return false;
	} else {
		var count=0;

		for (i=0;i<str.length;i++){
			if(str.charAt(i)<'0' || str.charAt(i)>'9') count++
		}

		if(count!=0) {
			return false;
		} else {
			return true;
		}
	}

}

// Ã¢´Ý±â
function selfClose() {
	self.close();
}

// µÚ·Î°¡±â
function selfBack() {
	history.back();
}

// ¼­ºñ½º ÁØºñÁß
function NotService(ntype){
	if (ntype==1)
	{
		alert("ÁË¼ÛÇÕ´Ï´Ù.ÇöÀç ¼­ºñ½º ÁØºñÁßÀÔ´Ï´Ù.");
		return;
	}
}

//½Ç½Ã°£ ÂÊÁö¹Þ±â,¸¶ÀÌÆäÀÌÁö ÂÊÁöÀÐ±â 
function popSlipWriteReOpen(code,prv) {
	winopen("/my/pop/popSlipWriteRe.bob?code="+code+"&prv="+prv,"viewSlip",385,400,"no","no");
}

// ³» Ä£±¸ Ã£±â ÆË¾÷
function popFindFriend() {
	winopen("/my/pop/popFindFriend.bob","friend",389,428,"no","no");
}

// ³» Æ÷ÀÎÆ® Á¶È¸
function viewMyPoint() {
	winopen("http://www.okcashbag.com/my/cashup_point.jsp","pointview",275,200,"no","no");
}

// °øÁö»çÇ× Á¶È¸
function openNoticeRead(n) {
	winopen("/cs/pop/announceRead.bob?idx="+n,"Notice",442,522,'no','no');
}

// ÂÊÁöº¸³»±â ÆË¾÷1
function openSendMemo(toid) {
  winopen("/community/pop/memoWrite.bob?strID="+toid,"memo",351,280,"no","no");
}

// ÀÏ´ëÀÏÃ¤ÆÃ ¿äÃ» ÆË¾÷1
function openMtoM(uid) {
	winopen("/community/pop/mtoMRequest.bob?uid=" + uid,"MtoM",402,375,"no","no");
}

// ÀÏ´ëÀÏÃ¤ÆÃ ¼ö½Å ÆË¾÷1
function openRcvMtoM(uid,msg) {
	winopen("/community/pop/mtoMReceive.bob?uid=" + uid + "&msg=" + msg,"MtoM",402,375,"no","no");
	
}

// ÂÊÁö¼ö½Å ÆË¾÷1
function openResendMemo(id,kind) {
	winopen("/community/pop/memoRead.bob?n4Id=" + id + "&strPrv=save",'slipReceive',456,460,'no','no');
}

// ÂÊÁö¼ö½Å °ÅÀýÆË¾÷1
function openRcvMtomNo(uid){
	winopen("/community/pop/mtoMReceiveNo.bob?uid=" + uid,"MtoM",402,250,"no","no");
}
// ÂÊÁö¼ö½Å ¼ö¶ôÆË¾÷1
function openRcvMtomYes(id,nRoomIdx,cNickName,cSex){
	winopen('/community/pop/mtoMReceiveYes.bob?nRoomIdx=' + nRoomIdx + '&userid=' + id + '&nin=' + cNickName + '&sex=' + cSex, nRoomIdx ,402,250,"no","no");
}

/*
// Ä£±¸ º¸±â ÆË¾÷1
function openFriendListPop()
{
	winopen("/pop/friendListPop.asp","friendList",456,500,"no","no");
}

//°ÔÀÓ¸Ó´ÏÇÑµµÃÊ°ú1
function overMoneyTime(jGame)
{
	winopen("/game/pop/gameOverTime.asp?pGame="+jGame,"game",424,520,"no","no");
}
*/

// ÄÁÅÙÃ÷ ÀÚ¼¼ÇÑ ¼³¸í ÆË¾÷
function openCsDescription(kind) {
	winopen("/cs/pop/description.bob?kind="+kind,"announce",582,620,"no","no");
}

// ¾Æ¹ÙÅ¸¼¥, OCB ÀÌ¿ë¾È³»
function openUseInfo(kind) {
	winopen("/avatar/pop/popUseInfo.bob?kind="+kind,"useInfo",580,706,"no","no");
}

//¶ôÇÇ ±ÇÇÑÀÌÀü ¾Ë¸² ÆË¾÷ ÆäÀÌÁö
function popLikePiOpen(code) 
{
	winopen("/lockp/pop/mngChange.bob?code="+code,"likePi",421,450,"no","no");
}

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 GoMenuUrl(cGubun){
	if (cGubun=='D0')   location.href="/game/GG1_smatgo/"
	else if (cGubun=='M0')   location.href="/game/GG2_mmatgo/"
	else if (cGubun=='G0')   location.href="/game/GG3_gmatgo/"
	else if (cGubun=='S0')   location.href="/game/GG4_sutda/"
	else if (cGubun=='R0')   location.href="/game/GG5_dori/"
	else if (cGubun=='L0')   location.href="/game/GG6_lgostop/"
	else if (cGubun=='Y0')   location.href="/game/GG7_ymatgo/"
	else if(cGubun=='Z0')   location.href="/game/GG8_nsmatgo/"
	else if (cGubun=='K0')   location.href="/game/GP1_kpoker/?gameType=1"
	else if (cGubun=='K1')   location.href="/game/GP1_kpoker/?gameType=2"
	else if (cGubun=='N0')   location.href="/game/GP2_spoker/"
	else if (cGubun=='H0')   location.href="/game/GP4_hoola/"
	else if (cGubun=='B0')   location.href="/game/GP5_baduki/"
	else if (cGubun=='BB')   location.href="/game/GB1_baduk/"
	else if (cGubun=='JB')   location.href="/game/GB2_janggi/"
	else if (cGubun=='OB')   location.href="/game/GB3_omok/"
	else if (cGubun=='TB')   location.href="/game/GB4_othello/"
	else if (cGubun=='SC')   location.href="/game/GC1_shoot/"
	else if (cGubun=='FC')   location.href="/game/GC2_sacheon/"
	else if (cGubun=='BC')   location.href="/game/GC3_bingo/"
	else if (cGubun=='CC')   location.href="/game/GC4_cross/"
   else{
     alert(cGubun+'   Not ready');
   }
}

// IE 6.0 ¼³°è º¯°æ¿¡ µû¸¥ ÇÃ·¡½¬ È£Ãâ
function embed(flash,w,h,mode,color){
var flashview = '';
flashview += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="'+w+'" height="'+h+'">';
flashview += '<param name="allowScriptAccess" value="sameDomain" />';
flashview += '<param name=movie value="'+flash+'">';
flashview += '<param name=quality value=high>';
//flashview += '<param name="bgcolor" value="'+color+'" />';
if (mode=="y")
{
	flashview += '<param name="wmode" value="transparent">';
}
flashview += '<embed src="'+flash+'" align=middle menu="false" quality=high  align=middle pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+w+'" height="'+h+'" wmode=transparent></embed>';
flashview += '</object>';
document.write(flashview);
}

// ·Î±×¾Æ¿ô
function goLogout() {

  location.href = "/member/logoutProc.bob";


}

// ·Î±×ÀÎ ÆäÀÌÁö·Î ÀÌµ¿(·Î±×ÀÎÆûÀ» ÅëÇÑ ·Î±×ÀÎ)
function viewLogin() {
    var vrtnUrl = dec2hex(location.href);
    top.mainFrame.location.href= "/member/login.bob?rtnUrl=" + vrtnUrl;
}

// ·Î±×ÀÎÆûÀ» ÅëÇÑ ·Î±×ÀÎ
function goLogin(bobCom) {
	saveid(document.frmLogin);
	with(document.frmLogin) {
		if(delSpace(comid.value).length < 1 || comid.value == "ID(¾ÆÀÌµð)") {
			alert("¾ÆÀÌµð¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä.");
			comid.value = "";
			comid.focus();
		}else if(delSpace(pwd.value).length < 1) {
			alert("ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä.");
			pwd.value = "";
			pwd.focus();
		}else if(comid.value.indexOf(" ") >= 0 || comid.value.indexOf("'") >=0) {
			alert("Çã¿ëÇÏÁö ¾Ê´Â ¹®ÀÚ°¡ ÀÔ·ÂµÇ¾ú½À´Ï´Ù.");
			comid.focus();
		}else if(pwd.value.indexOf(" ") >= 0 || pwd.value.indexOf("'") >=0) {
			alert("Çã¿ëÇÏÁö ¾Ê´Â ¹®ÀÚ°¡ ÀÔ·ÂµÇ¾ú½À´Ï´Ù.");
			pwd.value = "";
			pwd.focus();
		}else {
			if (bobCom=="ocb"){
			  loginname.value = comid.value;
			  password.value = pwd.value;
			  target = "_top";
			  action = "http://dcmp.okcashbag.com/dcm/auth/authUser.jsp";
		
			}else{
			 //alert("https:Àü¼Û");
			  target = "ifrLogin";
			  action = "/member/ifr/loginProc.bob";
			}
			submit();
		}
	}
}

function saveid(form) {
  var expdate = new Date();
  // ±âº»ÀûÀ¸·Î 30ÀÏµ¿¾È ±â¾ïÇÏ°Ô ÇÔ. ÀÏ¼ö¸¦ Á¶ÀýÇÏ·Á¸é * 30¿¡¼­ ¼ýÀÚ¸¦ Á¶ÀýÇÏ¸é µÊ
  if (form.chkid.checked)
    expdate.setTime(expdate.getTime() + 1000 * 3600 * 24 * 365); 
  else
    expdate.setTime(expdate.getTime() - 1); // ÄíÅ° »èÁ¦Á¶°Ç

  setIdCookie("saveid", form.comid.value, expdate);
}


// È¸¿ø°¡ÀÔ
function ocbJoin() {
	var rtnUrl = location.href;

	location.href = "http://doorman.okcashbag.com/user/auth/jsp/Inquiry.jsp?sid=PORTAL&nexturl=687474703A2F2F626F6270756C2E6F6B636173686261672E636F6D2F&returnurl=687474703A2F2F626F6270756C2E6F6B636173686261672E636F6D2F";
}

// OCB¿øÆÐ½º ¸Þ´º
function ocbPass(type) {
	if(type == "loginname") {
		window.open('http://doorman.okcashbag.com/user/auth/jsp/requestId_popup.jsp?sid=POTAL','view','width=550 height=400');
	} else if(type == "password") {
		window.open('http://doorman.okcashbag.com/user/auth/jsp/requestIssuePasswd_popup.jsp?sid=PORTAL','view','width=550 height=630');
	}
}
//¾ÆÀÌµð ÀÔ·ÂÃ¢ ¹é±×¶ó¿îµå
function changeTabId(){
	 if(document.getElementById("id").value == ""){
	 obj = document.getElementById("id").style;
	 obj.backgroundImage = "url(/img_bob/main_3/id_img.gif)";
	 obj.backgroundRepeat = "no-repeat";
	 obj.backgroundPosition = "5px 2px";
	}
}
//ºñ¹Ð¹øÈ£ ÀÔ·ÂÃ¢ ¹é±×¶ó¿îµå
function changeTabPw(){
	if(document.getElementById("pass").value == ""){
	 obj = document.getElementById("pass").style;
	 obj.backgroundImage = "url(/img_bob/main_3/pass.gif)";
	 obj.backgroundRepeat = "no-repeat";
	 obj.backgroundPosition = "5px 2px";
	}
}

//·Î±×ÀÎ ÅØ½ºÆ® ¹Ú½º¾È ±ÛÀÚ Ã³¸®
function ch (valuecomid) {
if(valuecomid ==  'comid')
	document.frmLogin.comid.style.backgroundImage="";
else
	document.frmLogin.pwd.style.backgroundImage="";

}

// Æ÷Ä¿½º°¡ ÀÎÇ² ¹Ú½º¸¦ ¹þ¾î³µÀ»¶§ ¹è°æÀÌ¹ÌÁö »ì¸®±â (ÀÔ·Â°ªÀÌ ÀÖÀ¸¸é »ì¸®Áö ¾Ê±â)
function chout (valuecomid) {
if(valuecomid ==  'comid') {
	if(!document.frmLogin.comid.value) document.frmLogin.comid.style.backgroundImage="url(/img_bob/main_3/login_id.gif)";
}
else {
	if(!document.frmLogin.pwd.value) document.frmLogin.pwd.style.backgroundImage="url(/img_bob/main_3/login_pass.gif)";
}

}
//·Î±×ÀÎ ÅØ½ºÆ® ¹Ú½º¾È ±ÛÀÚ Ã³¸® ¿Ï·á

function logInput(a) {
	if (a.defaultValue==a.value)
	a.value = ""
}

// ¹äÇ® È¸¿ø ¾ÆÀÌµð/ºñ¹Ð¹øÈ£ Ã£±â
function findId() {
	winopen('/member/pop/findIdForm.bob','findInfo',420, 450,"no","no");
}

function setIdCookie (name, value, expires) {
  document.cookie = name + "=" + escape (value) + "; path=/; expires=" + expires.toGMTString();
}

function getSaveId(Name) {
  var search = Name + "="
  if (document.cookie.length > 0) { // ÄíÅ°°¡ ¼³Á¤µÇ¾î ÀÖ´Ù¸é
    offset = document.cookie.indexOf(search)
    if (offset != -1) { // ÄíÅ°°¡ Á¸ÀçÇÏ¸é
      offset += search.length
      // set index of beginning of value
      end = document.cookie.indexOf(";", offset)
      // ÄíÅ° °ªÀÇ ¸¶Áö¸· À§Ä¡ ÀÎµ¦½º ¹øÈ£ ¼³Á¤
      if (end == -1)
        end = document.cookie.length
      return unescape(document.cookie.substring(offset, end))
    }
  }
  return "";
}

function keyLoginCheck(bobCom) {
	if(event.keyCode == 13) goLogin(bobCom);
}

function keyCheck(method) {
	if(event.keyCode == 13) eval(method);
}

function downFile(fn) {
	parent.location.href = '/inc/dataDown.bob?fn=' + fn;
}

//Ã¼Å©¹Ú½º Ã¼Å©
function isSelect(frm) {
	with(frm) {
		var rtnBool = false;

		if(typeof(idx.length) == "undefined") {
			if(idx.checked) rtnBool = true;
		} else {
			for(var i=0;i<idx.length;i++) {
				if(idx[i].checked) rtnBool = true;
			}
		}
	}
	return rtnBool;
}

//******************************* S: Ä³½¬ ÃæÀü ½ºÅ©¸³Æ® *********************************************
//Ä³½¬ÃæÀü
function openCashFill() {
  winopen('/wallet/pop/cashFill.bob','cashFill','425','600','no','no');
}

//Ã¤³Î»ç °áÁ¦´ÜÀ¸·Î Ä³½¬ÃæÀüÀÌ ÀÌ·ç¾î Áú¶§
function openChnCashFill() {
  //winopen('http://www.gamelamp.com/cont/mylamp/myCash.html','cashFill','425','600','no','no');
  GL.Pay.cashPop();
}
//******************************* E: Ä³½¬ ÃæÀü ½ºÅ©¸³Æ® *********************************************
 
//Ä³½¬¼±¹°
function openCashGift() {
	winopen('/shop/pop/cashGift.bob','cashgift',562,678);
}
//¸Ó´Ï ±³È¯
function bobpulChange() {
  winopen('/my/pop/bobpulChange.bob','bobpul','400','520','no','no');
}

//¾ÆÀÌÅÛ »ó¼¼º¸±â
function itemDetail() {
  //winopen('/my/pop/bobpulChange.bob','bobpul','400','520','no','no');
}

//¶ô ¹Ù·Î°¡±â
function goLock(a){
  if(document.frmBook.strCode.value!=""){
    document.frmBook.target = "ifrProc";
	document.frmBook.action="/lockp/ifr/goBookmarkProc.bob";
	document.frmBook.submit();
  }else if (a!=""){
    location.href="/lockp/index.bob?code="+a;
  }
}

//SMS
function openSms()
{
	winopen('/sms/pop/smsForm.bob','atten',746,553,'no','no');
}

function getcookie(name) {
	var nameOfCookie = name + "=";
	var x = 0;

	while(x <= document.cookie.length) {
		var y = (x + nameOfCookie.length);
		if(document.cookie.substring(x,y) == nameOfCookie) {
			if((endOfCookie = document.cookie.indexOf(";",y)) == -1) endOfCookie = document.cookie.length;
			return unescape(document.cookie.substring(y,endOfCookie));
		}

		x = document.cookie.indexOf(" ",x) + 1;

		if(x == 0) break;
	}

	return "";
}

// ¶ôÇÇ »õ·Î ¿­±â
function poplockpOpen(code) {
	var height = screen.height; 
    var width = screen.width; 
    if (code!=""){
	  window.open("/lockp/index.bob?code="+code,"lockp");
    }
}