//////////////////////////////////////////////////////////////
// var IMAGE_URL = "http://image.hangame.com/_images";		
var IMAGE_URL = "http://images.game.netvigator.com";		
var AVTSVR_URL = "http://avatar.game.netvigator.com";		
var AVIMAGE_URL = "http://avimages.game.netvigator.com";		
var DOWN_URL = "http://down.hangame.com";		
var MESSAGE_SERVER_URL = "milesvr.hangame.com:1099";		
var WWW_URL = "http://item.game.netvigator.com";		
var AVATAR_URL = "http://item.game.netvigator.com/hg/avatar";		
var GAME_URL = "http://item.game.netvigator.com/game";		
var LOGIN_URL = "http://item.game.netvigator.com/login";		
var REGIST_URL = "http://regist.localhost.hangame.com/regist";		
var MYHOME_URL = "http://myhome.localhost.hangame.com/myhome";		
var MILEAGE_URL = "http://mileage.localhost.hangame.com/mileage";		
var CS_URL = "http://cs.localhost.hangame.com/cs";		
var ADMIN_URL = "http://admin.localhost.hangame.com/admin";		
var MYINFO_URL = "http://item.game.netvigator.com/myinfo";		
var LOGIN = "http://item.game.netvigator.com/login/loginform.nhn";		

var EXIT_FORUM_URL = "http://forum.netvigator.com/forum/forum.jspa?forumID=164";
var EXIT_NOTICE_URL = "http://pctv.netvigator.com/html/event/exit_notice/notice_1.html";

//////////////////////////////////////////////////////////////


var CK_MEMBERID = 0;		// Member ID
var CK_PASSWORD = 1;		// Password (no use in HK)
var CK_NAME = 2;			// Name
var CK_SEX = 3;				// Sex
var CK_VALID = 4;			//
var CK_LASTDATE = 5;		// Last login date
var CK_AVATARID = 6;		// Avatar ID
var CK_HGSUBPLANSTATUS = 7;		// Hangame Plus Plan Status
var CK_HGSUBPLAN = 8;			// PlusÈ¸¿øÁ¾·ù(P1:ÇÃ·¯½º,P2:ÇÃ·¯½º°ñµå)
var CK_NETPASSID = 9;			// NETPass ID

var MAX_PASSWORD_LEN = 4;

var GMT_KOREA = -540;

// Get Hangame ID
// (e.g. id = getCookie(CK_MEMBERID);

function getCookie(n)
{

	var ckLogin = getStrCookie("login");
	if (ckLogin=="" || ckLogin=="undefined" || ckLogin==null) return "";

	var sList = ckLogin.split("%2C");
	if (n < sList.length) return sList[n];

	return "";
}

// Common function to get Cookie string for parsing
function getStrCookie(sName) {
	var aRec, aCook = document.cookie.split("; ");

	for (var i=0; i<aCook.length; i++) {
		aRec = aCook[i].split("=");
		if (sName.toLowerCase()==unescape(aRec[0].toLowerCase())) return aRec[1];
	}
	return "";
}

// Common function to set value to cookie
function setStrCookie(sName, sValue) {
	//var exDate = new Date;
	//exDate.setMonth(exDate.getMonth() + 6);
	//document.cookie = sName + "=" + sValue + ";expires=" + exDate.toGMTString();
	document.cookie = sName + "=" + sValue + ";domain=" + getFixDomain();
	return "";
}

function getFixDomain() {
	var s = document.domain;
	if ( s.indexOf("netvigator.com") >= 0 ) {
		return "netvigator.com";
	}	else {
		return s;
		//var n = s.indexOf(".");
		//return s.substring(n + 1, s.length);
	}
}

function setDomain() {
	document.domain = getFixDomain();
}

// this function will be called whereever the page include this js file!
setDomain();

function openWin(sURL, sWindowName, w, h, sScroll) {
	// È­Common function to create popup windows throughout the site.
	//   e.g.
	//			openWin('test.asp', 'winTest', 400, 300); (Popup without scroll bar)
	//			openWin('test.asp', 'winTest', 400, 300, 'yes'); (Popup with scroll bar)
	//			openWin('test.asp', 'winTest', 400, 300, 'auto'); (Popup with scroll bar display automatically)

	var x = (screen.width - w) / 2;
	var y = (screen.height - h) / 2;

	if (sScroll==null) sScroll = "no";

	var sOption = "";
	sOption = sOption + "toolbar=no, channelmode=no, location=no, directories=no, resizable=no, menubar=no";
	sOption = sOption + ", scrollbars=" + sScroll + ", left=" + x + ", top=" + y + ", width=" + w + ", height=" + h;

	var win = window.open(sURL, sWindowName, sOption);
	//return win;
}

