document.write('<script type="text/javascript" src="/javascript/prototype.js"></script>');
document.write('<script type="text/javascript" src="/javascript/func_link.js"></script>');
document.write('<script type="text/javascript" src="/javascript/start_link.js"></script>');

switch (document.location.hostname) {
	case "alpha-shotonline.hangame.com" :
		setTopMenu('noLogin');
		break;
	case "shotonline.hangame.com" :
		setTopMenu('noLogin');
		break;
	case "shotonline.sayclub.com" :
		show_gnb();
		break;
	case "alpha-shoton.playnetwork.co.kr" :
		//pnResizeIframeAndSyncCookie();
		break;
	case "shoton.playnetwork.co.kr" :
		//pnResizeIframeAndSyncCookie();
		break;
	case "shotonline.ndolfin.com" :
		nDolfin.GNB(980, "center", 10000);
		//nDolfin.Kdfense();
		break;
	default :
}

function focusin(val){
    document.getElementById(val).style.backgroundImage = '';
}

function focusout(val){

	switch (document.location.hostname) {
		case "alpha-shotonline.hangame.com" :
			if (document.getElementById(val).value.length==0) {
				if (val=="strmemberid") {
					document.getElementById(val).style.backgroundImage = 'url(/img/common/id.gif)';
				}else if (val=="strpassword") {
					document.getElementById(val).style.backgroundImage = 'url(/img/common/password.gif)';
				}
			}
			break;
		case "shotonline.hangame.com" :
			if (document.getElementById(val).value.length==0) {
				if (val=="strmemberid") {
					document.getElementById(val).style.backgroundImage = 'url(/img/common/id.gif)';
				}else if (val=="strpassword") {
					document.getElementById(val).style.backgroundImage = 'url(/img/common/password.gif)';
				}
			}
			break;
		case "shotonline.sayclub.com" :
			if (document.getElementById(val).value.length==0) {
				if (val=="usrid") {
					document.getElementById(val).style.backgroundImage = 'url(/img/common/id.gif)';
				}else if (val=="passwd") {
					document.getElementById(val).style.backgroundImage = 'url(/img/common/password.gif)';
				}
			}
			break;
		case "alpha-shoton.playnetwork.co.kr" :

			break;
		case "shoton.playnetwork.co.kr" :

			break;
		case "shotonline.ndolfin.com" :
			if (document.getElementById(val).value.length==0) {
				if (val=="FSWebID") {
					document.getElementById(val).style.backgroundImage = 'url(/img/common/id.gif)';
				}else if (val=="FSWebPW") {
					document.getElementById(val).style.backgroundImage = 'url(/img/common/password.gif)';
				}
			}
			break;
		case "shotonline.bugs.co.kr" :
			if (document.getElementById(val).value.length==0) {
				if (val=="uid") {
					document.getElementById(val).style.backgroundImage = 'url(/img/common/id.gif)';
				}else if (val=="upass") {
					document.getElementById(val).style.backgroundImage = 'url(/img/common/password.gif)';
				}
			}
			break;
		default :
			if (document.getElementById(val).value.length==0) {
				if (val=="uid") {
					document.getElementById(val).style.backgroundImage = 'url(/img/common/id.gif)';
				}else if (val=="upass") {
					document.getElementById(val).style.backgroundImage = 'url(/img/common/password.gif)';
				}
			}
			break;
	}
}


function loginCheck() {
    if (document.loginform.uid.value.split(' ').join('')=='') {
        alert('¾ÆÀÌµð¸¦ ÀÔ·ÂÇÏ¼¼¿ä');
        document.loginform.uid.value = '';
        document.loginform.uid.focus();
        return true;
    }

    if (document.loginform.upass.value.split(' ').join('')=='') {
        alert('ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä');
        document.loginform.upass.value = '';
        document.loginform.upass.focus();
        return true;
    }

    document.loginform.submit();
}

