var blnDev = (location.href.indexOf("http://dev-")==0);
var blnalpha = (location.href.indexOf("http://alpha-")==0);
var blnReal = (location.href.indexOf("http://sunonline")==0); 

var strProtocol = "http://";

if (blnDev)
{
    strHostPrefix1 = "dev-";
    strHostPrefix2 = "alpha-";
}
else if (blnalpha)
{
     strHostPrefix1 = "alpha-";
     strHostPrefix2 = "alpha-";
}
else if (blnReal)
{
	 strProtocol = "https://";
     strHostPrefix1 = "";
     strHostPrefix2 = "";
}
else
{
    strProtocol = "https://";
    strHostPrefix1 = "";
    strHostPrefix2 = "";
}

var strContentDir = "http://"+strHostPrefix1+"sunonline.hangame.com/";
var strMemberDir = strProtocol+strHostPrefix1+"wid-sunonline.hangame.com/";

var strPaymentDir = "http://"+strHostPrefix2+"pay-sunonline.hangame.com/";
var strHanMemberDir = "http://"+strHostPrefix2+"member.hangame.com/";
var strHanMembersDir = strProtocol+strHostPrefix2+"members.hangame.com/";

var strHanGameDir = "http://"+strHostPrefix1+"www.hangame.com";
 