function openWinFreePos(sURL, sWindowName, w, h, x, y, sScroll) {
	// È­Common function to create popup windows with optional location throughout the site.
	//   e.g.
	//			openWinFreePos('test.asp', 'winTest', 400, 300, 0, 0); (Popup without scroll bar)
	//			openWinFreePos('test.asp', 'winTest', 400, 300, 0, 0, 'yes'); (Popup with scroll bar)
	//			openWinFreePos('test.asp', 'winTest', 400, 300, 0, 0, 'auto'); (Popup with scroll bar display automatically)

	if (sScroll==null) sScroll = "no";

	var sOption = "";
	sOption = sOption + "toolbar=no, channelmode=no, location=no, directories=no, resizable=no, menubar=no";
	sOption = sOption + ", scrollbars=" + sScroll + ", left=" + x + ", top=" + y + ", width=" + w + ", height=" + h;

	var win = window.open(sURL, sWindowName, sOption);
	//return win;
}

function outputCopyright()
{
	// Client generate the copyright message
	// e.g.
	// outputCopyright();

  document.write("<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td>");
  document.write("      <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td width=\"5\" height=\"31\">&nbsp;</td><td align=\"right\" background=\"http://images.game.netvigator.com/footer/bot_1.gif\">");
  document.write("              <table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td><img src=\"http://images.game.netvigator.com/footer/bot_2.gif\" width=\"2\" height=\"14\" hspace=\"18\"></td><td><font color=\"7BBDDD\"><a href=\"javascript:openWin('http://game.netvigator.com/main/html/support/tnc/game_tnc.html', 'winTnC', 600, 450, 'yes');\"><font color=\"#7CBDDE\">±ø´Ú¤Î±ø¥ó</font></a></font></td><td><img src=\"http://images.game.netvigator.com/footer/bot_2.gif\" width=\"2\" height=\"14\" hspace=\"18\"></td><td><font color=\"7BBDDD\"><a href=\"http://www.hk.pccw.com/NASApp/cs/ContentServer?pagename=PCCW/PCCWHK/Legal/Standard&cid=995630457099&pagelang=chi\" target=\"_blank\"><font color=\"#7CBDDE\">¨pÁô¬Fµ¦</font></a></font></td><td width=\"22\">&nbsp;</td></tr></table>");
  document.write("  </td></tr></table>");
  document.write("</td></tr><tr><td height=\"40\" align=\"right\">");
  document.write("        <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td></td><td align=\"right\">&copy;<font color=\"#999999\">¹q°T¬Õ¬ì´CÅé¦³­­¤½¥q2004-2009. µÛ§@Åv©Ò¦³.</font></td><td width=\"86\" align=\"right\"><img src=\"http://images.game.netvigator.com/footer/pccw.gif\" width=\"86\" height=\"27\" hspace=\"5\"></td></tr></table>");
  document.write("</td></tr><tr><td>&nbsp;</td></tr></table>");
}

function outputCopyright_Landing()
{
	// Client generate the copyright message
	// e.g.
	// outputCopyright();

  document.write("<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td>");
  document.write("      <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td width=\"5\" height=\"31\">&nbsp;</td><td align=\"right\" background=\"http://images.game.netvigator.com/footer/bot_1.gif\">");
  document.write("              <table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td><img src=\"http://images.game.netvigator.com/footer/bot_2.gif\" width=\"2\" height=\"14\" hspace=\"18\"></td><td><font color=\"7BBDDD\"><a href=\"javascript:openWin('http://pctv.netvigator.com/html/netgame/faq/keycodefaq_index.htm', 'keycodeFAQ', 570, 450, 'yes');\"><font color=\"#7CBDDE\">±`¨£°ÝÃD</font></a></font></td><td><img src=\"http://images.game.netvigator.com/footer/bot_2.gif\" width=\"2\" height=\"14\" hspace=\"18\"></td><td><font color=\"7BBDDD\"><a href=\"javascript:openWin('http://game.netvigator.com/main/html/support/tnc/game_tnc.html', 'winTnC', 600, 450, 'yes');\"><font color=\"#7CBDDE\">±ø´Ú¤Î±ø¥ó</font></a></font></td><td><img src=\"http://images.game.netvigator.com/footer/bot_2.gif\" width=\"2\" height=\"14\" hspace=\"18\"></td><td><font color=\"7BBDDD\"><a href=\"http://www.hk.pccw.com/NASApp/cs/ContentServer?pagename=PCCW/PCCWHK/Legal/Standard&cid=995630457099&pagelang=chi\" target=\"_blank\"><font color=\"#7CBDDE\">¨pÁô¬Fµ¦</font></a></font></td><td width=\"22\">&nbsp;</td></tr></table>");
  document.write("  </td></tr></table>");
  document.write("</td></tr><tr><td height=\"40\" align=\"right\">");
  document.write("        <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td></td><td align=\"right\">&copy;<font color=\"#999999\">¹q°T¬Õ¬ì´CÅé¦³­­¤½¥q2004-2009. µÛ§@Åv©Ò¦³.</font></td><td width=\"86\" align=\"right\"><img src=\"http://images.game.netvigator.com/footer/pccw.gif\" width=\"86\" height=\"27\" hspace=\"5\"></td></tr></table>");
  document.write("</td></tr><tr><td>&nbsp;</td></tr></table>");


}