/* ¹÷½º·Î±×ÀÎ Ã¼Å© */
function bugsLoginCheck() {
	if (document.bugsLogin.uid.value.split(' ').join('')=='') {
        alert('¾ÆÀÌµð¸¦ ÀÔ·ÂÇÏ¼¼¿ä');
        document.bugsLogin.uid.value = '';
		document.bugsLogin.user_id.value = '';
        document.bugsLogin.uid.focus();
        return true;
    }

    if (document.bugsLogin.upass.value.split(' ').join('')=='') {
        alert('ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä');
        document.bugsLogin.upass.value = '';
		document.bugsLogin.passwd.value ='';
        document.bugsLogin.upass.focus();
        return true;
    }

	document.bugsLogin.user_id.value = document.bugsLogin.uid.value;
	document.bugsLogin.passwd.value = document.bugsLogin.upass.value;

	document.bugsLogin.submit();
}


function logoutCheck(idSave) {
	var url = ""
    var form = document.createElement("form");
    form.name = "common";
    form.id = "common";
    form.method = "post";
    document.body.appendChild(form);

    var obj = document.createElement("input");
    obj.type = "hidden";
    obj.name = "idRemove";
    obj.id = "idRemove";
    idSave != "" ? obj.value = "" : obj.value = "Y";
    form.appendChild(obj);

	if (document.domain == "shotonline.co.kr") {
		url = "https://cert.shotonline.co.kr/member/logout.php";
	}else{
		url = "/member/logout.php";
	}

	form.action = url;
    form.submit();
}

