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

function PortCheckSG(I){
	d =parseInt(I.value, 10);
	if (d>32768 || d<-32767) {
		alert('Port value is out of range [-32767 to 32768]');
		I.value = I.defaultValue;
	}
}

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

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

function netMaskCheck3(I){
	d =parseInt(I.value, 10);
	if( !(d==0 || d==128 || d==192 || d==224 || d==240 || d==248 || d==252 || d==254 )) {
		alert('Incorrect NetMask value!!!');
		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;
}

