function addZero(s, n) {
	if(s < n * 10) {
		return "0" + s;
	} else {
		return s;
	}
}

function checkBox(e, id) {
	if(e.src.search("active") > -1) {
		e.src = "/" + path + "images/control/checkbox.gif";
		document.getElementById(id).value = 0;
	} else {
		e.src = "/" + path + "images/control/checkbox_active.gif";
		document.getElementById(id).value = 1;
	}
}

function focusError(e, color) {
	e.focus();
	if(color == "red") { startColor = "FF0000"; }
	if(color == "green") { startColor = "00FF00"; }
	if(color == "blue") { startColor = "0000FF"; }
	var finalColor = "";//e.style.backgroundColor;
	if(finalColor == "") { finalColor = "FFFFFF"; }
	bgChanger(e, startColor, finalColor, 25)
}

function switchRadio(group, e) {
	var rg = document.getElementById("radio_group_" + group);
	var es = rg.getElementsByTagName("img");
	
	for(i = 0; i < es.length; i++) {
		es[i].src = "/" + PATH + "images/control/radiobtn.gif";
	}
	
	e.src = "/" + PATH + "images/control/radiobtn_active.gif";
}

function increaseValue(e, target, max) {
	var n = eval(document.getElementById(target).value);
	
	if(e.src.search("disabled") > -1 && n <= max) {
		return false;
	} else {
		var c = document.getElementById(target + "_down");
		if(n == max - 1) {
			e.src = "/" + PATH + "images/control/counter_down_disabled.gif";
		}
		if(c.src.search("disabled") > -1) {
			c.src = "/" + PATH + "images/control/counter_down.gif";
		}
		document.getElementById(target).value = addZero(n + 1, 1);
	}
}

function decreaseValue(e, target, min) {
	var n = eval(document.getElementById(target).value);
	
	if(e.src.search("disabled") > -1 && n >= min) {
		return false;
	} else {
		var c = document.getElementById(target + "_up");
		if(n == min + 1) {
			e.src = "/" + PATH + "images/control/counter_down_disabled.gif";
		}
		if(c.src.search("disabled") > -1) {
			c.src = "/" + PATH + "images/control/counter_up.gif";
		}
		document.getElementById(target).value = addZero(n - 1, 1);
	}
}

function setValue(id, value) {
	document.getElementById(id).value = value;
}

function setComboValue(id, vh, vt) {
	setValue(id, vh);
	setValue(id + "_text", vt);
}
