// common
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_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_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_showHideLayers() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
function MM_jumpMenu_blank(selObj,restore){ //v3.0
  eval("window.open='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

// rollover
function initRollovers() {
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'imgover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_on'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_on'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}

window.onload = initRollovers;

// Tab Content
function initTabMenu(tabContainerID) {
	var tabContainer = document.getElementById(tabContainerID);
	var tabAnchor = tabContainer.getElementsByTagName("a");
	var i = 0;

	for(i=0; i<tabAnchor.length; i++) {
		if (tabAnchor.item(i).className == "tab")
			thismenu = tabAnchor.item(i);
		else
			continue;

		thismenu.container = tabContainer;
		thismenu.targetEl = document.getElementById(tabAnchor.item(i).href.split("#")[1]);
		thismenu.targetEl.style.display = "none";
		thismenu.imgEl = thismenu.getElementsByTagName("img").item(0);
		thismenu.onclick = function tabMenuClick() {
			currentmenu = this.container.current;
			if (currentmenu == this)
				return false;

			if (currentmenu) {
				currentmenu.targetEl.style.display = "none";
				if (currentmenu.imgEl) {
					currentmenu.imgEl.src = currentmenu.imgEl.src.replace("_on.gif", ".gif");
				} else {
					currentmenu.className = currentmenu.className.replace(" on", "");
				}
			}
			this.targetEl.style.display = "";
			if (this.imgEl) {
				this.imgEl.src = this.imgEl.src.replace(".gif", "_on.gif");
			} else {
				this.className += " on";
			}
			this.container.current = this;

			return false;
		};

		if (!thismenu.container.first)
			thismenu.container.first = thismenu;
	}
	if (tabContainer.first)
		tabContainer.first.onclick();
}

// Change Over Row Class
function changeOverRowClass(elId, tagName, searchClass) {
	var el = document.getElementById(elId).getElementsByTagName(tagName);

	for (i=0; i<el.length; i++) {
		if (el[i].className == searchClass || el[i].className == searchClass + " on") {
			el[i].onmouseover = changeOverRowClassOver;
			el[i].onmouseout = changeOverRowClassOut;
		}
	}
}
function changeOverRowClassOver() {
	if (this.className == "") {
		this.className = this.className + " on";
	} else {
		this.className = "on";
	}
}
function changeOverRowClassOut() {
	if (this.className == "on") {
		this.className = "";
	} else {
		this.className = this.className.replace(" on", "");
	}
}

/* Add Even Row Class */
function addEvenRowClass(elId, tagName, searchClass, addClass) {
	var count = 1;
	var el = document.getElementById(elId).getElementsByTagName(tagName);

for (i=0; i<el.length; i++) {
		if (el[i].className == searchClass) {
			if (count%2) {
				el[i].className = el[i].className + " " + addClass;
			}
			count++;
		}
	}
}

// png
function setPng24(obj) { 
    obj.width=obj.height=1; 
    obj.className=obj.className.replace(/\bpng24\b/i,''); 
    obj.style.filter = 
    "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');" 
    obj.src='http://image.netgame.com/netgame/common/blank.gif';  
    return ''; 
}

// login
function input_clearbg_id() {
	document.getElementById("iId").style.backgroundImage="url(http://image.netgame.com/neo/hero/version01/images/login/bg_input.gif)";
}
function input_clearbg_pw() {
	document.getElementById("iPw").style.backgroundImage="url(http://image.netgame.com/neo/hero/version01/images/login/bg_input.gif)";
}

// 해당 menu
//function f_gotoMenu(pVal)
//{
//	
//	if(pVal == '1')	document.location.href  = '/download/index.php';
//	else if(pVal == '2')	document.location.href  = '/forum/index.php';
//	else if(pVal == '3')	document.location.href  = '/index.php/guide/index/index.php';
//	else if(pVal == '4')	document.location.href  = '/faq/index.php';
//	else if(pVal == '5')	document.location.href  = '/cutomer/index.php';
//	else if(pVal == '6')	document.location.href  = '/multimedia/index.php';
//	else if(pVal == '7')	document.location.href  = '/allgames/index.php';
//	
//}

//-----------------------------------
// message
//-----------------------------------
function f_readyMessage()
{
	alert('Sorry, comming soon.');
	return;	
}
function f_errorNeedLogin()
{
	alert("Please login");
}

function goHome() {
    document.location.href  = '/';
 }

// 상단 플레쉬 혹은 left메뉴 클릭시 
 function openURL(pFirst, pSecond) {
	 
	var locURL = '';
	
//	alert(pFirst+" : "+pSecond); 
	
	// notice
	 if(pFirst == '1')
	 {
		 if(pSecond == '0' || pSecond == '1') locURL = '/notice/all/';
		 else if(pSecond == '2') locURL = '/notice/notice/';
		 else if(pSecond == '3') locURL = '/notice/event/';
	 }
	// guide
	 else if(pFirst == '2')
	 {
		 // Hero Introduction
		 if(pSecond == '0' || pSecond == '1') locURL = '/guide/hero-introduction/synopsis/';
		 else if(pSecond == '12') locURL = '/guide/hero-introduction/special-features/';
		 else if(pSecond == '13') locURL = '/guide/hero-introduction/hero-story/';
		 
		 // Beginner guide
		 else if(pSecond == '2') locURL = '/guide/beginner-guide/installation-guide/';
		 else if(pSecond == '22') locURL = '/guide/beginner-guide/tutorial-guide/';
		 else if(pSecond == '23') locURL = '/guide/beginner-guide/personal-shop/';
		 else if(pSecond == '24') locURL = '/guide/beginner-guide/chat-system/';
		 
		 
		 // Intermediate guide
		 else if(pSecond == '3' || pSecond == '31') locURL = '/guide/intermediate-guide/pet-system/';
		 else if(pSecond == '32') locURL = '/guide/intermediate-guide/lot-system/';
		 else if(pSecond == '33') locURL = '/guide/intermediate-guide/house/';
		 else if(pSecond == '34') locURL = '/guide/intermediate-guide/promotion-system/';
		 else if(pSecond == '35') locURL = '/guide/intermediate-guide/strengthning/';
		 else if(pSecond == '36') locURL = '/guide/intermediate-guide/party-system/';
		 
		 // High class guide
		 else if(pSecond == '4') locURL = '/guide/high-class-guide/seal-system/';
		 else if(pSecond == '42') locURL = '/guide/high-class-guide/soul-transfer-system/';
		 else if(pSecond == '43') locURL = '/guide/high-class-guide/born-again/';
		 else if(pSecond == '44') locURL = '/guide/high-class-guide/mini-game/';
		 
		 // Warfare
		 else if(pSecond == '5') locURL = '/guide/warfare/';
		 else if(pSecond == '52') locURL = '/guide/warfare/golden-basin/';
		 else if(pSecond == '53') locURL = '/guide/warfare/hero-battle/';
		 else if(pSecond == '54') locURL = '/guide/warfare/pk-zone/';		 
		 
	 }
	// game inof
	 else if(pFirst == '3')
	 {
		 if(pSecond == '0' || pSecond == '1') locURL = '/gameinfo/character/';
		 else if(pSecond == '2') locURL = '/gameinfo/skills/';
		 else if(pSecond == '3') locURL = '/gameinfo/item/';
		 else if(pSecond == '4') locURL = '/gameinfo/monster/';
		 else if(pSecond == '5') locURL = '/gameinfo/npc/';
		 else if(pSecond == '6') locURL = '/gameinfo/pet/';
		 else if(pSecond == '7') locURL = '/gameinfo/area-map/';
		 else if(pSecond == '72') locURL = '/gameinfo/area-map/cate/2/';
		 else if(pSecond == '8') locURL = '/gameinfo/quest/';	 
	 }
	// community
	 else if(pFirst == '4')
	 {
		 if(pSecond == '0' || pSecond == '1') locURL = '/community/forum/';
		 else if(pSecond == '2') locURL = '/community/gm-diary/';
		 else if(pSecond == '3') locURL = '/community/ranking/';
		 else if(pSecond == '32') locURL = '/community/ranking/house-ranking/';
		 else if(pSecond == '33') {f_readyMessage(); return;}
		 else if(pSecond == '4') locURL = '/community/house/';
		 else if(pSecond == '5') locURL = '/community/screenshot/';
		 else if(pSecond == '6') locURL = '/community/players-photo/';
		 else if(pSecond == '7') locURL = '/community/fan-art/';
		 else if(pSecond == '8') locURL = '/community/gallery/';
		 else if(pSecond == '9') locURL = '/community/wallpaper/';
		 else if(pSecond == '10') locURL = '/community/multimedia/';
		 else if(pSecond == '11') locURL = '/community/poll/';
		 
	 }
	// cash item
	 else if(pFirst == '5')
	 {
		 if(pSecond == '0' || pSecond == '1') locURL = '/cashitem/item-info/';
		 else if(pSecond == '2') locURL = '/cashitem/premium-item-guide/';
		 else if(pSecond == '3') locURL = '/cashitem/guide/';
		 else if(pSecond == '4') 
		 {
			 window.open('http://eventmall.netgame.com/hero', 'eventmall', '');return;
		 }
		 else if(pSecond == '22') locURL = 'http://www.netgame.com/account/ncash.php';

	 }
	// support
	 else if(pFirst == '6')
	 {
		 if(pSecond == '0' || pSecond == '1') locURL = '/support/download';
		 else if(pSecond == '2') 
		 {
			 netgameFAQ('hero'); return;
		 }
	     else if(pSecond == '3') 
	     {
			 netgameCustomerService('hero'); return;
	     }
		 else if(pSecond == '4') locURL = '#';
		 else if(pSecond == '5') 
		 {
			 netgameAccount(2); return;
		 }
		 else if(pSecond == '6') locURL = 'http://www.netgame.com/account/coupon.php';
			 
	 }

	// support
	 else if(pFirst == '7')
	 {
		 if(pSecond == '0' || pSecond == '1') locURL = 'http://www.netgame.com';
		 else if(pSecond == '2') {f_readyMessage(); return;}

	 }

	// etc
	 else if(pFirst == '8')
	 {
//		 if(pSecond == '1') locURL = '/news/notice-view.php?Idx=363';
		 if(pSecond == '1') locURL = '/guide/beginner-install06.php';
		 else if(pSecond == '2') locURL = 'http://www.netgame.com/download/download.php';
	 }
	 else if(pFirst == '9')
	 {	 	
	 	if(pSecond == '1') 
	 	{
	 		locURL = 'http://hero.netgame.com/notice/notice/mode/view/idx/1235';
	 	}
	 	else if(pSecond == '2') 
	 	{
	 		error("The duration of registration is over. ");return;
	 	}
		else if(pSecond == '3') 
		{
			error("The duration of registration is over. ");return;
		}
	 }
	 else if(pFirst == '10')
	 {	 	
	 	if(pSecond == '1') 
	 	{
	 		locURL = SITE_PAGE_URL['vip-guide'];
	 	}
	 	else if(pSecond == '2') 
	 	{
	 		locURL = SITE_PAGE_URL['benefit-of-vip'];
	 	}
		else if(pSecond == '3') 
		{
			locURL = SITE_PAGE_URL['vip-notice'];
		}
		else if(pSecond == '4') 
		{
			locURL = SITE_PAGE_URL['vip-forum'];
		}
		else if(pSecond == '5') 
		{
			window.open('http://hero.netgame.com/vip/vip-chat', 'vipchat', 'width=730px, height=810px, scrollbars=no, status=no, location=no, toolbar=no, menubar=no, resizable=no');
			return;
		}	 	
	 }
	 
	if(locURL == '')
	{
		alert('Don\'t have URL');
		return;
	}
		
	document.location.href  = locURL;
 }
 
 
 

//게임 in 가이드 left메뉴 클릭시 
function openURLGame(pFirst, pSecond) {
	 
	var locURL = '';
	
//	alert(pFirst+" : "+pSecond);
	
	// guide
	 if(pFirst == '2')
	 {
		 // Hero Introduction
		 if(pSecond == '0' || pSecond == '1') locURL = '/gameinguide/hero-introduction/synopsis/';
		 else if(pSecond == '12') locURL = '/gameinguide/hero-introduction/special-features/';
		 else if(pSecond == '13') locURL = '/gameinguide/hero-introduction/hero-story/';
		 
		 // Beginner gameinguide
		 else if(pSecond == '2') locURL = '/gameinguide/beginner-guide/installation-guide/';
		 else if(pSecond == '22') locURL = '/gameinguide/beginner-guide/tutorial-guide/';
		 else if(pSecond == '23') locURL = '/gameinguide/beginner-guide/personal-shop/';
		 else if(pSecond == '24') locURL = '/gameinguide/beginner-guide/chat-system/';
		 
		 
		 // Intermediate gameinguide
//		 else if(pSecond == '3') locURL = '/gameinguide/inter_pet.php';
//		 else if(pSecond == '3') locURL = '/gameinguide/inter_lot.php';
		 else if(pSecond == '3' || pSecond == '31') locURL = '/gameinguide/intermediate-guide/pet-system/';
		 else if(pSecond == '32') locURL = '/gameinguide/intermediate-guide/lot-system/';
		 else if(pSecond == '33') locURL = '/gameinguide/intermediate-guide/house/';
		 else if(pSecond == '34') locURL = '/gameinguide/intermediate-guide/promotion-system/';
		 else if(pSecond == '35') locURL = '/gameinguide/intermediate-guide/strengthning/';
		 else if(pSecond == '36') locURL = '/gameinguide/intermediate-guide/party-system/';
		 
		 // High class gameinguide
		 else if(pSecond == '4') locURL = '/gameinguide/high-class-guide/seal-system/';
		 else if(pSecond == '42') locURL = '/gameinguide/high-class-guide/soul-transfer-system/';
		 else if(pSecond == '43') locURL = '/gameinguide/high-class-guide/born-again/';
		 else if(pSecond == '44') locURL = '/gameinguide/high-class-guide/mini-game/';
		 
		 // Warfare
		 else if(pSecond == '5') locURL = '/gameinguide/warfare/great-war/';
		 else if(pSecond == '52') locURL = '/gameinguide/warfare/golden-basin/';
		 else if(pSecond == '53') locURL = '/gameinguide/warfare/hero-battle/';
		 else if(pSecond == '54') locURL = '/gameinguide/warfare/pk-zone/';		 
	 }
	// community
	 else if(pFirst == '4')
	 {
		 if(pSecond == '0' || pSecond == '1') locURL = '/game/community/forum/';
		 else if(pSecond == '4') locURL = '/gameincommunity/screenshot';
		 else if(pSecond == '5') locURL = '/gameincommunity/players-photo';
		 else if(pSecond == '6') locURL = '/gameincommunity/fan-art';
	 }	 
	 
//	alert(locURL); 
	
	if(locURL == '')
	{
		alert('Don\'t have URL');
		return;
	}
		
	document.location.href  = locURL;
}
 function areaFun(c) {  
    //alert(c);
 }
 function HeroStart()
 {
//	 alert('gamestart');
// 	netgameStart('hero');
	 netgameStart('hero');

 }
 function imgReSize(imgObj) {
		var maxWidth = 550;
	    var imgWidth = imgObj.width;
	    var imgHeight = imgObj.height;
		
		document.img_frm.imgwidth.value = imgWidth;
     document.img_frm.imgheight.value = imgHeight;
	
  	if(imgWidth > maxWidth) {
   		var widthRatio = maxWidth/imgWidth;
			imgObj.width = maxWidth;
			imgObj.height = imgHeight * widthRatio;
  	}
 }	

function heroVipService()
{
	if(!getCookie("MGUSA")) 
	{
		error("Please use it after you sign in.");
		return false;
	}
	else
	{		
		location.href=SITE_PAGE_URL['vip-guide'];
	}
}

function vipQuickPass()
{
	if(getCookie("VIP_SUPPORT"))
	{
		location.href='http://www.netgame.com/help/inquiry.php?game=hero';
	}
}
