function checkForm(form) {	

	if (!checkFirstName(form.firstname.value)) {
		form.firstname.focus();
		return false;
	}else if (!checkLastName(form.lastname.value)) {
		form.lastname.focus();
		return false;
	}else if (!checkCity(form.city.value)) {
		form.city.focus();
		return false;		
	}else if (!checkCode2(form.code2.value)) {
		form.code2.focus();
		return false;
	}else if (!checkTelephone(form.telephone_number.value)) {
		form.telephone_number.focus();
		return false;
	}else if (!checkCommentJunk(form.comments.value)) {
		form.comments.focus();
		return false;	
	}else if (!checkEmail(form.email.value)) {
		form.email.focus();
		return false;
	/*}else if (!form.contractagree.checked) {			
		form.contractagree.focus();
		alert("Please consent to the use of your personal details");*/
	}else if (!checkRequest()) {
		form.request.focus();
		return false;
	} else {
		return true;
	}
	
	
	
}


function checkCommentJunk(comments) {
	if (comments.indexOf("href") >= 0) {
		alert("No links in your comments please");
		return false;
	}else{
	
	return true;
	}
}


function checkFirstName(firstname) {
	if (firstname == "") {
		alert("Please enter your first name");
		return false;
	}else{
	
	return true;
	}
}

function checkLastName(lastname) {
	if (lastname == "") {
		alert("Please enter your surname");
		return false;
	}else{
		return true;
	}
}


function checkCountry(country) {
	if (country == "") {
		alert("Please enter your country");
		return false;
	} else{
		return true;
	}
}


function checkCity(city) {
	if (city == "") {
		alert("Please enter your city");
		return false;
	} else{
		return true;
	}
}



function checkEmail(email) {
	if (checkBlank(email)) {
		alert("Please enter your E-mail address");
		return false; 
	}
	var atfound = email.indexOf("@");
	if(atfound == -1) {
		alert("Please enter a valid E-mail address with an @");
		return false;
	}
	
	if(email.indexOf(".", atfound) == -1) {
		alert("Please enter a valid E-mail domain after the @");
		return false;
	}
	return true;
}

function checkCode1(code1) {
	if (code1 == "") {
		alert("Please enter your country code");
		return false;
	}
	return true;
	
}

function checkCode2(code2) {
	if (code2 == "") {
		alert("Please enter your local code");
		return false;
	}
	return true;
}

function checkTelephone(telephone_number) {
	if (telephone_number == "") {
		alert("Please enter your telephone number");
		return false;
	}
	return true;
}


function checkBlank(string) {
	if(string.length == 0)
		return true;
	for (var i = 0; i <= string.length-1; i++) {
		if (string.charAt(i) != " ") { 
		}	return false;
		return true;
	}
}

function checkRequest() {
	if(document.contact_us.request.options[document.contact_us.request.selectedIndex].value==-1){
		alert("Please enter your type of request");
		return false;
	}
	return true;
}


