function validateWorkForUsForm() {
	name = f_form.f_name.value;
	email = f_form.f_email.value;
	position = f_form.f_position.value;	
	availability = f_form.f_availability.value;
	skills = f_form.f_skills.value;

	trimWhiteSpaces(name);
	trimWhiteSpaces(email);
	trimWhiteSpaces(position);
	trimWhiteSpaces(availability);
	trimWhiteSpaces(skills);

	if(isEmpty(name)){
		return returnWarning("Please specify your name.");
	}
	if(!isValidEmail(email)) {
		return returnWarning("Please specify a valid email address.");
	}
	if(isEmpty(position)) {
		return returnWarning("Please specify the position you are interested in.");
	}
	if(isEmpty(availability)) {
		return returnWarning("Please specify an availability date.");
	}
	if(isEmpty(skills)) {
		return returnWarning("Please provide a description of the skills you offer.");
	}
	
	return true;
}

function validateWorkForYouForm() {
	name = f_form.f_name.value;
	email = f_form.f_email.value;
	comments = f_form.f_comments.value;
	
	trimWhiteSpaces(name);
	trimWhiteSpaces(email);
	trimWhiteSpaces(comments);

	if(isEmpty(name)){
		return returnWarning("Please specify your name.");
	}
	if(!isValidEmail(email)) {
		return returnWarning("Please specify a valid email address.");
	}
	if(f_form.f_type_of_work.selectedIndex == 0) {
		return returnWarning("Please specify the type of work required.");
	}
	if(isEmpty(comments)) {
		return returnWarning("Please specify some comments.");
	}
	
	return true;
}

function validateContactUsForm() {
	name = f_form.f_name.value;
	email = f_form.f_email.value;
	comments = f_form.f_comments.value;

	trimWhiteSpaces(name);
	trimWhiteSpaces(email);
	trimWhiteSpaces(comments);
	
	if(isEmpty(name)){
		return returnWarning("Please specify your name.");
	}
	if(!isValidEmail(email)) {
		return returnWarning("Please specify a valid email address.");
	}
	if(isEmpty(comments)) {
		return returnWarning("Please specify some comments.");
	}
	
	return true;
}

function resetContactUsForm() {
	f_form.f_name.value = '';
	f_form.f_email.value = '';
	f_form.f_phone.value = '';
	f_form.f_comments.value = '';
	return false;
}

function resetWorkForYouForm() {
	f_form.f_name.value = '';
	f_form.f_email.value = '';
	f_form.f_phone.value = '';
	f_form.f_comments.value = '';
	f_form.f_date_required.value = '';
	f_form.f_type_of_work.selectedIndex = 0;
	return false;
}

function resetWorkForUsForm() {
	f_form.f_name.value = '';
	f_form.f_email.value = '';
	f_form.f_address.value = '';
	f_form.f_city.value = '';
	f_form.f_state_prov.value = '';
	f_form.f_zip_postal.value = '';
	f_form.f_country.value = '';
	f_form.f_phone.value = '';
	f_form.f_availability.value = '';
	f_form.f_position.value = '';
	f_form.f_skills.value = '';
	f_form.f_comments.value = '';
	return false;
}

function returnWarning(text) {
	alert(text);
	return false;
}

/************************************************************************************************/
function trimWhiteSpaces(s) {
	// trim leading spaces
	while(''+s.charAt(0)==' ')
		s=s.substring(1,s.length);
		
	// trim trailing spaces
	while(''+s.charAt(s.length-1)==' ')
		s=s.substring(0,s.length-1);
}

function isValidEmail(email) {
	return email.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
}

function isEmpty(s) {
	return s==null || s.length == 0;
}