
window_x = -1;
window_y = -1;
window_w = -1;
window_h = -1;
function h_scroll() {
	if (typeof(window.pageXOffset) == 'number') {
		var x = window.pageXOffset;
		var y = window.pageYOffset;
	}
	else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
    	var x = document.body.scrollLeft;
		var y = document.body.scrollTop;
	}
	else {
		var x = document.documentElement.scrollLeft;
		var y = document.documentElement.scrollTop;
	}

	var w = 0, h = 0;
	if (window.innerWidth) {
		w = window.innerWidth;
		h = window.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientWidth) {
		w = document.documentElement.clientWidth;
		h = document.documentElement.clientHeight;
	}
	else if (document.body && document.body.clientWidth) {
		w = document.body.clientWidth;
		h = document.body.clientHeight;
	}

	if (x != window_x || y != window_y || w != window_w || h != window_h) {
		window_x = x;
		window_y = y;
		window_w = w;
		window_h = h;

		var wrapper_x = 0, wrapper_y = 200, obj = document.getElementById('wrapper');
		while (obj) {
			wrapper_x += obj.offsetLeft;
			obj = obj.offsetParent;
		}

		var w = 120;
		var y_offset = 20;

		x = wrapper_x - w;
		y = wrapper_y > window_y ? wrapper_y : window_y;
		y += y_offset;

		var obj = document.getElementById('animg');
		obj.style.left = x + 'px';
		obj.style.top = y + 'px';
	}
}

function animg_init() {
	var x = 0, y = 220, obj = document.getElementById('wrapper');
	while (obj) {
		x += obj.offsetLeft;
		obj = obj.offsetParent;
	}

	var obj = document.getElementById('animg');
	obj.style.left = x + 'px';
	obj.style.top = y + 'px';

	setInterval('h_scroll()', 1000);
}

if (window.addEventListener)
	window.addEventListener('load', animg_init, false);
else if (window.attachEvent)
	window.attachEvent('onload', animg_init);
