// counter itself
var countRemaining=0;
function nextCount() {


	// ultimately this just repeats
	if (!inArea) {
		if (countRemaining>0) {
			countRemaining-=1;
		} else {
			if (lastEntry>0) {
				hideElement(document.getElementById('subblock_'+lastEntry));
				lastEntry=0;
			}
		}
	} else {
		resetTimer();
	}

	setTimeout('nextCount()',1);
}
function resetTimer() {
	countRemaining=20;
}


function showElement(o) {
	if (o) o.style.display='block';
}
function hideElement(o) {
	if (o) o.style.display='none';
}

// call when mouse enters
function newEntry(id) {
	// check for any current showing area
	if (lastEntry>0) {
		// if is same as this one
		if (lastEntry==id) {
			inArea=true;
			resetTimer();

		// if not the same
		} else {
			// hide old one
			hideElement(document.getElementById('subblock_'+lastEntry))

			// show new one
			lastEntry=id;
			inArea=true;
			showElement(document.getElementById('subblock_'+id));
		}

	// if no last entry
	} else {
		// show new one
		lastEntry=id;
		inArea=true;
		showElement(document.getElementById('subblock_'+id));
	}
}

// call when mouse exits
function exit(id) {
	inArea=false;
}

// call to instantly hide any showing menu
function instantHide() {
	countRemaining=0;
}




// handling of mouseover/outs
var lastEntry=0;
var inArea=false;

function mouseOverMain(id) {
	newEntry(id);
}

function mouseOutMain(id) {
	exit(id);
}

function mouseOverChild(id) {
	newEntry(id);
}

function mouseOutChild(id) {
	exit(id);
}



// setup callbacks
document.getElementById('body').onclick=instantHide;


// start the timer
setTimeout('nextCount()',1);
