/*=======================================================================================================================
 * 
 * NXTS : NeXon Total Search
 *
 * ¿ÜºÎ ÇÔ¼ö ¹× º¯¼ö
 *
 *=======================================================================================================================*/

var strNXTS_SearchURL = "http://search.nexon.com/Nx/Page/"
var strNXTS_SearchURL_GameChannel = "http://channel.nexon.com/Nx/Page/"
var strNXTS_SearchBanURL = strNXTS_SearchURL + "Gnx.aspx?URL=Search/NxBanWord";

/*
  : °øÅë ÆÄ¶ó¹ÌÅÍ ¼³¸í
	strSearchTextBoxID  				: °Ë»ö¾î ÀÔ·ÂÇÑ TextBox ÆûÀÇ ID , ex) <input type='text' id='xxxx'> ÀÏ¶§ xxxx
	strSearchCategorySelectBoxID		: °Ë»öÄ«Å×°í¸® SelectBoxÆûÀÇ ID
	strCategory							: °Ë»öÄ«Å×°í¸®¿¡ µé¾î°¥ ½ºÆ®¸µ. (TOTAL, GAMEWEB, GAMECHANNEL ~~~~)
	isPopup								: PopupÀ¸·Î ¶ç¿ï °ÍÀÎÁö ¿©ºÎ
	strPopupStyle						: PopupÀ¸·Î ¶ç¿ï Stype ex) 'toolbar=no,location=no,scrollbars=no,resizable=no,width=360,height=400'
	strLogParam							: ·Î±×³²±æ¶§ »ç¿ëÇÏ±â À§ÇÑ ÆÄ¶ó¹ÌÅÍ "a=b" ÇüÅÂ·Î ÀÛ¼º
*/


/* ¿ë         µµ : ³Ø½¼´ÚÄÄGNB¿ë¿¡ µé¾î°¡´Â ÅëÇÕ°Ë»ö ÇÔ¼ö
 *
 * strLogParam   : "SearchPosition=searchGNB"
 */
function submitSearch_GNB( strSearchTextBoxID , isPopup , strPopupStyle, strLogParam )
{
	return submitSearch_Category( strSearchTextBoxID , "TOTAL" , isPopup , strPopupStyle, strLogParam );
}


/* ¿ë         µµ : °ÔÀÓGNB¿ë¿¡ µé¾î°¡´Â ÅëÇÕ°Ë»ö ÇÔ¼ö
 *
 * strLogParam   : "SearchPosition=searchGNBgame"
 */
function submitSearch_GNBGame( strSearchTextBoxID , strCategory , isPopup , strPopupStyle, strLogParam )
{
	return submitSearch_Category( strSearchTextBoxID , strCategory , isPopup , strPopupStyle, strLogParam);
}

/* ¿ë         µµ : Æ¯Á¤ °ÔÀÓ ½ÎÀÌÆ®¿¡ µé¾î°¡´Â ÅëÇÕ°Ë»ö ÇÔ¼ö
 *
 * strLogParam   : "SearchPosition=searchGNBgame"
 */
function submitSearch_GameWebSite( strSearchTextBoxID , strCategory , isPopup , strPopupStyle, maskGameCode )
{
	if ( !NXTS_isCheckValidation_SearchText( strSearchTextBoxID , isPopup, strPopupStyle, '', '') )
		return false;
	return submitSearch_Category( strSearchTextBoxID , strCategory , isPopup , strPopupStyle, "Nxs_maskGameCode=" + maskGameCode + NXTS_GetLogParam_FromMaskGameCode(maskGameCode));
}


/* ¿ë         µµ : ³Ø½¼¸ÞÀÎÆäÀÌÁö(Home/Index)ÀÇ ÅëÇÕ°Ë»ö ÇÔ¼ö
 *                 °Ë»ö¾î TextBox¿Í Ä«Å×°í¸® SelectBox °ªÀ¸·Î ¸µÅ©ÁÖ¼Ò ¸¸µë
 *
 * strLogParam   : "SearchPosition=nxmain"
 */
