﻿//window.onload = function(){
//    // IE6이하 배경짤림 보완
//	if(navigator.userAgent.indexOf("MSIE 6")>0 && navigator.userAgent.indexOf("MSIE 7")<0){
//       fnWrapResize();
//    }
//    
//    if (!document.getElementById("Gate_News")) return false;
//	if (!document.getElementById("news_prev")) return false;
//	if (!document.getElementById("news_next")) return false;
//	newsObj = document.getElementById("Gate_News");
//	prevObj = document.getElementById("news_prev");
//	nextObj = document.getElementById("news_next");
//	childCnt = 0;
//	activeCnt = 0;
//	newsArray = new Array();
//	for (i=0; i<newsObj.childNodes.length; i++){
//		if (newsObj.childNodes[i].nodeName.toUpperCase() == "UL"){
//			newsArray[childCnt] = i;
//			childCnt += 1;
//			if (childCnt == 1){
//				newsObj.childNodes[i].style.display = "block";
//				activeCnt = childCnt;
//			}
//			newsObj.childNodes[i].getElementsByTagName("LI")[newsObj.childNodes[i].getElementsByTagName("LI").length-1].className = "end";
//			//end : border = none
//		}
//	}
//	if (childCnt <= 1) nextObj.src = nextObj.src.replace("_on.gif",".gif");
//	prevObj.onclick = function(){fnNewsShow("prev");}
//	nextObj.onclick = function(){fnNewsShow("next");}
//}

function fnNewsShow(e){
	newsObj.childNodes[newsArray[activeCnt-1]].style.display = "none";
	if (e == "prev" && activeCnt > 1) activeCnt -= 1;
	if (e == "next" && activeCnt < childCnt) activeCnt += 1;
	newsObj.childNodes[newsArray[activeCnt-1]].style.display = "block";
	if (prevObj.src.indexOf("_on.gif") != -1) prevObj.src = prevObj.src.replace("_on.gif",".gif");
	if (nextObj.src.indexOf("_on.gif") != -1) nextObj.src = nextObj.src.replace("_on.gif",".gif");
	if (activeCnt > 1) prevObj.src = prevObj.src.replace(".gif","_on.gif");
	if (activeCnt < childCnt) nextObj.src = nextObj.src.replace(".gif","_on.gif");
}

function fnLinkShow(){
	var idxObj = document.getElementById("family_idx");
	idxObj.style.display = "block";
	idxObj.onmouseover = function(){idxObj.style.display = "block";}
	idxObj.onmouseout = function(){idxObj.style.display = "none";}
}

function fnEmbedGateFlash(strNickName){
	var flaObj;
	flaObj = "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" width=\"990\" height=\"687\" id=\"Main_flash\">"+
				"<param name=\"allowScriptAccess\" value=\"sameDomain\" />"+
				"<param name=\"base\" value=\"/Swf/\" />"+
				"<param name=\"quality\" value=\"high\" />"+
				"<param name=\"wmode\" value=\"transparent\" />"+
				"<param name=\"movie\" value=\"/Swf/index.swf?xmlURL=/mainEvnetXml.aspx&login="+ strNickName +"\" />"+
				"<embed src=\"/Swf/index.swf?xmlURL=/mainEvnetXml.aspx&login="+ strNickName +"\" quality=\"high\" base=\"/Swf/\" wmode=\"transparent\" width=\"990\" height=\"687\" name=\"Main_flash\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />"+
				"</object>";
	document.write(flaObj);
}

function fnOpenPopup(strurl, strname, w, h) {
	window.open(strurl,strname,'width='+w+', height='+h+', scrollbars=0 ,toolbar=no, location=no, status=yes, resizable=no, top=0,left=0');
}


function fnValidateEmpty(objField, strMessage)
{
	var objReplace = objField.value.replace(/(^\s*)|(\s*$)/g, "");
	
	if (objReplace == "")
	{
		if (strMessage != "")
		{
			alert(strMessage);
			if(objField.type != "hidden")
				objField.focus();
		}
		objField.value = objReplace;
		return false;
	}
	
	return true;
}


