﻿
/* 이미지 오버아웃 */
function menuon(imgel)
{
	imgel.src = imgel.src.replace(".gif", "_on.gif");
}

function menuout(imgel)
{
	imgel.src = imgel.src.replace("_on.gif", ".gif");
}

/* 슬라이딩 퀵메뉴 */
function flashResize(id,wid,hei){
	//var flashEl = 	document.getElementById("quick_menu");
	var flashEl = document.quick_menu;
//	alert(document.quick_menu);
//alert(document.getElementById("gotop").style.left);
	if(wid == 22){
		document.getElementById("gotop").style.left = 825 + 154;
	}
	else{
		document.getElementById("gotop").style.left = 825;
	}
		flashEl.style.width = wid;
		flashEl.style.height = hei;
}

/* 레이어 오버아웃 */
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);

function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}
/* menu over */
// image roll
function imgOver() {
	this.src = this.src.replace(".gif", ".gif");
}
function imgOut() {
	this.src = this.src.replace(".gif", ".gif");
}

function initSubMenu(tabContainer) {
	triggers = tabContainer.getElementsByTagName("a");

	for(i = 0; i < triggers.length; i++) {
		triggers.item(i).imgEl = triggers.item(i).getElementsByTagName("img").item(0);
		/*triggers.item(i).imgEl.onmouseover = imgOver;
		triggers.item(i).imgEl.onmouseout = imgOut;*/

		if (triggers.item(i).href.split("#")[1])
			triggers.item(i).targetEl = document.getElementById(triggers.item(i).href.split("#")[1]);
		if (!triggers.item(i).targetEl)
			continue;
		
		triggers.item(i).targetEl.style.display = "none";

		triggers.item(i).onclick = function () {
			if (tabContainer.current == this) {
				this.targetEl.style.display = "none";
				this.imgEl.src = this.imgEl.src.replace("_on.gif", ".gif");
				tabContainer.current = null;
			} else {
				if (tabContainer.current) {
					tabContainer.current.targetEl.style.display = "none";
					tabContainer.current.imgEl.src =tabContainer.current.imgEl.src.replace("_on.gif", ".gif");
				}
				this.imgEl.src = this.imgEl.src.replace(".gif", "_on.gif");
				this.targetEl.style.display = "block";
				tabContainer.current = this;
			}
			return false;
		}
	}
}


/* iframe */
function iframe_autoresize(arg) //인수:아이프레임
{
	arg.height = eval(arg.name+".document.body.scrollHeight"); //높이만 스크롤 길이만큼 iframe를 설정
}


/* png */
function IE_enablePng(img)
{
	img.style.display = "inline";
	if (typeof(img.style.filter) == "string") {
		img.style.width = img.offsetWidth + "px";
		img.style.height = img.offsetHeight + "px";
		img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + img.src + "', sizingMethod='scale')";
		setTimeout(function() {
		}, 1);
		img.src = "/img/06com/blank.gif";
	}
}
function topnavpng() {
	topLinkImg = document.getElementById("toplink").getElementsByTagName("img").item(0);
	IE_enablePng(topLinkImg);
	topnavImg = document.getElementById("topnav").getElementsByTagName("img");
	for (i = 0; i < topnavImg.length; i++) {
		IE_enablePng(topnavImg.item(i));
	}
}


/* 점프 메뉴 */
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


/* 팝업창 띄우기 */
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


/* alert 창 띄우기 */
function MM_popupMsg(msg) { //v1.0
  alert(msg);
}


/* 탑버튼 */
function topPage() { 
document.body.scrollTop = 0; 
} 


/* 텍스트 이미지 점선테두리 없애기 */
function bluring(){ 
if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") document.body.focus(); 
} 
//document.onfocusin=bluring; 

function Onclick_Href(url){
 location.href=url;
}


/* 레디오 버튼 체크 */
function checkRadio(field) {
		var field=eval("document.forms[0]."+ field );

        for(var i=0;i<field.length;        i++) { // 라디오버튼의 갯수-1 만큼 루프를 돌립니다
                if (field[i].checked == true) { // 체크된 버튼을 찾으면
                return false;
                }
        }
        if(i==field.length) {        
        	field[0].focus();
        	all_Field_Valid = false;

          return true;
        }
}

/* faq */
function initView(tabContainer) {
	triggers = tabContainer.getElementsByTagName("a");

	for(i = 0; i < triggers.length; i++) {
		if (triggers.item(i).href.split("#")[1])
			triggers.item(i).targetEl = document.getElementById(triggers.item(i).href.split("#")[1]);

		if (!triggers.item(i).targetEl)
			continue;
		
		triggers.item(i).targetEl.style.display = "none";
		triggers.item(i).onclick = function () {
			if (tabContainer.current == this) {
				this.targetEl.style.display = "none";
				this.className = "";
				tabContainer.current = null;
			} else {
				if (tabContainer.current) {
					tabContainer.current.className ="";
					tabContainer.current.targetEl.style.display = "none";
				}
				this.className = "b";
				this.targetEl.style.display = "block";
				tabContainer.current = this;
			}
			return false;
		}
	}
}

