if (navigator.product == "Gecko" && navigator.userAgent.indexOf('Chrome') < 0) {
	Document.prototype.elementFromPoint = function(x, y){
			//define globals
			FoundValue = [];
			FoundNode = null;
		   
			var from = document.body;
			efpi(from, x, y, 0, [], getElementPosX(from), getElementPosY(from));
		   
			return FoundNode;
	}
	
	function getStyle(el, prop) {
			return document.defaultView.getComputedStyle(el,'').getPropertyValue(prop);
	}
	
	function efpi(from, x, y, CurIndex, CurValue, px, py){
			var StartValue = CurValue;
			var StartIndex = CurIndex;
		   
			//Loop through childNodes
			var nodes = from.childNodes;
			for(var n,i=0;i<from.childNodes.length;i++){
					n = from.childNodes[i];
					if( n.nodeType != Node.TEXT_NODE && getStyle(n, 'display') != 'none' ){
							var sx = px + n.offsetLeft;//getElementPosX(n);
							var sy = py + n.offsetTop;//getElementPosY(n);
							var ex = sx + n.offsetWidth; var ey = sy + n.offsetHeight;
						   
							//if(Child is position absolute/relative and overflow == "hidden" && !inSpace) continue;
							var isAbs = getStyle(n, "position");
							isAbs = isAbs == "absolute" || isAbs == "relative";
							var isHidden = getStyle(n, "overflow") == "hidden";
							var inSpace = (x > sx && x < ex && y > sy && y < ey);
							if(isAbs && isHidden && !inSpace) continue;
		   
							CurIndex = StartIndex;
							CurValue = StartValue.copy();
		   
							//if (Child is position absolute/relative and has zIndex) or overflow == "hidden"
							var z = parseInt(getStyle(n, "z-index"));
							if(isAbs && (z || z == 0) || isHidden){
									//if(!is position absolute/relative) zIndex = 0
									if(!isAbs) z = 0;
								   
									//if zIndex >= FoundValue[CurIndex]
									if(z >= (FoundValue[CurIndex] || 0)){
											//if zIndex > CurValue[CurIndex];
											if(z > (CurValue[CurIndex] || 0)){
													//CurValue = StartValue.copy();
												   
													//set CurValue[CurIndex] = zIndex
													CurValue[CurIndex] = z;
											}
										   
											CurIndex++
										   
											//if(inSpace && CurIndex >= FoundValue.length)
											if(inSpace && CurIndex >= FoundValue.length) {
													//Set FoundNode is currentNode
													FoundNode = n;
													//Set FoundValue is CurValue
													FoundValue = CurValue;//.copy();
											}
									}
									//else continue; //Ignore this treedepth
									else continue;
							}
							else if(inSpace && CurIndex >= FoundValue.length){
									//Set FoundNode is currentNode
									FoundNode = n;
									//Set FoundValue is CurValue
									FoundValue = CurValue;//.copy();
							}
						   
							//loop through childnodes recursively
							efpi(n, x, y, CurIndex, CurValue, isAbs ? sx : px, isAbs ? sy : py)
					}
			}
	}
	
	Array.prototype.copy = function(){
			var ar = new Array();
			for(var i=0;i<this.length;i++)
					ar[i] = this[i] && this[i].copy ? this[i].copy() : this[i];
	
			return ar;
	}
}