function outputCopyright_mmostore()
{
	// Client generate the copyright message
	// e.g.
	// outputCopyright();

  document.write("<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td>");
  document.write("      <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td width=\"5\" height=\"31\">&nbsp;</td><td align=\"right\" background=\"http://images.game.netvigator.com/footer/bot_1.gif\">");
  document.write("              <table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td><img src=\"http://images.game.netvigator.com/footer/bot_2.gif\" width=\"2\" height=\"14\" hspace=\"18\"></td><td><font color=\"7BBDDD\"><a href=\"javascript:openWin('http://pctv.netvigator.com/html/netgame/faq/keycodefaq_index.htm', 'keycodeFAQ', 570, 450, 'yes');\"><font color=\"#7CBDDE\">±`¨£°ÝÃD</font></a></font></td><td><img src=\"http://images.game.netvigator.com/footer/bot_2.gif\" width=\"2\" height=\"14\" hspace=\"18\"></td><td><font color=\"7BBDDD\"><a href=\"javascript:openWin('http://game.netvigator.com/main/html/support/tnc/game_tnc.html', 'winTnC', 600, 450, 'yes');\"><font color=\"#7CBDDE\">±ø´Ú¤Î±ø¥ó</font></a></font></td><td><img src=\"http://images.game.netvigator.com/footer/bot_2.gif\" width=\"2\" height=\"14\" hspace=\"18\"></td><td><font color=\"7BBDDD\"><a href=\"http://www.hk.pccw.com/NASApp/cs/ContentServer?pagename=PCCW/PCCWHK/Legal/Standard&cid=995630457099&pagelang=chi\" target=\"_blank\"><font color=\"#7CBDDE\">¨pÁô¬Fµ¦</font></a></font></td><td width=\"22\">&nbsp;</td></tr></table>");
  document.write("		</td></tr></table>");
  document.write("</td></tr>");
  document.write("</table>");


}
function setMenuURL(sValue) {
	// What is this????????????
	setStrCookie("menuurl", sValue);
}

function numberFormat(nVar, nSize)
{
	// function to create a fix length number like 0000000123 , where nSize should be from 0 to 9.
	// e.g.
	//			n = 2;
	//			s = numberFormat(n, 5); (Output s = "00002")
	//			s = numberFormat(n); (Output s = "02")

	if (nSize==null) nSize = 2;

	var s = "0000000000" + nVar;
	var n = s.length;

	return s.substring(n - nSize, n);
}

var monthLength = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
	
function checkDate(year, month, day)
{	
	

	if (!day || !month || !year){	return false;	}
	if (year/4 == parseInt(year/4)){ monthLength[1] = 29;	}
	if (day > monthLength[month-1]){ return false;	}

	monthLength[1] = 28;

	var now = new Date();
	now = now.getTime(); //NN3

	var dateToCheck = new Date();
	dateToCheck.setFullYear(year);
	dateToCheck.setMonth(month-1);
	dateToCheck.setDate(day);
	var checkDate = dateToCheck.getTime();
	if (now > checkDate){
		return true;
	} else {
		return false;
	}
}

function hasChinese(str) {
	// function to verify if a string contains Chinese character.
	// e.g.
	//			b = hasChinese("¤¤¤å¦rabc") (b = true)
	//			b = hasChinese("123abc") (b = false)
  var strlen=str.length;
  if(strlen>0){
    var oldstrlen=str.length
    for(var i=0;i<strlen;i++) {
      c='';  c = escape(str.charAt(i));
      if( c.charAt(0) == '%') {
        cc = c.charAt(1);//IE~u,NS~A
        if(cc =='A' ||cc =='u'){ return true; }
      }
    }
  return false; } else { return false; }
}

function isNum(sVal) {
	// function to verify if a value is integer.
	// e.g.
	//			b = isNum("123") (b = true)
	//			b = isNum("123°¡³ª´Ù") (b = false)

	if (sVal=="") return false;
	for (var i=0; i<sVal.length; i++) {
		if (sVal.charAt(i) < "0") return false;
		if (sVal.charAt(i) > "9") return false;
	}
	return true;
}

function isErrorID_Char(sBuf) {
	// function to verify if there is any invalid character listed below
	// if invalid character (including SPACE character) exist, return true!
	var sChk = "!@#$%&*()|'[];:\" ^|><~`=+-\\/{}^_,.?	";
	for ( var i=0; i<sBuf.length; i++ ) {
		if (sChk.indexOf(sBuf.charAt(i)) >= 0) {
			return true;
		}
	}
	return false;
}