/* FAQ style 
var preNum;
var flag=1;
function changeLayer(sNum){
	if(sNum==preNum && flag==1){
		//alert('a');
		temp = eval("document.all."+sNum);
		if(temp){
			temp.style.display='none';
			flag=0;
		}
	}else if(sNum==preNum && flag==0){
		//alert('b');
		temp = eval("document.all."+sNum);
		if(temp){
			temp.style.display='';
			flag=1;
		}
	}else if(sNum!=preNum){
		//alert('c');
		temp = eval("document.all."+preNum);
		if(temp)
			temp.style.display='none';

		temp1 = eval("document.all."+sNum);
		if(temp1)
			temp1.style.display='';
		flag=1;
	}
	preNum=sNum;
}
*/

/* 좌측 메뉴 */
var old_menu = '';
function menuclick(submenu) {
    if( old_menu != submenu ) {
		if( old_menu !='' ) {
		    old_menu.style.display = 'none';
		}
		submenu.style.display = 'block';
		old_menu = submenu;
    } else {
        submenu.style.display = 'none';
        old_menu = '';
    }
}

/* new + - */
function FaqContentShow(FaqShowNum)
{
	var divfaq = eval("faq"+ FaqShowNum);
	var divfaqp = eval("faqp"+ FaqShowNum);
	var divfaqm = eval("faqm"+ FaqShowNum);

	divfaq.style.display = "";
	divfaqp.style.display = "none";
	divfaqm.style.display = "";
}

function FaqContentClose(FaqCloseNum)
{
	var divfaq = eval("faq"+ FaqCloseNum);
	var divfaqp = eval("faqp"+ FaqCloseNum);
	var divfaqm = eval("faqm"+ FaqCloseNum);

	divfaq.style.display = "none";
	divfaqp.style.display = "";
	divfaqm.style.display = "none";
}

function isField(keyword) {

	var st_num,key_len;
	st_num = keyword.indexOf(" ");

	while (st_num != -1){
		keyword = keyword.replace(" ", "");
		st_num  = keyword.indexOf(" ");
	}
	key_len=keyword.length;
	return key_len;
}


// site path
function initSitePath() {
	pathAnchorEl = document.getElementById("site-path").getElementsByTagName("a");
	pathAnchorEl.item(pathAnchorEl.length - 1).style.fontWeight = "bold";
}
// content rating moving
function startRatingScroll() {
	setTimeout("slideRating()", 10);
}
function slideRating() {
	el = document.getElementById("content-rating-form");

	if (el.topPos == null || (el.isDone && el.isOn == false)) {
		el.isDone = false;
		el.topPos = 74;
		el.topTo = 0;
	} else if (el.isDone && el.isOn){
		el.isDone = false;
		el.topTo = 74;
	}
	if (Math.abs(el.topTo - el.topPos) > 1) {
		el.topPos += (el.topTo - el.topPos) / 8;
		el.style.top = el.topPos + "px";
		startRatingScroll();
	} else {
		if (el.topTo == 0) {
			el.isOn = true;
		} else {
			el.isOn = false;
		}
		el.topPos = el.topTo;
		el.style.top = el.topPos + "px";
		el.isDone = true;
	}
}


// family site
var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
var enableanchorlink=0 //Enable or disable the anchor link when clicked on? (1=e, 0=d)
var hidemenu_onclick=1 //hide menu when user clicks within menu? (1=yes, 0=no)


var ie5=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
    var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
    var parentEl=what.offsetParent;
    while (parentEl!=null){
        totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
        parentEl=parentEl.offsetParent;
    }
    return totaloffset;
}

function showhide(obj, e, visible, hidden){
    if (ie5||ns6)
        dropmenuobj.style.left=dropmenuobj.style.top=-500
    if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
        obj.visibility=visible
    else if (e.type=="click")
        obj.visibility=hidden
}

function iecompattest(){
    return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
    var edgeoffset=0
    if (whichedge=="rightedge"){
    var windowedge=ie5 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
        dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
    if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
        edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
    }
    else{
    var windowedge=ie5 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
        dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
    if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
        edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
    }
    return edgeoffset
}

