//var children = new Array();
var myStash = {
	count : 0,
	elements: [],
	x : 0,
	y : 0,
	target: {}
}

function init(el, count) {
	window.onresize();
	count++;
	myStash.count = count;
	for(var counter=0; counter<count; counter++) {
		myStash.elements[counter] = document.getElementById(el+'_'+counter);
	}
	document.onmousemove = getMouseXY;

}

function getMouseXY(e) {
	console.log(myStash);
	var X = e.pageX;
	var Y = e.pageY;
	if (X < 0){X = 0;}
	if (Y < 0){Y = 0;}  
    for(var counter=0; counter<myStash.count; counter++) {
       	if(X<myStash.target.x) {
	    	xBlur = ( ( (X-myStash.target.x) /myStash.target.x) * (-5))-1;       
       	} else {
	    	xBlur = ( ( (X-myStash.target.x) /myStash.x) * 5)-1;       		
       	}
       	if(Y<myStash.target.y) {
	    	yBlur = ( ( (Y-myStash.target.y) /myStash.target.y) * (-3))-1;       
       	} else {
	    	yBlur = ( ( (Y-myStash.target.y) /myStash.y) * 5)-1;       		
       	}
	    var hRatio = ((X/myStash.x)*100+(xBlur*counter));
    	var vRatio = ((Y/myStash.y)*128+(yBlur*counter));    
		myStash.elements[counter].style.paddingTop = (180-vRatio)+"px";
		myStash.elements[counter].style.paddingLeft = hRatio+"px";
	}
	return true;
}

window.onresize = function () {
	if (document.body && document.body.offsetWidth) {
		myStash.x = document.body.offsetWidth;
		myStash.y = document.body.offsetHeight;
	}
	if (document.compatMode=='CSS1Compat' &&
     document.documentElement &&
     document.documentElement.offsetWidth ) {
 		myStash.x = document.documentElement.offsetWidth;
 		myStash.y = document.documentElement.offsetHeight;
	}
	if (window.innerWidth && window.innerHeight) {
 		myStash.x = window.innerWidth;
 		myStash.y = window.innerHeight;
	}
	myStash.target.x = myStash.target.y = 0;
	var obj = document.getElementById('target');
	if (obj.offsetParent) {
		do {
			myStash.target.x += obj.offsetLeft;
			myStash.target.y += obj.offsetTop;
		} while (obj = obj.offsetParent);
	} else {
		myStash.target.x += obj.offsetLeft;
		myStash.target.y += obj.offsetTop;
	}
}
