// JavaScript Document for ajax search facility function setinputfocus() { location=document.getElementById('location'); location.focus(); } function checkclub() { var thisField = document.getElementById('club'); if(thisField.value!="") { var url = '../../assets/getclub.php?q='+escape(thisField.value); new AJAXRequest('GET', url, null, function(AJAX) { var msgHTML = ''; if(AJAX.readyState == 4) { if(AJAX.status == 200 ) { if(AJAX.responseText != 'null') { msgHTML = AJAX.responseText; } } } document.getElementById('clubselect').innerHTML = msgHTML; document.getElementById('postcode').checked=true; document.getElementById('location').value=""; }, true, true); } } function updateClub() { clubval=document.getElementById('clubname'); clubinput=document.getElementById('club'); } function resetbox() { loc=document.getElementById('location'); loc.style.color="#000000"; } /*============================================================================== Application: Utiity Function Author: John Gardner Version: V1.0 Date: 18th November 2003 Description: Used to check the validity of a UK postcode Version: V2.0 Date: 8th March 2005 Description: BFPO postcodes implemented. The rules concerning which alphabetic characters are alllowed in which part of the postcode were more stringently implementd. Parameters: toCheck - postcodeto be checked. This function checks the value of the parameter for a valid postcode format. The space between the inward part and the outward part is optional, although is inserted if not there as it is part of the official postcode. If the postcode is found to be in a valid format, the function returns the postcode properly formatted (in capitals with the outward code and the inward code separated by a space. If the postcode is deemed to be incorrect a value of false is returned. Example call: if (checkPostCode (myPostCode)) { alert ("Postcode has a valid format") } else {alert ("Postcode has invalid format")}; ------------------------------------------------------------------------------*/ function checkPostCode (toCheck) { // Permitted letters depend upon their position in the postcode. var alpha1 = "[abcdefghijklmnoprstuwyz]"; // Character 1 var alpha2 = "[abcdefghklmnopqrstuvwxy]"; // Character 2 var alpha3 = "[abcdefghjkstuw]"; // Character 3 var alpha4 = "[abehmnprvwxy]"; // Character 4 var alpha5 = "[abdefghjlnpqrstuwxyz]"; // Character 5 // Array holds the regular expressions for the valid postcodes var pcexp = new Array (); // Expression for postcodes: AN NAA, ANN NAA, AAN NAA, and AANN NAA pcexp.push (new RegExp ("^(" + alpha1 + "{1}" + alpha2 + "?[0-9]{1,2})(\\s*)([0-9]{1}" + alpha5 + "{2})$","i")); // Expression for postcodes: ANA NAA pcexp.push (new RegExp ("^(" + alpha1 + "{1}[0-9]{1}" + alpha3 + "{1})(\\s*)([0-9]{1}" + alpha5 + "{2})$","i")); // Expression for postcodes: AANA NAA pcexp.push (new RegExp ("^(" + alpha1 + "{1}" + alpha2 + "?[0-9]{1}" + alpha4 +"{1})(\\s*)([0-9]{1}" + alpha5 + "{2})$","i")); // Exception for the special postcode GIR 0AA pcexp.push (/^(GIR)(\s*)(0AA)$/i); // Standard BFPO numbers pcexp.push (/^(bfpo)(\s*)([0-9]{1,4})$/i); // c/o BFPO numbers pcexp.push (/^(bfpo)(\s*)(c\/o\s*[0-9]{1,3})$/i); // Load up the string to check var postCode = toCheck; // Assume we're not going to find a valid postcode var valid = false; // Check the string against the types of post codes for ( var i=0; i0) { window.open('../...co.uk/error.php','error','width=300,height=300'); } document.getElementById('savedsearch').setAttribute("src",msgHTML); }, true, true); } } function setAlert(strsearch,imageid) { var thisField = imageid; if(thisField.value!="") { var url = '../../functions/setalerts.php?q='+escape(strsearch); new AJAXRequest('GET', url, null, function(AJAX) { var msgHTML = ''; if(AJAX.readyState == 4) { if(AJAX.status == 200 ) { if(AJAX.responseText != 'null') { msgHTML = AJAX.responseText; } } } var result=msgHTML; if (result.indexOf('_err')>0) { window.location.href='../../login/index.php'; } document.getElementById(thisField).setAttribute("src",msgHTML); }, true, true); } }