function fnGoMenu(strCode) {
	switch (strCode) {
		
		case 100 :
			location.href = "/GameInfo/Features/";
			break;
		case 110 :			
			location.href = "/GameInfo/Features/";
			break;
		case 120 :
			location.href = "/GameInfo/Scenario/";
			break;
		case 130 :
			location.href = "/GameInfo/Character/";
			break;
		case 131 :
			location.href = "/GameInfo/Character/";
			break;
		case 132 :
			location.href = "/GameInfo/Character/viewDragonKnight.asp";
			break;
		case 133 :
			location.href = "/GameInfo/Character/viewValkyrie.asp";
			break;
		case 134 :
			location.href = "/GameInfo/Character/viewElementalist.asp";
			break;
		case 135 :
			location.href = "/GameInfo/Character/viewShadow.asp";
			break;
		case 140 :
			location.href= "/GameInfo/World/";
			break;
		case 150 :
			location.href = "/GameInfo/System/";
			break;
			

		
		case 200 :
			location.href = "/GameGuide/Beginner/";
			break;
		case 210 :
			location.href = "/GameGuide/Beginner/";
			break;
		case 220 :
			location.href = "/GameGuide/Install/viewInstallAndRun.asp";
			break;
		case 230 :
			location.href = "/GameGuide/Interface/";
			break;
		case 231 :
			location.href = "/GameGuide/Interface/";
			break;
		case 232 :
			location.href = "/GameGuide/Interface/viewControl.asp";
			break;
		case 240 :
			location.href = "/GameGuide/GameStart/";
			break;
		case 250 :
			location.href = "/GameGuide/Route/";
			break;
		case 251 :
			location.href = "/GameGuide/Route/";
			break;		
		

		
		case 300 :
			location.href = "/News/Notice/";
			break;
		case 310 :
			location.href = "/News/Notice/";
			break;			
		case 320 :
			location.href = "/News/Press/";
			break;
		case 330 :
			location.href = "/News/Update/";
			break;
		case 340 :
			//alert("ÁØºñÁßÀÔ´Ï´Ù");
			location.href = "/News/Event/";
			break;
		case 350 :
			location.href = "/News/Event/";
			break;
		
		
		
		case 400 :
			location.href = "/Community/ThemeBoard/";
			break;
		case 410 :
			location.href = "/Community/ThemeBoard/";
			break;						
		case 420 :
			location.href = "/Community/ThemeBoard/listCharacterBoard.asp";
			break;
		case 421 :
			location.href = "/Community/ThemeBoard/listCharacterBoard.asp";
			break;
		case 422 :
			location.href = "/Community/ThemeBoard/listCaptureBoard.asp";
			break;
		case 423 :
			location.href = "/Community/ThemeBoard/listServerBoard.asp";
			break;
		case 430 :
			location.href = "/Community/Discussion/";
			break;
		case 440 :
			location.href = "/Community/HotlineBoard/";
			break;
		case 450 :
			location.href = "/Community/MakingForum/";
			break;
		case 460 :
			location.href = "/Community/ScreenArt/";
			break;
		case 470 :
			location.href = "/Community/FanPage/";
			break;


		
		case 500 :
			location.href = "/PDS/DownLoad/";
			break;
		case 510 :
			location.href = "/PDS/DownLoad/";
			break;
		case 511 :
			location.href = "/PDS/DownLoad/";
			break;			
		case 512 :
			location.href = "/PDS/DownLoad/downloadDrivers.asp";
			break;			
		case 520 :
			location.href = "/PDS/VOD/";
			break;
		case 530 :
			location.href = "/PDS/OST/";
			break;
		case 531 :
			location.href = "/PDS/OST/";
			break;			
		case 532 :
			location.href = "/PDS/OST/aboutHoward.asp";
			break;			
		case 533 :
			location.href = "/PDS/OST/writeComment.asp";
			break;			
		case 540 :
			location.href = "/PDS/Wallpaper/";
			break;
		case 550 :
			location.href = "/PDS/Picture/";
			break;
		case 560 :
			location.href = "/PDS/FanSiteKit/";
			break;			


		
		case 600 :
			location.href = "/Customer/Faq/";
			break;
		case 610 :
			location.href = "/Customer/Faq/";
			break;
		case 620 :
			location.href = "/Customer/Inquiry/";
			break;
		case 621 :
			location.href = "/Customer/Inquiry/";
			break;			
		case 622 :
			location.href = "/Customer/Hacking/";
			break;			
		case 623 :
			location.href = "/Customer/BadUserReport/";
			break;	
		case 624 :
			location.href = "/Customer/Declare/";
			break;								
		case 630 :
			location.href = "/Customer/BugReport/";
			break;
		case 640 :
			location.href = "/Customer/Policy/";
			break;
		
	
		
		case 700 :
			location.href = strMemberDir+"MyFolder/PersonalLog/";
			break;
		case 710 :
			location.href = strMemberDir+"MyFolder/PersonalLog/";
			break;
		case 720 :
			location.href = "/MyFolder/Letter/";
			break;
		case 730 :
			location.href = strMemberDir+"MyFolder/ModifyInformation/";
			break;
		case 740 :
			location.href = strMemberDir+"MyFolder/ChangeQA/";
			break;	
		case 750 :
			location.href = strMemberDir+"MyFolder/ChangePwd/";
			break;
		case 760 :
			location.href = strMemberDir+"MyFolder/IDaddition/";
			break;						
		case 770 :
			location.href = strMemberDir+"MyFolder/Secession/";
			break;
		case 780 :
			location.href = strMemberDir+"PersonAuth/";
			break;
		case 790 :		
			location.href = strMemberDir+"Login/hanCookieDeleteProcess.asp";
			//top.location.href = strHanMembersDir+"myinfo/cancelgame.nhn?gameid=k_sunonline&period=30&nxtURL="+strContentDir;							
			break;		
		case 810 :
			fnOpenWindow('/Common/FlashPopupView.asp?iFN=1','MainFlash', 'width=752,height=492')		
			break;
		case 820 :
			fnOpenWindow('/Common/FlashPopupView.asp?iFN=2','MainFlash', 'width=752,height=492')		
			break;
		case 830 :
			fnOpenWindow('/Common/FlashPopupView.asp?iFN=3','MainFlash', 'width=752,height=492')		
			break;
		case 840 :
			fnOpenWindow('/Common/FlashPopupView.asp?iFN=4','MainFlash', 'width=752,height=492')		
			break;
		case 850 :
			fnOpenWindow('/Common/FlashPopupView.asp?iFN=5','MainFlash', 'width=752,height=492')		
			break;


		
		case 900 :
			location.href = "/sitemain.asp";
			break;
		case 910 :						
			location.href = strHanMemberDir+"register/index.nhn?docref="+strContentDir;
			break;
		case 920 :
			alert("ÁØºñÁßÀÔ´Ï´Ù.");break;
			location.href = "";
			break;
		case 930 :
			alert("ÁØºñÁßÀÔ´Ï´Ù.");break;
			location.href = "";
			break;						
		case 940 :
			location.href = "/siteinfo/sitemap.asp";
			break;
		case 950 : 
			//fnOpenWindow('/Common/popPCBangList.asp','wnPCList','width=675,height=168,scrollbars=yes');
			fnOpenWindow('http://pcbang.webzen.co.kr/Common/PCSearch/findSunPCBang.asp','wnPCList','width=675,height=168,scrollbars=yes');
			break;
		case 960 :
			location.href = strMemberDir + "Common/Friend/";
			break;

		//case 991 :
		//	window.open('http://itemmall.okcashbag.com/gamemall/sun/sun_online.jsp');
		//	location.href = "/News/Event/readEvent.asp?iC=49&iPN=1&tC=-1";
		//	break;	
		
		case 991 :
			location.href = "/News/Notice/readNotice.asp?iC=3579&sT=&iPN=1&hidsF=&sC=0&iBK=0&tC=1859&tT=1";
			break;
		//case 992 :
		//	fnOpenWindow('/SWF/Event/AntiPhishing_20070813/Default.asp','wnAnti','width=600,height=540,scrollbars=no');			
		//	break;
		case 992 :
			fnOpenWindow('http://glog.sunonline.co.kr/GM','popGLog','width=811,height=547,scrollbars=no');
			break;	
		case 993 :
			location.href = "/News/Update/readUpdate.asp?iC=40&sT=&iPN=1&sC=0&tC=27";		
			break;	
		case 994 :
			fnOpenWindow('/Common/popNewMember.asp','popNewMember','top=0,left=0,width=485,height=724,scrollbars=no');
			break;	
		case 995 :
			window.open(strContentDir + 'Event/OccupyRegion_20100121/');
			break;									
		case 996 :
			location.href = "/News/Notice/readNotice.asp?iC=3659&sT=&iPN=1&hidsF=&sC=0&iBK=0&tC=1924&tT=1";
			break;										
		case 997 :
			location.href = "/News/Event/readEvent.asp?iC=128&iPN=1&tC=-1";
			break;
		case 998 :
			location.href = "/News/Notice/readNotice.asp?iC=3761&sT=&iPN=1&hidsF=&sC=0&iBK=0&tC=1924&tT=1";
			break;

		
		case 999 :
			fnOpenWindow('/SiteInfo/popPolicy.asp','popPolicy', 'width=620,height=600,scrollbars=no');
			break;


		
		case 1000 :
			location.href = "/ItemMall/";
			break;
		case 1001 :
			location.href = strPaymentDir+"Payment/Cash/CashChargeMain.aspx";
			break;
		case 1002 :
			location.href = "/itemmall/service/";
			break;
		case 1003 :
			location.href = "/ItemMall/ItemCatalog/";
			break;
		case 1004 :
			location.href = strPaymentDir+"Payment/Cash/CashHistoryListForm.aspx";
			break;
		case 1005 :
			location.href = "/ItemMall/Coupon/";
			break;
		case 1006 :
			location.href = "/ItemMall/FreeCharge/";
			break;

		case 1010 : 			
			fnOpenWindow('/ItemMall/Common/popFreeCash.asp','winFreeCash','width=365,height=353,scrollbars=no');
			break;
		case 1020 : 			
			//fnOpenWindow(strMemberDir+'Event/VirtualID/','winVirtualID','width=627,height=600,scrollbars=no');
			alert('¼­ºñ½º ÁØºñÁß ÀÔ´Ï´Ù.');
			break;
		case 1030 : 			
			//fnOpenWindow('/Event/Safe_20070809/popFishing.asp','winfishing','width=550,height=353,scrollbars=no');
			break;

		default :
			location.href = "/";
	}
}



