// ==UserScript==
// @name newegg.com - Fix tooltips
// @author Tomcat76 
// @namespace http://userjs.org/ 
// @version 1.0
// @description  Corrects the behaviour of the tooltips on the
//			newegg.com product pages.
// @ujs:category site: fixes
// @ujs:published 2005-08-26 10:12
// @ujs:modified 2005-09-19 09:19
// @ujs:documentation http://userjs.org/scripts/site/fixes/newegg-com-tooltip-fix 
// @ujs:download http://userjs.org/scripts/download/site/fixes/newegg-com-tooltip-fix.js 
// @include http://www.newegg.com/*
// ==/UserScript==


/* 
 * This script is granted to the Public Domain.
 */

// Position the tooltips correctly and stop the "jerkiness".
// This is caused by bad browser sniffing.

	window.opera.defineMagicFunction('getMouseXY',function(real,thisObj,e){
		pTop=(e.pageY+22)+"px";
		pLeft=(e.pageX-6)+"px";
	});
	window.opera.defineMagicFunction('doMove',function(real,thisObj,id){
		var div;
		if( div = document.getElementById(id) ) {
			div.style.top = pTop;
			div.style.left = pLeft;
		}
	});

// Avoid the remains of the tooltip when moving the cursor away again.
// The biggest cause is the display="inline" setting on mouseover;
// setting it to display="block" reduces the remains by a great deal
// but there may still be some when moving the cursor too fast, so a
// delay is needed.
// Because of the delay, the finest eyes will notice a slight increase
// in "jerkiness" again, so we make it display="block" in all cases and
// play with "visibility" instead.

	window.opera.defineMagicFunction('doOver',function(real,thisObj,id){
		if (document.getElementById(id)){
			function showIt(){
				document.getElementById(id).style.display="block";
				document.getElementById(id).style.visibility="visible";
			}
			window.setTimeout(showIt,50);
		}
	});
	window.opera.defineMagicFunction('doOut',function(real,thisObj,id){
		if (document.getElementById(id)){
			function hideIt(){
				document.getElementById(id).style.display="block";
				document.getElementById(id).style.visibility="hidden";
			}
			window.setTimeout(hideIt,50);
		}
	});


// Tomcat76 thanks Andrew for explaining how to use "defineMagicFunction"
// and sgunhouse for locating the cause of the "mispositioning".
