function staticroute_ed(kval, en, type, target, netmask, gateway)
{
	//document.staticroute_frm.kval.value=kval;
	
	document.staticroute_frm.kval.value=kval;
	document.staticroute_frm._en.checked=en;
	selectoption(document.staticroute_frm._type, type);
	document.staticroute_frm._target.value=target;
	selectoption(document.staticroute_frm._netmask, netmask);
	document.staticroute_frm._gateway.value=gateway;
}

function staticroute_submitchk(f)
{
	var type=f._type.options[f._type.options.selectedIndex].value;
	var mask=f._netmask.options[f._netmask.options.selectedIndex].value;

	if (!valid(f._target.value, is_ip, "Target is in invalid format.") ||
	    !valid(f._gateway.value, is_ip, "Gateway is in invalid format.") ) {
		return false;
	}
	if (type=="net" && !is_network(f._target.value, mask)) {
		alert("The Target is not a network number under netmask "+mask);
		return false;
	}
	if (type=="host" && mask!="255.255.255.255") {
		alert("The host type route must have netmask 255.255.255.255");
		return false;
	}
	return true;
}


function selectoption (menu, value)
{
	var i_default=0;

	for (var i=0; i<menu.length; i++) {
		if (menu.options[i].value==value) {
			menu.options[i].selected=true;
			return i;
		}
		if (menu.options[i].defaultSelected) {
			i_default=i;
		}
	}

	menu.options[i_default].selected=true;
	return i_default;
}

var lastid=-1;
function set_hicolor (id)
{
	document.getElementById(id).className="opt_list_hicolor";
	if (lastid!=-1 && lastid!=id)
		document.getElementById(lastid).className="opt_list";
	lastid=id;
}	

