function PortCheck(I,low){
	d =parseInt(I.value, 10);
	if ( !( d<65536 && d>=low) ) {
		alert('Port value out of range ['+low+' - 65535]');
		I.value = I.defaultValue;
	}
}

function IPCheck(I){
	d =parseInt(I.value, 10);
	if ( !(d<256 && d>=0) ) {
		alert('IP value out of range [0 - 255]');
		I.value = I.defaultValue;
	}
}

function netMaskCheck(I,last){
	d =parseInt(I.value, 10);
	if( !(d==0 || d==128 || d==192 || d==224 || d==240 || d==248 || d==252 || d==254 || (!last && d==255) )) {
		alert('Incorrect netmask value');
		I.value = I.defaultValue;
	}
}

function volumeCheck(I) {
	d =parseInt(I.value, 10);
	if (d<0 || d>100) {
		alert('Volume setting out of range [0 - 100]');
		I.value=I.defaultValue;
	}
}

function serial_check(){
	f=document.forms["settings"];
	x=(f.B498.selectedIndex==1);	/* VSC */
	y=(f.B498.selectedIndex==1||f.B498.selectedIndex==2);	/* VSC or command port */
	/* serial settings */
	f.B81.disabled=x;
	f["B80b2-3"].disabled=x;
	f["B80b4-5"].disabled=x;
	f["B80b6-7"].disabled=x;
	f.B82.disabled=x;
	/* GW IP and port */
	f.W92.disabled=y;
	f.B88.disabled=y;
	f.B89.disabled=y;
	f.B90.disabled=y;
	f.B91.disabled=y;
}

function prio_vol_check() {
	f=document.forms["settings"];
	f.B243.disabled=(f.B240.selectedIndex==1);		/* fixed volume (idx=0) -> enable, configurable (idx=1) -> disable */
}