function fnGoFamilySite(value) {
	if (value != "") {
		window.open(value, 'family', '');
	}
}

	

function fnOpenWindow(strUrl, strWinName, strFeature) {
	window.open(strUrl, strWinName, strFeature);
}



function fnChkLogin(strLoginLocation, chrIDValid){
	//if(confirm("·Î±×ÀÎÀÌ ÇÊ¿äÇÕ´Ï´Ù. ·Î±×ÀÎÆäÀÌÁö·Î ÀÌµ¿ÇÏ½Ã°Ú½À´Ï±î?"))
	//	self.location=strLoginLocation;

	if(chrIDValid == 'Y' || chrIDValid == 'R') {	//Á¤È¸¿ø
		if (window.confirm('¾à°üµ¿ÀÇ ÈÄ ÀÌ¿ëÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù.\nÁö±Ý ¾à°üµ¿ÀÇ ÇÏ½Ã°Ú½À´Ï±î?')) {
			self.location = strMemberDir + "account/hanViewAgreement.asp";
		}
	}else if(chrIDValid == 'S') {	//ÁØÈ¸¿ø
		if (window.confirm('Á¤È¸¿ø ÀüÈ¯ ÈÄ ÀÌ¿ëÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù.\nÁö±Ý Á¤È¸¿øÀ¸·Î ÀüÈ¯ ÇÏ½Ã°Ú½À´Ï±î?')) {
			self.location = strHanMemberDir + "myinfo/upgrade.nhn";		
		}		
	}else if(chrIDValid == 'D' || chrIDValid == 'A' || chrIDValid == 'J') {	//ºñ½Ç¸íÈ¸¿ø
		if (window.confirm('½Ç¸íÀÎÁõ ÈÄ ÀÌ¿ëÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù.\nÁö±Ý ½Ç¸íÀÎÁõ ÇÏ½Ã°Ú½À´Ï±î?')) {
			self.location = strHanMemberDir + "permissionDeniedView.nhn?code=bbswrite&next=" + strMemberDir + "Account/hanViewAgreement.asp&homeurl=" + strHanGameDir;
		}
	}else{
		alert("·Î±×ÀÎ ÇÏ½Å ÈÄ ÀÌ¿ëÇØ ÁÖ¼¼¿ä.");
	}
}