function isErrorID_tab(sBuf) {
	// function to verify if there is any tab space in a string
	// if tab space exist, return true!
	var sChk = "	";
	for ( var i=0; i<sBuf.length; i++ ) {
		if (sChk.indexOf(sBuf.charAt(i)) >= 0) {
			return true;
		}
	}
	return false;
}


function isErrorAddress(sBuf) {
	// function to verify if there is any invalid character in an address entry.
	// if invalid character (exclude SPACE character!) exist, return true!

	var sChk = "!@#$%&*()|'[];:\"^|><~`=+-\\/{}^_,.?";
	for ( var i=0; i<sBuf.length; i++ ) {
		if (sChk.indexOf(sBuf.charAt(i)) >= 0) {
			return true;
		}
	}
	return false;
}

function isErrorID_Word(sBuf) {
	// function to verify if there is any invalid userid or word in a string.
	// if invalid id / word exist, return true!
	// need to modify the list below!!!!!!!!!

	var sChk = "ÇÑ°ÔÀÓ,Å×½ºÆ®,µµ¿ì¹Ì,µµ¿À¹Ì,°ü¸®,¿î¿µ,¸¶½ºÅÍ,¸¶½ºÅ¸,admin,root,doumi,ubnf,qlor,anbf,mouky".split(",");
	for ( var i=0; i<sChk.length; i++ ) {
		if (sBuf.indexOf(sChk[i]) >= 0) {
			return true;
		}
	}
	return false;
}

String.prototype.trim = function() {
	// function to trim a string.
	// e.g.
	//			s = "       ¤¤¤å¦r     ".trim(); (Output s = "¤¤¤å¦r")
	//			s = "       A B C     ".trim(); (Output s = "A B C")
	// Need to confirm this!!!
    return this.replace(/(^\s*)|(\s*$)/g, "");
}

String.prototype.replaceA = function(a, b) {
	// function to replace part of a string.
	// e.g.
	//			s = "abc¤¤¤å¦rdef".replace("¤¤¤å¦r", ""); (Output s = "abcdef")
	var s = this;
	var n1, n2, s1, s2;

	while (true) {
		if ( s=="" || a=="" ) break;
		n1 = s.indexOf(a);
		if ( n1 < 0 ) break;
		n2 = n1 + a.length;
		if ( n1==0 ) {
			s1 = b;
		}
		else {
			s1 = s.substring(0, n1) + b;
		}
		if ( n2 >= s.length ) {
			s2 = "";
		}
		else {
			s2 = s.substring(n2, s.length);
		}
		s = s1 + s2;
	}
	return s;
}

function checkEmail(EmailForm) {
	// function to verify if the email is valid
	// if email is valid, return true.
	// you must include error.js if you use this function!
	var strEmail = EmailForm.value;
	var i;
	var strCheck1 = false;
	var strCheck2 = false;
	var iEmailLen = strEmail.length

	if (iEmailLen > 0) {
		// if strEmail does not contain '@' and '.' in the correct place
		if ((strEmail.indexOf(".@") != -1) || (strEmail.indexOf("@.") != -1) ||
			(strEmail.substring(0,1) == ".") || (strEmail.substring(0,1) == "@") ||
			(strEmail.substring(iEmailLen-1,iEmailLen) == ".") || (strEmail.substring(iEmailLen-1,iEmailLen) == "@"))
		{
      showErr('001001'); // invalid email
      EmailForm.focus();
			return false;
		}
	    for ( i=0; i<iEmailLen; i++ ) {
	        if ( (strEmail.substring(i,i+1) == ".") || (strEmail.substring(i,i+1) == "-") || (strEmail.substring(i,i+1) == "_") ||
				((strEmail.substring(i,i+1) >= "0") && (strEmail.substring(i,i+1) <= "9")) ||
				((strEmail.substring(i,i+1) >= "@") && (strEmail.substring(i,i+1) <= "Z")) ||
				((strEmail.substring(i,i+1) >= "a") && (strEmail.substring(i,i+1) <= "z")) ) {
	                if (strEmail.substring(i,i+1) == ".")
						strCheck1 = true;
	                if (strEmail.substring(i,i+1) == "@")
						strCheck2 = true;
	        }
	        else {
	            showErr('001001'); // invalid email
	            EmailForm.focus();
					return false;
	        }
	    }

	    if ((strCheck1 == false) || (strCheck2 == false)) {
	        showErr('001001'); // invalid email
	        EmailForm.focus();
					return false;
	    }

	}
	// when comes here, email is valid.
  return true;
}

function getTimezone() {
	// Client GMT..

	now = new Date();
	return now.getTimezoneOffset();
}

