While there is some tidying up for you to do in your PHP, it is not the cause of your javascript errors. THEY are in your javascript code.
Your function is not too bad. Use a semi-colon to end your statement, and use cleaner layout (style).
Also, remove the end of the HTML comment that you have in your script for no-script browsers...unless you want to include code for starting the HTML comment at the beginning, as I have done here:
<script language="javascript">
<!--
function pviiObjbg(obj, new_color) {
obj.style.backgroundColor=new_color;
}
// -->
</script>
Okay, now that that's clean, let's take a quick look at the missing code that triggers the function.
Frankly, that's where your problem is, yet you did not include it for us to see.
Your function requires two arguments to be passed to it...very specific arguments:
obj = a javascript OBJECT, not a name
new_color = a valid color reference
Let's say I have a table cell that needs to change background color when a mouse is rolled over the link contained in the cell. I need to (a) place the trigger code in an object that supports events, and I need to include the correct arguments for the function:
<table><tr>
<td id="cell1">
<a href="#"
onmouseover="pviiObjbg(document.all.cell1,'0000ff')">Go Blue!</a>
</td>
</tr></table>
By assigning an "id" to the cell, I have given IE the information it needs to identify that particular cell. As an argument, if I will be using it as you have in your function, I need to refer to that object completely enough so that when the function fills in the rest of the code, the whole object is available to IE (no Netscape for this type of activity).
The color reference is a "string", not a variable or an object, so I need to enclose it. I have used apostrophes, here, because I used quotation marks to define the start and end of the "onmouseover" attribute's value.
1) Be sure your functions are properly coded.
2) Be sure your object references are complete.
3) Be sure you are correctly defining strings.
Have fun!