// Parts of script by Glen Murphy - http://glenmurphy.com/

var d = document;

var isNav, isIE, isNS6;
if(d.layers) {isNav = 1;}
else if(d.all) {isIE = 1;}
else if (d.getElementByID) {isNS6 = 1;}

function getWinHeight() { 
  var height = window.innerHeight;
  if (height > 0) return height;
  height = document.documentElement.clientHeight;
  if (height > 0) return height;
  height = document.body.clientHeight;
  return height;
}

function getWinWidth() { 
  var width = window.innerWidth;
  if (width > 0) return width;
  width = document.documentElement.clientWidth;
  if (width > 0) return width;
  width = document.body.clientWidth;
  return width;
}

function mousemove(e) {
  var mx, my;
	if (isIE) {
		mx = window.event.clientX;
		my = window.event.clientY;
		}
	else {
		mx = e.pageX;
		my = e.pageY;
		}
	var row = document.getElementById("row");
	if (Math.random() * 1000 > 1) {
    var other = getRandomRow();
    other.style.display = "block";
	  other.style.left = row.style.left;
	}
	row.style.left = ((Math.floor(mx / 2) * 2) - 3) + "px";
	}	
	
	function getRandomRow() {
		var rn = Math.random();
	  var r = Math.pow(rn, .4);
	  var i = Math.ceil(r * 5);
	  if (i == 0) i = 1;
	  if (Math.random() * 1000 < 2) i = 6;
	  var el = document.getElementById("row" + i);
		if (el == null) alert("r=" + rn + ", r=" + r + ", i=" + i + ", el=" + el);
		return el;
	}
	
function startup() {
	if (isNav) d.captureEvents(Event.MOUSEMOVE);
	d.onmousemove = mousemove;
	}
