Posted By

dottDesign on 01/20/11


Tagged

javascript textmate


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

virendrakryadav


Chaneg Image On Season


 / Published in: jQuery
 

  1. <script type="text/javascript">
  2. function start() {
  3. var north = true;
  4. var backImg = ['/summer_header.jpg','/autumn_header.jpg','/winter_header.jpg','/spring_header.jpg'];
  5. var today = new Date();
  6. var month = today.getMonth();
  7. if (today.getDate() > 20) month++;
  8. document.getElementById('page_header_inner').style.backgroundImage = 'url('+backImg[Math.floor((month+(north?6:0))/3)%4]+')';
  9. }
  10.  
  11. var pageLoaded = 0;
  12. window.onload = function() {pageLoaded = 1;}
  13. function loaded(i,f) {
  14. if (document.getElementById && document.getElementById(i) != null) f();
  15. else if (!pageLoaded) setTimeout('loaded(''+i+'','+f+')',100);
  16. }
  17. loaded('page_header_inner',start);
  18.  
  19.  
  20. </script>

Report this snippet  

You need to login to post a comment.