function dropdownmenu(obj, e, dropmenuID){
    if (window.event) event.cancelBubble=true
    else if (e.stopPropagation) e.stopPropagation()
    if (typeof dropmenuobj!="undefined") //hide previous menu
        dropmenuobj.style.visibility="hidden"
        clearhidemenu()
    if (ie5||ns6){
        obj.onmouseout=delayhidemenu
        dropmenuobj=document.getElementById(dropmenuID)
    if (hidemenu_onclick) dropmenuobj.onclick=function(){dropmenuobj.style.visibility='hidden'}
        dropmenuobj.onmouseover=clearhidemenu
        dropmenuobj.onmouseout=ie5? function(){ dynamichide(event)} : function(event){ dynamichide(event)}
        showhide(dropmenuobj.style, e, "visible", "hidden")
        dropmenuobj.x=getposOffset(obj, "left")
        dropmenuobj.y=getposOffset(obj, "top")
        dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
        dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
    }
    return clickreturnvalue()
}

function clickreturnvalue(){
    if ((ie5||ns6) && !enableanchorlink) return false
    else return true
}

function contains_ns6(a, b) {
    while (b.parentNode)
    if ((b = b.parentNode) == a)
    return true;
    return false;
}

function dynamichide(e){
    if (ie5&&!dropmenuobj.contains(e.toElement))
        delayhidemenu()
    else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
    delayhidemenu()
}

function delayhidemenu(){
    delayhide=setTimeout("dropmenuobj.style.visibility='hidden'",disappeardelay)
}

function clearhidemenu(){
    if (typeof delayhide!="undefined")
        clearTimeout(delayhide)
}


<!--
// flashWrite(파일경로, 가로, 세로[, 변수][,배경색][,윈도우모드])
function flashWrite(url,w,h,vars,bg,win){
	
	var id=url.split("/")[url.split("/").length-1].split(".")[0]; //id는 파일명으로 설정
	if(vars==null) vars='';
	if(bg==null) bg='#FFFFFF';
	if(win==null) win='transparent';

	if(document.forms.length > 0){
		id = document.forms[0].id;
	}

	// 플래시 코드 정의
	var flashStr= "	<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'";
		flashStr+="			codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0'";
		flashStr+="			width='"+w+"'";
		flashStr+="			height='"+h+"'";
		flashStr+="			id='"+id+"'";
		flashStr+="			align='middle'>";

		flashStr+="		<param name='allowScriptAccess' value='always' />";
		flashStr+="		<param name='movie' value='"+url+"' />";
		flashStr+="		<param name='FlashVars' value='"+vars+"' />";
		flashStr+="		<param name='wmode' value='"+win+"' />";
		flashStr+="		<param name='menu' value='true' />";
		flashStr+="		<param name='quality' value='high' />";
		flashStr+="		<param name='bgcolor' value='"+bg+"' />";
	
	
		flashStr+="		<embed src='"+url+"'";
		flashStr+="		       flashVars='"+vars+"'";
		flashStr+="		       wmode='"+win+"'";
		flashStr+="		       menu='true'";
		flashStr+="		       quality='high'";
		flashStr+="		       bgcolor='"+bg+"'";
		flashStr+="		       width='"+w+"'";
		flashStr+="		       height='"+h+"'";
		flashStr+="		       name='"+id+"'";
		flashStr+="		       align='middle'";
		flashStr+="		       allowScriptAccess='always'";
		flashStr+="		       type='application/x-shockwave-flash'";
		flashStr+="		       pluginspage='http://www.macromedia.com/go/getflashplayer' />";
		flashStr+=" </object>";

	// 플래시 코드 출력
	document.write(flashStr);
}


/* 미디어플래이어 */
inputMOV = function(id, src, width, height, autostart, loop, showaudiocontrols, showcontrols, showpositioncontrols, showtracker){
	document.write('<object id="'+id+'" name="MediaPlayer" classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715" width="'+width+'" height="'+height+'" standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject" align="center">');
	document.write('  <param name="Filename" value="'+src+'">');
	document.write('  <param name="AutoStart" value="'+autostart+'">');
	document.write('  <param name="loop" value="'+loop+'">');
	document.write('  <param name="ShowAudioControls" value="'+showaudiocontrols+'">');
	document.write('  <param name="ShowControls" value="'+showcontrols+'">');
	document.write('  <param name="ShowPositionControls" value="'+showpositioncontrols+'">');
	document.write('  <param name="ShowTracker" value="'+showtracker+'">');
	document.write('  <embed id="'+id+'" type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/" width="'+width+'" height="'+height+'" src="'+src+'" AutoStart="'+autostart+'" loop="'+loop+'" ShowAudioControls="'+showaudiocontrols+'" ShowControls="'+showcontrols+'" ShowPositionControls="'+showpositioncontrols+'" ShowTracker="'+showtracker+'"></embed>');
	document.write('</object>');
};


