// Calc:
function t0choice(jd) {
	for(var i=1; i<3; i++) {
		var a = $("t0" + i).style;
		a.display = (!jd) ? "block" : "none";
	}
	if(jd) {
		$('t01').options[11].selected = true;
		$('t02').options[30].selected = true;
	}
}
function ts0choice(jd) {
	$('ts0').style.color = (jd) ? "#000" : "#666";
	$('tyousa').disabled = (jd) ? false : true;
}
function chDays() {
	$('t40').value = $('t30').value;
	$('t41').value = $('t31').value;
	$('t42').value = $('t32').value;
}
function tihouChoice(jd) {
	for(var i=1; i<4; i++) {
		$('valsx' + i).style.color = (jd) ? "#000" : "#666";
		$('vals' + i).disabled = (jd) ? false : true;
	}
}
function clearCk() {
	return (confirm(E_TEXTS1)) ? true : false;
}
function show() {
	$('calc_form_non').style.display = "block";
	$('results').style.display = "none";
	$('stepmenu').innerHTML = '<strong>STEP1</strong> <img src="./img/oh.gif" alt="icon" /> STEP2 <img src="./img/oh.gif" alt="icon" /> STEP3';
}
function valshow(id) {
	id = (id) ? id : '';
	var i = changeI($('vals' + id).value);
	if(+i==+i) {
		$('valshowx' + id).innerHTML = checkSum(i);
		return true;
	}else {
		alert(E_TEXTS2);
		$('vals' + id).value = '';
		$('valshowx' + id).innerHTML = '';
		return false;
	}
}
function changeI(str) {
	var val = new Array();
	for(var i=0; i<str.length; i++) {
		c = str.charCodeAt(i);
		if((c>=0xff10 && c<=0xff19) || c==0xff0c) {
			c = String.fromCharCode(c - 0xff10 + 0x30);
		}else {
			c = str[i];
		}
		val.push(c);
	}
	return val.join('').replace(',', '');
}
function checkSum(i) {
	i = Math.floor(i);
	return String(i).replace(/[0-9]+/gm, function(chr) {
		var k, cnt=0, n="";
		for(k=chr.length-1; k>=0; k--) {
			n = chr.charAt(k) + n;
			cnt++;
			if(!(cnt%3) && k) {
				n = "," + n;
			}
		}
		return n;
	});
}
function hide(id) {
	var a = $(id).style;
	a.display = (a.display=="none") ? "block" : "none";
}
// document.getElementById
function $(tagId) {
	return document.getElementById(tagId);
}
