function calcID(f) {
 var aux = (f.IP4.value<<23)+(f.IP3.value<<15)+(f.IP2.value<<7)+(f.IP1.value>>1);
 var last = f.IP1.value & 1 ;
 var cinq = aux % 5 ;
 last += 2*cinq ;
 aux = (aux - cinq)/5 ;
 f.ID.value = aux.toString(10) + last.toString(10) ;
}

function calcIP(f) {
f.IP1.value = f.ID.value & 255 ;
f.IP2.value = (f.ID.value >>8) & 255 ;
f.IP3.value = (f.ID.value >>16) & 255 ;
f.IP4.value = (f.ID.value >>24) & 255 ;
}

function IP(f,c)
{
var n;
if (c == 1) n = f.IP1.value;
if (c == 2) n = f.IP2.value;
if (c == 3) n = f.IP3.value;
if (c == 4) n = f.IP4.value;
if (n < 0) {
	alert("la valeur doit etre comprise entre 0 et 255");
	n = 0 ;
	}
if (n > 255) {
	alert("la valeur doit etre comprise entre 0 et 255");
	n = 255;
	}
if (c == 1) f.IP1.value = n;
if (c == 2) f.IP2.value = n;
if (c == 3) f.IP3.value = n;
if (c == 4) f.IP4.value = n;
calcID(f);
}


