﻿function swapState(btn,btnPrec) {
	//Turn the old layer off
	if (btnPrec > 0) {
//	    alert(layerList[btnPrec]);
		MM_showHideLayers(layerList[btnPrec],'','hide');
//		if (btnname[btnPrec] != currentBtn) {
//			MM_swapImage(btnname[btnPrec],'',btnon[btnPrec]);
//		}
		//MM_swapImgRestore()
	}
	//change state of designated button and layer
	if (btn > 0) {
//	    alert(layerList[btn]);
		MM_showHideLayers(layerList[btn],'','show');
//		MM_swapImage(btnname[btn],'',btnoff[btn]);
	}
	return true;
}

function stopclock() {
	if(timerRunning)
	clearTimeout(timerID);
	timerRunning = false;
}

function StageRedraw() {
	updateStage()
	timerID = setTimeout("StageRedraw()",400);
	timerRunning = true;
}

function updateStage() {
	if (hoverCourant != hoverPrecedent) {
		swapState(hoverCourant,hoverPrecedent);
		hoverPrecedent = hoverCourant;

	}
}

function startclock() {
	stopclock();
	StageRedraw();
}

function passEsc(evt) {
	if (window.event.keyCode == 27) { hoverCourant = 0; updateStage();}
}


function DisplayBlock(object) {
state = MM_findObj(object).style.display;
if (state == 'block'){locateObject(object).style.display = 'none';}
if (state == 'none'){locateObject(object).style.display = 'block';}
				
	}

