var isIE = (navigator.appName == "Microsoft Internet Explorer");

//印刷用js

function PrintPage(){
	if(document.getElementById || document.layers){
		window.print();	
	}
}



//fla用js

function MM_openBrWindow(theURL,winName,features) {
window.open(theURL,winName,features);
}


//open Window
function m_win(url,windowname,width,height) {
 var features="location=no, menubar=no, status=yes, scrollbars=no, resizable=yes, toolbar=no";
 if (width) {
  if (window.screen.width > width)
   features+=", left="+0;
  else width=window.screen.width;
  features+=", width="+width;
 }
 if (height) {
  if (window.screen.height > height)
   features+=", top="+0;
  else height=window.screen.height;
  features+=", height="+height;
 }
 window.open(url,windowname,features);
}



//blank
window.onload = function() {
　var node_a = document.getElementsByTagName('a');
　for (var i in node_a) {
　　if (node_a[i].className == 'blank') {
　　　node_a[i].onclick = function() {
　　　　window.open(this.href, '', '');
　　　　return false;
　　　};
　　}
　}
};

//大学名検索用
function checkSnForm() {
	if(!document.snFind.name.value){
		alert("大学名が入力されていません。");
		document.snFind.name.focus();
	}else{
		location.href="http://www.hitorigurashi-japan.com/search/list/0?name="+encodeURI(document.snFind.name.value);
	}
}

// フォーム用 js

hanKana = " ｱｲｳｴｵｶｷｸｹｺｻｼｽｾｿﾀﾁﾂﾃﾄﾅﾆﾇﾈﾉﾊﾋﾌﾍﾎﾏﾐﾑﾒﾓﾔﾕﾖﾗﾘﾙﾚﾛﾜｦﾝｧｨｩｪｫｬｭｮ､｡｢｣ﾞﾟ";
zenKana = "　アイウエオカキクケコサシスセソタチツテトナニヌネノ";
zenKana += "ハヒフヘホマミムメモヤユヨラリルレロワヲンァィゥェォャュョ、。「」゛゜";
zenGana = "ガギグゲゴザジズゼゾダヂヅデドバビブベボ";
hanGana = "ｶｷｸｹｺｻｼｽｾｿﾀﾁﾂﾃﾄﾊﾋﾌﾍﾎ";
zenPana = "パピプペポ";
hanPana = "ﾊﾋﾌﾍﾎ";

hanNum = "0123456789-----";
zenNum = "０１２３４５６７８９ー–-—‐";

function inputCheck(){
	//区分
	if(! document.toroku.reruest.value){
		alert("区分を選択してください！");
		return false;
	}

	//お申し込みされる方
	if(! document.toroku.who.value){
		alert("お申し込みされる方を選択してください！");
		return false;
	}

	//フリガナ
	if(document.toroku.furi.value==""){
		alert("フリガナ入力してください。");
		document.toroku.furi.focus();
		return false;
	}

	//氏名
	if(document.toroku.shimei.value==""){
		alert("氏名を入力して下さい。");
		document.toroku.shimei.focus();
		return false;
	}

	//性別
	if(! document.toroku.sex.value){
		alert("性別を選択してください！");
		return false;
	}

	//郵便番号
	if(document.toroku.zip.value==""){
		alert("郵便番号を入力して下さい。");
		document.toroku.zip.focus();
		return false;
	}
	if(document.toroku.zip.value.length < 8){
		alert("郵便番号は000-0000形式で半角数字で入力してください。");
		document.toroku.zip.focus();
		return false;
	}

	//住所
	if(document.toroku.address.value==""){
		alert("住所を入力して下さい。");
		document.toroku.address.focus();
		return false;
	}

	//TEL等
	if(document.toroku.tel.value==""){
		alert("TELを入力して下さい。");
		document.toroku.tel.focus();
		return false;
	}
	if(document.toroku.tel.value.length < 11){
		alert("TELは00-0000-0000形式で半角数字で入力してください。");
		document.toroku.tel.focus();
		return false;
	}

	//このサイトを知ったきっかけ
	if(! document.toroku.reason_id.value){
		alert("このサイトを知ったきっかけを選択してください。");
		return false;
	}

	//学生の種類
	if(! document.toroku.sttype_id.value){
		alert("学生の種類を選択してください。");
		return false;
	}

	document.toroku.action="/shop/check.php";
	document.toroku.submit();
}

function sendData()
{
	document.toroku.action="/shop/send.php";
	document.toroku.submit();
}

function toHankakuNumConvert(obj)
{
	obj.value = toHankakuNum(obj.value);
}

function toZenkakuKanaConvert(obj)
{
	obj.value = toZenkakuKana(obj.value);
}

//半角カナから全角カナへ変換する
function toZenkakuKana(motoText)
{
	str = "";
	for (i=0;i<motoText.length;i++){
		x = "";
		c = motoText.charAt(i);

		n = hanKana.indexOf(c,0);
		if(n>=0) x = zenKana.charAt(n);

		n = zenKana.indexOf(c,0);
		if(n>=0) x = zenKana.charAt(n);

		n = zenGana.indexOf(c,0);
		if(n>=0) x = zenGana.charAt(n);

		n = zenPana.indexOf(c,0);
		if(n>=0) x = zenPana.charAt(n);

		str += x;
	}
	return str; 
}

//全角数値から半角数値へ変換する
function toHankakuNum(motoText)
{
	str = "";
	for (i=0;i<motoText.length;i++){
		x = "";
		c = motoText.charAt(i);

		n = hanNum.indexOf(c,0);
		if(n>=0) x = hanNum.charAt(n);

		n = zenNum.indexOf(c,0);
		if(n>=0) x = hanNum.charAt(n);

		str += x;
	}
	return str; 
}


function inputCheckContact(){
	//フリガナ
	if(document.toroku.furi.value==""){
		alert("フリガナ入力してください。");
		document.toroku.furi.focus();
		return false;
	}

	//氏名
	if(document.toroku.shimei.value==""){
		alert("氏名を入力して下さい。");
		document.toroku.shimei.focus();
		return false;
	}

	//メールアドレス
	if(document.toroku.mail.value==""){
		alert("メールアドレスを入力して下さい。");
		document.toroku.mail.focus();
		return false;
	}

	emails = document.toroku.mail.value;
	cflag1 = 0;
	for(var i=0; i < emails.length; i++){
		if(emails.charAt(i) == "@"){
			cflag1++;
		}
	}
	cflag2 = emails.indexOf(".");
	if(emails == "" || cflag1 != 1 || cflag2 < 1 || emails.length < 7){
		alert("メールアドレスを正しく入力してください。");
		document.toroku.mail.focus();
		return false
	}

	//TEL等
	if(document.toroku.tel.value==""){
		alert("TELを入力して下さい。");
		document.toroku.tel.focus();
		return false;
	}
	if(document.toroku.tel.value.length < 11){
		alert("TELは00-0000-0000形式で半角数字で入力してください。");
		document.toroku.tel.focus();
		return false;
	}
	document.toroku.action="/contact/check.php";
	document.toroku.submit();
}
