var maxHeight = 85;
var m1 = null;
var m2 = null;
var m3 = null;
var m4 = null;

function closer(index) {
    this.popup = document.getElementById("subMenu" + index);
    this.whatToDo = 0;
    this.name = "m" + index;
}
closer.prototype.ShowHideMenu = function(whatHaveToDo){
	var timerShowSpan;
	var CurrentSize;
	
	var popup = this.popup;
	
	if ((whatHaveToDo>-1)&&(whatHaveToDo<3)) {
	    this.whatToDo = whatHaveToDo;
	}
	
	if (popup.style.height=="") {
			popup.style.height="10px";
	}
	
	CurrentSize = popup.style.height.slice(0,popup.style.height.length-2);
	CurrentSize--;
	
	if (this.whatToDo == 1){
		popup.style.visibility = "visible";
		if (CurrentSize<(maxHeight-10)) {
			timerShowSpan = setTimeout(this.name + ".ShowHideMenu()",20)
			popup.style.height=parseInt(CurrentSize+10) + "px";
		}
		else{
			this.whatToDo = 0;
			popup.style.height=parseInt(maxHeight) + "px";
		}
	}
	if (this.whatToDo == 2){
		if (CurrentSize>10) {
			timerShowSpan = setTimeout(this.name + ".ShowHideMenu()",20)
			popup.style.height=parseInt(CurrentSize-10) + "px";
		}
		else{
			this.whatToDo = 0;
			popup.style.height="1px";
			popup.style.visibility = "hidden";
		}
	}
}
closer.prototype.changeMenuOnMouseOver = function(whichMenu,typeOfEvent){
	if (typeOfEvent=="out") {
		this.ShowHideMenu("2");
	}
	else{
		this.ShowHideMenu("1");
	}
}

function init() {
    m1 = new closer(1);
    m2 = new closer(2);
    m3 = new closer(3);
    m4 = new closer(4);
}
