// JS used to search the js array created by update.asp// Change History//  12/09/05	SW	- Added code for dealing with international agents//	05/05/05	SW	- Moved lookupPostcode() function into an include file to split code from design//	20/04/05	SW	- Created page// Global variable to hold request objectvar req// Function to perform a search on the postcode enteredfunction lookUpCoach( inCoach /*string*/) {	var inStrLastChar = inCoach.length;	var matchedAgents = new Array();		if ( inStrLastChar > 0 ) {			loadXMLDoc( "/coach/getCoach.php?station=" + inCoach );		}}// Function to send the requestfunction loadXMLDoc( url ) {	// Internet Explorer	try { 		req = new ActiveXObject( "Msxml2.XMLHTTP" );	} catch( e ) {		try { 			req = new ActiveXObject("Microsoft.XMLHTTP");		}	catch( oc ) {			req = null;		}	}	// Mozailla/Safari	if ( !req && typeof XMLHttpRequest != "undefined" ) {		req = new XMLHttpRequest();	}	// Call the processChange() function when the page has loaded	if ( req != null ) {		req.onreadystatechange = processChange;		req.open( "GET", url, true );		req.send( null );	}}// Function to catch the reply to the requestfunction processChange() {	// The page has loaded and the HTTP status code is 200 OK	if ( req.readyState == 4 && req.status == 200 ) {		// Check we have reults, otherwise do nothing		if ( req.responseText != "NULL" ) {						// Split the data string that comes back so that we have an array			var matchedAgents = req.responseText.split( "|" );			// Write the array results into options tags in our select			var outputSelect = getObject( "results" );						// Loop round my results putting them into the results select on the form			outputSelect.options.length = 0;						for ( arrayIndex = 0; arrayIndex < matchedAgents.length; arrayIndex++ ) { 				var agentData = matchedAgents[ arrayIndex ].split( ";" );				var optionText = agentData[1];				var optionValue = agentData[0];				var newOption = new Option( optionText, optionValue );				outputSelect.options[ arrayIndex ] = newOption;			}		}	}}// Function to get HTML objectsfunction getObject( name ) {	var ns4 = ( document.layers ) ? true : false;	var w3c = ( document.getElementById ) ? true : false;	var ie4 = ( document.all ) ? true : false;	if ( ns4 ) return eval( 'document.' + name );	if ( w3c ) return document.getElementById( name );	if ( ie4 ) return eval( 'document.all.' + name );	return false;}