
var isLogin = false;

// Common Messagebox
function showMessageBox(msg, title) {
	layerAlert.open(360, 160, title, msg, ['閉じる'], true);
	return false;
};
function hideMessageBox() {
	LPlib.close();
	return false;
};

// Left Login Box Submit: wrapping RBLoginControl.ValidateLoginForm()
function checkLeftLoginForm() {
	layerAlert.open(250, 120, null, "ログイン中です。<br/>しばらくお待ちください。", [], false);
	f_createHiddenIframe("__iframe_proc");
	return RBLoginControl.ValidateLoginForm();
}

// Goto Login Page
function gotoLoginForm() {
	try{
		opener.location.href = _WEB_URL_PORTAL + "/?d_url=" + encodeURIComponent("https://secure.gameyarou.jp/Member/Login/__Common_Login_Form.asp?r_url=" + encodeURIComponent(opener.location.href));
		opener.focus();
	}catch(e){
		top.location.href = _WEB_URL_PORTAL + "/?d_url=" + encodeURIComponent("https://secure.gameyarou.jp/Member/Login/__Common_Login_Form.asp?r_url=" + encodeURIComponent(top.location.href));
	}
}

// Go Menu
function getMenu(code) {
	var Menus = {};

	Menus["-010"] = { name:"会員登録", target:"blank",  url:"/secure/regist.asp" };

	Menus["0000"] = { name:"トップ", target:"top",  url:"/" };

	Menus["1000"] = { name:"ノース便り", target:"top",  url:"/news/" };

	Menus["1100"] = { name:"お知らせ", target:"top",  url:"/news/list.asp?ntc_sort=N" };

	Menus["1200"] = { name:"メンテナンス", target:"top",  url:"/news/list.asp?ntc_sort=M" };

	Menus["1300"] = { name:"イベント", target:"top",  url:"/news/list.asp?ntc_sort=E" };

	Menus["2000"] = { name:"ノース物語", target:"top",  url:"/story/" };

	Menus["2100"] = { name:"ノーステイルの世界", target:"top",  url:"/story/world/" };

	Menus["2200"] = { name:"Act解説", target:"top",  url:"/story/act/" };

	Menus["3000"] = { name:"ノースガイド", target:"top",  url:"/guide/" };

	Menus["3100"] = { name:"ノーステイルを始めよう！", target:"top",  url:"/guide/start/" };

	Menus["3200"] = { name:"覚えておきたいこと！", target:"top",  url:"/guide/functions/" };

	Menus["3300"] = { name:"プレイガイド", target:"top",  url:"/guide/playguide/" };

	Menus["3310"] = { name:"初級編", target:"top",  url:"/guide/playguide/guide0300.asp" };

	Menus["3320"] = { name:"中級編", target:"top",  url:"/guide/playguide/guide0401.asp" };

	Menus["3330"] = { name:"戦闘編", target:"top",  url:"/guide/playguide/guide0501.asp" };

	Menus["4000"] = { name:"ノースデータ", target:"top",  url:"/gamedata/" };

	Menus["4100"] = { name:"スキル", target:"top",  url:"/gamedata/skills/" };

	Menus["4200"] = { name:"アイテム", target:"top",  url:"/gamedata/items/" };

	Menus["4300"] = { name:"マップ＆モンスター", target:"top",  url:"/gamedata/maps/" };

	Menus["5000"] = { name:"コミュニティ", target:"top",  url:"/community/" };

	Menus["5100"] = { name:"みんなの掲示板", target:"top",  url:"/community/board/free/" };

	Menus["5200"] = { name:"オモシロ掲示板", target:"top",  url:"/community/board/screenshot/" };

	Menus["5300"] = { name:"ファンサイト", target:"top",  url:"/community/fansite/" };

	Menus["5400"] = { name:"アンケート", target:"top",  url:"/community/enquete/" };

	Menus["6000"] = { name:"ノース倉庫", target:"top",  url:"/library/" };

	Menus["6100"] = { name:"ゲームダウンロード", target:"top",  url:"/library/gameclient/" };

	Menus["6200"] = { name:"壁紙", target:"top",  url:"/library/wallpaper/" };

	Menus["6300"] = { name:"スクリーンショット", target:"top",  url:"/library/screenshot/" };

	Menus["6400"] = { name:"ムービー", target:"top",  url:"/library/movie/" };

	Menus["7000"] = { name:"アイテムショップ", target:"top",  url:"/itemshop/" };

	Menus["7100"] = { name:"購入ガイド", target:"top",  url:"/itemshop/guide/" };

	Menus["7200"] = { name:"販売アイテム一覧", target:"top",  url:"/itemshop/webmall/" };

	Menus["7210"] = { name:"プレイヤー", target:"top",  url:"/itemshop/webmall/list.asp?cate=1" };

	Menus["7220"] = { name:"ノースメイト", target:"top",  url:"/itemshop/webmall/list.asp?cate=2" };

	Menus["7230"] = { name:"飾る", target:"top",  url:"/itemshop/webmall/list.asp?cate=3" };

	Menus["7240"] = { name:"消耗品", target:"top",  url:"/itemshop/webmall/list.asp?cate=4" };

	Menus["7300"] = { name:"チャージ", target:"blank",  url:"/secure/charge.asp" };

	Menus["7400"] = { name:"購入履歴", target:"blank",  url:"/secure/charge_history.asp" };

	Menus["8000"] = { name:"サポート", target:"top",  url:"/supports/" };

	Menus["8100"] = { name:"運営ポリシー", target:"top",  url:"/supports/policy/" };

	Menus["8200"] = { name:"よくある質問", target:"top",  url:"/supports/faq/" };

	Menus["8300"] = { name:"お問い合わせ", target:"top",  url:"/supports/qna/" };

	Menus["8400"] = { name:"GM紹介", target:"top",  url:"/supports/gm/" };

	return Menus[code];
}

