/* JS Fisheye */

var fisheyemenu = {
	startSize : 57,
	endSize : 70,
	init : function () {
		var animElements = document.getElementById("fisheye_menu").getElementsByTagName("img");
		for(var i=0; i<animElements.length; i++) {
			var y = animElements[i];
			fisheyemenu.imgSmall(y);
			y.style.width = fisheyemenu.startSize+'px';
			animElements[i].onmouseover = changeSize;
			animElements[i].onmouseout = restoreSize;
		}
		function changeSize() {
			fisheyemenu.imgLarge(this);
			//var x = this.parentNode.getElementsByTagName("span");
			//x[0].style.display = 'block';
			fisheyemenu.resizeAnimation(this, fisheyemenu.startSize, fisheyemenu.endSize,15,10,0.4);
		}
		function restoreSize() {
			fisheyemenu.imgSmall(this);
			//var x = this.parentNode.getElementsByTagName("span");
			//x[0].style.display = 'none';
			fisheyemenu.resizeAnimation(this,fisheyemenu.endSize, fisheyemenu.startSize,15,10,0.4);	
		}
	},
	resizeAnimation : function (elem,startWidth,endWidth,steps,intervals,powr) {
		if (elem.widthChangeMemInt) window.clearInterval(elem.widthChangeMemInt);
		var actStep = 0;
		elem.widthChangeMemInt = window.setInterval(
			function() {
				elem.currentWidth = fisheyemenu.easeInOut(startWidth,endWidth,steps,actStep,powr);
				elem.style.width = elem.currentWidth+"px";
				actStep++;
				if (actStep > steps) window.clearInterval(elem.widthChangeMemInt);
			}
			,intervals)
	},
	easeInOut : function (minValue,maxValue,totalSteps,actualStep,powr) {
		var delta = maxValue - minValue;
		var stepp = minValue+(Math.pow(((1 / totalSteps)*actualStep),powr)*delta);
		return Math.ceil(stepp)
	},
	imgSmall : function (obj) {
		imgSrc = obj.getAttribute("src");
		obj.setAttribute("src", imgSrc);
	},
	imgLarge : function (obj) {
		imgSrc = obj.getAttribute("src");
		obj.setAttribute("src", imgSrc);
	}
}

// Add event with wide browser support
if ( typeof window.addEventListener != "undefined" )
    window.addEventListener( "load", fisheyemenu.init, false );
else if ( typeof window.attachEvent != "undefined" )
    window.attachEvent( "onload", fisheyemenu.init );
else {
    if ( window.onload != null ) {
        var oldOnload = window.onload;
        window.onload = function ( e ) {
            oldOnload( e );
            fisheyemenu.init();
        };
    }
    else
        window.onload = fisheyemenu.init;
}