/* this script clears the default values of form fiels when the field recieves focus from the user */

// specify the name of your form
var thisForm = "contact";

// load field names and default values into list
var defaultVals = new Array();
defaultVals[0] = new Array("yourname", "Enter your name");
defaultVals[1] = new Array("subject", "How can we help you");
defaultVals[2] = new Array("email", "Enter your e-mail address");
defaultVals[3] = new Array("comments", "Enter your comments in the space provided");


// populate fields with default values on page load
function loadDefaultValues() {
with (document.forms[thisForm]) {
for (var n=0; n<defaultVals.length; n++) {
var thisField = defaultVals[n][0];
var thisDefault = defaultVals[n][1];
if (elements[thisField].value == '')
elements[thisField].value = thisDefault;
}}}

// clear default value from field when selected
function clearFields(field) {
var fieldName = field.name;
for (var n=0; n<defaultVals.length; n++) {
var thisField = defaultVals[n][0];
var thisDefault = defaultVals[n][1];
if (thisField == fieldName) {
if (field.value == thisDefault) field.value = '';
break;
}}}

// clear all defaults when form is submitted
function clearAll() {
with (document.forms[thisForm]) {
for (var n=0; n<defaultVals.length; n++) {
var thisField = defaultVals[n][0];
var thisDefault = defaultVals[n][1];
if (elements[thisField].value == thisDefault)
elements[thisField].value = '';
}}}

