function image(id, action, move) { var div = document.getElementById(id); if (action == 'next') { div.style.backgroundPosition += '0px '+move+'px'; } } image('idhere','next','-172')