// ==UserScript==
// @name        Metro Mojo Fix for Scrolling FM CPU Hog Problem
// @namespace   http://dse.webonastick.com/
// @author      Darren Stuart Embry http://dse.webonastick.com/
// @description Scrolling fifteen-minute messages are CPU hogs in Firefox.  This fixes the problem by reimplementing them as <marquee> elements.
// @include http://www.*mojo.com/*
// ==/UserScript==
//
// This is a Greasemonkey user script.
// To install it, you need Greasemonkey: http://greasemonkey.mozdev.org/
// Then restart Firefox, and revisit this script.
//
// If you're still using Internet Explorer, then well, it ain't my problem.

(function () {	
	if (window.addEventListener) {
		unsafeWindow.removeEventListener("load",
						 unsafeWindow.populatescroller,
						 false);
	}
	else if (unsafeWindow.attachEvent) {
		unsafeWindow.detachEvent("onload",
					 unsafeWindow.populatescroller);
	}
	else {
		if (unsafeWindow.onload === unsafeWindow.populatescroller) {
			unsafeWindow.onload = function () {};
		}
	}

	var content = unsafeWindow.memorycontent;
	if (!content) return;
	var node;
	var name;

	node = unsafeWindow.document.getElementById("memoryscroller");
	if (!node) {
		return;
	}

	node = node.parentNode;
	if (node.nodeName.toLowerCase() !== "div") { return; }
	if (!(node.onmouseover && node.onmouseout)) { return; }

	node = node.parentNode;
	if (node.nodeName.toLowerCase() !== "td") { return; }
	node = node.parentNode;
	if (node.nodeName.toLowerCase() !== "tr") { return; }
	node = node.parentNode;
	if (node.nodeName.toLowerCase() !== "tbody") { return; }
	node = node.parentNode;
	if (node.nodeName.toLowerCase() !== "table") { return; }
	
	var marquee = unsafeWindow.document.createElement("marquee");
	node.parentNode.insertBefore(marquee, node);
	node.parentNode.removeChild(node);
	marquee.innerHTML = content;
	marquee.setAttribute("scrollamount", 3);  // pixels
	marquee.setAttribute("scrolldelay", 100); // milliseconds
	marquee.onmouseover = function () {
		if (this.stop) { this.stop(); }
	};
	marquee.onmouseout  = function () { 
		if (this.start) { this.start(); }
	};
})();