function click_topmenu(code) {
	var thisMenu = getMenu( code.substr(1,2)+"00" );
	if (thisMenu) {
		if (thisMenu.target == "blank") {
			window.open( thisMenu.url );
		}else{
			var win = eval( thisMenu.target );
			if (win) win.location.href = thisMenu.url;
			else self.location.href = thisMenu.url;
		}
	}
}

// Game Start
function getLinkGameExecute() {
	if (!isLogin) {
		gotoLoginForm();
	}else{
		f_createHiddenIframe("__iframe_proc");
		var form = document.getElementById("FormGameExecute");
		if (!form) {
			form = document.createElement('FORM');
			form.setAttribute("id","FormGameExecute");
			document.body.appendChild( form );
		}
		form.method	= "post";
		form.target	= "__iframe_proc";
		form.action	= "/gameexecute/execute.prepare.asp";
		form.submit();
	}
}
function doGameExecuteConfirmNostale(selectedIndex) {
	if (selectedIndex == 2) {
		var form = document.getElementById("FormGameExecute");
		if (form) {
			form.action	= "/gameexecute/gameexecute.asp";
			form.submit();
		}
	}else if (selectedIndex == 1) {
		top.location.href = "/events/200908_ikan/";
	}
}

// System Check
function doSystemCheckNostale() {
	var agent_name	= navigator.userAgent.toLowerCase();
	var is_ie		= ((agent_name.indexOf("msie") != -1) && (agent_name.indexOf("opera") == -1));
	if (!is_ie) {
		layerAlert.open(350, 160, null, "誠に恐れ入りますが、PC仕様チェック機能は、<br/>Microsoft社のInternet Explorerのみご利用いただけます。", ["閉じる"], true, null);
		return false;
	}
	f_createHiddenIframe("__iframe_proc");
	var win = ((is_ie) ? document.getElementById("__iframe_proc").contentWindow : window.frames["__iframe_proc"]);
	win.location.replace("./envcheck.do.asp");
}

// Flash Embed
function f_writeFlashTags(id,src,width,height,wmode,bgcolor,flashvars,scriptAccess) {
	var requiredMajorVersion = 9;
	var requiredMinorVersion = 0;
	var requiredRevision = 124;
	var hasProductInstall = DetectFlashVer(6, 0, 65);
	var hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
	if ( hasProductInstall && !hasRequestedVersion ) {
		var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn";
		var MMredirectURL = window.location;
		document.title = document.title.slice(0, 47) + " - Flash Player Installation";
		var MMdoctitle = document.title;
		AC_FL_RunContent(
			"src", "/swf/playerProductInstall",
			"FlashVars", "MMredirect"+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"",
			"width", width,
			"height", height,
			"align", "middle",
			"id", id,
			"quality", "high",
			"bgcolor", (bgcolor?bgcolor:""),
			"wmode", (wmode?wmode:"window"),
			"name", id,
			"allowScriptAccess", (scriptAccess?scriptAccess:"sameDomain"),
			"type", "application/x-shockwave-flash",
			"pluginspage", "http://www.adobe.com/go/getflashplayer"
		);
	} else if (hasRequestedVersion) {
		AC_FL_RunContent(
		"src", src,
		"flashvars", (flashvars?flashvars:""),
		"width", width,
		"height", height,
		"align", "middle",
		"id", id,
		"quality", "high",
		"bgcolor", (bgcolor?bgcolor:""),
		"wmode", (wmode?wmode:"window"),
		"name", id,
		"allowScriptAccess", (scriptAccess?scriptAccess:"sameDomain"),
		"type", "application/x-shockwave-flash",
		"pluginspage", "http://www.adobe.com/go/getflashplayer"
		);
	} else {
		var alternateContent = 'このサイトをご覧になるには<a href="http://www.adobe.com/go/getflash/" target="_blank">FlashPlayer</a>が必要です。';
		document.write(alternateContent);
	}
};


