var hit = 0;
var maxHits = -1;

function findNext() {

	lasthit = hit;
	hit++;

	lastHitElement = top.frames['eadframe'].document.getElementById("hid" + lasthit);
	if(lastHitElement) {
		lastHitElement.style.background = "white";
	}

	hitElement = top.frames['eadframe'].document.getElementById("hid" + hit);

	if(!hitElement) {
		hitElement = top.frames['eadframe'].document.getElementById("hid1");
		hit = 1;
	}

	hitElement.style.background = "yellow";
	top.frames['eadframe'].location.hash = hitElement.id;
}

function findPrev() {
	// if we don't know how many hits we have in this document, so lets just loop and count
	if(maxHits == -1) {
		var thit = 1;
		while(top.frames['eadframe'].document.getElementById("hid" + thit)) {
			thit++;
		}
		maxHits = thit - 1;
	}

	lasthit = hit;
	hit--;

	lastHitElement = top.frames['eadframe'].document.getElementById("hid" + lasthit);
	if(lastHitElement) {
		lastHitElement.style.background = "white";
	}

	hitElement = top.frames['eadframe'].document.getElementById("hid" + hit);

	if(!hitElement) {
		hitElement = top.frames['eadframe'].document.getElementById("hid" + maxHits);
		hit = maxHits;
	}

	hitElement.style.background = "yellow";
	top.frames['eadframe'].location.hash = hitElement.id;
}

// Toggle the item with the given id
function toggleVis(id)
{
	var div, img;

	style = document.getElementById(id).style;
	img = document.getElementById(id + '_image');

	if (style.display == 'none') {
		style.display = 'block';
		if(img) {
			img.src = 'minus.gif';
		}
	}
	else {
		style.display = 'none';
		if(img) {
			img.src = 'plus.gif';
		}
	}
}