function AjaxCall(page) {
	switch (document.location.pathname){
		case "/" :
		case "/index.php" :
			AjaxBanner(page);
			showCalendar('', '');

//			if (document.location.hostname == "shotonline.game.daum.net") {
//				if(!(getCookie("popup0127") || getCookie("popup0127"))){
//					//openPop('/popup/', 'popup_notice', 667, 800, 'yes');
//					try {
//						document.getElementById('mainLayerPopup').style.display = 'block';
//					}catch(e){
//
//					}
//				}
//			}

//			if (document.location.hostname == "shotonline.co.kr") {
//				if(!(getCookie("popup1111") || getCookie("popup1111"))){
//					try {
//						document.getElementById('mainLayerPopup').style.display = 'block';
//						document.getElementById('backImg').style.display = 'block';
//
//					}catch(e){
//
//					}
//				}
//			}

			break;
		case "/download/movie.php" :
			AjaxLIst(page, '/download/movie.list.jquery.php', 'movieList');
			break;
		case "/news/off_match.php" :
			//AjaxOffMatchView(page);
			break;
		case "/schedule/schedule.php" :

			if (page != ''){
				var arrpage = page.split("|");
				var year = arrpage[0];
				var month = arrpage[1];

				scheduleList(year, month, 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y');
			}else{
				scheduleList('', '', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y');
			}
			break;
		default:
	}
}


function searchCheck() {
    if (document.searchfrom.keyword.value.split(' ').join('')=='') {
        alert('°Ë»öÇÒ ´Ü¾î¸¦ ÀÔ·ÂÇÏ¼¼¿ä');
        document.searchfrom.keyword.value = '';
        document.searchfrom.keyword.focus();
        return true;
    }else{
		document.searchfrom.submit();
	}
}


function RanksearchCheck() {
    document.searchfrom.submit();
}


function openPop(url, description, width, height, scrollbars){

	if (typeof(scrollbars)=="undefined"){
		var scrollbars = "no";
	}

	var screenPosX = screen.availWidth/2 - width/2;
	var screenPosY = screen.availHeight/2 - height/2;
	var features = "'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars="+scrollbars+", resizable=no, top="+screenPosY+", left="+screenPosX+", width="+width+", height="+height+"'";

	var win = window.open(url, description, features);

	if (win == null) {
		alert("ÆË¾÷Ã¢ÀÌ Â÷´ÜµÇ¾î ÀÖ½À´Ï´Ù	\nÆË¾÷Ã¢À» ÇØÁ¦ÇØ ÁÖ¼¼¿ä	");
		return false;
	}
}

function AjaxLIst(pageNum, pageUrl, pageDiv){
	$.ajax({
			type: "GET",
			url: pageUrl,
			data: "page="+pageNum,
			success: function(result){
				document.getElementById(pageDiv).innerHTML = result;
		}
	});
}


function specCheck() {

	var ret;
	var rText = "";
	var InstallChk = false;

	try {
		var Install = new ActiveXObject("SPECCHECK.SpecCheckCtrl.1");
		InstallChk = true;
	}
	catch(ex)
	{
		InstallChk = false;
	}

	if(InstallChk)
	{

		ret = SpecCheck.GameSpecCheck();
		if(ret) {
			strcpu = SpecCheck.strcpu;
			strdirectx = SpecCheck.strdirectx;
			strgrephyic = SpecCheck.strgrephyic;
			stros = SpecCheck.stros;
			strram = SpecCheck.strram;
			strsoundcard = SpecCheck.strsoundcard;
			strhard = SpecCheck.strhard;
		}
	/*
		document.write("¿î¿µÃ¼Á¦ Á¤º¸ : " + stros + "<br>");
		document.write("CPU Á¤º¸      : " + strcpu + "<br>");
		document.write("HDD ¿©À¯°ø°£  : " + strhard + "<br>");
		document.write("RAM Á¤º¸      : " + strram + "<br>");
		document.write("DirectX ¹öÀü  : " + strdirectx + "<br>");
		document.write("±×·¡ÇÈ Ä«µå Á¤º¸ : " + strgrephyic + "<br>");
		document.write("»ç¿îµå Ä«µå Á¤º¸ : " + strsoundcard + "<br>");
	*/

		 var rowgrephyic = new Array();
		 var rowstrsoundcard = new Array();

		 rowgrephyic = strgrephyic.trim().split(";");
		 rowstrsoundcard = strsoundcard.trim().split(";");

		strgrephyic = rowgrephyic[rowgrephyic.length - 1];
		strsoundcard =  rowstrsoundcard[rowgrephyic.length - 1];


		rText = "¿î¿µÃ¼Á¦ Á¤º¸     : " + stros.trim() + "\n" + "CPU Á¤º¸           : " + strcpu.trim() + "\n" + "HDD ¿©À¯°ø°£     : " + strhard.trim() + "\n" + "RAM Á¤º¸          : " + strram.trim() + "\n" + "DirectX ¹öÀü       : " + strdirectx.trim() + "\n" + "±×·¡ÇÈ Ä«µå Á¤º¸ : " + strgrephyic + "\n" + "»ç¿îµå Ä«µå Á¤º¸ : " + strsoundcard + "\n";
	}

	return rText
}

/* Ä³½¬ÃæÀü ÆäÀÌÁö ÀÌµ¿ */
function goCash() {
	var prefix = location.href.indexOf('alpha-') > 0 ? 'alpha-' : '';

	if (document.location.hostname == prefix+"shoton.playnetwork.co.kr") {
		openPop("https://"+prefix+"bill.playnetwork.co.kr/pay/charge.nhn?CHNL=PN&CLOSETYPE=S&RURL=http://"+prefix+"www.playnet.naver.com/pageRefresh.nhn", '', 800, 800);
	}else{
		location.href = "/itemmall/cashcharge.php"
	}
}


/* È¸¿øÁ¤º¸¼öÁ¤ ÆäÀÌÁö ÀÌµ¿ */
function goMyInfo(){
	switch (document.location.hostname) {
		case "shotonline.co.kr" :
			location.href="https://cert.shotonline.co.kr/mypage/member_modify_01.php";
			break;
		case "alpha-shotonline.hangame.com" :
			goUserMove('myinfo');
			break;
		case "shotonline.hangame.com" :
			goUserMove('myinfo');
			break;
		case "shotonline.sayclub.com" :
			location.href = "http://me.sayclub.com/admin/my/info";
			break;
		case "alpha-shoton.playnetwork.co.kr" :
			location.href="https://nid.naver.com/user/help.nhn?todo=changeMain";
			//pnResizeIframeAndSyncCookie();
			break;
		case "shoton.playnetwork.co.kr" :
			location.href="https://nid.naver.com/user/help.nhn?todo=changeMain";
			//pnResizeIframeAndSyncCookie();
			break;
		case "shotonline.ndolfin.com" :
			nDolfin.Button('MyPage');
			break;
		case "shotonline.bugs.co.kr" :
			location.href="https://secure.bugs.co.kr/myinfo/memberedit/view";
			break;
		case "shotonline.game.daum.net" :
			location.href="https://user.daum.net/modifyuser/modifyuser.daum?t__nil_loginbox=modify2";
			break;
		default :
	}
}

/* ÇÑ°ÔÀÓ SPC ¹æ */
function hangameSpc(v){
	document.getElementById('spclayer').style.display = v;
}


/* ½ºÄÉÁì ÆäÀÌÁö·Î ÀÌµ¿ */
function goSchedule (year, month) {
	if (document.location.pathname != "/schedule/schedule.php") {
		var obj = new Array();

		var form = document.createElement("form");
		form.name = "common";
		form.id = "common";
		form.method = "post";
		form.action = "/schedule/schedule.php";
		document.body.appendChild(form);

		obj[0] = document.createElement("input");
		obj[0].type = "hidden";
		obj[0].name = "setYear";
		obj[0].id = "setYear";
		obj[0].value = year;
		form.appendChild(obj[0]);

		obj[1] = document.createElement("input");
		obj[1].type = "hidden";
		obj[1].name = "setMonth";
		obj[1].id = "setMonth";
		obj[1].value = month;
		form.appendChild(obj[1]);

		form.submit();
	}else{
		scheduleList(year, month, 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y');
	}
}

/* ½ºÄÉÁì */
function scheduleList(year, month, ctg1, ctg2, ctg3, ctg4, ctg5, ctg6, ctg7, ctg8, ctg9){

	//alert("setYear="+year+"&setMonth="+month+"&category1="+ctg1+"&category2="+ctg2+"&category3="+ctg3+"&category4="+ctg4+"&category5="+ctg5+"&category6="+ctg6+"&category7="+ctg7+"&category8="+ctg8+"&category9="+ctg9+"");

	$.ajax({
			type: "GET",
			url: '/schedule/schedule.jquery.php',
			data: "setYear="+year+"&setMonth="+month+"&category1="+ctg1+"&category2="+ctg2+"&category3="+ctg3+"&category4="+ctg4+"&category5="+ctg5+"&category6="+ctg6+"&category7="+ctg7+"&category8="+ctg8+"&category9="+ctg9,
			success: function(result){
				document.getElementById('scheduleList').innerHTML = result;
		}
	});
}

/* ½ºÄÉÁì Ä«Å×°í¸® ¼±ÅÃ */
function scheduleCtg (ctg) {

	if (ctg==1) {
		if (document.form1.category1.checked==true){
			document.form1.category2.checked = true;
			document.form1.category3.checked = true;
			document.form1.category4.checked = true;
			document.form1.category5.checked = true;
			document.form1.category6.checked = true;
			document.form1.category7.checked = true;
			document.form1.category8.checked = true;
			document.form1.category9.checked = true;
			var arrCtg = Array("Y","Y","Y","Y","Y","Y","Y","Y","Y");
		}else{
			document.form1.category2.checked = false;
			document.form1.category3.checked = false;
			document.form1.category4.checked = false;
			document.form1.category5.checked = false;
			document.form1.category6.checked = false;
			document.form1.category7.checked = false;
			document.form1.category8.checked = false;
			document.form1.category9.checked = false;
			var arrCtg = Array("","","","","","","","","");
		}
	}else{
		if (document.form1.category2.checked
			&& document.form1.category3.checked
			&& document.form1.category4.checked
			&& document.form1.category5.checked
			&& document.form1.category6.checked
			&& document.form1.category7.checked
			&& document.form1.category8.checked
			&& document.form1.category9.checked) {
			document.form1.category1.checked = true;
			var arrCtg = Array("Y","Y","Y","Y","Y","Y","Y","Y","Y");
		}else{
			document.form1.category1.checked = false;

			var arrCtg = Array("","Y","Y","Y","Y","Y","Y","Y","Y");

			arrCtg[1] = document.form1.category2.checked==true ? "Y" : "";
			arrCtg[2] = document.form1.category3.checked==true ? "Y" : "";
			arrCtg[3] = document.form1.category4.checked==true ? "Y" : "";
			arrCtg[4] = document.form1.category5.checked==true ? "Y" : "";
			arrCtg[5] = document.form1.category6.checked==true ? "Y" : "";
			arrCtg[6] = document.form1.category7.checked==true ? "Y" : "";
			arrCtg[7] = document.form1.category8.checked==true ? "Y" : "";
			arrCtg[8] = document.form1.category9.checked==true ? "Y" : "";
		}
	}

	var year = document.form1.setYear.value;
	var month = document.form1.setMonth.value;
	scheduleList(year, month, arrCtg[0],arrCtg[1],arrCtg[2],arrCtg[3],arrCtg[4],arrCtg[5],arrCtg[6],arrCtg[7],arrCtg[8]);
}

/* ÆÐ¹Ð¸® »çÀÌÆ® */
function FamilyMove(val) {
	switch (val) {
		case "us" : window.open("http://shotonline.gamescampus.com", "", ""); break;
		case "hk" : window.open("http://shot-online.hk", "", ""); break;
		case "tw" : window.open("http://shot-online.tw", "", ""); break;
		case "de" : window.open("http://shotonline.gamescampus.eu/", "", ""); break;
		case "es" : window.open("http://shotonline.gamescampus.eu/", "", ""); break;
		case "fr" : window.open("http://shotonline.gamescampus.eu/", "", ""); break;
		case "jp" : window.open("http://shotonline.gamescampus.co.jp", "", ""); break;
		case "onnet" : window.open("http://www.onnet.co.kr", "", ""); break;
		default:
	}
}


function setPng24(obj) {
    obj.width=obj.height=1;
    obj.className=obj.className.replace(/\bpng24\b/i,'');
    obj.style.filter ="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src+"',sizingMethod='image');";
		obj.style.backgroundImage = "url('"+ obj.src +"')";
    obj.src='';
    return '';
}

function getCookie(name){
	var cname = name + "=";
	var i = 0;

	while (i <= document.cookie.length)
	{
		var start = i;
		var end = (start + cname.length);
		if (document.cookie.substring(start, end) == cname)
		{
			if ((cend = document.cookie.indexOf(";", end)) == -1)
			{
				cend = document.cookie.length;
			}
			return document.cookie.substring(end, cend);
		}
		start = document.cookie.indexOf(" ", start) + 1;
		if (start == 0) break;
		i++;
	}
	return "";
}


function setCookie(name, value, expiredays){
	var todayDate = new Date();
	todayDate.setDate(todayDate.getDate() + expiredays);
	document.cookie = name + "=" + escape(value) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}

function gameItemCheck(code){
	$.ajax({
			type: "GET",
			url: "/batch/gameItemCheck.php",
			data: "code="+code,
			success: function(result){
				if (result >= 0){

					if (code == "1") {
						var itemName = "ÇÃ·¹Å¸";
					}else if (code == "2") {
						var itemName = "¾Æ½º°¡¸£µå";
					}

					alert(""+itemName+"»óÀÚ¸¦ °³ºÀÇÑ °³¼ö´Â ÃÑ "+result+"°³ ÀÔ´Ï´Ù.");
				}else{
					alert('·Î±×ÀÎÀ» ¸ÕÀú ÇØÁÖ¼¼¿ä');
					document.location.href = '/member/login.php?gotourl=/test.html';
				}
		}
	});
}

function daumLogin(){
	document.location.href = 'http://login.daum.net/accounts/loginform.do?url=http://shotonline.game.daum.net&category=game';
}

function attendance () {

	$.ajax({
			type: "GET",
			url: '/member/loginCheck.jquery.php',
			data: "",
			success: function(result){
				if (result == "-1") {
					if (confirm("Ãâ¼®Ã¼Å©¸¦ È®ÀÎÇÏ½Ã·Á¸é, ·Î±×ÀÎÀÌ ÇÊ¿äÇÕ´Ï´Ù.\n·Î±×ÀÎ ÇÏ½Ã°Ú½À´Ï±î?")) {
						document.location.href = "/member/login.php";
					}
					return false;
				}else{
					openPop('/event/attendance/popup.php', 'popup_attendance', 726, 900, 'yes');
				}
		}
	});
}