/*
f_addEvent( window, "onload", removeAtagFocus, false );

function removeAtagFocus(){
	var objs = document.getElementsByTagName("A");
	for (var i=0; i<objs.length; i++) 
		objs[i].onfocus = onFocusAtag;
};
function onFocusAtag() {
	this.blur();
};
*/

// Form Input Guide
var InputGuide = new Object();
InputGuide.addFormGuide = function( form ){
	var objs = form.getElementsByTagName('INPUT');
	for (var i=0; i<objs.length; i++) {
		if ((objs[i].type=='text') && (objs[i].title.length>0)) this.addInputGuide( objs[i] );
	}
};
InputGuide.addInputGuide = function( obj ) {
	obj.onfocus = this.onInputGuideFocus;
	obj.onblur	= this.onInputGuideBlur;
	this.onInputGuideBlur.bind( obj )();
};
InputGuide.onInputGuideFocus = function() {
	if (this.value==this.title) {
		this.style.color = "#000000";
		this.value = "";
	}
	return true;
};
InputGuide.onInputGuideBlur = function() {
	if ((this.value.trim().length==0) || (this.value==this.title)) {
		this.style.color = "#999999";
		this.value = this.title;
	}
	return true;
};

//Check Form
function onKeyDownCheckNumber(e) {
	var obj		= ( (window.event) ? window.event.srcElement : e.target );
	var code	= ( (window.event) ? event.keyCode : e.which );
	var shift	= ( (window.event) ? event.shiftKey : e.shiftKey );
	var ctrl	= ( (window.event) ? event.ctrlKey : e.ctrlKey );
	var alt		= ( (window.event) ? event.altKey : e.altKey );
	if (
		((alt == true) && (code >= 37 && code <= 40)) ||
		((ctrl == true && (code == 78 || code == 82)) || (code >= 112 && code <= 123)) ||
		((!alt) && (!ctrl) && code!=8 && code!=9 && code!=46 && (code<35 || code>40) && (code<48 || code>57) && (code<96 || code>105)) ||
		((shift==true) && (code<35 || code>40))
		) {
		//alert(alt.toString() + ctrl.toString() + shift.toString() + code.toString());
		if (window.event) { try { event.keyCode = 0; event.cancelBubble = true; event.returnValue = false; }catch(e){} }
		return false;
		
	}
	return true;
};

function onKeyDownCheckEmail(e) {
	var obj		= ( (window.event) ? window.event.srcElement : e.target );
	var code	= ( (window.event) ? event.keyCode : e.which );
	var shift	= ( (window.event) ? event.shiftKey : e.shiftKey );
	var ctrl	= ( (window.event) ? event.ctrlKey : e.ctrlKey );
	var alt		= ( (window.event) ? event.altKey : e.altKey );
	if (
		((alt == true) && (code >= 37 && code <= 40)) ||
		((ctrl == true && (code == 78 || code == 82)) || (code >= 112 && code <= 123)) ||
		((!alt) && (!ctrl) && code!=8 && code!=9 && code!=46 && (code<35 || code>40) && (code<48 || code>57) && (code<96 || code>105) && (code<65 || code>90) && code!=189 && code!=109 && code!=190 && code!=110 ) ||
		((shift==true) && (code<35 || code>40) && code!=50 && code!=109 && code!=189)
		) {
		//alert(alt.toString() + ctrl.toString() + shift.toString() + code.toString());
		if (window.event) { try { event.keyCode = 0; event.cancelBubble = true; event.returnValue = false; }catch(e){} }
		return false;
		
	}
	return true;
};

