function blank(field) {

	var trimmed_field = Trim(field);
	if ((field.length == 0) || (trimmed_field.length == 0)) return true;
	return false;
}

function Trim(trim_value) {
	
	if (trim_value.length < 1) {
		return "";
	}
	
	trim_value = rTrim(trim_value);
	trim_value = lTrim(trim_value);
	
	if (trim_value == "") {
		return "";
	}
	else {
		return trim_value;
	}
}

function rTrim(trim_value) {
	
	var w_space = String.fromCharCode(32);
	var v_length = trim_value.length;
	var strTemp = "";
	if(v_length < 0) {
		return "";
	}
	var iTemp = v_length -1;
	
	while (iTemp > -1) {
		if (trim_value.charAt(iTemp) == w_space) {
		}
		else {
			strTemp = trim_value.substring(0,iTemp +1);
			break;
		}
		iTemp = iTemp-1;	
	}
	return strTemp;
}

function lTrim(trim_value) {
	
	var w_space = String.fromCharCode(32);
	if(v_length < 1){
		return "";
	}
	var v_length = trim_value.length;
	var strTemp = "";
	
	var iTemp = 0;
	
	while(iTemp < v_length) {
		if(trim_value.charAt(iTemp) == w_space) {
		}
		else {
			strTemp = trim_value.substring(iTemp,v_length);
		break;
		}
		iTemp = iTemp + 1;
	}
	return strTemp;
}


function checkForm() {
	
	var f = document.forms["f"];

	if (blank(f.fullname.value)) {
		alert('Please type in your name!');
		f.fullname.focus();
		return;
	}
	else if (blank(f.email.value)) {
		alert('Please type in your e-mail address!');
		f.email.focus();
		return;
	}

	else if (!f.agree.checked) {
		alert('Please confirm your details!');
		f.agree.focus();
		return;
	}
	
	f.submit();
}
