<?php
	require("../../_myhome/__common__/__define_common.php");
	require("../__common__/__define_mobile.php");

	require("../lib/hawhaw.inc");

	require("../../_myhome/__common__/include-common-all.php");
	require("../__common__/include-common-mobile.php");

	$myPage = mobile_init('Login', '#e0f0ff');

	if ($_POST['account'].'' <> '') {
		$errmsg = post_done_proc($myPage);
	}
	login_form($myPage, $errmsg);
	exit();
?>
<?php
function login_form($myPage, $msg='') {
	$myForm	= new HAW_form($_SERVER['SCRIPT_NAME'], HAW_METHOD_POST);

	$myAccount = new HAW_input('account','',mobile_encode('アカウント'));
	$myAccount->set_size(12);
	$myPassword = new HAW_input('password','',mobile_encode('パスワード'));
	$myPassword->set_size(12);
	$myPassword->set_type(HAW_INPUT_PASSWORD);
	$mySubmit = new HAW_submit(mobile_encode('ログイン'),'Login');

	$myForm->add_input($myAccount);
	$myForm->add_input($myPassword);
	$myForm->add_submit($mySubmit);
	$myPage->add_form($myForm);
	if ($msg) {
		mobile_add_text($myPage, $msg);
	}
	$myPage->create_page();
	return;
}
function post_done_proc($myPage) {
	if (isset($_POST['account'])) {
		$account = form_str_adjust($_POST['account']);
	}
	if (isset($_POST['password'])) {
		$password = $_POST['password'];
	}
	if (($errmsg=mobile_login($myPage, $account, $password)) == '') {
		redirect('../?'.SID);
		//redirect('../calendar/?'.SID);
	}
	return $errmsg;
}
?>
