function showBackGroundImage(index){
    if (index!=0){
        if (index == null){
 	        index = Math.round(10 * Math.random() )%imageCache.length;
            //index = Math.round(Math.random()*10);
            //index = index > 9 ? index - 10 : index;
        }else index = index-1;
        document.getElementById(objectId).style.backgroundImage='url(' + imageCache[index] + ')';
        if (backgroundSelecter!=null) backgroundSelecter.selectedIndex = 0;
    }
}
function addBackground(imgLocation, imgName){
    imageCache[imageCache.length] = imgLocation;
    var optn = document.createElement("OPTION");
    optn.text = imgName;
    backgroundSelecter.options.add(optn);
}

document.write('<form>');
document.write('<select id=imageSelection onchange="javascript:showBackGroundImage(selectedIndex);">');
document.write('<option> Select a background');
document.write('</select>');
document.write('</form>');

var backgroundSelecter = document.getElementById('imageSelection');
var imageCache = new Array();
var objectId = '';
