// 4th version - targets the new ajax browser code.

function suppressEnter(e){ //e is event object passed from function invocation
	var characterCode	

	 if(e && e.which){ //if which property of event object is supported (NN4)
	 e = e	
	 characterCode = e.which //character code is contained in NN4's which property
	 }	
	 else{								
	 e = event								
	 characterCode = e.keyCode //character code is contained in IE's keyCode property
	 }

	 if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
	 return false 
	 }
	 else{
	 return true 
	 }	
}
	
function redirectSearch() {

	var OriginalRequest = document.search.ref.value;

	var isJGjobno = new RegExp("^[Jj][Gg][0-9][0-9].[0-9]+$");

	var isJGref = new RegExp("^[Jj][Gg][0-9][0-9].[0-9]+[^0-9].*$");
	
	var isWild = new RegExp("^[^\\*]*\\*$");	

	// Trap JG ref browse requests

	if (isJGref.test(OriginalRequest)) {
		window.location="http://figures.jet.efda.org/"+OriginalRequest+".eps";
		return false;	
	}	


	if (isJGjobno.test(OriginalRequest)) {
		window.location="http://figures.jet.efda.org/cgi-bin/jgbrowse.py?jgjob="+OriginalRequest;
		return false;	
	}	

	// Trap Figure Requests
		
	if (isWild.test(OriginalRequest)) {
			
		var wildReplace = new RegExp("\\*", "gi");

		var wildRequest = OriginalRequest.replace(wildReplace, "");	

		window.location="http://figures.jet.efda.org/Harvest/cgi-bin/nph-voc-search.cgi?broker=FiguresB&caseflag=on&jetflag=wildcard&wordflag=on&runnumber=0&objectsperpage=50&brokerqueryconfig=reprographics8.cf&query="+wildRequest;

		return false;

	}	
	
	window.location="http://figures.jet.efda.org/Harvest/cgi-bin/nph-voc-search.cgi?broker=FiguresB&caseflag=on&wordflag=on&runnumber=0&objectsperpage=50&brokerqueryconfig=reprographics8.cf&query="+OriginalRequest;

	return false;
}