function submitSearch_NxcomMain( strSearchTextBoxID , strSearchCategorySelectBoxID, isPopup , strPopupStyle)
{
	if ( !NXTS_isCheckValidation_SearchMDEP( strSearchCategorySelectBoxID ) )
		return false;
	
	var strPath = NXTS_GetPath_FromMDEP( strSearchCategorySelectBoxID );
	if ( strPath == '' ) 
		return false;
	
	if ( !NXTS_isExistForm(strSearchTextBoxID ) )
		return false;

	var objSearchTextBox = eval ( "document.all." + strSearchTextBoxID );
	var strText = objSearchTextBox.value;

	var strLinkURL_WhenNoneSearchText = strNXTS_SearchURL + "Gnx.aspx?URL=" + NXTS_GetDetailPath_FromPath_String(strPath) + "&SearchPosition=nxmain";
	var strLinkURL_WhenRestrictWord   = strNXTS_SearchBanURL + "&SearchPosition=nxmain";
	
	if ( !NXTS_isCheckValidation_SearchText( strSearchTextBoxID , isPopup, strPopupStyle, strLinkURL_WhenNoneSearchText, strLinkURL_WhenRestrictWord) )
		return false;
		
	var strURL = strNXTS_SearchURL + "Gnx.aspx?URL=" + strPath + "&Nxs_strSearchText=" + NXTS_GetValue_SearchText( strSearchTextBoxID ) + "&SearchPosition=nxmain";
	
	return DoSubmit_TotalSearch( strURL , isPopup , strPopupStyle );
}


/* ¿ë         µµ : °ÔÀÓÃ¤³Î¿¡ µé¾î°¡´Â ¿À¸¥ÂÊ ÅëÇÕ°Ë»ö¼½¼ÇÀÇ ÅëÇÕ°Ë»ö ÇÔ¼ö
 *                 °Ë»ö¾î TextBox¸¸ »ç¿ëÇÔ
 *
 * strLogParam   : "SearchPosition=nxgamechannel_bar"
 */
function submitSearch_GameChannel( strSearchTextBoxID )
{
	if ( !NXTS_isCheckValidation_SearchText( strSearchTextBoxID, '','','',strNXTS_SearchBanURL ) )
		return false;	

	var strURL = strNXTS_SearchURL_GameChannel + "Gnx.aspx?URL=GameChannel/TagSearch&Nxs_strSearchText=" + NXTS_GetValue_SearchText( strSearchTextBoxID ) + "&SearchPosition=nxgamechannel_bar";

	return DoSubmit_TotalSearch( strURL , false , '' );
}


/*=======================================================================================================================
 * 
 * NXTS : NeXon Total Search
 *
 * ³»ºÎ ÇÔ¼ö
 *
 *=======================================================================================================================*/

/*--------------------------------------------------------------------------------------------
 * °øÅë
 *--------------------------------------------------------------------------------------------

/* ¿ë         µµ : °Ë»ö¾î TextBox ¿Í, String Ä«Å×°í¸®°ªÀ¸·Î ¸µÅ©
 *
 * strLogParam   : °ªÀÌ ÀÖÀ¸¸é.. "&" ºÙ¿©¼­ URL¿¡ Ãß°¡ÇÔ
 * strCategory   : "TOTAL" Ã³·³ »ç¿ë
 */
function submitSearch_Category( strSearchTextBoxID , strCategory , isPopup , strPopupStyle, strLogParam)
{
	var strPath = NXTS_GetPath_FromMDEP_String( strCategory );
	if ( strPath == '' )
	{
		alert('ÅëÇÕ°Ë»ö Ä«Å×°í¸® °ªÀÌ ¾ø½À´Ï´Ù');
		return false;
	}

	var strLogParamText = "";
	if ( NXTS_IsParamUsed(strLogParam) )//·Î±× Ã³¸®
		strLogParamText = "&" + strLogParam;
	
	var strLinkURL_WhenNoneSearchText = strNXTS_SearchURL + "Gnx.aspx?URL=" + NXTS_GetDetailPath_FromPath_String(strPath) + strLogParamText;
	var strLinkURL_WhenRestrictWord   = strNXTS_SearchBanURL;
	if ( !NXTS_isCheckValidation_SearchText( strSearchTextBoxID, isPopup, strPopupStyle, strLinkURL_WhenNoneSearchText, strLinkURL_WhenRestrictWord ) )
		return false;

	var strURL = strNXTS_SearchURL + "Gnx.aspx?URL=" + strPath + "&Nxs_strSearchText=" + NXTS_GetValue_SearchText( strSearchTextBoxID ) + strLogParamText;

	return DoSubmit_TotalSearch( strURL , isPopup , strPopupStyle );
}


/* ¿ë         µµ : ½ÇÁ¦ ÆË¾÷ÀÌ³ª ÀÌµ¿ÇÒ ¶§ »ç¿ëÇÏ´Â ÇÔ¼ö (Á¤»óÀûÀÎ °Ë»öÁ¶°Ç¿¡ °Ë»ö¾î¸é, ¸¶Áö¸·¿¡ ÀÌ°ÍÀ» Å½ )
 */
function DoSubmit_TotalSearch( strURL , isPopup , strPopupStyle )
{
	if ( !NXTS_IsParamUsed(isPopup) || isPopup == false )
	{
		top.location.href = strURL;
	}
	else
	{
		if ( NXTS_IsParamUsed(strPopupStyle) )
			window.open( strURL, 'TotalSearchPopup', strPopupStyle );
		else
			window.open( strURL, 'TotalSearchPopup');
	}
	return true;
}

