function checkip(form) {
	
	var octet=form.networkadd.value.split(".");
	var i=3;
	while(i >= 0)
	{
	octet[i] = parseInt(octet[i]);
		if ((/[^0-9]/g.test(octet[i])) || octet[i] > '255') {
		alert(octet[i] + ' : Network address should be in the form of X.X.X.X where X is a positive integer between 0-255');
		form.networkadd.focus();
		return false;
		}
	i -= 1;
	}
}


function checkipgrp(form) {
	var octet1=form.startip.value.split(".");
	var octet2=form.endip.value.split(".");
	var i=3;
		while(i >= 0)
		{
		octet1[i] = parseInt(octet1[i]);
			if ((/[^0-9]/g.test(octet1[i])) || octet1[i] > '255') {
				alert(octet1[i] + ' : Network address should be in the form of X.X.X.X where X is a positive integer between 0-255');
				form.startip.focus();
				return false;
				}
		i -= 1;
		}
		i=3;
		while(i >= 0)
		{
		octet2[i] = parseInt(octet2[i]);
			if ((/[^0-9]/g.test(octet2[i])) || octet2[i] > '255') {
				alert(octet2[i] + ' : Network address should be in the form of X.X.X.X where X is a positive integer between 0-255');
				form.endip.focus();
				return false;
				}
		i -= 1;
		}
}

function bin2dec(inputValue) {


	for (z=0; z <= inputValue.length-1; z++) { //ensure input contains only 1s and 0s
		if(inputValue.charAt(z) != "0" && inputValue.charAt(z) != "1") {
			alert("All digits must be a binary 0 or a 1."); //alert user of error
			return false; //abort conversion
		}
	}

	outputValue = 0; //initially assume output value is zero

	for(i = inputValue.length-1; i >= 0; i -= 1) { //for each binary digit in input
		//add base two value for each binary 1 in input
		outputValue += eval(inputValue.charAt(i)) * Math.pow(2, inputValue.length-i-1);
	}

	document.getElementById("result").innerHTML = outputValue; //display output value in output field


}

function dec2bin(x) {

	
if ((/[^0-9]/g.test(x)) || x == "") {
alert ("You must enter an integer decimal number!");
document.getElementById("deci").value = "";
document.getElementById("deci").focus();
return false;
}
x = parseInt(x);
var bin = x.toString(2);
	document.getElementById("result").innerHTML = bin; //display output value in output field
	}
