function ChainEvent(evt, f) {
	if (window.addEventListener)
		window.addEventListener(evt, f, true);
	else
		window.attachEvent('on' + evt, f);
    }

ChainEvent('load', function() {
	var snowman = document.createElement('img');
	var now_date = new Date()
	var img_name = 'snowman.png';
	if (now_date.getMonth() == 11 && now_date.getDate() >= 25)
	  img_name = 'snowman-xmas.png';
	else
	  if (now_date.getMonth() == 0 && now_date.getDate() <= 10)
		img_name = 'snowman-newyear.png';
	snowman.setAttribute('id', 'snowman');
	snowman.setAttribute('src', 'http://sites.google.com/site/livibetter/blog-files/snow/' + img_name + '?attredirects=0');
	snowman.style.position = 'absolute';
	snowman.style.left = 0;
	snowman.style.top = ((window.pageYOffset ? window.pageYOffset : (document.body.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop)) + 
		(window.innerHeight ? window.innerHeight : (document.documentElement.clientHeight ? document.documentElement.clientHeight: document.body.clientHeight)) - 300) + 'px';
	document.getElementsByTagName('body')[0].appendChild(snowman);
	});

var SnowmanMove = function() {
		var snowman = document.getElementById('snowman');
		if (snowman) {
		snowman.style.top = ((window.pageYOffset ? window.pageYOffset : (document.body.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop)) + 
			(window.innerHeight ? window.innerHeight : (document.documentElement.clientHeight ? document.documentElement.clientHeight: document.body.clientHeight)) - 300) + 'px';
			}
		};

ChainEvent('scroll', SnowmanMove);
ChainEvent('resize', SnowmanMove);
