
function all_of_enable_change(){

	pf_wan_enable_change(document.pf_wanform);
	pf_lan_enable_change(document.pf_lanform);
	pf_mac_enable_change(document.pf_macform);
}

function pf_wan_enable_change(f)
{
	if (f.pf_wan_enable.checked) {	// enabled
		document.getElementById("table_pf_wan").className = "data_visible";
	} else {
		document.getElementById("table_pf_wan").className = "data_invisible";
	}
}

function pf_lan_enable_change(f)
{
	if (f.pf_lan_enable.checked) {	// enabled
		document.getElementById("table_pf_lan").className = "data_visible";
	} else {
		document.getElementById("table_pf_lan").className = "data_invisible";
	}
}

function pf_mac_enable_change(f)
{
	if (f.pf_mac_enable.checked) {	// enabled
		document.getElementById("table_pf_mac").className = "data_visible";
	} else {
		document.getElementById("table_pf_mac").className = "data_invisible";
	}
}

function pf_wanchk(f)
{
	var sche=f._wansche.options[f._wansche.options.selectedIndex].value;
	var tstart=f._wantstart.options[f._wantstart.options.selectedIndex].value;
	var tstop=f._wantstop.options[f._wantstop.options.selectedIndex].value;	
	if (	!valid(f._wansip.value, is_ip, "WAN source IP is in invalid format.") ||
		!value_between(f._wandport.value, 1, 65535, "LAN destination Port should be between 1..65535.") ) {
		return false;
	}
	if (sche == 1 && tstart >= tstop ) {
		alert("Stop time should be greater than the start time");
		return false;
	}
	return true;
}

function pf_lanchk(f)
{
	var sche=f._lansche.options[f._lansche.options.selectedIndex].value;
	var tstart=f._lantstart.options[f._lantstart.options.selectedIndex].value;
	var tstop=f._lantstop.options[f._lantstop.options.selectedIndex].value;	
	if (	!valid(f._lansip.value, is_ip, "LAN source IP is in invalid format.") ||
		!value_between(f._landport.value, 1, 65535, "LAN destination Port should be between 1..65535.") ) {
		return false;
	}
	if (sche == 1 && tstart >= tstop ) {
		alert("Stop time should be greater than the start time");
		return false;
	}
	return true;
}

function pf_macchk(f)
{
	var sche=f._macsche.options[f._macsche.options.selectedIndex].value;
	var tstart=f._mactstart.options[f._mactstart.options.selectedIndex].value;
	var tstop=f._mactstop.options[f._mactstop.options.selectedIndex].value;	
	f._mac.value=f._mac.value.toUpperCase();
	if (	!valid(f._mac.value, is_mac, "The MAC should be in xx:xx:xx:xx:xx:xx format.") ) {
		return false;
	}
	if (sche == 1 && tstart >= tstop ) {
		alert("Stop time should be greater than the start time");
		return false;
	}
	return true;
}

function pf_wan_ed(kval, wanen, wansip, wandport, wanprot, wansche, wandays, wantstart, wantstop)
{
	document.pf_wan_frm.kval.value=kval;
	document.pf_wan_frm._wanen.checked=wanen;
	document.pf_wan_frm._wansip.value= wansip;
	document.pf_wan_frm._wandport.value=wandport;
	document.pf_wan_frm._wanprot.value=wanprot;
	document.pf_wan_frm._wansche.value=wansche;
	document.pf_wan_frm._wandays.value=wandays;
	document.pf_wan_frm._wantstart.value=wantstart;
	document.pf_wan_frm._wantstop.value=wantstop;
}

function pf_lan_ed(kval, lanen, lansip, landport, lanprot, lansche, landays, lantstart, lantstop)
{
	document.pf_lan_frm.kval.value=kval;
	document.pf_lan_frm._lanen.checked=lanen;
	document.pf_lan_frm._lansip.value= lansip;
	document.pf_lan_frm._landport.value=landport;
	document.pf_lan_frm._lanprot.value=lanprot;
	document.pf_lan_frm._lansche.value=lansche;
	document.pf_lan_frm._landays.value=landays;
	document.pf_lan_frm._lantstart.value=lantstart;
	document.pf_lan_frm._lantstop.value=lantstop;
}

function pf_mac_ed(kval, macen, mac, macsche, macdays, mactstart, mactstop)
{
	document.pf_mac_frm.kval.value=kval;
	document.pf_mac_frm._macen.checked=macen;
	document.pf_mac_frm._mac.value=mac;
	document.pf_mac_frm._macsche.value=macsche;
	document.pf_mac_frm._macdays.value=macdays;
	document.pf_mac_frm._mactstart.value=mactstart;
	document.pf_mac_frm._mactstop.value=mactstop;
}
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;
}	

var lastwanid=-1;
function set_wan_hicolor (id)
{
	document.getElementById(id).className="opt_list_hicolor";
	if (lastwanid!=-1 && lastwanid!=id) document.getElementById(lastwanid).className="opt_list";
	lastwanid=id;
}	
var lastlanid=-1;
function set_lan_hicolor (id)
{
	document.getElementById(id).className="opt_list_hicolor";
	if (lastlanid!=-1 && lastlanid!=id) document.getElementById(lastlanid).className="opt_list";
	lastlanid=id;
}	
var lastmacid=-1;
function set_mac_hicolor (id)
{
	document.getElementById(id).className="opt_list_hicolor";
	if (lastmacid!=-1 && lastmacid!=id) document.getElementById(lastmacid).className="opt_list";
	lastid=id;
}	

