function specialCharCheck(event) {
    var keyCode = event.keyCode;
    // Çã¿ëÇÒ ±â´É Ű: ¹é½ºÆäÀ̽º(8), ÅÇ(9), ¿£ÅÍ(13), ½ºÆäÀ̽º¹Ù(32), È»ìÇ¥ Ű(37-40) µî
    if (keyCode == 8 || keyCode == 9 || keyCode == 13 || (keyCode >= 35 && keyCode <= 40) || keyCode == 46) {
        return true;
    }
    var key = event.key;
            var regex = /^[a-zA-Z0-9\uAC00-\uD7A3\s._+~@!\-]$/;
    
    var allowed = regex.test(key);
    if (!allowed) {
        event.preventDefault(); // ±âº» À̺¥Æ® µ¿ÀÛ(¹®ÀÚ ÀÔ·Â)À» ¸·½À´Ï´Ù.
        return false;
    }
    return true;
}
function keyCheckblur(thisone) {
	thisone.value = thisone.value.replace("'","");
}
function getCookie( 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 "";
}
function bonClick() {
	//$('#t').val(""); //º»µð½ºÅ©È¸¿ø¶§¹®¿¡
	//$("#t").css('background-image', 'none');
	//$("#t").css("color","black");
	//$('#t').css("font-size", '12px');
}
$(function(){
    var searchKeyword = getParameterByName('searchKeyword');
    var searchWord = getParameterByName('searchWord');
    if (searchKeyword != "content_id") {
        if (searchWord!="" && searchWord!="fujrtu") {
            $("#searchWord").val(searchWord);
            $("#searchWord").css("background-image", "none");
            $("#searchKeyword").val(searchKeyword);
        }
    }
    $('.filesh>ul>li>a').mouseover(function() {
        $('.filesh>ul>li').removeClass('on');
        $(this).closest('li').addClass('on');
    });
	//³×ºñ:ÀüüīÅ×°í¸® idsplay
	$(".allmnBtn").click(function(){
		if($('#allbox').css('display')=='block'){
            $('.filesh>ul>li').removeClass('on');
            $(this).removeClass('open');
            $('#allbox').hide();
		}else{
            $(this).addClass('open');
			$('#allbox').show();
		}
	});
	$('#joinclub').focus(function(){
		if ($('#allbox').css('display') != 'none') {
            $('#joinclub').removeClass('open');
			$('.allmnBtn>img').attr('src','/images/images_re/common/mtop_mn_all.gif');
			$('#allbox').hide();
		}
	});
	$('.filesh a').focus(function(){
		if($('#allbox').css('display')!='none'){
			$('.allmnBtn>img').attr('src','/images/images_re/common/mtop_mn_all.gif');
			$('#allbox').hide();
		}
	});
	$(".club").click(function(){
		if(getCookie("uid")){
			if(listload == 0)
			{
                $('#joinclub').addClass('open');
				setTimeout(function() {myListLoad1('club', $('.lst.myJoiner')); }, 1);
			}else{
				if ($('.lst').css('display')!='block') {
                    $('#joinclub').addClass('open');
                    //$('#clublist').show();
				}  else {
                    $('#joinclub').removeClass('open');
                }
				$(".lst").slideToggle('fast');
			}
		}else{
			//alert("·Î±×ÀÎÀÌ ÇÊ¿äÇÕ´Ï´Ù");
			location.href = "https://member.pdpop.com/login/index_re.html";
			return;
		}
	});
});
document.write(" ");
document.write(" ");
document.write(" ");
document.write(" ");
//document.write(" ");
document.write(" ");
document.write(" ");
document.write(" ");
document.write(" ");
document.write(" ");
document.write("");
document.write("
");
document.write("    
");
document.write("        
ÇǵðÆË »ç¿ëÇϱâ. ");
document.write("        
");
document.write("            ");
document.write("         ");
document.write("    
");
document.write("
 ");
document.write("");
document.write("");
document.write("    ");
document.write("     ");
document.write("    ");
document.write("      ");
document.write("      ");
var listload = 0;
function myListLoad1(target, obj){
	if (document.location.href.indexOf("https") != '-1') {
		var url = "//www.pdpop.com/login/load_club.php";
	}else {
		var url = "//www.pdpop.com/login/load_club.php";
	}
	var target_name = "Ŭ·´";
	var make_url = "https://jjanghard.pdpop.com/club/make_re.php";
  if(!getCookie("uid")) return;
  var ancestor=$("#joinclub");
  var mdivPLayer=document.createElement("div");
  $.getJSON(url+'?callback=?','uid='+getCookie("uid"),
    function(jdata){
	var mHtml='';
	var jc=0;
	mHtml +="
°¡ÀÔÇÑ Å¬·´¸®½ºÆ® "
	if(jdata.length == 0){
		mHtml +="
  ÇǵðÆË Ŭ·´¸¸µé±â "
	}else{
		mHtml +="
";
		for(i in jdata){
			if(target == "club" && jdata[i]!=""){
				if(jdata[i].length>13){
					jdata[i]=jdata[i].substring(0,10)+"...";
				}
				mHtml+="- "+jdata[i]+"   ";
				jc++;
			}else{
				return;
			}
		}
		mHtml +="";
	}
      $(mdivPLayer).css("display","none").attr({"id":"clublist","class":"lst"}).insertAfter(ancestor);
      $(mdivPLayer).html(mHtml);
      $(mdivPLayer).slideToggle('fast')
    }
	);
	listload++;
}
//°¡ÀÔ Å¬·´ ·Îµù
function myListLoad(target, obj)
{
  if(getCookie("uid")){
	  if(listload == 0)
	  {
			//var scriptLink = document.createElement("script");
			//scriptLink.language = "javascript";
			//scriptLink.src = "/images/script/jquery-1.7.1.min.js";
			//scriptLink.type = 'text/javascript';
			//scriptLink.async = true;
			//document.body.appendChild(scriptLink);
			setTimeout(function() {myListLoad1(target, obj); }, 1);
	  }else{
		//myListLoad1(target, obj);
		/*
		 *Ŭ¸¯°ú Áߺ¹À¸·Î ÁÖ¼®Ã³¸®
		  if($(".myJoiner").css('display') == 'block'){
		    $(".myJoiner").hide();
		    return;
		  }else{
		    $(".myJoiner").slideToggle('fast');
		 	}
		*/
	  }
    return;
  }else{
	alert("·Î±×ÀÎÀÌ ÇÊ¿äÇÕ´Ï´Ù");
	return;
  }
}
function getParameterByName(name) {
    name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
    var regex = new RegExp("[\\?&]" + name + "=([^]*)"),
        results = regex.exec(location.search);
    return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
//--- °Ë»ö¾î°ü·Ã script
window.addEventListener('pageshow', function () {
	callRecommentSearchWord(); // Ãßõ°Ë»ö¾î ajax LOAD
	setTimeout(callSearchWordHistory, 500); // ³»°Ë»ö¾î ajax LOAD
	//--- ·¹À̾î open
	var searchWordObj = document.getElementById('searchWord');
	searchWordObj.addEventListener('click', function() {
		document.getElementById('suggest_layer').style.display = 'block';
	});
	//-- ´Ý±â¹öư ·¹À̾î close
	var searchLayoutCloseBtn = document.getElementById('searchLayoutCloseBtn');
	searchLayoutCloseBtn.addEventListener('click', searchLayerClose);
    //-- ¿ÜºÎ Ŭ¸¯ ½Ã ·¹À̾î close
    var suggest_layer = document.getElementById('suggest_layer');
    document.addEventListener('click', function(e) {
        if (suggest_layer.style.display == 'block' && !suggest_layer.contains(e.target) && !searchWordObj.contains(e.target)) {
            suggest_layer.style.display = 'none';
        }
    });
    var dropdown = document.getElementsByClassName('dropdown');
    for (var i = 0; i < dropdown.length; i++) dropdown[i].addEventListener('click',searchLayerClose);
    //dropdown.forEach((selboxObj) => selboxObj.addEventListener('click', searchLayerClose));
	//--- ÅǼ±ÅÃ
	var suggestTab = document.querySelectorAll('.tab_suggest > ul > li');
    for (var index = 0; index < suggestTab.length; index++) tabClick(index);
    function tabClick(index) {
        suggestTab[index].addEventListener("click", function() {
            tabSelect(index);
        });
    }
    // ÅÇ ÃʱâÈ
    if (getCookie('uid')) {
        tabSelect(0);
    } else {
        tabSelect(1);
    }
});
function tabSelect(index)
{
    var suggestTab = document.querySelectorAll('.tab_suggest > ul > li');
    for (var tabIdx = 0; tabIdx < suggestTab.length; tabIdx++) {
        suggestTab[tabIdx].classList.remove('on');
    }
    suggestTab[index].classList.add('on');
    var contents = document.querySelectorAll('.list_suggest');
    for (var contentIdx = 0; contentIdx < contents.length; contentIdx++) {
        contents[contentIdx].style.display = 'none';
    }
    contents[index].style.display = '';
    var clearSearchWordBtn = document.getElementById('clearSearchWordBtn');
    var recent_keyword = document.getElementById('recent_keyword');
    if (index == 1) {
        clearSearchWordBtn.style.display = 'none';
        recent_keyword.style.display = 'none';
    } else {
        clearSearchWordBtn.style.display = 'block';
        recent_keyword.style.display = 'block';
    }
}
//--- °Ë»ö¾î ·¹ÀÌ¾î ´Ý±â
function searchLayerClose()
{
    var searchLayer = document.getElementById('suggest_layer');
    if (searchLayer.style.display != 'none') searchLayer.style.display = 'none';
}
function showEmptySearchWordText()
{
	if (!getCookie('uid')) return;
	if (getCookie('searchWordHistoryOff') == 1) return;
	if (getCookie('searchWordHistory')) return;
	document.getElementById('emptySearchWordText').style.display = 'block';
	document.getElementById('searchWordHistoryUl').style.display = 'none';
	return;
}
// Ãßõ°Ë»ö¾î ³»°Ë»ö¾î cookie load
function callSearchWordHistory()
{
	if (!getCookie('uid')) return; // ºñ·Î±×Àνà ǥ½ÃµÇÁö¾ÊÀ½
	var resultData = getCookie('searchWordHistory');
	if (!resultData) {
		showEmptySearchWordText();
		return;
	}
	resultData = decodeURI(resultData).split('|');
	if (!resultData[0]) return;
	var searchWordHistoryUl = document.getElementById('searchWordHistoryUl');
	searchWordHistoryUl.innerHTML = '';
    for (var index = 0; index < resultData.length; index++) searchWordHistoryUl.insertAdjacentHTML('beforeend', searchHistoryTemplate(resultData[index]));
}
// Ãßõ°Ë»ö¾î ajax call
function callRecommentSearchWord()
{
    var PUBLIC_KEY = '15acbe608ded25cc6aa0693d8545ff83b0308656ecf016c5e9394825ad8af3f4';
    var RAND_KEY = '7871157';
    $.ajax({
        url: "//www.pdpop.com/API.php/getRecommendSearchWord",
        method: 'GET',
        dataType: 'json',
        headers: {
            'PUBLIC-KEY': PUBLIC_KEY,
            'RAND-KEY': RAND_KEY
        }, xhrFields: {
            withCredentials: true // ¡Ú ÄíŰ Æ÷ÇÔ
        },
        success: function (resultData) {
            if (!resultData) return;
            var recommendSearchWordUl = document.getElementById('recommendSearchWord');
            recommendSearchWordUl.innerHTML = '';
            for (var index = 0; index < resultData.length; index++) recommendSearchWordUl.insertAdjacentHTML('beforeend', recommendTemplate(resultData[index]));
        }
	});
}
// Ãßõ°Ë»ö¾î li »ý¼º Template
function recommendTemplate(row)
{
	var searchUrl = "//bbs.pdpop.com/board_re.php?mode=list&searchKeyword=content_id&searchWord=" + row.content_id;
	var listRow = '';
	listRow += "";
	listRow += "	" + row.search_word + " ";
	if (row.saleIcon) {
		listRow += "	 ";
	}
	listRow += "	 ";
	listRow += " ";
	return listRow;
}
// ³»°Ë»ö¾î li »ý¼º Template
var searchHistoryNum = 0;
function searchHistoryTemplate(searchWord)
{
	var searchUrl = "//bbs.pdpop.com/board_re.php?mode=list&code=&searchKeyword=bbs_subject&searchWord=" + encodeURIComponent(searchWord)+ "&hash=" + Math.floor(Math.random() * 100000000);
	var listRow = '';
	listRow += "";
	listRow += "	" + searchWord + "  ";
	listRow += "	»èÁ¦  ";
	listRow += " ";
	searchHistoryNum++;
	return listRow;
}
// °Ë»ö±â·Ï »èÁ¦
function deleteSearchWord(searchHistoryNum)
{
	document.getElementById("searchWordLi-" + searchHistoryNum).style.display = 'none';
	var selectObj = document.getElementById("searchWord-" + searchHistoryNum);
	var searchWordHistoryArray = decodeURI(getCookie('searchWordHistory')).split('|');
	var deleteWord = selectObj.innerText;
	var newSearchWord = searchWordHistoryArray.filter(function (item, index, array) {
		return deleteWord != item;
	});
	notice_setCookie('searchWordHistory', encodeURI(newSearchWord.join('|')), 30); // ¿ä¼Ò »èÁ¦ ÈÄ ´Ù½Ã ÄíŰ ¼ÂÆÃ
	if (!newSearchWord.join('|')) showEmptySearchWordText();
	return;
}
// °Ë»ö±â·Ï Àüü»èÁ¦
function clearSearchWord()
{
	notice_setCookie('searchWordHistory', '', 30);
	var searchWordHistoryUl = document.getElementById('searchWordHistoryUl');
	searchWordHistoryUl.innerHTML = ''; // Àڽijëµå Àüü Áö¿ò
	showEmptySearchWordText();
}
// °Ë»ö ÀÚµ¿ÀúÀå ½ºÀ§Ä¡ µ¿ÀÛ¿¡ µû¸¥ proc
function setSearchWordHistorySwitch(switchNode)
{
	var noneLoginSearchWordText = document.getElementById('noneLoginSearchWordText');
	var searchWordHistoryOffText = document.getElementById('searchWordHistoryOffText');
	var searchWordHistorySwitchText = document.getElementById('searchWordHistorySwitchText');
	var searchWordHistoryUl = document.getElementById('searchWordHistoryUl');
	var noticeText = document.querySelectorAll('.kwd_info');
    for (var index=0; index < noticeText.length; index++) noticeText[index].style.display = 'none';
	if (!getCookie('uid')) {
		noneLoginSearchWordText.style.display = '';
	}
	if (switchNode.checked) {
		notice_setCookie('searchWordHistoryOff', 0, 30);
		if (getCookie('uid')) {
			searchWordHistoryUl.style.display = '';
		}
		searchWordHistorySwitchText.innerText = '°Ë»ö ÀÚµ¿ÀúÀå ²ô±â';
	} else {
		notice_setCookie('searchWordHistoryOff', 1, 30);
		if (getCookie('uid')) {
			searchWordHistoryOffText.style.display = '';
			searchWordHistoryUl.style.display = 'none';
		}
		searchWordHistorySwitchText.innerText = '°Ë»ö ÀÚµ¿ÀúÀå Äѱâ';
	}
	showEmptySearchWordText();
	return;
}
// °Ë»ö¾î°ü·Ã script end
function redirectMobile()
{
    if (navigator.userAgent.match(/iPad/) == null && navigator.userAgent.match(/iPhone|Mobile|UP.Browser|Android|BlackBerry|Windows CE|Nokia|webOS|Opera Mini|SonyEricsson|opera mobi|Windows Phone|IEMobile|POLARIS/) != null) {
        var key = 'todo';
        key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
        var regex = new RegExp("[\\?&]"+key+"=([^]*)");
        var qs = regex.exec(window.location.href);
        if (!qs || qs[1] != 'pc') {
            location.replace("https://m.pdpop.com/_renew");
        }
    }
}