var maxHeight = new Array();
maxHeight[3] = 110;
maxHeight[2] = 162;
maxHeight[1] = 88;
var m1 = null;
var m2 = null;
var m3 = null;

function closer(index) {
    this.popup = document.getElementById("spanMenuPlace" + index);
    this.whatToDo = 0;
    this.name = "m" + index;
    this.index = index;

    this.baseOpener = document.getElementById("baseOpener" + index);
    
    this.delay = null;
}
closer.prototype.ShowHideMenu = function(whatHaveToDo){
	var timerShowSpan;
	var CurrentSize;
	var delay;
	
	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){
		if (this.index == 1 ) this.baseOpener.className = "products_act"
		else if (this.index == 2 ) this.baseOpener.className = "customers_act"
		else if (this.index == 3 ) this.baseOpener.className = "promo_act"

		popup.style.visibility = "visible";
		if (CurrentSize<(maxHeight[this.index]-10)) {
			timerShowSpan = setTimeout(this.name + ".ShowHideMenu()",20)
			popup.style.height=parseInt(CurrentSize+10) + "px";
		}
		else{
			this.whatToDo = 0;
			popup.style.height=parseInt(maxHeight[this.index]) + "px";
		}
	}
	if (this.whatToDo == 2){
		if (CurrentSize>10) {
			timerShowSpan = setTimeout(this.name + ".ShowHideMenu()",20)
			popup.style.height=parseInt(CurrentSize-10) + "px";
		}
		else{
			
			if (this.index == 1 ) this.baseOpener.className = "products"
			else if (this.index == 2 ) this.baseOpener.className = "customers"
			else if (this.index == 3 ) this.baseOpener.className = "promo"

			this.whatToDo = 0;
			popup.style.height="1px";
			popup.style.visibility = "hidden";
		}
	}
}
closer.prototype.changeMenuOnMouseOver = function(typeOfEvent){
	if (typeOfEvent=="out") {
	    if (!this.delay) {
	        var obj = this;
	        this.delay = setInterval(function() {
	            obj.ShowHideMenu("2");
	            clearInterval(obj.delay);
	            obj.delay = null;
	        }, 1000);
	    }
	}
	else {
	    clearInterval(this.delay);
	    this.delay = null;
		this.ShowHideMenu("1");
	}
}

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