/* ¿ë         µµ : ÆûÀÌ Á¸Àç ÇÏ´ÂÁö È®ÀÎ
 */
function NXTS_isExistForm( strFormID )
{
	var objSearchTextBox = eval ( "document.all." + strFormID );
	if ( objSearchTextBox != '[object]' )
	{
		alert( "formÀ» Ã£À» ¼ö ¾ø½À´Ï´Ù." );
		return false;
	}
	return true;
}


/*--------------------------------------------------------------------------------------------
 * °Ë»ö¾î Ã³¸®
 *--------------------------------------------------------------------------------------------*/

/* ¿ë         µµ : °Ë»ö¾î°¡ À¯È¿¼º °Ë»ç ¹× Ã³¸®
 *                 ±ÝÄ¢¾î Ã³¸® Æ÷ÇÔ
 *                 °Ë»ö¾î°¡ ¾øÀ» ¶§, PopupÀ» ¶ç¿ì°Å³ª ÀÌµ¿À» ÇÏµµ·Ï ±â´É Ãß°¡¸¦ ÇØ¼­ ÆÄ¶ó¹ÌÅÍ°¡ ¸¹´Ù. T_T 
 *
 * strFormID     : TextBox id °ª
 * isPopup       : strRedirectURLÀÌ ÀÖ´Â °æ¿ì, ÆË¾÷À¸·Î ¶ç¿î´Ù.
 * strPopupStyle : isPopupÀÌ ÀÖ´Â °æ¿ì, ÆË¾÷À¸·Î ¶ç¿î´Ù.
 * strLinkURL_WhenNoneSearchText : °Ë»ö¾î°¡ ¾øÀ» °æ¿ì URL
 * strLinkURL_WhenRestrictWord   : ±ÝÄ¢¾îÀÏ °æ¿ì °æ¿ì URL
 */
function NXTS_isCheckValidation_SearchText( strFormID , isPopup, strPopupStyle, strLinkURL_WhenNoneSearchText, strLinkURL_WhenRestrictWord)
{
	if ( !NXTS_isExistForm(strFormID ) )
		return false;

	var objSearchTextBox = eval ( "document.all." + strFormID );
	var strText = objSearchTextBox.value;
	if ( strText == "" )
	{
		if ( NXTS_IsParamUsed(strLinkURL_WhenNoneSearchText) )
		{
			DoSubmit_TotalSearch( strLinkURL_WhenNoneSearchText , isPopup , strPopupStyle );
		}
		else
		{
			alert( "°Ë»ö¾î¸¦ ÀÔ·ÂÇÏ¼¼¿ä" );
		}
		return false;
	}

	///////////////////////////////////////////////////
	// ±ÝÄ¢¾î Ã³¸®	=> ÅëÇÕ°Ë»ö ÆäÀÌÁö¿¡¼­ ÇÏ±â·Î º¯°æ
	
	/*if( strText.length > 0 && GnxRestrictWords.HasBanWords( strText, 65536 ) )
	//{
	//	alert( '\n°Ë»ö¾î¿¡ ±ÝÁö¾î°¡ Æ÷ÇÔµÇ¾î ÀÖ½À´Ï´Ù.    \n\nÇØ´ç ±ÝÁö¾î¸¦ ¼öÁ¤/»èÁ¦ÇÏ¼Å¾ß °Ë»öÀÌ °¡´ÉÇÕ´Ï´Ù.   ' );
	//	return false;
	//}

    if( strText.length > 0 && GnxRestrictWords.IsReservedID( strText, 268632064 ) )
    {
		if ( NXTS_IsParamUsed(strLinkURL_WhenRestrictWord) )
		{
			DoSubmit_TotalSearch( strLinkURL_WhenRestrictWord , isPopup , strPopupStyle );
		}
		else
		{
			alert( '\n°Ë»ö¾î¿¡ ±ÝÁö¾î°¡ Æ÷ÇÔµÇ¾î ÀÖ½À´Ï´Ù.    \n\nÇØ´ç ±ÝÁö¾î¸¦ ¼öÁ¤/»èÁ¦ÇÏ¼Å¾ß °Ë»öÀÌ °¡´ÉÇÕ´Ï´Ù.   ' );
		}
	    return false;
    }
    */
	// ±ÝÄ¢¾î Ã³Ã³¸® ]
	////////////////////////////////////////////////////
	
	return true;
}

/* °Ë»ö¾î °¡Á®¿À±â */
function NXTS_GetValue_SearchText( strFormID )
{
	var objSearchTextBox = eval ( "document.all." + strFormID );
	return objSearchTextBox.value;
}

