﻿/************************************************************

	heal.js

	ヒール回復量シミュレータ

	(C) 2004 - 2006 Raginfo : www.raginfo.net

************************************************************/

var blv;
var sint;
var blessinglv;
var meditatiolv;

function keydown(){
	if((event.keyCode == 13) || (event.keyCode == 108)){
		correct();
	}
}

function initialize(){
	document.select.base_level.selectedIndex = 98;
	document.select.status_int.selectedIndex = 98;
	document.select.blessing.selectedIndex = 10;
	document.select.meditatio.selectedIndex = 0;

	correct();
}

function correct(){
	blv = parseInt(document.select.base_level.selectedIndex) +1;
	sint = parseInt(document.select.status_int.selectedIndex) +1;
	blessinglv = parseInt(document.select.blessing.selectedIndex);
	meditatiolv = parseInt(document.select.meditatio.selectedIndex);

	if((isNaN(blv)) || ((blv < 0) || (blv > 99))){
		blv = 1;
		document.select.base_level.value = 1;
		document.select.base_level.selectedIndex = 0;
	}

	if((isNaN(sint)) || (sint < 0)){
		sint = 1;
		document.select.status_int.value = 1;
		document.select.status_int.selectedIndex = 0;
	}

	if((isNaN(blessinglv)) || (blessinglv < 0)){
		blessinglv = 0;
		document.select.blessing.value = 0;
		document.select.blessing.selectedIndex = 0;
	}

	if((isNaN(meditatiolv)) || (meditatiolv < 0)){
		meditatiolv = 0;
		document.select.meditatio.value = 0;
		document.select.meditatio.selectedIndex = 0;
	}

	calculate();
}

function calculate(){
	var i = Math.floor((blv + sint + blessinglv) / 8) * 4;
	var result = new Array("");

	for(var j = 1; j <= 10; j ++){
		result[j] = Math.floor(i * (j * 2 + 1) * (1 + meditatiolv * 0.02));
		document.result.result[j - 1].value = result[j];
	}
}
