e questo:

document.getElementById(id).style.background = 'url('+currentBackground+')';

non funziona perché dovrebbe essere backgroundImage