Hey I finally worked it out, like I said it was pretty simple really,
replaced
Code:
document.getElementById(div_id).innerHTML = err;
with
Code:
document.getElementById(div_id).innerHTML = window[err];
// or also works
document.getElementById(div_id).innerHTML = this[err];
and now it works 100% 
But how would I go about using the same principal for replacing the field name in the following line, the other method doesn't work???
Code:
document.forms[form_id].fieldname.focus();
ok found it!
Code:
document.forms[form_id][fieldname].focus();
// or
document.forms[form_id].elements[fieldname].focus();
Bookmarks