function fnValidateSize(objField, strMessage, intSize, bitByte, bitCheck)
{
	var objReplace = objField.value.replace(/(^\s*)|(\s*$)/g, "");
	var intLength, intChrCode, strblnResult
	
	intLength = 0;
	
	if (bitByte)
	{
		for (var i=0; i<objReplace.length; i++)
		{
			intChrCode = objReplace.charCodeAt(i);
			if ((intChrCode>=0) && (intChrCode < 256))
				intLength ++;
			else
				intLength += 2;
		}
	}
	else
	{
		intLength = objReplace.length;
	}

	if (bitCheck == 1)
	{
		if (intLength > intSize)
			blnResult = true;
		else
			blnResult = false;
	}
	else
	{
		if (intLength < intSize)
			blnResult = true;
		else
			blnResult = false;
	}

	if (blnResult)
	{
		if (strMessage != "")
		{
			alert(strMessage);
			if(objField.type != "hidden")
				objField.focus();
		}
		objField.value = objReplace;
		return false;
	}
	
	return true;
}


function fnWindowResize(intWidth, intHeight){

    intWidth += 10;
    
    if (navigator.userAgent.indexOf("MSIE 7")>0) {
        intHeight += 22;
    } else if(navigator.userAgent.indexOf("Firefox") >0 ){
        intHeight += 0;
    } else {
        intHeight += 0;
    }
    
	window.resizeTo(intWidth, intHeight);
}



function raiseEnterAction(btn)
{
	if(event.keyCode == 13)
	{
		self.focus();
		document.all[btn].click();
		return false;
	}
	return true;
}


function fnIsNumeric(objNumber)
{
	var temp = new String(objNumber)
		
	if(temp.search(/\D/) != -1) 
	{
		return false;
	}
	
	return true;	
}

function fnGetCookie(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 "";
}


//글보기. 2007.08.29 권순용function fnMoveView(PageName, intSeq) {
	var frm = document.forms["form1"];

	if ( PageName.indexOf('?') >= 0) {
		PageName = PageName + "&iQ=" + intSeq;
	}
	else {
		PageName = PageName + "?iQ=" + intSeq;
	}

	frm.action = PageName;
	frm.submit();
}


function fnMainMoveView(intBoardKind, intSeq) {
	var frm = document.forms["form1"];

	if (intBoardKind == 6) {
		PageName = "/Community/GameHot/readGameHot.aspx?iQ=" + intSeq;
	}
	else if (intBoardKind == 7) {
		PageName = "/Community/ScreenShot/readScreen.aspx?iQ=" + intSeq;
	}
	else
	{
		PageName = "/Community/GameMov/readGameMov.aspx?iQ=" + intSeq;
	}

	frm.action = PageName;
	frm.submit();
}

// 리스트로 이동. 2007.07.24 권순용function fnGoList(PageName) {

	var frm = document.forms["form1"];
    frm.action = PageName;
	frm.submit();
}

function fnValidatePersonalNum(intSocialNo1, intSocialNo2)
{
	var intSocialNo = intSocialNo1 + intSocialNo2;
	var intCode = "234567892345";
	var intSum=0;

	//숫자여부 체크
	if(!fnIsNumeric(intSocialNo)) return false;
	
	//주민등록번호 체크
	if (intSocialNo.substring(2,3) > 1) return false;
	if (intSocialNo.substring(4,5) > 3) return false;
	if ( intSocialNo.substring(0,2) == '00') {
		//1800 년생은 뒷번호 첫번째 자리가 0, 9 사실상 1800년생이 살아 있을 확률은 없다.
		if( intSocialNo.substring(6,7) == 0 || intSocialNo.substring(6,7) == 9 ) {
			return false;
		}
		//1900 년생은 뒷번호 첫번째 자리가 1, 2 사실상 1900년생이 살아 있을 확률은 없다.
		else if( intSocialNo.substring(6,7) == 1 || intSocialNo.substring(6,7) == 2 )  {
			return false;
		}
		//2000 년생은 뒷번호 첫번째 자리가 3, 4
		else if( !( intSocialNo.substring(6,7) == 3 || intSocialNo.substring(6,7) == 4 ) ) {
			return false;
		}
	}
	
	if ( intSocialNo.substring(0,2) != '00' && ( intSocialNo.substring(6,7) > 4 || intSocialNo.substring(6,7) == 0 ) ) return false;
	
	for(var i=0; i < 13; i ++)
		intSum += intSocialNo.substr(i, 1) * intCode.substr(i,1);
	  
	intSum = 11 - (intSum % 11);
	  
	if(intSum == 10)
		intSum = 0;
	else if (intSum == 11)
		intSum = 1;
	
	if(intSocialNo.substr(12,1) == intSum)
		return true;
	else 
		return false;
}


