// ÆË¾÷Ã¢ ¶ç¿ì±â
function openPopupWindow(URL, winWidth, winHeight)
{
	if ( !winWidth || typeof(winWidth) == 'undefined' )
      var winWidth = 300;
    if ( !winHeight || typeof(winHeight) == 'undefined' )
      var winHeight = 220;
      
    var win = null;
	var winl = (screen.width - winWidth) / 2;
	var wint = (screen.height - winHeight) / 2;
	var settings  ='height='+winHeight+',';
		settings +='width='+winWidth+',';
		settings +='top='+wint+',';
		settings +='left='+winl+',';
		settings +='resizable=no';
		win = window.open(URL, "PopupPage", settings);
	
	if ( parseInt(navigator.appVersion) >= 4 )
		win.window.focus();
}

// ¾ËÆÄ¼ýÀÚÇü½ÄÀÎÁö Ã¼Å©
function isAlphaNumCheck ( strEmail )
{
	//var emailfilter = /^(\w+(?:\.\w+)*)@((?:\w+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i ; ±âÁ¸ Á¤±Ô½Ä
	var emailfilter = /^[A-Za-z0-9]{4,50}$/i; // ¸ðµç ¾ËÆÄºª°ú ¼ýÀÚ
	
	if ( emailfilter.test(strEmail) )
		return true;
	else
		return false;	
}

// ÀÌ¸ÞÀÏÇü½ÄÀÎÁö Ã¼Å©
function isEmailCheck ( strEmail )
{
	//var emailfilter = /^(\w+(?:\.\w+)*)@((?:\w+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i ; ±âÁ¸ Á¤±Ô½Ä
	var emailfilter = /@/;
	
	if ( emailfilter.test(strEmail) )
		return true;
	else
		return false;	
}

// ÀÌ¸ÞÀÏ Çü½Ä¿¡ ¸Â´ÂÁö Ã¼Å©
function isEmail( strEmail )
{
	//var emailfilter = /^(\w+(?:\.\w+)*)@((?:\w+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i ; ±âÁ¸ Á¤±Ô½Ä
	var emailfilter = /^((?:(?:(?:[a-zA-Z0-9][\.\-\+_]?)*)[a-zA-Z0-9])+)\@((?:(?:(?:[a-zA-Z0-9][\.\-_]?){0,62})[a-zA-Z0-9])+)\.([a-zA-Z0-9]{2,6})$/i;
	
	if ( strEmail == "" )
		return false;
	else if ( !emailfilter.test(strEmail) )
		return false;
	
	return true;
}

// µµ¸ÞÀÎ Çü½Ä¿¡ ºÎÇÕÇÏ´ÂÁö Ã¼Å©
function checkDetailUrl(strUrl) 
{
    //var expUrl = /^(http\:\/\/)?((\w+)[.])+(asia|biz|cc|cn|com|de|eu|in|info|jobs|jp|kr|mobi|mx|name|net|nz|org|travel|tv|tw|uk|us)(\/(\w*))*$/i;
    var expUrl = /(http\:\/\/)?((\w+)[.])+(asia|biz|cc|cn|com|de|eu|in|info|jobs|jp|kr|mobi|mx|name|net|nz|org|travel|tv|ro|gg|tw|uk|us)(\/(\w*))*/i;
    return expUrl.test(strUrl);
    // Á¦¸ñ¶õ¿¡ µµ¸ÞÀÎÀº ÀÔ·ÂÇÏ½Ç ¼ö ¾ø½À´Ï´Ù.

}



function isAlphaNum( input ) 
{
	if ( isAlphabet(input) )
	{
		if ( isNumber(input) )
		{
			return false;
		}
		else
		{
			return true;
		}
	}
	else
	{
		return true;
	}
}

function isAlphabet( input ) 
{
    var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
    return containsChars( input, chars );
}

function isNumber( input ) 
{
    var chars = "0123456789";
    return containsChars(input,chars);
}

function containsChars( input, chars ) 
{
    for ( var inx = 0; inx < input.value.length; inx++ ) 
    {
       if ( chars.indexOf(input.value.charAt(inx)) != -1 )
		   return true;
    }
    
    return false;
}




