function dhcp_enable_change(f)
{
	var f=document.dhcpform;
	if (f.dhcp_enable.checked) {	// dhcp server enabled
	
		document.getElementById("row_dhcp_eip").className = "data_visible";
		document.getElementById("row_dhcp_ip").className = "data_visible";
		document.getElementById("row_dhcp_leasetime").className = "data_visible";
		//document.getElementById("title_dhcp_st").className = "data_visible";
		document.getElementById("table_dhcp_st").className = "data_visible";
		document.getElementById("table_dhcp_cl").className = "data_visible";
		
	} else {				// dhcp server disabled
		document.getElementById("row_dhcp_eip").className = "data_invisible";
		document.getElementById("row_dhcp_ip").className = "data_invisible";
		document.getElementById("row_dhcp_leasetime").className = "data_invisible";
		//document.getElementById("title_dhcp_st").className = "data_invisible";
		document.getElementById("table_dhcp_st").className = "data_invisible";
		document.getElementById("table_dhcp_cl").className = "data_invisible";
		
	}
}


function submitchk(f)
{
	var dhcp_ip_start;
	var dhcp_ip_end;

	
	dhcp_ip_start=lan_ip_subnet+"."+f.dhcp_number_start.value;
	dhcp_ip_end=lan_ip_subnet+"."+f.dhcp_number_end.value;
	
	if (f.dhcp_enable.checked) {
	
		if (!valid(dhcp_ip_start, is_ip, "DHCP Start IP is invalid format.")){
			f.dhcp_number_start.focus();
			return false;
		}
		
		if (!valid(dhcp_ip_end, is_ip, "DHCP End IP is invalid format.")){
			f.dhcp_number_end.focus();
			return false;
		}
		
		if (is_ip_gt(dhcp_ip_start, dhcp_ip_end)) {
			alert("DHCP START IP shot not be larger than DHCP END IP.");
			return false;
		}
		if (is_ip_ge(f.lan_ip.value, dhcp_ip_start) && is_ip_le(f.lan_ip.value, dhcp_ip_end)) {
			alert("The DHCP IP "+ dhcp_ip_start + " .. " + dhcp_ip_end + " should not include the LAN IP " + f.lan_ip.value + ".");
			return false;
		}
		
		if (!integer_between(f.dhcp_leasetime.value, 60, 864000, "DHCP lease time should be an integer between 60..846000.")) 
			return false;
	}
	
	setMutiCookie("changeLogs","udhcpd,",30);
	return true;
}

function dhcp_st_ed(kval, mac, ip, desc)
{
	document.dhcp_st_frm.kval.value=kval;
	document.dhcp_st_frm._mac.value=mac;
	document.dhcp_st_frm._ip.value=ip;
	document.dhcp_st_frm._desc.value=desc;
}
function st_submitchk(f)
{
	if (!valid(f._mac.value, is_mac, "The MAC should be in xx:xx:xx:xx:xx:xx format.") ||
	    !valid(f._ip.value, is_ip, "The IP is in invalid format.") ) {
		return false;
	}
	return true;
}

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;
}	