function onKeyDownCheckAlphabet(e) {
	var obj		= ( (window.event) ? window.event.srcElement : e.target );
	var code	= ( (window.event) ? event.keyCode : e.which );
	var shift	= ( (window.event) ? event.shiftKey : e.shiftKey );
	var ctrl	= ( (window.event) ? event.ctrlKey : e.ctrlKey );
	var alt		= ( (window.event) ? event.altKey : e.altKey );
	if (
		(alt == true) ||
		(ctrl == true) ||
		(code!=8 && code!=9 && code!=46 && (code<35 || code>40) && (code<65 || code>90) )
		) {
		if (window.event) { try { event.keyCode = 0; event.cancelBubble = true; event.returnValue = false; }catch(e){} }
		return false;
		
	}
	return true;
};

function onKeyDownCheckTelephone(e) {
	var obj		= ( (window.event) ? window.event.srcElement : e.target );
	var code	= ( (window.event) ? event.keyCode : e.which );
	var shift	= ( (window.event) ? event.shiftKey : e.shiftKey );
	var ctrl	= ( (window.event) ? event.ctrlKey : e.ctrlKey );
	var alt		= ( (window.event) ? event.altKey : e.altKey );
	if (
		((alt == true) && (code >= 37 && code <= 40)) ||
		((ctrl == true && (code == 78 || code == 82)) || (code >= 112 && code <= 123)) ||
		((!alt) && (!ctrl) && code!=8 && code!=9 && code!=46 && (code<35 || code>40) && (code<48 || code>57) && (code<96 || code>105) && code!=189 && code!=109 ) ||
		((shift==true) && (code<35 || code>40) && code!=48 && code!=57)
		) {
		//alert(alt.toString() + ctrl.toString() + shift.toString() + code.toString());
		if (window.event) { try { event.keyCode = 0; event.cancelBubble = true; event.returnValue = false; }catch(e){} }
		return false;
		
	}
	return true;
};

function f_checkKanjiHiraKana(str) {
	for (var i=0; i<str.length; i++) if ((!str.isHiraKana(i)) && (!str.isKanji(i))) return false;
	return true;
};


/* Top Right Message Box *************************/

var v_Cur_Comment_num = 0;
function f_mainTopComment_scroll(vVal){
	if (vVal == null || vVal == '') { vVal = 0; } 
	var v_Arr_index = parseInt(vVal); 
	var tLayer = document.getElementById('L_MAIN_TOP_COMMENT');
	var v_Comment_content = '';
	var v_Next_val;

	if (typeof(v_toggle_txt_200301)=="undefined") return;
	if (v_toggle_txt_200301.length > 0) {

		v_Comment_content = v_toggle_txt_200301[v_Arr_index];

		var v_Inner_text = '<table border="0" cellpadding="0" cellspacing="0" style="width:200px; height:80px; margin:25px 0 0 42px;">';
		v_Inner_text += '<tr>';
		v_Inner_text += '	<td style="vertical-align:middle; text-align:center;">' + v_Comment_content + '</td>';
		v_Inner_text += '</tr>';
		v_Inner_text += '</table>';
		
		SetObjectStyle.SetinnerHTML(tLayer, v_Inner_text);
		v_Cur_Comment_num = v_Arr_index;
		if ((v_Arr_index + 1) == (v_toggle_txt_200301.length)) {
			v_Next_val = 0;
		} else {
			v_Next_val = parseInt(v_Arr_index) + 1;
		}

	}
	//setTimeout('f_mainTopComment_scroll(\'' + v_Next_val + '\')', 5000);
}

function f_callTopCommentScroll(){
	f_mainTopComment_scroll(0);
}

f_addEvent(window, "onload", f_callTopCommentScroll, false);


/* Dospara Coupon **/

function openDosparaCoupon() {
	if (!isLogin) {
		gotoLoginForm();
	}else{
		window.open("/events/coupon/dospara/", "DosparaCoupon", "width=490,height=300,status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=0");
	}
}

/* GNB Login Redefine **/

if (typeof(Service_TopLink) != "undefined") {
	if ((Service_TopLink) && (Service_TopLink.MB_Login)) {
		Service_TopLink.MB_Login = new SvcItem_TopLink("MB12", _WEB_URL_PORTAL + "/?d_url=" + encodeURIComponent("https://secure.gameyarou.jp/Member/Login/__Common_Login_Form.asp?r_url=" + encodeURIComponent(self.location.href)), top);
	}
}

