function wopen(login_type){

	var strTemp;
	//画面の解像度を取得します。
	nSizeWidth = 0;
	nSizeHeight = 0;
	nSizeWidth = screen.width;
	nSizeHeight = screen.height;
	//取得した解像度の子ウィンドウを開きます。
	var nvua = navigator.userAgent;
	nvua = nvua.split('(');
	nvua = nvua[1];
	nvua = nvua.split(';');
	var br = nvua[1]
	var sp = nvua[3]
	nvua = nvua[2];
	nvua = nvua.split(' ');
	br = br.split(' ');
	br = br[2];
	if (nvua[3]) {
		nvua = nvua[3];
		nvua = nvua.split(')');
		nvua = nvua[0];
	} else {
		nvua = 0;
	}

	if(nvua <= 5) {
		if(br >= 7) {
			strTemp = "scrollbars=yes,resizable=yes";
			strTemp += ",fullscreen=yes";
		} else {
			var h=screen.height;
			h = h - 52;	//	76
			var w=screen.width;
			w = w - 4;
			strTemp = 'width='+w+',height='+h;
			strTemp += ",scrollbars=yes,resizable=no,status=no";
		}
	} else {
		if (document.all) {
			strTemp = "scrollbars=yes,resizable=yes";
			strTemp += ",fullscreen=yes";
		} else {
			var h=screen.height;
			h = h - 52;	//	76
			var w=screen.width;
			w = w - 4;
			strTemp = 'width='+w+',height='+h;
			strTemp += ",scrollbars=yes,resizable=no,status=no";
			strTemp += ",left=0,top=0";
		}
	}
	if (login_type == 1) {
		//	座席データーを復活させる為
		window.location.reload();
		var target = './student/login_school.php';
	} else if (login_type == 2) {
		var target = './exam/login_form_exam.php';
	} else {
		var target = './student/login.php';
	}

	if (strTemp) {
		var NWIN = window.open(target,'study',strTemp);
	}
	if (NWIN) {
		if(nvua <= 5) { NWIN.moveTo(0,0); }
		NWIN.focus();
	} else {
		data = "&type=CAN NOT OPEN WINDOW";
		dataFileName = '/student/error_system.php';
		sendRequest(onloaded,data,'POST',dataFileName,true)
	}
}

function wopen2(index_url){

	if (document.forms[0].win_open_flg.value==0){
		return;
	}
	document.forms[0].win_open_flg.value=0;

	var strTemp;
	//画面の解像度を取得します。
	nSizeWidth = 0;
	nSizeHeight = 0;
	nSizeWidth = screen.width;
	nSizeHeight = screen.height;
	//取得した解像度の子ウィンドウを開きます。

	var nvua = navigator.userAgent;
	nvua = nvua.split('(');
	nvua = nvua[1];
	nvua = nvua.split(';');
	var br = nvua[1]
	var sp = nvua[3]
	nvua = nvua[2];
	nvua = nvua.split(' ');
	br = br.split(' ');
	br = br[2];
	if (nvua[3]) {
		nvua = nvua[3];
		nvua = nvua.split(')');
		nvua = nvua[0];
	} else {
		nvua = 0;
	}

	if(nvua <= 5) {
		if(br >= 7) {
			strTemp = "scrollbars=yes,resizable=yes";
			strTemp += ",fullscreen=yes";
		} else {
			var h=screen.height;
			h = h - 52;	//	76
			var w=screen.width;
			w = w - 4;
			strTemp = 'width='+w+',height='+h;
			strTemp += ",scrollbars=yes,resizable=no,status=no";
		}
	} else {
		if (document.all) {
			strTemp = "scrollbars=yes,resizable=yes";
			strTemp += ",fullscreen=yes";
		} else {
			var h=screen.height;
			h = h - 52;	//	76
			var w=screen.width;
			w = w - 4;
			strTemp = 'width='+w+',height='+h;
			strTemp += ",scrollbars=yes,resizable=no,status=no";
			strTemp += ",left=0,top=0";
		}
	}

	var target = index_url;

	if (strTemp) {
		var NWIN = window.open(target,'study',strTemp);
	}
	if (NWIN) {
		if(nvua <= 5) { NWIN.moveTo(0,0); }
		NWIN.focus();
	} else {
		data = "&type=CAN NOT OPEN WINDOW";
		dataFileName = target+'error_system.php';
		sendRequest(onloaded,data,'POST',dataFileName,true)
	}
}

function createHttpRequest() {
	if(window.ActiveXObject) {
		try {
			return new ActiveXObject("Msxml2.XMLHTTP") ;
		} catch (e) {
			try {
				return new ActiveXObject("Microsoft.XMLHTTP") ;
			} catch (e) {
				return null ;
 			}
 		}
	} else if(window.XMLHttpRequest){
		return new XMLHttpRequest() ;
	} else {
		return null ;
	}
}

function sendRequest(callback,data,method,url,async) {
	var obj = createHttpRequest();
	if( obj == null ) return null;

	//ブラウザ判定
	var ua = navigator.userAgent;
	var safari	= ua.indexOf("Safari")!=-1;
	var konqueror = ua.indexOf("Konqueror")!=-1;
	var mozes	 = ((a=navigator.userAgent.split("Gecko/")[1] ) ?a.split(" ")[0]:0) >= 20011128 ;

	//受信処理
	if(window.opera || safari || mozes){
		obj.onload = function () { callback(obj); }
	} else {
		obj.onreadystatechange =function () {
			if (obj.readyState == 4 && obj.status == 200){
				callback(obj);
			}
		}
	}

	//URLエンコード
	if(method == 'GET') {
		var encdata = '';
		var datas = data.split('&');
		for(i=0;i<datas.length;i++) {
			var dataq = datas[i].split('=');
			encdata += '&'+encodeURI(dataq[0])+'='+encodeURI(dataq[1]);
		}
		url=url + encodeURI(data);
	}

	//open メソッド
	obj.open(method,url,async);

	//ヘッダセット
	if(method == 'POST') {
		if(!window.opera)
			obj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	} 

	//send メソッド
	obj.send(data);
}

function onloaded(res) {
	var resdata = res.responseText;
	document.getElementById("index").innerHTML += resdata;
//	alert(resdata);
}

window.document.onkeydown=not_bskey;

//BackSpaceキー押下防止 
function not_bskey(e) { 
	var tagname;
	var i_type;
	var i_flag;

	if (navigator.appName == "Microsoft Internet Explorer") {

		//ALT＋←ダメ 
		if( event.keyCode == 0x25 && event.altKey == true ) {
//			alert("ALT＋←はダメ！");
			return false ;
		} 

		tagname = window.document.activeElement.tagName;

		if((tagname == "INPUT") ||(tagname == "TEXTAREA")){

			i_type = window.document.activeElement.type;
			i_flag = window.document.activeElement.readOnly;

			if(((tagname == "INPUT") && (i_flag == false) && ((i_type == "text") ||(i_type == "password")))
				|| ((tagname == "TEXTAREA") && (i_flag == false))){
				return true; 
			}
		}

		//BackSpaceダメ 
		if( event.keyCode == 8 ) { 
//			alert("BackSpaseはダメ！"); 
			return false ;
		}

	} else if (navigator.appName == "Netscape") { 
		if (e.which == 8) { 
			return false; 
		}
	}
}

function check_ssl(setssl){

	// ＳＳＬで接続
	if (setssl=="1" && location.protocol=="http:"){
		location.href = "https://" + location.hostname + location.pathname;
	}
}

