function updateForm(what,count) {
	var selected = what.mySelect.selectedIndex;
	var value = what.mySelect.options[selected].value;
	for (var i = 0, pos = 0, oldpos = -1; pos >= 0; i++) {
		pos = value.indexOf(',',oldpos+1);
		if (pos == -1) {
			break;
		}
		var data = value.substring(oldpos+1,pos);
		if (data.indexOf("index:") === 0) {
			what.elements["route_index"].value = data.slice("index:".length);
			if (data.length > "index:".length+1) {
				what.elements["route_index"].style.background = "white";
			}
		} else if (data.indexOf("name:") === 0) {
			what.elements["name"].value = data.slice("name:".length);
			if (data.length > "name:".length+1) {
				what.elements["name"].style.background = "white";
			}
		} else if (data.indexOf("addr:") === 0) {
			what.elements["inet_addr"].value = data.slice("addr:".length);
			if (data.length > "addr:".length+1) {
				what.elements["inet_addr"].style.background = "white";
			}
		} else if (data.indexOf("port:") === 0) {
//			what.elements["inet_port"].value = data.slice("port:".length);
//			if (data.length > "port:".length+1) {
//			what.elements["inet_port"].style.background = "white";
		} else if (data.indexOf("pid:") === 0) {
			what.elements["pid"].value = data.slice("pid:".length);
			if (data.length > "pid:".length+1) {
				what.elements["pid"].style.background = "white";
			}
		} else if (data.indexOf("max:") === 0) {
			what.elements["max_rate"].value = data.slice("max:".length);
			if (data.length > "max:".length+1) {
				what.elements["max_rate"].style.background = "white";
			}
		} else if (data.indexOf("enabled:") === 0) {
			what.elements["enabled"].value = data.slice("enabled:".length);
			if (data.length > "enabled:".length+1) {
				what.elements["enabled"].style.background = "white";
			}
		}
		oldpos = pos;
	}
//	for (var i = 0, oldpos = -1; i<count-1; i++) {
//		pos = value.indexOf(',',oldpos+1);
//		data = value.substring(oldpos+1,pos);
//		what.elements['text' + i].value = value.substring(oldpos+1,pos);
//		oldpos = pos;
//	}
//	what.elements['text' + i].value = value.substring(oldpos+1,value.length)
}

function addRoute(form) {
	var text = form.elements['text0'].value + " - " + form.elements['text1'].value;
	var value = form.elements['text0'].value + "," + form.elements['text1'].value + "," + form.elements['text2'].value + "," + form.elements['text3'].value;
	form.mySelect.options[form.mySelect.options.length] = new Option( text, value, false, false);
}

function modifyRoute(form) {
	var selected = form.mySelect.selectedIndex;
	form.mySelect.options[selected].text = form.text0.value + " - " + form.text1.value;
	form.mySelect.options[selected].value = form.text0.value + "," + form.text1.value + "," + form.text2.value + "," + form.text3.value;
}

function clearText(form) {
	form.elements['text0'].value = "";
	form.elements['text1'].value = "";
	form.elements['text2'].value = "";
	form.elements['text3'].value = "";
}