function getTargetString(sGameid) {
	var gm = "";
	var sx;

	if ( location.href.indexOf("/game/") >= 0 ) {
		gm = (sGameid==null) ? getStrCookie("gameid") : sGameid;
	}
	sx = getCookie(CK_SEX).toLowerCase();

	return "&showme=html&gm=" + gm + "&sx=" + sx;
}

function getAdvurl(sAdcase, sGameid) {
	// function to get advertisement URL
	var sTarget = getTargetString(sGameid);
	var sKor = "http://hangamead.naver.com/ad?loc=hangame." + sAdcase + sTarget + "&refresh=5";

	return sKor;
}

function getForumurl(){
	return "http://forum.netvigator.com/forum/index.jspa";
}

function errPassword(sPassword, sBirth) {
	// function to verify if the password is valid.
	// if the password is invalid, return true.
	// case 1: Password length is shorter then MAX_PASSWORD_LEN
	// case 2: Password with 2 same character.
	// case 3: Password is same as user birthday
	// case 4: Password equals to "1234";
	// e.g.
	//		bErr = errPassword("abcd");

	var ch, i, nLen, sSocialID;

	nLen = sPassword.length;
	if (nLen < MAX_PASSWORD_LEN) return true;

	ch = sPassword.substring(0, 1);
	for ( i=0; i<nLen; i++ ) {
		if (ch != sPassword.substring(i, i + 1)) break;
	}
	if (i >= nLen) return true;
	if (sBirth && sBirth.indexOf(sPassword) >= 0) return true;
	if (sPassword=="1234") return true;

	return false;
}

function chkPwdjohap(sPassword) {
	// ¿µ¹®, ¼ýÀÚ È¥ÇÕ
	var d1=new Array(10);
	var s1=0;
	var s2=0;

	for(i=0;i<sPassword.length;i++) {
		d1[i]=sPassword.substring(i,i+1);
	}
	for(i=0;i<sPassword.length;i++) {
		if('A'<=d1[i] && d1[i]<='Z'||'a'<=d1[i] && d1[i]<='z') s1++;
		if('0'<=d1[i] && d1[i]<='9') s2++;
	}

	if(s1 < 1 || s2 < 1) return true;

	return false;
}

function errChar(ch) {
	// ¼ýÀÚ, ¿µ¹®, ÇÑ±Û ÀÌ¿ÜÀÇ ¹®ÀÚÀÌ¸é true ¸®ÅÏÇÔ

	if ( ch >= "0" && ch <= "9" ) return false;
	if ( ch >= "a" && ch <= "z" ) return false;
	if ( ch >= "A" && ch <= "Z" ) return false;

	var sEncode = encodeURI(ch);
	if ( sEncode.length==9 ) {
		var sHex = sEncode.substring(1, 3);
		if ( sHex >= "EA" && sHex <= "ED" ) return false;
	}

	return true;
}

function errStandard(sChk)
{
	// ½ºÆ®¸µ¿¡ ¼ýÀÚ, ¿µ¹®, ÇÑ±Û ÀÌ¿ÜÀÇ ¹®ÀÚ°¡ µé¾îÀÖÀ¸¸é true ¸®ÅÏÇÔ

	var ch;

	for (var i=0; i<sChk.length; i++) {
		ch = sChk.substring(i, i + 1);
		if ( errChar(ch) ) return true;
	}

	return false;
}

function setTopMenu(s)
{
	if ( typeof(top.header)=='object' ) {
		if ( typeof(top.header.changePattern)=='function' ) {
			top.header.changePattern(s);
			return;
		}
	}
	setTimeout("setTopmenu(\"" + s + "\")", 500);
}

function avClick(){}

//''''''''''''''''''''''''''''''''''''''''''''
// Getting AVATAR MENU
//
//''''''''''''''''''''''''''''''''''''''''''''
function avRealClick(thiswin,thisimg,mode,defaultmenu){
	try{
		browser50=browser50||(defaultmenu=="true");
		if(browser50) {mypage();return}
		avatarmenu=document.getElementById("avatar_menu"+mode+"_"); //eval("avatar_menu"+mode+"_");
		avimg=thisimg;
		x=thiswin.event.screenX-top.screenLeft + (typeof(top.detail)=='object' ? top.detail.document.body.scrollLeft : 0) ;y=thiswin.event.screenY-top.screenTop + (typeof(top.detail)=='object' ? top.detail.document.body.scrollTop : 0);
		showavatarlayer();
		if (mode=="") avatarmenu.style.left=x; else avatarmenu.style.left=x-avatarmenu.offsetWidth;
		avatarmenu.style.top=y-20;
	}
	catch(e){}
}

function avClick(thisimg,mode,defaultmenu){
	if (typeof(top.detail)=="object")
		if (typeof(top.detail.avRealClick)=="function"){
			if(!mode) mode="";
			top.detail.avRealClick(window,thisimg,mode,defaultmenu);
//		   	           avRealClick(window,thisimg,mode,defaultmenu);
		}
}

