// Clock script's copyright is belong to: Nicolas - http://www.javascript-page.com
// Modified by NKC - 2005 - 03 - 31

function IsNumeric(sText) {
	var ValidChars = "0123456789";
	var IsNumber=true;
	var Char;
 
	for (i = 0; i < sText.length && IsNumber == true; i++) { 
		Char = sText.charAt(i); 
		if (ValidChars.indexOf(Char) == -1) {
			IsNumber = false;
		}
	}
	return IsNumber;
}

function auction_check(i) {
	oForm = document.getElementById("betting_form_" + i);
	if (IsNumeric(oForm.amount_val.value)) 
		oForm.submit();
	else {
		oForm.amount_val.focus();
		window.alert("幾らで参加したっけ？？");
		}
}

var clockID = 0;
function UpdateClock() {
	if(clockID) {
		clearTimeout(clockID);
	clockID  = 0;
	}
	var tDate = new Date();
	document.getElementById("NKC_clock").value = "★現在の日時　"
					+ ( (tDate.getYear()<2000) ? (1900+tDate.getYear()) : tDate.getYear() ) + "年"
					+ (tDate.getMonth()+1) + "月"
					+ tDate.getDate() + "日 "
					+ tDate.getHours() + ":" 
					+ ((tDate.getMinutes()<10)?"0"+tDate.getMinutes():tDate.getMinutes()) + ":" 
					+ ((tDate.getSeconds()<10)?"0"+tDate.getSeconds():tDate.getSeconds()) + "★";
	clockID = setTimeout("UpdateClock()", 1000);
}

function StartClock() {
	clockID = setTimeout("UpdateClock()", 500);
}

function KillClock() {
	if(clockID) {
		clearTimeout(clockID);
		clockID  = 0;
	}
}

function check_account (i) {
	oForm = document.getElementById("betting_form_" + i);
	oForm.task.value = "check_account";
	oForm.submit();
}

window.onload = StartClock;
window.onunload = KillClock;
