I'm doing some webpage work and need to change the background image of a div and need to decide what image to use at runtime. So I want to use a variable when I change the background image. Here's what I'm doing and what I want to change for it to work like I want it to. I put all the info in the comments. The basic problem is I can't get a variable to work when I set the background image path. Any help would be appreciated.

// What I want to do but doesn't work
//
// I want to set the button image at runtime to
// different buttons from different locations. So
// basically I want to use a variable when I set
// the background image of the div. I don't have
// much experience doing this so if you can help
// I'd really appreciate it.
//
function changeBGImage(div_id, btn_state)
{
var root_path = getRootPath();
if(btn_state == 'up')
{
var btn_path = root_path + 'graphics/btn-unselected.gif';
document.getElementById(div_id).style.backgroundIm age = 'url(btn_path)';
}
if(btn_state == 'dn')
{
var btn_path = root_path + 'graphics/btn-selected.gif';
document.getElementById(div_id).style.backgroundIm age = 'url(btn_path)';
}
}

I'm doing some webpage work and need to change the background image of a div and need to decide what image to use at runtime. So I want to use a variable when I change the background image. Here's what I'm doing and what I want to change for it to work like I want it to. I put all the info in the comments. The basic problem is I can't get a variable to work when I set the background image path. Any help would be appreciated.

// What I want to do but doesn't work
//
// I want to set the button image at runtime to
// different buttons from different locations. So
// basically I want to use a variable when I set
// the background image of the div. I don't have
// much experience doing this so if you can help
// I'd really appreciate it.
//
function changeBGImage(div_id, btn_state)
{
var root_path = getRootPath();
if(btn_state == 'up')
{
var btn_path = root_path + 'graphics/btn-unselected.gif';
document.getElementById(div_id).style.backgroundIm age = 'url(btn_path)';
}
if(btn_state == 'dn')
{
var btn_path = root_path + 'graphics/btn-selected.gif';
document.getElementById(div_id).style.backgroundIm age = 'url(btn_path)';
}
}