﻿function MovePic(ptr){
	var currentPos = parseInt(ptr.style.paddingTop);
	var currentChange;
	if(ptr.isDown){
		currentChange = 4;
	}else{
		currentChange = -2;
	}
	ptr.style.paddingTop = (currentPos + currentChange)+"px";
	ptr.style.height = (parseInt(ptr.style.height)- currentChange)+"px";
	if((ptr.isDown && currentPos + currentChange < ptr.finalTop) || (!ptr.isDown && currentPos + currentChange > ptr.finalTop)){
		var f = function() {MovePic(ptr)};
		ptr.setTimeoutId = setTimeout(f, 30);
	}else if(ptr.isDown && currentPos + currentChange >= ptr.finalTop){
		ptr.isDown = false;
		ptr.finalTop -= 10;
		var f = function() {MovePic(ptr)};
		ptr.setTimeoutId = setTimeout(f, 80);
	}
}

var nn = 100;
function setRollOver(ptr, isDown){
	if(isDown){
		ptr.finalTop = 20;
		ptr.isDown= true;
	}else{
		ptr.isDown= false;
		ptr.finalTop = 0;
	}
	clearTimeout(ptr.setTimeoutId);
	MovePic(ptr);
}

function initItems(id){
	var ptr = window.document.getElementById("menu"+id);
	ptr.onmouseover = function onmouseover(){setRollOver(this, true)}
	ptr.onmouseout = function onmouseout (){setRollOver(this, false)}
	ptr.style.paddingTop = "0px";
	ptr.style.height= "69px";
}
function initMenu(){
	for(var i = 0; i<10; i++){
		 initItems(i+1)
	}
}


