function getCenterPosition(windowWidth, windowHeight) {  
	var top = (screen.availHeight/2)-(windowHeight/2);
	var left = (screen.availWidth/2)-(windowWidth/2);
	return new Array(left, top);
}
function showLoginConfirmDialog() {
	if( login_flg ){
		var pos = getCenterPosition(300,140);
		var targetWindow = window.open("login_confirm.html", "login_confirm", "status=no,scrollbars=no,width=300,height=140,left="+pos[0]+",top="+pos[1]);
		targetWindow.focus();
	}
	return false;
}
function showLoginErrorDialog() {
	var pos = getCenterPosition(300,140);
	var targetWindow = window.open("login_error.html", "login_error", "status=no,scrollbars=no,width=300,height=140,left="+pos[0]+",top="+pos[1]);
	targetWindow.focus();
}
//function openWindow(url, title, height, width)
//{
//	var targetWindow = window.open(url, title, "height=" + height + ",width=" + width + ",status=no");
//	targetWindow.focus();
//}
function loginSubmit(form_id) {
	if(form_id == "login_confirm_yes") {
		window.opener.document.getElementById('cookie').value = '1';
	} else {
		window.opener.document.getElementById('cookie').value = '';
	}
	window.opener.ParentWindowSubmit();
	self.window.close();
}
function loginCheck(form_p){
	var url= "logincheck.json";
	var data="LoginID1="+form_p.LoginID1.value+"&LoginID2="+form_p.LoginID2.value+"&LoginPW="+form_p.LoginPW.value;
	var myAjax = new Ajax.Request(
		url,
		{
			method: 'POST',
			parameters: data,
			onFailure: function() { alert("通信に失敗しました"); },
			onException: function(ajax, exception) {alert('エラー: ' + exception.message);},
			onComplete: function(res,json){
						if(json == null) {
							alert("会員番号かパスワードに誤りがあります。");
						} else {
							if( json[0].result == "ok" ){
									var uName = navigator.userAgent;
									if (uName.indexOf("Safari") > -1){
										//ダミーの要素作成しイベントハンドラ設置、内部にwindow.openを記述(SAFARI POPUP対策)
										var E = document.createElement("div");
										E.onclick = function()
										{
											var pos = getCenterPosition(300,140);
											var targetWindow = window.open("login_confirm.html", "login_confirm", "status=no,scrollbars=no,width=300,height=140,left="+pos[0]+",top="+pos[1]);
											targetWindow.focus();
										};
										//クリックイベント送出
										var evt = document.createEvent("MouseEvents");
										evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
										E.dispatchEvent(evt);
									}else{
										var pos = getCenterPosition(300,140);
										var targetWindow = window.open("login_confirm.html", "login_confirm", "status=no,scrollbars=no,width=300,height=140,left="+pos[0]+",top="+pos[1]);
										if( targetWindow == undefined || !targetWindow ){
												alert("このサイトのポップアップブロックを許可してください。");
											}else{
												targetWindow.focus();
											}
									}
							}else{
								alert("会員番号かパスワードに誤りがあります。");
							}
						}
						
					}
		});
	return false;
}