function validate_signup(signup){
	if(signup != 1){
		if(document.signup.new_pass1.value != document.signup.new_pass2.value){
			alert("New passwords do not match!");
			return;
		}
	}
	
	if(document.signup.email.value == false){
		alert("Please fill in 'Email' field!");
		document.signup.email.focus();
	}
	else if(document.signup.first_name.value == false){
		alert("Please fill in 'First name' field!");
		document.signup.first_name.focus();
	}
	else if(document.signup.last_name.value == false){
		alert("Please fill in 'Last name' field!");
		document.signup.last_name.focus();
	}
	else if(document.signup.user_address.value == false){
		alert("Please fill in 'Address' field!");
		document.signup.user_address.focus();
	}
	else{
		document.signup.submit();
	}
}

function check_for_num(){
	if(!Math.abs(document.property.rent.value) && document.property.rent.value.length > 0){
		alert("'Monthly rent' should be a number and more than 0");
		document.property.rent.value = '';
		document.property.rent.focus();
	}
}

function validate_post(){
	if(document.property.address.value == false){
		alert("Please fill in 'Address' field");
		document.property.address.focus();
	}
	else if(document.property.zip.value == false){
		alert("Please fill in 'Zip' field");
		document.property.zip.focus();
	}
	else if(document.property.area.value == false){
		alert("Please, specify approximate area!");
		document.property.area.focus();
	}
	else if(!Math.abs(document.property.area.value)){
		alert("'Area' should be a number and more than 0");
		document.property.area.focus();
	}
	else if(document.property.rent.value == false){
		alert("Please fill in 'Monthly rent' field");
		document.property.rent.focus();
	}
	else if(!Math.abs(document.property.rent.value)){
		alert("'Monthly rent' should be a number and more than 0");
		document.property.rent.focus();
	}
	else if(Math.abs(document.property.spots.value) < 0 && document.property.spots.value.length > 0){
		alert("'Spots' should be a number");
		document.property.spots.focus();
	}
	else if(Math.abs(document.property.security_deposit.value) < 0 && document.property.security_deposit.value.length > 0){
		alert("'Security deposit' should be a number");
		document.property.security_deposit.focus();
	}
	else if(Math.abs(document.property.key_deposit.value) < 0 && document.property.key_deposit.value.length > 0){
		alert("'Key deposit' should be a number");
		document.property.key_deposit.focus();
	}
	else{
		document.property.submit();
	}	
}

function validate_roommate(){
	if(document.roommate.age.value == false){
		alert("Specify your age please!");
		document.roommate.age.focus();
	}
	else if(!Math.abs(document.roommate.age.value) && document.roommate.age.value.length > 0){
		alert("'Age' should be a number and more than 0");
		document.roommate.age.focus();
	}
	else if(document.roommate.occupation.value == false){
		alert("Specify your occupation please!");
		document.roommate.occupation.focus();
	}
	else{
		document.roommate.submit();
	}
}

function validate_apt_post(){
	if(document.property.rent.value == false){
		alert("Specify monthly rent price please!");
		document.property.rent.focus();
	}
	else if(document.property.area.value == false){
		alert("Specify approximate area please!");
		document.property.rent.focus();
	}
	else if(!Math.abs(document.property.rent.value)){
		alert("'Monthly rent' should be a number and more than 0");
		document.property.rent.focus();
	}
	else if(Math.abs(document.property.spots.value) < 0 && document.property.spots.value.length > 0){
		alert("'Spots' should be a number");
		document.property.spots.focus();
	}
/*	else if(!Math.abs(document.property.spot_price.value)){
		alert("'Spot price' should be a number");
		document.property.spot_price.focus();
	}
	else if(!Math.abs(document.property.security_deposit.value) && document.property.security_deposit.value.length > 0){
		alert("'Security deposit' should be a number and more than 0");
		document.property.security_deposit.focus();
	}
	else if(!Math.abs(document.property.key_deposit.value) && document.property.key_deposit.value.length > 0){
		alert("'Key deposit' should be a number and more than 0");
		document.property.key_deposit.focus();
	}*/
	else{
		document.property.submit();
	}
}

function check_unit_type(){
	if(document.property.unit_type.value == 'Single Family'){
		document.property.floor.disabled = true;
		document.property.topfloor.disabled = true;
	}
	else{
		document.property.floor.disabled = false;
		document.property.topfloor.disabled = false;	
	}
}

function check_parking(){
	if(document.property.parking.checked == true){
		document.property.spots.disabled = false;
		document.property.spot_price.disabled = false;
	}
	else{
		document.property.spots.disabled = true;
		document.property.spot_price.disabled = true;
	}
}

function other_sel(){
	if(document.property.fee.value == 'Other'){
		document.property.other_fee.disabled = false;
		document.property.other_fee.value = '';
	}
	else{
		document.property.other_fee.disabled = true;
		if(document.property.fee.value == 'No fee'){
			document.property.other_fee.value = '0';
		}
		else if(document.property.fee.value == '1/2 month fee'){
			document.property.other_fee.value = document.property.rent.value / 2;
		}
		else if(document.property.fee.value == 'One month fee'){
			document.property.other_fee.value = document.property.rent.value;
		}
	}
}

function laundry_chk(){
	if(document.property.laundry.checked == true){
		document.property.laundry_type.disabled = false;
		document.property.laundry_disp.disabled = false;
	}
	else{
		document.property.laundry_type.disabled = true;
		document.property.laundry_disp.disabled = true;
	}
}
