//
// weblog common scripts
// Copyright (C) bko 2009,10

function prev_month() {
	with (document.forms.F_ARCHIVE) {
		var current = month.value;
		var cur_year = current.substr(0,4);
		var cur_month = current.substr(4,2);
		--cur_month;
		if (cur_month <= 0) {
			--cur_year;
			cur_month = 12;
		}
		if (cur_month < 10) cur_month = '0' + cur_month;
		month.value = '' + cur_year + cur_month;
		submit();
	}
}

function go_month() {
	with (document.forms.F_ARCHIVE) {
		var go_year = sel_year.value;
		var go_month = sel_month.value;
		month.value = go_year.concat(go_month);
		submit();
	}
}

function next_month() {
	with (document.forms.F_ARCHIVE) {
		var current = month.value;
		var cur_year = current.substr(0,4);
		var cur_month = current.substr(4,2);
		++cur_month;
		if (cur_month > 12) {
			++cur_year;
			cur_month = 1;
		}
		if (cur_month < 10) cur_month = '0' + cur_month;
		month.value = '' + cur_year + cur_month;
		submit();
	}
}

function go_home() {
	document.location.href = 'weblog.cgi';
}

function preform(opt) {
	with (document.forms.F_ADMIN) {
		cmd.value = 'preform_' + opt;
		submit();
	}
}

function login() {
	with (document.forms.F_LOGIN) {
		if (log_username.value == "") {
			alert("ユーザ名を入力して下さい");
			log_username.focus();
			return false;
		}
		if (log_password.value == "") {
			alert("パスワードを入力して下さい");
			log_password.focus();
			return false;
		}
	}
	return true;
}

function help() {
	with (document.forms.F_ADMIN) {
		cmd.value = 'help';
		submit();
	}
}

function logout() {
	with (document.forms.F_ADMIN) {
		cmd.value = 'logout';
		submit();
	}
}
