
// autoclear enquiry form fields
document.observe("dom:loaded", function() {

  // list all enquiry fields
  $$('input.cfield','textarea.cfield').each( function(oField) {

    oField.observe('focus', fieldFocus);
    oField.observe('blur',  fieldBlur);

  });

});

// clears the title text from a form field, allowing the user to type
function fieldFocus(oEvent){

  // get field name and value
  var sName  = Event.element(oEvent).name.toLowerCase();
  var sValue = Event.element(oEvent).value.toLowerCase();

  // if the field value is the same as the name, clear it
  if( sName == sValue )
    Event.element(oEvent).value = "";
}

// resets a fields value to its name, if its blank
function fieldBlur(oEvent){

  // if element is blank, put in field name
  if( !Event.element(oEvent).value )
    Event.element(oEvent).value = Event.element(oEvent).name.capitalize();
}