function showavatarlayer(){
	avOver(avimg);
	avatarmenu.style.display="inline";
}

function hideavatarlayer(){
	if(!browser50) {
		avOut(avimg);
		avatarmenu.style.display="none";
	}
}

function avOver(avimg){
	avimg.style.borderStyle="solid";
	avimg.style.borderTopColor="#EBEBEB";
	avimg.style.borderRightColor="#C3C3C3";
	avimg.style.borderBottomColor="#B2B2B2";
	avimg.style.borderLeftColor="#EBEBEB";

}

function avOut(avimg){
	avimg.style.borderColor="#FFFFFF";

}


//''''''''''''''''''''''''''''''''''''''''''''
// Menu Implement
//
//''''''''''''''''''''''''''''''''''''''''''''
function showFinduser(){
	if (top.f_smartbar) if (top.f_smartbar.showFinduser) top.controlbar.showFinduser();
	//hideavatarlayer();
}

function openSms(){
	if (top.f_smartbar) if (top.f_smartbar.openSms) top.controlbar.openSms();
	//hideavatarlayer();
}

function hancoin(){
	openWin('http://game.netvigator.com/hg/main/jsp/function/hancoin/billingRedirect.jsp','hancoin_input', 380, 460);
	//hideavatarlayer();
}

function mypage(){
	openWin('http://game.netvigator.com/hg/main/jsp/function/myhome/myhome_index.jsp','mypage', 750, 500);
	//hideavatarlayer();
}

function goGuild(){
//	top.detail.location.href="http://club.hangame.naver.com/club/guild_default.asp";
	top.detail.location.href="http://guild.hangame.naver.com/guild/guild_default.jsp";
	//hideavatarlayer();
}

//''''''''''''''''''''''''''''''''''''''''''''
// Code by ADTeam
//
//''''''''''''''''''''''''''''''''''''''''''''

function getComeBackURLEncode(target1, target2) {
	if (target1!=null & target1!="") {
		target1 = escape(target1);
	}
	if (target2!=null & target2!="") {
		target2 = escape(target2);
	}
	return(getComeBackURL(target1, target2));
}

function getComeBackURL(target1, target2) {
	var cbURL = "";
	if (target1!=null & target1!="") {
		cbURL = "?target1=" + target1;
		if (target2!=null & target2!="") {
			cbURL = cbURL + "&target2=" + target2;
		}
	}
	if (cbURL!="") {
		cbURL = "http://game.netvigator.com/hg/common/jsp/redirect.jsp" + cbURL;
	}
	return cbURL;
}

function getAVComeBackURLEncode(target1, target2) {
	if (target1!=null & target1!="") {
		target1 = escape(target1);
	}
	if (target2!=null & target2!="") {
		target2 = escape(target2);
	}
	return(getAVComeBackURL(target1, target2));
}

function getAVComeBackURL(target1, target2) {
	var cbURL = "";
	if (target1!=null & target1!="") {
		cbURL = "?target1=" + target1;
		if (target2!=null & target2!="") {
			cbURL = cbURL + "&target2=" + target2;
		}
	}
	if (cbURL!="") {
		cbURL = "http://item.game.netvigator.com/hg/avatar/jsp/common/redirect.jsp" + cbURL;
	}
	return cbURL;
}

function HGLogin(surl, furl) {
	if (surl!=null & surl!="") {
		document.forms['formHGLogin'].successurl.value=surl;
	}
	if (furl!=null & furl!="") {
		document.forms['formHGLogin'].failurl.value=furl;
	}
	document.forms['formHGLogin'].submit();
}

function HGLogout(surl, furl) {
	if (surl!=null & surl!="") {
			//document.forms['formHGLogout'].nexturl.value=surl;
	}
	if (furl!=null & furl!="") {
			document.forms['formHGLogout'].failurl.value=furl;
	}
	document.forms['formHGLogout'].submit();
}

function goHGProfile(surl, furl, pftype) {
	if (surl!=null & surl!="") {
		//document.forms['formHGProfile'].successurl.value = getComeBackURLEncode(surl, '');
		var tmpsurl = getComeBackURLEncode(surl, '');
		document.forms['formHGProfile'].successurl.value = tmpsurl;
	}
	if (furl!=null & furl!="") {
		document.forms['formHGProfile'].failurl.value = furl;
	}
	if (pftype!=null & pftype!="") {
		document.forms['formHGProfile'].type.value = pftype;
	}
	document.forms['formHGProfile'].submit();
}