function fnValidateLogin()
{
    alert("로그인 후 이용이 가능합니다.");
	return false;
}


 //날짜 비교(date 값 Month/Day 형태로 입력)
function fnCompareDate(dtmDate1, dtmDate2)
{
    var dtmM1, dtmM2;
	
    dtmM1 = eval(dtmDate1.substring(0, dtmDate1.indexOf("/")));
    dtmM2 = eval(dtmDate2.substring(0, dtmDate2.indexOf("/")));
	
    if(dtmM1 > dtmM2)
    {
	    return true;		//dtmDate1 > dtmDate2 
    }
    else if(dtmM1 < dtmM2)
    {
	    return false;	//dtmDate1 < dtmDate2
    }
    else
    {
	    var dtmD1, dtmD2;
		
	    dtmD1 = eval(dtmDate1.substring(dtmDate1.indexOf("/")+1));
	    dtmD2 = eval(dtmDate2.substring(dtmDate2.indexOf("/")+1));
		
	    if (dtmD1 >= dtmD2)
	    {
		    return true;		//dtmDate1 > dtmDate2
	    }
	    else
	    {
		    return false;	//dtmDate1 < dtmDate2
	    }
    }
}


// IE6이하 배경짤림 보완
//if(navigator.userAgent.indexOf("MSIE 6")>0 && navigator.userAgent.indexOf("MSIE 7")<0){
//    window.onresize = fnWrapResize;
//}

function fnWrapResize(){
    var objBody = document.body;
    var objWrap = document.getElementById("WZ_Gate");

    //너비 기본값 990 : SideBanner로 인한 사이즈 변경
    var objWidth = objBody.offsetWidth > 1400 ? objWrap.style.width = "100%" : objWrap.style.width = 1400 + "px"
    var objHeight = objBody.offsetHeight > 820 ? objWrap.style.width = "100%" : objWrap.style.width = 820 + "px"
    objWrap.style.width = objWidth;
    objWrap.style.height = objHeight;
 }

// 공백 제거 함수. 2007.07.24 권순용function trim(str) {
  return str.replace(/(^\s+)|(\s+)$/,"");
}

//메인 공지 영역 Over
function fnMainNewsListOver(ns){
	var overimg;
	overimg = ns.parentNode.firstChild.src;
	ns.parentNode.firstChild.src = overimg.replace('.gif','_on.gif');
	ns.onmouseout = function(){
		ns.parentNode.firstChild.src = overimg.replace('_on.gif','.gif');
	}
}


var fm_all = null;
var div = null;
var imgdiv = null;
var fm = null;

function coverScreen(strDivSrc){

	var h = parseInt(document.documentElement.scrollHeight )+ "px" ;
	var w = parseInt(document.body.offsetWidth) +"px" ;

	div = document.createElement("iframe");
	div.className = "imgview_back";
	div.style.top = "0px";
	div.style.left = "0px";
	div.style.width = w;
	div.style.height = h;
	div.style.position = "absolute";
	div.style.zIndex = 100;
	div.style.display = "none";
	div.frameBorder = "0";
	div.style.margin = "0";
	div.src = strDivSrc;

	document.body.appendChild( div );

	document.body.onresize = document.body.onresizestart = document.body.onresizeend = document.body.onscroll = function(){
		div.style.top = "0px";
		div.style.left = "0px";
		div.style.width = parseInt(document.body.offsetWidth) + 'px';
		div.style.height = parseInt(document.documentElement.scrollHeight)+"px" ;
		imgdiv.style.left = ( parseInt( document.documentElement.clientWidth ) / 2 ) - ( parseInt( imgdiv.style.width ) / 2 ) + 'px';
	}

	imgdiv =  document.createElement("div");
	imgdiv.style.width = 400;
	imgdiv.style.height = 400;
	imgdiv.style.left = ( parseInt( div.style.width ) / 2 ) - ( parseInt( imgdiv.style.width ) / 2 ) + 'px';
	imgdiv.style.top = ( parseInt( document.documentElement.clientHeight ) / 2 ) - ( parseInt( imgdiv.style.height ) / 2 ) + 'px';
	imgdiv.style.position = "absolute";
	imgdiv.style.zIndex = 101;
	imgdiv.style.display = "none";
	imgdiv.style.backgroundColor = "transparent";
	imgdiv.style.color = "#ffffff";
	document.body.appendChild( imgdiv );

	fm = document.createElement("iframe");
	fm.id = "iframe_pop";
	fm.style.width = "100%";
	fm.style.height = "100%";
	fm.allowTransparency = "true";
	fm.style.backgroundColor = "transparent";
	fm.frameBorder = "0";
	fm.style.margin = "0";
	imgdiv.appendChild( fm );
}