/* ÇÔ¼ö ÆÄ¸®¹ÌÅÍ·Î °ªÀÌ µé¾î ¿Ô´ÂÁö È®ÀÎ */
function NXTS_IsParamUsed( strValue )
{
	if ( strValue != null && strValue != "undefined" && strValue != "")
		return true;
	else
		return false;
}


/*--------------------------------------------------------------------------------------------
 * Ä«Å×°í¸® (MDEP) Ã³¸®
 *--------------------------------------------------------------------------------------------
/* Ä«Å×°í¸®°ª Ã¼Å© 
	"TOTAL",		"ÅëÇÕ°Ë»ö"
	"GAMEWEB",		"°ÔÀÓÀ¥°Ë»ö"  
	"GAMECHANNEL",	"°ÔÀÓÃ¤³Î°Ë»ö"
	"GUILD",		"±æµåÅëÇÕ°Ë»ö"    
	"GUILDWEB",		"±æµå°Ô½Ã¹°°Ë»ö"    
	"WEB",			"À¥ÆäÀÌÁö°Ë»ö"
*/
function NXTS_isCheckValidation_SearchMDEP( strFormID )
{
	if ( !NXTS_isExistForm(strFormID ) )
		return false;

	var objSelectBox = eval ( "document.all." + strFormID );
	var strValue = objSelectBox.value;
	if ( strValue == "TOTAL" || strValue == "GAMEWEB" || strValue == "GAMECHANNEL" || strValue == "GUILD" || strValue == "WEB" || strValue == "GUILDWEB")
	{
		return true;
	}

    alert( '\n¾Ë ¼ö ¾ø´Â Ä«Å×°í¸® °ªÀÔ´Ï´Ù.' );
    return false;
}

/* MDEP ÄÚµå°ª¿¡ µû¸¥ Path °ª °¡Á®¿À±â ex) Search/NxTotal */
function NXTS_GetPath_FromMDEP( strFormID )
{
	if ( !NXTS_isExistForm(strFormID ) )
		return '';

	var objSelectBox = eval ( "document.all." + strFormID );
	var strValue = objSelectBox.value;
	
	return NXTS_GetPath_FromMDEP_String(strValue);
}

/* MDEP ÄÚµå°ª¿¡ µû¸¥ Path °ª °¡Á®¿À±â ex) Search/NxTotal */
function NXTS_GetPath_FromMDEP_String( strString )
{
	//SearchPosition´Â ·Î±× ¶§¹®
	if ( strString == "TOTAL" )				return 'Search/NxTotal';
	else if( strString == "GAMEWEB" )		return 'Search/NxGameWebTotal';
	else if( strString == "GAMEWEBONE" )		return 'Search/NxGameWeb';
	else if( strString == "GAMECHANNEL" )	return 'Search/NxGameChannel';
	else if( strString == "GUILD" )			return 'Search/NxGuildTotal';
	else if( strString == "GUILDWEB" )		return 'Search/NxGuildWeb&Nxs_strGuildSection=GDBD';
	else if( strString == "WEB")			return 'Search/OpenApiWebKr';

    alert( '\n¾Ë ¼ö ¾ø´Â Ä«Å×°í¸® °ªÀÔ´Ï´Ù.' );
    return '';
}

/* MDEP ÄÚµå°ª¿¡ µû¸¥ Path °ª °¡Á®¿À±â ex) Search/NxTotal */
function NXTS_GetDetailPath_FromPath_String( strString )
{
	//SearchPosition´Â ·Î±× ¶§¹®
	if ( strString == "Search/NxTotal" )				return 'Search/NxTotalDetail';
	else if( strString == "Search/NxGameWebTotal" )		return 'Search/NxGameWebDetail';
	else if( strString == "Search/NxGameWeb" )		return 'Search/NxGameWebDetail';
	else if( strString == "Search/NxGameChannel" )	return 'Search/NxGameChannelDetail';
	else if( strString == "Search/NxGuildTotal" )			return 'Search/NxGuildDetail';
	else if( strString == "Search/NxGuildWeb&Nxs_strGuildSection=GDBD" )		return 'Search/NxGuildDetail';
	else if( strString == "Search/OpenApiWebKr")			return 'Search/OpenApiWebKrDetail';

    alert( '\n¾Ë ¼ö ¾ø´Â Path °ªÀÔ´Ï´Ù.' );
    return '';
}

/* maskGameCode °ª¿¡ µû¶ó, ÆÄ¶ó¹ÌÅÍ Ãß°¡(for ·Î±×) ( */
function NXTS_GetLogParam_FromMaskGameCode( maskGameCode )
{
	//SearchPosition´Â ·Î±× ¶§¹®
	if ( maskGameCode == "94213" )				return '&SearchPosition=lunia_search';
  return '';
}


