
function agencycheck(){
	minLength=6;
	maxLength=12;
	inputbox = 0;
	inputname=document.form.name.value;
	inputtelephone=document.form.tel.value;
	inputemail=document.form.email.value;
	inputtel=document.form.tel.value;
	inputad=document.form.ad.value;
	inputservice=document.form.service.value;
	inputcountry=document.form.country_id[document.form.country_id.selectedIndex].value;
	inputcity=document.form.swapper[document.form.swapper.selectedIndex].value;
	inputcity=document.form.other_city.value;
	inputpass1=document.form.password.value;
	inputpass2=document.form.conpassword.value;
	if (document.form.agree.checked) {
	inputbox = 1; 
	}
	
	
	
	if (inputname==""){
	document.form.name.focus();
	alert("Type in an Agency Name");
	return false;
	}
	else if (inputtel==""){
	document.form.tel.focus();
	alert("Type in a telephone number for your advert.");
	return false;
	}	
	else if (inputemail==""){
	document.form.email.focus();
	alert("Type in an email address where we can contact you");
	return false;
	}
	else if (inputcountry==""){
	document.form.country_id.focus();
	alert("Please choose a country");
	return false;
	}	
	else if (inputcity=="" && (inputothercity==""||inputothercity=="Type area here")){
		document.form.swapper.focus();
		alert("Please choose a city.");
		return false;
	}
	else if (inputservice==""){
	document.form.service.focus();
	alert("Type in the area that your service covers. Please be accurate as this will appear on your advert.");
	return false;
	}
	else if (inputad==""){
	document.form.ad.focus();
	alert("Type in some text to describe your agency.");
	return false;
	}
	else if (inputpass1==""){
		document.form.password.focus();
		alert("Please type in a password");
		return false;
	}
	else if (inputpass1.length < minLength) {
		document.form.password.focus();
		alert('Your password must be at least ' + minLength + ' characters long. Try again.');
		return false;
	}
	else if (inputpass1.length > maxLength) {
		document.form.password.focus();
		alert('Your password must be no more than ' + maxLength + ' characters long. Try again.');
		return false;
	}
	/* check for spaces
	else if (inputpass1.indexOf(invalid) > -1) {
		document.form.password.focus();
		alert("Sorry, spaces are not allowed.");
		return false;
	}*/

	else if (inputpass1!=inputpass2){
					document.form.conpassword.focus();
					alert("Please confirm password");
					return false;
	}
	else if (inputbox==0) {
	document.form.agree.focus();
	alert("Please tick this box to confirm the statement.");
	return false;
	}

	else{
		return true;
	}
}
