function menuImg(img) {
    this.opened = false;
    this.over = false;
    this.image = img;
}

function menuImgUpdate() {
    if (this.opened) {
	if (this.over) {
	    this.image.src = this.i_open.src;
	} else {
	    this.image.src = this.i_open_over.src;
	}
    } else {
	if (this.over) {
	    this.image.src = this.i_closed_over.src;
	} else {
	    this.image.src = this.i_closed.src;
	}
    }
    
}

function menuImgIn() {
    this.over = true;
    this.update();
}

function menuImgOut() {
    this.over = false;
    this.update();
}

menuImg.prototype.i_closed = new Image();
menuImg.prototype.i_closed.src = "/img/icn_menu.png";
menuImg.prototype.i_closed_over = new Image();
menuImg.prototype.i_closed_over.src = "/img/icn_menu_over.png";
menuImg.prototype.i_open = new Image();
menuImg.prototype.i_open.src = "/img/icn_menu_open.png";
menuImg.prototype.i_open_over = new Image();
menuImg.prototype.i_open_over.src = "/img/icn_menu_open_over.png";
menuImg.prototype.mousein = menuImgIn;
menuImg.prototype.mouseout = menuImgOut;
menuImg.prototype.update = menuImgUpdate;

function over(img) {
    if (!img.menu) {
	img.menu = new menuImg(img);
    }
    img.menu.mousein();
}

function out(img) {
    if (!img.menu) {
	img.menu = new menuImg(img);
    }
    img.menu.mouseout();
}
function toggle2(img, item) {
    if (!img.target) {
	img.target = epBrowser.getObj(item);
    }
    toggle(img, 0);
}

function toggle(img, i) {
    if (!img.target) {
	img.target = epBrowser.getObj("item" + i);
    }
    if (!img.menu) {
	img.menu = new menuImg(img);
    }
    var t = img.target;
    var m = img.menu;

    last = document.lastOpened;
    if (last) {
        if (last != img) {
	    last.menu.opened = false;
	    last.target.style.display="none";
	    last.menu.update();
	}
    }
    document.lastOpened = null;

    if (m.opened) {
      t.style.display="none";
    } else {
      t.style.display="";
      document.lastOpened = img;
    }
    m.opened = !m.opened;
    m.update();
}

