Background changer

Background changer

Hello,
Im not sure what is wrong with my script : | When i alert new background styles, it looks ok. When i click #go1, background disappears, but than appears same background : / I want to change it to bg+l+.jpg where l is number of background (i have 4 backgrounds).
Script:

  1.       <div id="inner" style="background:url(bg1.jpg) no-repeat center">Jakis tekst</div>
  2. <script>
  3.  var l = 1;
  4.  var str = "url(bg"+l+".jpg) no-repeat center";
  5.  $('#go1').click( function(){ 
  6.    $('#inner').fadeOut( 'slow', function(){
  7. l=l+1;
  8. if(l==5) {l=1;}
  9. str = "url(bg"+l+".jpg) no-repeat center";
  10. document.write(str);
  11. document.getElementById('inner').style.background = str;
  12.    })
  13.  });
  14. </script>