$(function(){
	//tableあったら
	if($("table").size() > 0) {
		tablecloth(false,true,false);
	}
	//ログインページ
	if($(".login").size() > 0) {
		setHeight();
	}
		formCustom();
});
//ログインページ高さ
function setHeight() {
	if(navigator.appName=="Microsoft Internet Explorer"){
			WinSize = document.body.clientWidth - 440;
			}
		else {
			WinSize = window.innerHeight;
			}
		$(".login").css("padding-top",WinSize/4);
		$(".login").css("padding-bottom",WinSize/4);
}

//ログインフォーム
function formCustom() {
	$("select[@name = startday]").hide();
		$("input[@name = search_day]").click(function(){
				if($(this).attr("checked") == true) {
					$("select").fadeIn();
				}
				else {
					$("select").fadeOut();
				}
			});
		$("input[@name = login_id]").parent().append("<div class='err_id'><span></span></div>");
		$("input[@name = login_pass]").parent().append("<div class='err_pass'><span></span></div>");
		$("input[@name = login_id]").blur(function(){
			CheckId();
		});
		$("input[@name = login_pass]").blur(function(){
			CheckPw();
		});
		$("form[@name = form1]").submit(function(){
			return CheckAll();
		});
}
//半角英数字判定
function upperCheck(c) {
    var s = escape(c);
    if (s == c)	{
    	return true;
    }
    else if (s.length == 3) {
        code = s.charAt(1) + s.charAt(2);
        nm = parseInt(code, 16);
        if (nm > 0 && nm < 127)	{
        	return true;
    	}
    }
    else {
    	return false;
    }
}
//check
function CheckId () {
	var txt = document.form1.login_id.value;
	if(txt.match(/[Ａ-Ｚあ-んア-ンａ-ｚ]/)){
		$(".err_id span").text("半角英数字で入力してください。");
		$(".err_id").fadeIn();
    	return 1;
	}
	else if((txt.length < 4) || (txt.length > 10)) {
		$(".err_id span").text("4文字以上10文字以内で入力してください。");
		$(".err_id").fadeIn();
    	return 1;
	}
	$(".err_id").fadeOut();
    return 0;
}
function CheckPw () {
	var txt = document.form1.login_pass.value;
	if((txt.length < 4) || (txt.length >10)) {
		$(".err_pass span").text("4文字以上10文字以内で入力してください。");
		$(".err_pass").fadeIn();
    	return 1;
	}
	$(".err_pass").fadeOut();
    return 0;
}
function CheckAll () {
	check = 0;
	check += CheckId();
	check += CheckPw();
	if(check != 0) {
		return false;
	}
	return true;
}
