// ==UserScript==
// @name           Internations UserImages MouseOver
// @namespace      com.daniel-lange
// @description    Enlarge user images from internations.org on mouse over
// @include        *.internations.org/*
// ==/UserScript==

// For updates see http://daniel-lange.com/software

// v1.0 19.11.10 created based on xingopenbc_userimages.user.js
// v1.1 07.10.11 extended to support in-cdn URLs (Internations CDN(?), looks like NetDNA) based on Marc's request

/*
This is a Greasemonkey user script.
To install, you need Greasemonkey: http://www.greasespot.net/
Then restart Firefox and revisit this script.
Under Tools, there will be a new menu item to "Install User Script".
Accept the default configuration and install.
To uninstall, go to Tools/Manage User Scripts,
select "internations_userimages.user.js", and click Uninstall.
*/

(function() {
	function cumulativeOffset(element) {
		var valueT = 0, valueL = 0;
		do {
			valueT += element.offsetTop || 0;
			valueL += element.offsetLeft || 0;
			element = element.offsetParent;
		} while (element);
		return [valueL, valueT];
	}
   window.addEventListener("load", function(e) {
    	var imgList = document.getElementsByTagName("img");
	for( i=0; i < imgList.length; i++) {
		var imgName = imgList[i].src;
		var s = imgName.search(/((\/upload)|(img\.in-cdn\.net))\/.+_u_(1|2|3|4)\.(jpg|gif|png)$/);
		if( s != -1) {
			bigimage=imgName.replace(/\_u_(1|2|3|4)\./, "_u_5.");
			newImg = document.createElement("img");
			ow=imgList[i].width;
			imgList[i].addEventListener("mouseover",
				function(e){
					newX=cumulativeOffset(this)[0]
					newY=cumulativeOffset(this)[1]
					newImg.src=this.src.replace(/\_u_(1|2|3|4)\./, "_u_5.");
//					newImg.style.width="139px";
					newImg.style.height = "170px";
					newImg.style.position="absolute";
					newImg.style.zIndex='999';
					newImg.style.top=(newY-185/2).toString() + 'px';
					newImg.style.left=(newX+ow).toString() + 'px';
					document.body.appendChild(newImg);
				},false);
			imgList[i].addEventListener("mouseout",
				function(e){
					document.body.removeChild(newImg);
				},false);
		}
	}
	return;
  }, false);
})();

