
function trim(ele) {
	while (ele.value.substring(0,1)==' ') {ele.value=ele.value.substring(1, ele.value.length)};
	while (ele.value.substring(ele.value.length-1,ele.value.length)==' ') {ele.value=ele.value.substring(0,ele.value.length-1)};
}


function row_on(key) {
	document.getElementById(key).className = "obj_on";
}


function row_off(key) {
	document.getElementById(key).className = "obj_off";
}


function inline_box(id) {
	if (document.getElementById(id).style.display == "inline") {
		document.getElementById(id).style.display = "none";
	} else {
		document.getElementById(id).style.display = "inline";
	}
}


function checktime(thetime) {
	var a,b,c,f,err=0;
	a=thetime.value;
	if (a.length == 4 && a.substring(2,1) == ':') {
		b = a.substring(0,1);
		f = a.substring(2,4);
		if (/\D/g.test(b)) err=1; //not a number
		if (/\D/g.test(f)) err=1;
		if (b<0 || b>9) err=1;
		if (f<0 || f>59) err=1;
		if (err==0) thetime.value = "0" + thetime.value;
	} else {
		b = a.substring(0,2);
		c = a.substring(2,3);
		f = a.substring(3,5);
		if (a.length != 5) err=1;
		if (/\D/g.test(b)) err=1; //not a number
		if (/\D/g.test(f)) err=1;
		if (b<0 || b>23) err=1;
		if (f<0 || f>59) err=1;
		if (c != ':') err=1;
	}

	if (err==1) {
		alert ('This is not a valid time!\nPlease enter in format HH:MM ');
		thetime.value = "";
		thetime.focus();
	}
}