function flashWrite_only_layer(){
	
	// 플래시 코드 정의
var flashStr= "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'";
	flashStr+=" codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0'";
	flashStr+=" width='450'";
	flashStr+=" height='555'";
	flashStr+=" id='event3'";
	flashStr+=" align='middle'>";

	flashStr+="<param name='allowScriptAccess' value='always' />";
	flashStr+="<param name='movie' value='../images/event/061107/event3.swf' />";
    flashStr+="<param name='quality' value='high' />";
    flashStr+="<param name='bgcolor' value='#ffffff' />";
    flashStr+="<param name='FlashVars' value='' />";
    flashStr+="<param name='wmode' value='transparent' />";
    flashStr+="<param name='menu' value='true' />";


    flashStr+="<embed src='../images/event/061107/event3.swf'   wmode='transparent' flashVars='' menu='true'  quality='high' bgcolor='#ffffff' width='450' height='555' name='event3' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />";
		flashStr+=" </object>";





	// 플래시 코드 출력
	document.write(flashStr);
}

/* ------------------------------------------------------------------------------------------------------------------------------- */
/*----------------- 조이맥스의 common.js 의 내용 추가 시작----------------------------- */

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_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 JM_FamilySite(siteurl)
{
	var siteurl
	if (siteurl != "") {
		window.open(siteurl,"_blank", "");
	}
}


// 캐릭터명 변경 팝업창
function UserCharCng()
{
	var iMyWidth;
	var iMyHeight;
	
	iMyWidth = (window.screen.width/2) - (200 + 10);
	iMyHeight = (window.screen.height/2) - (160 + 50);
	
	urlstr = "http://www.joymax.com/silkroad/silkroad_front.jmx?workURL=http://silkroadcp.joymax.com/member/uname/ucharid.asp"
	var winpop = window.open(urlstr,"UserCC","width=441,height=302,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",status=no,scrollbars=no,directories=no,menubar=no,toolbar=no,resizable=no");
	winpop.focus();
}

// 아바타 변경 팝업창
function UserAvatarCng()
{
	var width_ = 600;
	var height_ = 520;
	var left_ = screen.width;
	var top_ = screen.height;

	left_ = left_/2 - (width_/2);
	top_ = top_/2 - (height_/2);
	
	urlstr = "http://www.joymax.com/silkroad/silkroad_front.jmx?workURL=http://silkroadcp.joymax.com/member/avatar/avatarcng.asp"
	var winpop = window.open(urlstr, "AvatarCng", "width="+ width_ +", height="+ height_ +", top="+ top_ +", left="+ left_ +", resizable=0, fullscreen=0, scrollbars=0, directories=0, menubar=0, toolbar=0");
	winpop.focus();
}

// 실크 충전 팝업창
function SilkChargeGO()
{
	var width_ = 400;
	var height_ = 458;
	var left_ = screen.width;
	var top_ = screen.height;

	left_ = left_/2 - (width_/2);
	top_ = top_/2 - (height_/2);

	var GoUrl = "/itemmall/silkcharge_goods.asp"
	window.open(GoUrl, "silkcharge", "width="+ width_ +", height="+ height_ +", top="+ top_ +", left="+ left_ +", resizable=0, fullscreen=0, scrollbars=0, directories=0, menubar=0, toolbar=0");
}


// *** 이올라스 건으로 패치된 외부 컨트롤 사용 스크립트, 두 가지 방식 중에 택일하여 사용
// s: source url
// d: flash id -> 사용안함 (function mf(s,d,w,h,t)  -> width="+w+" height="+h+" id="+d+">)
// w: source width
// h: source height
// t: wmode ("" for none, transparent, opaque ...)
//function mf(s,w,h,t){
        //return "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" width="+w+" height="+h+"><param name=wmode value="+t+" /><param name=movie value="+s+" /><param name=quality value=high /><embed src="+s+" quality=high wmode="+t+" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?p1_prod_version=shockwaveflash\" width="+w+" height="+h+"></embed></object>";
//}

function mf(s,w,h,t){
	var wh_length = s.length
	var sc_length = wh_length - 3
	var filep = s.substring(wh_length, sc_length)

	if(filep == 'swf') {
		return "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" width="+w+" height="+h+"><param name=wmode value="+t+" /><param name=movie value="+s+" /><param name=quality value=high /><embed src="+s+" quality=high wmode="+t+" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?p1_prod_version=shockwaveflash\" width="+w+" height="+h+"></embed></object>";
	}
	else {
		return "<object classid=\"clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95\" codebase=\"http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701\" width="+w+" height="+h+"><param name=filename value="+s+" /><param name=quality value=high /></object>";
	}
}

// write document contents
function flashview(src){
	document.write(src);
}

// assign code innerHTML
function setcode(target, code){
	target.innerHTML = code;
}

/*----------------- 조이맥스의 common.js 의 내용 추가 끝----------------------------- */
/* ------------------------------------------------------------------------------------------------------------------------------- */

