

function validate_search() {
	var d = document.search_room;
	var c = d.city.value;
	var s = d.surface.value;
	var p = d.price.value;
	if (c == '-' || c == '') {
		return false;
	}
	else if (s == '0') {
		s = 'geen-voorkeur';
	}
	else {
		s = 'min-'+s+'-m2';
	}
	if (p == '0' || p == '501') {
		p = 'geen-voorkeur';
	} else {
		p = 'max-'+p;
	}
	document.location.href = 'http://www.allekoten.be/kot-'+c+'/'+p+'/'+s+'/';
	
	return false;
}
function validate_searchHave() {
	var d = document.search_profile;
	var c = d.city.value;
	var male = d.m.checked;
	var female = d.f.checked;
	var sexe;
	var p = d.price.value;
	if (c == '-' || c == '') {
		return false;
	}
	if (male == true && female == true) {
		sexe = 'man-vrouw';
	}
	else if (male == true) {
		sexe = 'man';
	}
	else if (female == true) {
		sexe = 'vrouw';
	}
	else {
		sexe = 'man-vrouw';
	}
	if (p == 0 || p == 501) {
		p = 'geen-voorkeur';
	} else {
		p = 'min-'+p;
	}
	document.location.href = 'http://www.allekoten.be/kot-'+c+'/zoekprofielen/'+sexe+'/'+p+'/';
	
	return false;
}

function validate_placeRoom() {
	var d = document.place_room;
	var errorsarray = new Array();
	if (d.street.value=='') {
		errorsarray.push(forgotField.replace("%fieldname%", street));
	}
	if (d.pc.value=='') {
		errorsarray.push(forgotField.replace("%fieldname%", zip_code));
	}
	if (d.no.value=='') {
	errorsarray.push(forgotField.replace("%fieldname%", no));
	}
	if (d.pc.value.length!=4) {
		errorsarray.push(amountField.replace("%fieldname%", zip_code));
	}
	if (d.city.value=='') {
		errorsarray.push(forgotField.replace("%fieldname%", city));
	}
	if (d.price.value=='') {
		errorsarray.push(forgotField.replace("%fieldname%", price));
	}
	if (d.surface.value=='') {
		errorsarray.push(forgotField.replace("%fieldname%", surface));
	}
	if (d.type_object.selectedIndex==0) {
		errorsarray.push(forgotSelectField.replace("%fieldname%", type_object));
	}
	if (d.description.value=='') {
		errorsarray.push(forgotField.replace("%fieldname%", description));
	}
	if (d.description.value.length<15) {
		errorsarray.push(shortField.replace("%fieldname%", description));
	}
	if (errorsarray.length > 0) {
		var errortext = '';
		for(var x = 0; x < errorsarray.length; x ++) {
			errortext = errortext + "&mdash; "+errorsarray[x] + "<br>";
		}
		$("#errormessage").html(errortext);
		$("#errormessage").slideDown();
		return false;
	} else {
		
		document.getElementById('submit').value = busy;

		document.getElementById('submit').disabled = 1;
		return true;
	}
}



function validate_placeProfile() {
	var d = document.place_profile;
	var errorsarray = new Array();
	if (d.city.value=='') {
		errorsarray.push(forgotField.replace("%fieldname%", city));
	}
	if (d.price.value=='') {
		errorsarray.push(forgotField.replace("%fieldname%", price));
	}
	if (d.surface.value=='') {
	errorsarray.push(forgotField.replace("%fieldname%", surface));
	}
	if (d.movingdate.value=='') {
		errorsarray.push(forgotField.replace("%fieldname%", movingdate));
	}
	if (d.age.value=='') {
		errorsarray.push(forgotField.replace("%fieldname%", age));
	}
	if (d.sexe[0].checked==false && d.sexe[1].checked==false) {
		errorsarray.push(forgotField.replace("%fieldname%", sexe));
	}
	if (d.profession[0].checked==false && d.profession[1].checked==false) {
		errorsarray.push(forgotField.replace("%fieldname%", profession));
	}
	if (d.description.value=='') {
		errorsarray.push(forgotField.replace("%fieldname%", description));
	}
	if (d.description.value.length<15) {
		errorsarray.push(shortField.replace("%fieldname%", description));
	}
	if (errorsarray.length > 0) {
		var errortext = '';
		for(var x = 0; x < errorsarray.length; x ++) {
			errortext = errortext + "&mdash; "+errorsarray[x] + "<br>";
		}
		$("#errormessage").html(errortext);
		$("#errormessage").slideDown();
		return false;
	} else {
		document.getElementById('submit').value = busy;
		
		document.getElementById('submit').disabled = 1;
		return true;
	}
}



function validate_contact() {
	var d = document.contact;
	var errorsarray = new Array();
	if (d.name.value=='') {
		errorsarray.push(forgotField.replace("%fieldname%", name));
	}
	if (d.email.value=='') {
		errorsarray.push(forgotField.replace("%fieldname%", email));
	}
	if (d.message.value=='') {
		errorsarray.push(forgotField.replace("%fieldname%", message));
	}
	if (d.agree.checked==false) {
		errorsarray.push(forgotAccept.replace("%fieldname%", agreement));
	}
	

	if (errorsarray.length > 0) {
		var errortext = '';
		for(var x = 0; x < errorsarray.length; x ++) {
			errortext = errortext + "&mdash; "+errorsarray[x] + "<br>";
		}
		$("#errormessage").html(errortext);
		$("#errormessage").slideDown();
		return false;
	} else {
		return true;
	}
}

