function mar_add(p,o) {

	var k;
	document.write('<a class="marg" ');
	for (k in p) {
		document.write(' '+k+'="' + p[k] + '"');
	}
	document.write('><img ');
	for (k in o) {
		document.write(' '+k+'="' + o[k] + '"');
	}
	document.write(' /></a>');
}

function mar_animate() {
	if (mar_animate._paused) return true;

	var i;
	var them = mar_animate._them;
	for (i = 0; i < them.length; i++) {
		var p = them[i];
		p._pos = p._pos + p._speed;
		if (p._width) {
			while (p._pos >= p._width) p._pos -= p._width;
			while (p._pos <  0) p._pos += p._width;
		}
		p.scrollLeft = p._pos;
	}
	return true;
}
function _mar_mouse1(e) { mar_animate._paused = true; if (!e) e = window.event; e.cancelBubble=true; if (e.preventDefault) e.preventDefault(); return true; }
function _mar_mouse2(e) { mar_animate._paused = false; }
function mar_init() {
	var g = document.getElementsByTagName('a');
	var i;
	mar_animate._them = [];
	document.onmousemove = _mar_mouse2;
	document.body.onmousemove = _mar_mouse2;
	for (i = 0; i < g.length; i++) {
		var o = g[i];
		if (o.className.indexOf('marg') > -1) {
			o.onmousemove = _mar_mouse1;

			var p = o.parentNode;
			if (p._did) continue;
			p._did = true;
			if (p.getAttribute('speed')) {
				p._speed = parseInt(p.getAttribute('speed'));
			} else {
				p._speed = 1;
			}
			p.style.whiteSpace = 'nowrap';
			p.style.overflow = 'hidden';
			p._width = p.scrollWidth || p.offsetWidth;
			p._pos = 0;
			p.innerHTML = p.innerHTML + p.innerHTML;
			p.scrollLeft = 0;
			var a = p.firstChild;
			while (a) {
				var b = a.nextSibling;
				if (a.data) {
					p.removeChild(a);
				}
				a = b;
			}
			mar_animate._them[ mar_animate._them.length ] = p;
		}
	}
	window.setInterval(mar_animate,15);
}


