// Hjaltland Housing Association
//
// Common routines for page information and form processing.

function getYear() {
	var dNow = new Date();
	return(dNow.getFullYear());
}

function getWebmaster() {
	var csWebmasterEmail = "mail@hjaltland.org";
	var sResult = "<a href=\"mailto:" + csWebmasterEmail + "\">Webmaster</a>";
	
	return(sResult);
}

// This function runs when the user clicks the Submit button on a form.
// Input parameters: theform represents the name of the form
//                   requiredItems is a comma-delimited list of the elements that require values
// Output value: returns true if each required element has a value, otherwise displays message and returns false.
function formSubmit(theform, requiredItems) {
  var x;													// Counter for loop
  var ok = true;											// Return value, set initially to true
  var Str = new String('Please enter something for the following items:');  // Message to display
  var TmpStr = new String('')								// A temporary string processing value
  var requiredList = requiredItems.split(",");				// An array containing the names of the required elements,
  															//  set by the requiredItems paramenter
	
  for(x=0; x<requiredList.length; x++) {					// Loop for all items in requiredList array
	  if(theform.elements[requiredList[x]].value=='') {			// If the element contains no value...
		  ok = false;												// Set return value to false
          TmpStr = theform.elements[requiredList[x]].id;			// Stick the name of the element into TmpStr
          Str += '\n\t*  '+TmpStr.replace(/_/g, ' ');				// Add element name to message (replacing underscore _ with space) 
	  }															// End of If statement
  }															// End of loop
	  
  if(!ok) {													// If return value is false, display message
      alert(Str);
  }
	  
  return ok;												// Output return value
}
