

var lastIteration = "";

function lookupIteration(label) {
	iteration = document.form1.iterationfind.value.toLowerCase();
	
	// remove any trailing '*'s
	iteration = iteration.replace(/\*+$/g, "");
	
	if (iteration.length == 0) {
		alert("Enter a " + label + " or part of a " + label + " name and click 'Find'.");
		return;
	} 
	
	selectbox = document.form1.iterationselect;
	found = 0;
	
	if (iteration != lastIteration) {
		start = 0;
		lastIteration = iteration;
	} else {
		start = selectbox.selectedIndex + 1;
	}
	
	for(i=start; i<selectbox.options.length && found==0; i++) {
		if(selectbox.options[i].text.toLowerCase().indexOf(iteration) >= 0) {
			selectbox.selectedIndex = i;
			found = 1;
			document.getElementById("find_btn").src = "/img/saff/en/find_next.gif";
		}
	}
	
	if (found == 0) {
		if (start == 0)
			alert("'" + iteration + "' not found.");
		else {
			alert("No more groups matching '" + iteration + "' found.");
			lastIteration = "";
			document.getElementById("find_btn").src = "/img/saff/en/find.gif";
		}
	}
	
}

function iterationfind_change(myfield,e,label) {
	var keycode;
	if (window.event) {
		keycode = window.event.keyCode;
	}
	else if (e) {
		keycode = e.which;
	}
	else 
		return true;
		
	document.getElementById("find_btn").src = "/img/saff/en/find.gif";
	
	if (keycode == 13) {
		 lookupIteration(label);
		 return false;
	} else {
		return true;
	}
		
}


function go_button_click(label) {
	var table;
	var iteration;
	var url, reg;
	
	if (document.form1.iterationselect.selectedIndex < 0) {
		alert("Select a " + label + " and click 'GO'")
		return;
	}
	
	iteration  = document.form1.iterationselect[document.form1.iterationselect.selectedIndex].value;	
}


