var imgButton = new Array();

//initialize menu
function imgButtonInit(_lyr){
	if(_lyr == null){
		_lyr = document
	}
	
	for(var i=0; i < _lyr.images.length;i++){
		if(_lyr.images[i].name.indexOf('but') != -1){
			imgButton[_lyr.images[i].name] = new ImgButton(_lyr.images[i]);
			
		}
	}
}

function imgButtonLock(_but){
	imgButton[_but].img.lo = Function();
	imgButton[_but].img.ov();
}

//initialize menu buttons
function ImgButton(_img) {	
	this.imgLo = new Image();
	this.imgOv = new Image();
	
	this.imgLo.src = _img.src;
	this.imgOv.src = _img.src.replace('_lo','_hi');
	
	_img.button = this;
	this.img = _img;
	
	this.locked = false;
	
	_img.lo = ImgButtonLo;
	_img.ov = ImgButtonOv;
	
	_img.lock = ImgButtonLock;
	_img.unlock = ImgButtonUnlock;
}

function ImgButtonLo(){
	if(!this.button.locked){
		this.src = imgButton[this.name].imgLo.src;
	}
}

function ImgButtonOv(){
	this.src = imgButton[this.name].imgOv.src;
}

function ImgButtonLock(){
	this.button.locked = true;
	this.ov();
}

function ImgButtonUnlock(){
	this.button.locked = false;
	this.lo();
}
