+//////////////////// basic chackers
+function IPCheckerAtom (ip,id) {
+ if ( ! ip ) return "Empty field " + id;
+ ip_a = ip.split('.');
+ if ( ip_a.length != 4) return "Invalid IP (" + id + ") "+ ip;
+ for (var i=0; i<4; i++) if (ip_a[i]<0 || ip_a[i]>256) return "Invalid IP (" + id + ") "+ ip;
+ return "";
+}
+
+function IPCheckerSilent (id) { return IPCheckerAtom ( $(id).value, id); }
+
+function netmaskCheckerSilent (id) {
+ var netmask=$(id).value;
+ var check_ip = IPCheckerAtom (netmask,'netmask');
+ if (check_ip) return check_ip;
+ var masklen = get_masklen (netmask);
+ if (masklen <= 0) return "Invalid netmask " + netmask;
+ return "";
+}
+
+// focus on the field to check, other ones checked already
+function subnetChecker(id, optional) {
+ var error= subnetCheckerSilent($(id).value);
+ if (error) {
+ Form.Element.focus($(id));
+ alert(error);
+ }
+}
+
+function subnetCheckerSilent (id, optional) {
+
+ var subnet=$(id).value;
+ // skip this field if optional
+ if (optional && (subnet=="")) return "";
+ var check_ip = IPCheckerAtom (subnet,id);
+ if (check_ip) return check_ip;
+
+ var masklen = get_masklen ($('netmask').value);
+ if (masklen < 0) return "Could not check " + id;
+