// Áßº¹µÇÁö ¾ÊÀº ¸ÞÀÏ ÁÖ¼Ò¸¦ »ç¿ëÇÔ
function useThisEmail( intType )
{
	//intType = ( typeof( intType ) == "undefined" ) ? 0 : intType;
	//Type) 0 = È¸¿ø°¡ÀÔ / 1 = °èÁ¤Á¤º¸º¯°æ / 2 = 2Â÷ ºñ¹øº¯°æ
	
	var objPopEmail = "";      // ÆË¾÷Ã¢ÀÇ ÀÌ¸ÞÀÏ ÁÖ¼Ò ¹Ú½º
	var objOrgEmail = "";      // ¿øº» ÆäÀÌÁöÀÇ ÀÌ¸ÞÀÏ ÁÖ¼Ò ¹Ú½º
	
	if ( intType == "0" )
	{
		objPopEmail = document.all[ "useEmail" ];
		objOrgEmail = opener.document.all[ "G_gnxMapleAccountCreateContainer_g_txtEmail" ];
	}
	else if ( intType == "1" )
	{
		objPopEmail = document.all[ "useEmail" ];
		objOrgEmail = opener.document.all[ "G_gnxMapleChangeAccountInfoContainer_g_txtEmail" ];
	}
	else if ( intType == "2" )
	{
		objPopEmail = document.all[ "useEmail" ];
		objOrgEmail = opener.document.all[ "G_gnxMapleChange2ndPasswordContainer_g_txtEmail" ];
		
	}
	else
	{
		return
	}
	
	objOrgEmail.value = objPopEmail.innerHTML;
	self.close();

}

function LogoutPopup()
{
    if ( document.mxconn )
	{
		try
		{
			//alert('¼öÇàµÊ');
			//con = parent.frmTop.mxconn;
			con = document.mxconn;
			con.ResetCookie();
		}
		catch (ex)
		{
		
		}
		
	}	
}

function getCookies(nameVal) 
{
	var numCookie = document.cookie.length;
	var oven = document.cookie.split( "; " );
	for ( var i = 0; i < oven.length; i++ ) 
	{
		if(oven[i].indexOf("=") != -1) 
			cookieName = oven[i].substring(0,oven[i].indexOf("="))
		else 
			cookieName = oven[i]
		
		if(cookieName == nameVal) 
		{
			if(oven[i].indexOf("=") != -1) 
				cookieVal = oven[i].substr(oven[i].indexOf("=")+1)
			else 
				cookieVal = ""
			
			return cookieVal
		}
	}
	return ""

}

function LogoutPopup()
{
    /*
    if ( document.mxconn )
	{
		try
		{
			con = document.mxconn;
			con.ResetCookie();
		}
		catch (ex)
		{
		
		}
		
	}
	*/	
}

function LogoutPopupT()
{
    if ( document.mxconnt )
	{
		try
		{
			con = document.mxconnt;
			con.ResetCookie();
		}
		catch (ex)
		{
		
		}
		
	}	
}

// ¸ÞÀÌÇÃ ¾ÆÀÌµðÃ£±â ÆË¾÷
function popFindMapleID()
{
	window.open( 'Gnx.aspx?URL=HelpDesk/POP_MemberInfoSearch', 'SearchMapleID', 'scrollbars=no, resizable=no, width=550, height=550' );
}

// °ÔÀÓ °èÁ¤ °¡ÀÔ ÆË¾÷
function popJoinMapleID()
{
	window.open( 'Gnx.aspx?URL=HelpDesk/POP_MemberJoinStep01', 'JoinMapleID', 'scrollbars=no, resizable=no, width=550, height=580' );
}

function func_itcg()
{
	window.open( 'http://itcg.maplestory.nexon.com/ITCG2/Page/Gnx.aspx?URL=Home/Main', 'ITCG', 'scrollbars=no, resizable=no, width=1000, height=695' ); 
}

function func_myfamily_common( wid, cid )
{	
	
	if ( getCookies( "MIL" ) == "1" )
	{
		//alert( wid );
		//alert( cid );
		
		var win1 = window.open( 'http://maplestory.nexon.com/MapleStory/Page/Gnx.aspx?URL=Plaza/FamilyTree&WorldID=' + wid + '&CharacterID=' + cid, "winFamily", 'top=0, left=0, status=yes, scrollbars=yes, width=' + screen.width + ', height=' + screen.height + '' );
		win1.focus(); 		
	}
	else
	{
		alert( '·Î±×ÀÎ ÈÄ ÀÌ¿ëÇØÁÖ¼¼¿ä' );
	}
}