function goAVProfile(surl, furl, pftype) {
	if (surl!=null & surl!="") {
		//document.forms['formHGProfile'].successurl.value = getComeBackURLEncode(surl, '');
		//var tmpsurl = getAVComeBackURLEncode(surl, '');
		//document.forms['formHGProfile'].successurl.value = tmpsurl;
	}
	if (furl!=null & furl!="") {
		document.forms['formHGProfile'].failurl.value = furl;
	}
	if (pftype!=null & pftype!="") {
		document.forms['formHGProfile'].type.value = pftype;
	}
	document.forms['formHGProfile'].submit();
}

function goAVProfile(surl, furl, pftype) {
	if (surl!=null & surl!="") {
		//document.forms['formHGProfile'].successurl.value = getComeBackURLEncode(surl, '');
		//var tmpsurl = getAVComeBackURLEncode(surl, '');
		//document.forms['formHGProfile'].successurl.value = tmpsurl;
	}
	if (furl!=null & furl!="") {
		document.forms['formHGProfile'].failurl.value = furl;
	}
	if (pftype!=null & pftype!="") {
		document.forms['formHGProfile'].type.value = pftype;
	}
	document.forms['formHGProfile'].submit();
}

function goAVTProfile(surl, furl, pftype) {
	if (surl!=null & surl!="") {
		//document.forms['formAVTProfile'].successurl.value = getComeBackURLEncode(surl, '');
		//var tmpsurl = getComeBackURLEncode(surl, '');
		//document.forms['formAVTProfile'].successurl.value = tmpsurl;
		document.forms['formAVTProfile'].successurl.value = surl;
	}
	if (furl!=null & furl!="") {
		document.forms['formAVTProfile'].failurl.value = furl;
	}
	if (pftype!=null & pftype!="") {
		document.forms['formAVTProfile'].type.value = pftype;
	}
	document.forms['formAVTProfile'].submit();
}

function goNETPassProfile(surl, furl) {
	if (surl!=null & surl!="") {
		//document.forms['formNPProfile'].successurl.value = getComeBackURLEncode(surl, '');
		var tmpsurl = getComeBackURLEncode(surl, '');
		//document.forms['formNPProfile'].successurl.value = "http://game.netvigator.com";
		document.forms['formNPProfile'].successurl.value = surl;
	}
	if (furl!=null & furl!="") {
		document.forms['formNPProfile'].failurl.value = furl;
	}
	document.forms['formNPProfile'].submit();
}

function goAVNETPassProfile(surl, furl) {
	if (surl!=null & surl!="") {
		//document.forms['formNPProfile'].successurl.value = getComeBackURLEncode(surl, '');
		var tmpsurl = getAVComeBackURLEncode(surl, '');
		//document.forms['formNPProfile'].successurl.value = "http://game.netvigator.com";
		document.forms['formNPProfile'].successurl.value = tmpsurl;
	}
	if (furl!=null & furl!="") {
		document.forms['formNPProfile'].failurl.value = furl;
	}
	document.forms['formNPProfile'].submit();
}

function goNPLogout(surl, furl) {
	if (surl!=null & surl!="") {
		document.forms['formNPLogout'].successurl.value = surl;
	}
	if (furl!=null & furl!="") {
		document.forms['formNPLogout'].failurl.value = furl;
	}
	document.forms['formNPLogout'].submit();
}

function goAvatar (avatarurl) {
//	var targetURL = escape(avatarurl);
//	var redirectURL = "http://item.game.netvigator.com/hg/avatar/jsp/common/redirect.jsp";
//	top.location.href = redirectURL + "?target1=" + targetURL;
	document.goavatar.target1.value=avatarurl;
	document.goavatar.submit();
}

function goGame (gameurl) {
//	var targetURL = escape(gameurl);
//	var redirectURL = "http://game.netvigator.com/hg/common/jsp/redirect.jsp";
//	top.location.href = redirectURL + "?target1=" + targetURL;
	document.gogame.target1.value=gameurl;
	document.gogame.submit();
}

function goGameItemBag () {
//	var targetURL = escape(avatarurl);
//	var redirectURL = "http://item.game.netvigator.com/hg/avatar/jsp/common/redirect.jsp";
//	top.location.href = redirectURL + "?target1=" + targetURL;
	document.gogameitem.target1.value="http://item.game.netvigator.com/hg/gameitem/jsp/item_bag/item_mybag_all.jsp";
	document.gogameitem.submit();
}

function goExitForum () {
	top.location.href = 
EXIT_FORUM_URL;
}

function goExitNotice (){
	top.location.href = EXIT_NOTICE_URL;
}

/*
function refreshNP() {
	if (top.f_ctrl.sessImg) {
		top.f_ctrl.sessImg.src = "http://npgw.netvigator.com/npgw/servlet/npgif";
	}
}

if (top.f_ctrl) {
	refreshNP();
}
*/

function goAvatarMMS(referrer) {
	if (referrer=="" || referrer==null)
		referrer="game";
	javascript:openWinFreePos('http://pctv.netvigator.com/pctv/estore/mobile/mms/avatarinput?referrer='+referrer,'AvatarMMS',520,590,100,100,'no');
}

