// LSS 247 Diary Submission Validation
function checkFields(form) {	
    if ( isBlank(form.name.value) ) {
      alert("Please enter your display name.");
      form.name.focus();
      return false;
    }
	
    if(form.niche.value == "none") {
      alert("Please select a community group.");
      form.niche.focus();
      return false;
    }

	if(form.byear.value == "none") {
	  alert("Please select a diary year.");
	  form.byear.focus();
	  return false;
	}
	
    if(form.bmonth.value == "none") {
      alert("Please select a diary month.");
      form.bmonth.focus();
      return false;
    }
	
	if(form.bday.value == "none") {
	  alert("Please select a diary day.");
	  form.bday.focus();
	  return false;
	}
	var thisDate = new Date();	
    var formDate = new Date(form.byear.value + " " + form.bmonth.value + " " + form.bday.value);
		
	if (formDate >= thisDate) {
	  alert("You may only enter a diary with a date previous to the current date or on the current date.");
	  return false;
	}

    if ( isBlank(form.entry.value) ) {
      alert("Please enter a diary entry.");
      form.entry.focus();
      return false;
    }
	
	if(form.termsRegs.checked == "") {
	  alert("You must agree to the Terms and Conditions before submitting your day diary.");
	  form.termsRegs.focus();
	  return false;
	}

  }

  function isBlank(s) {
    for( var i=0;i<s.length;i++ ) {
      var c = s.charAt(i);
      if( (c != ' ') && (c != '\n') && (c != '\t') )
        return false;
    }
    return true;
  }	