function func_security()
{
	window.open( 'http://security.maplestory.nexon.com/default.aspx?URL=home/index', 'main', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizeable=no,copyhistory=no, width=1010, height=713' ); 
}

function func_security_board(valueoid,valuearticle)
{
	if ( valueoid == 184549383 )
	{
		window.open( 'http://security.maplestory.nexon.com/default.aspx?URL=sub01/board&MaskPageType=2&oidArticle='+valuearticle, 'main', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizeable=no,copyhistory=no, width=1010, height=713' ); 
	}
	else if( valueoid == 184549384 )
	{
		window.open( 'http://security.maplestory.nexon.com/default.aspx?URL=sub02/board&MaskPageType=2&oidArticle='+valuearticle, 'main', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizeable=no,copyhistory=no, width=1010, height=713' ); 
	}
	else if( valueoid == 184549385 )
	{
		window.open( 'http://security.maplestory.nexon.com/default.aspx?URL=sub04/imageboard&MaskPageType=2&oidArticle='+valuearticle, 'main', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizeable=no,copyhistory=no, width=1010, height=713' ); 
	}
	else if( valueoid == 184549386 )
	{
		window.open( 'http://security.maplestory.nexon.com/default.aspx?URL=sub04/board&MaskPageType=2&oidArticle='+valuearticle, 'main', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizeable=no,copyhistory=no, width=1010, height=713' ); 
	}
}

function goCygnus()
{
	var win1 = window.open( "http://cygnus.maplestory.nexon.com/MapleStory/Page/Gnx.aspx?URL=Cygnus/Main", "winCygnus", 'top=0, left=0, status=yes, scrollbars=yes, width=' + screen.width + ', height=' + screen.height + '' );
	//var win1 = window.open( "http://cygnus.maplestory.nexon.com/MapleStory/Page/Gnx.aspx?URL=Cygnus/Main", "winCygnus", 'top=0, left=0, status=yes, width=' + screen.width + ', height=' + screen.height + '' );
	win1.focus(); 		
}

function goEventURL(strURL, popWidth, popHeight)
{
    var win1;
    
    win1 = window.open( strURL, "win1", "top=0, left=0, status=yes, scrollbars=yes, width=" + popWidth + ", height=" + popHeight );

	win1.focus(); 		    
	self.close();
}


function goEventList()
{
	var winEventList = window.open( 'Gnx.aspx?URL=Event/POP_EventList', 'win5', 'top=0, width=550, height=450' );
	winEventList.focus(); 		    
}

function Apply01()
{
   var selCnt = 0;
   var ans = 0;

   for ( var i = 0; i < document.all.rdoQ1.length; i++ )
   {
      if ( document.all.rdoQ1[i].checked == true )
      {
	 selCnt++;
         ans = document.all.rdoQ1[i].value;
      }
   }

   if ( selCnt == 0 )
   {
      alert( '´äÀ» ¼±ÅÃÇØÁÖ¼¼¿ä' );
      return false;
   }

   window.open( 'http://maplestory.nexon.com/MapleStory/Page/Gnx.aspx?URL=Event/Itcg/Event090813&num=1&ans=' + ans, 'evtItcg', 'width=394, height=179' );
}

function Apply02()
{
   var selCnt = 0;
   var ans = 0;

   for ( var i = 0; i < document.all.rdoQ2.length; i++ )
   {
      if ( document.all.rdoQ2[i].checked == true )
      {
	 selCnt++;
         ans = document.all.rdoQ2[i].value;
      }
   }

   if ( selCnt == 0 )
   {
      alert( '´äÀ» ¼±ÅÃÇØÁÖ¼¼¿ä' );
      return false;
   }

   window.open( 'http://maplestory.nexon.com/MapleStory/Page/Gnx.aspx?URL=Event/Itcg/Event090813&num=2&ans=' + ans, 'evtItcg', 'width=394, height=179' );
}