function createForm() {
	document.write("<form name=\"formHGLogin\" method=\"get\" target=\"_top\" action=\"https://netpass.netvigator.com/netpass/jsp/np_login_index.jsp\">");
	document.write("<input type=\"hidden\" name=\"successurl\" value=\"http://game.netvigator.com\">");
	document.write("<input type=\"hidden\" name=\"failurl\" value=\"http://game.netvigator.com\">");
	document.write("</form>");

	document.write("<form name=\"formHGLogout\" method=\"get\" target=\"_top\" action=\"http://game.netvigator.com/hg/main/jsp/function/accmain/logout.jsp\">");
	document.write("<input type=\"hidden\" name=\"nexturl\" value=\"http://game.netvigator.com\">");
	document.write("<input type=\"hidden\" name=\"failurl\" value=\"http://game.netvigator.com\">");
	document.write("</form>");

	document.write("<form name=\"formHGProfile\" method=\"post\" target=\"_top\" action=\"https://netpass.netvigator.com/netpass/servlet/NPMainServlet\">");
	document.write("<input type=\"hidden\" name=\"action\" value=\"hangame_pf_index\">");
	document.write("<input type=\"hidden\" name=\"charset\" value=\"big5\">");
	document.write("<input type=\"hidden\" name=\"loadBean\" value=\"yes\">");
	document.write("<input type=\"hidden\" name=\"successurl\" value=\"http://game.netvigator.com\">");
	document.write("<input type=\"hidden\" name=\"failurl\" value=\"http://game.netvigator.com\">");
	document.write("<input type=\"hidden\" name=\"type\" value=\"profile\">");
	document.write("</form>");

	document.write("<form name=\"formAVTProfile\" method=\"post\" target=\"_top\" action=\"https://netpass.netvigator.com/netpass/servlet/NPMainServlet\">");
	document.write("<input type=\"hidden\" name=\"action\" value=\"avatar_pf_index\">");
	document.write("<input type=\"hidden\" name=\"charset\" value=\"big5\">");
	document.write("<input type=\"hidden\" name=\"loadBean\" value=\"yes\">");
	document.write("<input type=\"hidden\" name=\"successurl\" value=\"http://avatar.now.com.hk\">");
	document.write("<input type=\"hidden\" name=\"failurl\" value=\"http://avatar.now.com.hk\">");
	document.write("<input type=\"hidden\" name=\"type\" value=\"profile\">");
	document.write("</form>");

	document.write("<form name=\"formNPProfile\" method=\"get\" target=\"_top\" action=\"https://netpass.netvigator.com/netpass/servlet/NPMainServlet\">");
	document.write("<input type=\"hidden\" name=\"action\" value=\"np_acct_pf_index\">");
	document.write("<input type=\"hidden\" name=\"returntype\" value=\"jsp\">");
	document.write("<input type=\"hidden\" name=\"loadBean\" value=\"yes\">");
	document.write("<input type=\"hidden\" name=\"successurl\" value=\"http://game.netvigator.com\">");
	document.write("<input type=\"hidden\" name=\"failurl\" value=\"http://game.netvigator.com\">");
	document.write("</form>");

	document.write("<form name=\"formNPLogout\" method=\"get\" target=\"_top\" action=\"https://netpass.netvigator.com/netpass/servlet/NPMainServlet\">");
	document.write("<input type=\"hidden\" name=\"action\" value=\"np_logout\">");
	document.write("<input type=\"hidden\" name=\"loadBean\" value=\"yes\">");
	document.write("<input type=\"hidden\" name=\"successurl\" value=\"http://game.netvigator.com\">");
	document.write("<input type=\"hidden\" name=\"failurl\" value=\"http://game.netvigator.com\">");
	document.write("</form>");

	document.write("<form name=\"goavatar\" method=\"get\" target=\"_top\" action=\"http://item.game.netvigator.com/hg/avatar/jsp/common/redirect.jsp\">");
	document.write("<input type=\"hidden\" name=\"target1\" value=\"\">");
	document.write("</form>");

	document.write("<form name=\"gogame\" method=\"get\" target=\"_top\" action=\"http://game.netvigator.com/hg/common/jsp/redirect.jsp\">");
	document.write("<input type=\"hidden\" name=\"target1\" value=\"\">");
	document.write("</form>");

	document.write("<form name=\"gogameitem\" method=\"get\" target=\"_top\" action=\"http://item.game.netvigator.com/hg/avatar/jsp/common/redirect.jsp\">");
	document.write("<input type=\"hidden\" name=\"target1\" value=\"\">");
	document.write("</form>");
}

function viewHompy (hompyid) {
	top.location.href="http://hompy.now.com.hk/id/"+hompyid;
}

createForm();