function fnPopViewImage(strurl) {
	showImg(1020, 623, "/_Common/popImageView.aspx?src="+strurl);
}

function showImg(_w , _h , _src){
	if(div == null){
		 coverScreen("/_HTML/imageViewLayerBack.html");
	 }
	imgdiv.style.width = _w + 'px';
	imgdiv.style.height = _h + 'px';
	imgdiv.style.left = ( parseInt( document.documentElement.clientWidth ) / 2 ) - ( parseInt( imgdiv.style.width ) / 2 ) + 'px';
	imgdiv.style.top = ((parseInt( document.documentElement.clientHeight ) / 2 ) + ( parseInt( document.documentElement.scrollTop ))) - (parseInt(_h)/2) + 'px';

	fm.src = _src;
	div.style.display = "block";
	imgdiv.style.display = "block";
}

function hideImg(){
	div.style.display = "none";
	imgdiv.style.display = "none";
	fm.src = "";
}

// 주민등록번호 (내,외국인 포함 처리)
function fhCheckResidentNo(varSno1, varSno2) {
    var sno = varSno1 + varSno2;
    var IDAdd = "234567892345";
    var iDot = 0;


    if (!fnIsNumeric(sno))
        return (false);


    if (sno.length != 13)
        return (false);


    if (sno.substring(6, 7) == 5 || sno.substring(6, 7) == 6) { //외국인 등록번호 체크
        if (sno.substring(7, 9) % 2 != 0) return (false);
        if ((sno.substring(11, 12) != 6) && (sno.substring(11, 12) != 7) && (sno.substring(11, 12) != 8) && (sno.substring(11, 12) != 9)) return (false);

        for (var i = 0; i < 13; i++)
            iDot += sno.substr(i, 1) * IDAdd.substr(i, 1);

        iDot = 11 - (iDot % 11);

        if (iDot >= 10) iDot -= 10;

        iDot += 2;

        if (iDot >= 10) iDot -= 10;

        if (sno.substr(12, 1) == iDot) {
            return (true);
        }
        else {
            return (false);
        }

    }
    else { //내국인 등록번호 체크
        if (sno.substring(2, 3) > 1) return (false);
        if (sno.substring(4, 5) > 3) return (false);
        if (sno.substring(0, 2) == '00' && (sno.substring(6, 7) != 0 || sno.substring(6, 7) != 9 || sno.substring(6, 7) != 3 || sno.substring(6, 7) != 4)) return (false);
        if (sno.substring(0, 2) != '00' && (sno.substring(6, 7) > 4 || sno.substring(6, 7) == 0)) return (false);

        for (var i = 0; i < 13; i++)
            iDot = iDot + sno.substr(i, 1) * IDAdd.substr(i, 1);

        iDot = 11 - (iDot % 11);

        if (iDot == 10) {
            iDot = 0;
        } else if (iDot == 11) {
            iDot = 1;
        }

        if (sno.substr(12, 1) == iDot) {
            return (true);
        } else {
            return (false);
        }
    }
}



function doPostBack(eventTarget, eventArgument) {

    var theform = document.frmMain;
    theform.__EVENTTARGET.value = eventTarget;
    theform.__EVENTARGUMENT.value = eventArgument;
    theform.submit();
}

function fnSetCookie(name, value) {
    var todayDate = new Date();
    todayDate.setDate(todayDate.getDate() + 1);
    document.cookie = name + "=" + escape(value) + ";path=/;expires=" + todayDate.toGMTString() + ";"
}

function fnGetCookie(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 "";
}
