// JavaScript Document

function displayMenu(currentMenu) {

    var thisMenu = document.getElementById(currentMenu).style

    // If the menu is expanded, contract it
    if (thisMenu.display == "block") {
        thisMenu.display = "none"
    }
    else {
        // If the menu is contracted, expand it
        thisMenu.display = "block"
    }
    return false
}



function returnPoster(N) {
	document.close;
	window.open(N, 'popD','toolbar=no,menubar=no,resizable=no,scrollbars=yes,status=no,location=no,width=500,height=500');
}



function isEmptyField(inputValue) {
	
	var aCharExists = false;
	
	for (var i=0; i <= inputValue.length; i++)
		{
		     if (inputValue.charAt(i) != " " && inputValue.charAt(i) != "")
			 {
				aCharExists = true;
			        break;
			 }
		}

    return aCharExists
}


function checksearch() {

  
  if (!isEmptyField(document.reosearch.STATE.value)) {
   	alert("Please fill in the state.");
   	document.reosearch.STATE.focus();
   	return false;
  }  

        

  document.reosearch.submit();

}

function checkpsw() {

  
  if (!isEmptyField(document.forgotPSW.FNAME.value)) {
   	alert("Please provide your first name.");
   	document.forgotPSW.FNAME.focus();
   	return false;
  }

  if (!isEmptyField(document.forgotPSW.LNAME.value)) {
   	alert("Please provide your last name.");
   	document.forgotPSW.LNAME.focus();
   	return false;
  }


  if (!isEmptyField(document.forgotPSW.EMAIL.value)) {
    alert("Please provide your email address.");
    document.forgotPSW.EMAIL.focus();
    return false;
  }

  document.forgotPSW.submit();

}

function checkpropertyloadform() {

  
  if (!isEmptyField(document.property.STREET_ADDRESS.value)) {
   	alert("Please fill in the property's street address.");
   	document.property.STREET_ADDRESS.focus();
   	return false;
  }
  if (!isEmptyField(document.property.CITY.value)) {
    alert("Please fill in the city.");
    document.property.CITY.focus();
    return false;
  }
  if (!isEmptyField(document.property.STATE.value)) {
   	alert("Please fill in the state.");
   	document.property.STATE.focus();
   	return false;
  }
  if (!isEmptyField(document.property.ZIP.value)) {
    alert("Please fill in your zip code.");
    document.property.ZIP.focus();
    return false;
  }
  if (!isEmptyField(document.property.FEE.value)) {
   	alert("Please provide the transaction fee.");
   	document.property.FEE.focus();
   	return false;
  }
  if (!isEmptyField(document.property.PRICE.value)) {
   	alert("Please provide the price.");
   	document.property.PRICE.focus();
   	return false;
  }
  if (!isEmptyField(document.property.BEDROOMS.value)) {
   	alert("Please fill in the number of bedrooms.");
   	document.property.BEDROOMS.focus();
   	return false;
  }
  if (!isEmptyField(document.property.BATHROOMS.value)) {
   	alert("Please select the number of bathrooms.");
   	document.property.BATHROOMS.focus();
   	return false;
  }
        

  document.property.submit();

}

function checkform() {

  if (!isEmptyField(document.candidate.FIRSTNAME.value)) {
   	alert("Please fill in the First Name.");
   	document.candidate.FIRSTNAME.focus();
   	return false;
  }

  if (!isEmptyField(document.candidate.LASTNAME.value)) {
   	alert("Please fill in the Last Name.");
   	document.candidate.LASTNAME.focus();
   	return false;
  }


  if (!isEmptyField(document.candidate.EMAIL.value)) {
   	alert("Please fill in the Email Address.");
   	document.candidate.EMAIL.focus();
   	return false;
  }

  if (!isEmptyField(document.candidate.DAYCONTACT.value)) {
   	alert("Please provide a phone number.");
   	document.candidate.DAYCONTACT.focus();
   	return false;
  }

  if (!isEmptyField(document.candidate.COMMENTS.value)) {
    alert("Please tell us the nature of your concern.");
    document.candidate.COMMENTS.focus();
    return false;
  }

      

  document.candidate.submit();

}

function checkpropertyID() {


  if (!isEmptyField(document.checkID.STREET.value)) {
   	alert("Please fill in the property's street address.");
   	document.checkID.STREET.focus();
   	return false;
  }
        

  document.checkID.submit();

}


function closePopUp(){
	self.close();
	}
