function setCoef() {var coef = document.getElementById('coef').value;if (coef.match(/^[01](\.\d+)?$/)) {setGlobalVar('coef', coef);};}; function restoreCoef() {var coef = getGlobalVar('coef');if (coef !== undefined && coef > 0) {document.getElementById('coef').value = coef;} else {document.getElementById('coef').value = 1;}};