function fnRunWebStarter(value)
{
	var intLoginCheck = fnCheckWebStarter();

	if(intLoginCheck == 0)
	{
		alert("·Î±×ÀÎ Á¢¼ÓÈÄ Game Start ÇÏ¼¼¿ä!");
	}
	else if(intLoginCheck == 1)
	{
		if(document.WebStarter==null || typeof(document.WebStarter) == "undefined" || document.WebStarter.object == null)
		{
			alert("Game Start¸¦ ½ÇÇàÇÏ½Ã·Á¸é ActiveX ¸¦ ¼³Ä¡ÇØ ÁÖ¼¼¿ä!");
		}
		else
		{
			//if(document.WebStarter.IsExecGameClient(strContentDir + 'Common/WebStarterXml.xml', 2, value, 1))
			//{
			//	alert("ÀÌ¹Ì °ÔÀÓÀÌ ½ÇÇàÁß ÀÔ´Ï´Ù.");
			//}
			//else
			//{
				KeySearchJs.src = "/Script/jsWebStarterExec.asp?iSK="+value;
			//}
		}
	}
}

document.onkeydown = function() {
	if (event.keyCode == 116) {
		event.keyCode = 505;
	}
	if (event.keyCode == 505) { 
		return false;
	}
}


function over() {
         var targetid, srcElement, targetElement;
		 var submenus;
         srcElement=window.event.srcElement.parentElement;

        if(event.srcElement.parentElement.className.indexOf("outline") >= 0) 
          {
           targetid=srcElement.id + "d";

			 submenus = document.all.submenupanel;
			 var child;

			 for (i = 0; i < submenus.children.length; i++) {
				child = submenus.children.item(i);
				if (child.id == targetid) {
					child.style.display = "";
				}else{
					child.style.display = "none";
				}
			 }

        }

}

function Over() {
	if(event.srcElement.className == "rollover") {
		var srcPath = event.srcElement.src;
		var newSrcPath = srcPath.replace(".gif", "on.gif");
		event.srcElement.src = newSrcPath;
	}
}

function Out() {
	if(event.srcElement.className == "rollover") {
		var srcPath = event.srcElement.src;
		var newSrcPath = srcPath.replace("on.gif", ".gif");
		event.srcElement.src = newSrcPath;
	}
}


function fnInitLeftMenu() {
	document.body.attachEvent("onmouseover", Over);
	document.body.attachEvent("onmouseout", Out);
}

document.onmouseover=over;