Could you not use the placeholder attribute?
Edit:
Doing as Thomas Upton mentioned will not work because he is using the .value attribute. As soon as the user types something in, the value will change, therefore the function will not be able to check the (default) value correctly because it has been changed.
He could use the placeholder attribute instead to aid the function. Something like this:
<input type="text" name="lname" value="" placeholder="Last Name" style="color:gray;"
onblur="javascript:onBlurAction(this.name);"
onfocus="javascript:onBlurAction(this.name);"
onselect="javascript:onBlurAction(this.name);"
onclick="javascript:onBlurAction(this.name);">
function onBlurAction(elname)
{
value = document.getElementById(elname).getAttribute("placeholder");
if ((this.value == value) || (this.value == ''))
{
this.value = value;
this.style.color = 'gray';
}
else {
this.style.color = 'black';
}
}
He passes the element name to the function and this function will get the placeholder value. This will work for all his text inputs reusing the function as he wishes.
Test here: http://fiddle.jshell.net/6qMj8/1/