								var c_intLocationIndex = -1;
								var c_blnCallWaiting = false;
								var c_blnCallInProgress = false;
								var c_objSuggestedLocations;
								var c_objSelectedLocation;
								var c_blnROI = false;
								var c_intLast;
								var IE6 = false /*@cc_on || @_jscript_version < 5.7 @*/;

								//this lets us know if a single location has  been selected, if it hasn't then we should throw an error on submit
								var locationFound = false;

								function checkLocationFound()
								{
									if (!locationFound)
									{
										alert('You have not selected a valid location, please try a different search');
										return false;
									}
									else
									{
										return true;
									}

								}

								document.onkeypress = KeyPress;

								function KeyPress(e)
								{
									var intKeycode = e ? e.which : window.event.keyCode;
									return intKeycode != 13;
								}

								function SearchTextChanged(intKeycode)
								{
									var txtSearchText = document.getElementById('ctl00_ctl00_txtSearchText');
									var divLayer = document.getElementById('ctl00_ctl00_divLayer')

									divLayer.style.zIndex = 2;

									switch (intKeycode)
									{
										case 32:
											//do nothing - space
											return;
										case 37:
											//do nothing - cursor left
											return;
										case 39:
											//do nothing - cursor right
											return;
										case 38:
											// up arrow
											// if we have some suggestions and we're not right at the top, highlight the previous item
											if (c_objSuggestedLocations && c_intLocationIndex > 0)
											{
												Highlight(c_intLocationIndex - 1);
											}
											break;
										case 40:
											// down arrow
											// if we have some suggestions and we're not right at the bottom, highlight the next item
											if (c_objSuggestedLocations && c_intLocationIndex < c_objSuggestedLocations.length - 1)
											{
												Highlight(c_intLocationIndex + 1);
											}
											break;
										case 13:
											// if we have a selected location, submit the form
											if (c_objSelectedLocation)
											{
												document.forms[0].submit();
											}
											else
											{
												// if the current location index is valid, select it
												if (c_intLocationIndex >= 0)
												{
													SelectLocation(c_intLocationIndex);
												}
											}
											break;
										default:
											// if at least 3 characters of text has been typed, suggest some locations
											if ((txtSearchText.value.length == 2 && parseInt(txtSearchText.value.substring(1, 2))) || txtSearchText.value.length >= 3)
											{
												SuggestLocations();
											}
											else
											{
												// hide the layer
												divLayer.style.visibility = 'hidden';
												c_objSuggestedLocations = null;
												OnPopupHide();
												//WCH.Discard('ctl00_ctl00_divLayer');
											}
											break;
									}
								}

								function SuggestLocations()
								{
									// is an ajax call already in progress?
									c_blnCallWaiting = c_blnCallInProgress;
									// if not, make a call
									if (!c_blnCallWaiting)
									{
										// flag that a call is in progress
										c_blnCallInProgress = true;
										wctlLocationSuggestor.SuggestLocations(document.getElementById('ctl00_ctl00_txtSearchText').value, c_blnROI, 10, SuggestedLocations)
									}
								}

								function SuggestedLocations(xhttp)
								{
									var txtSearchText = document.getElementById('ctl00_ctl00_txtSearchText');
									var divLayer = document.getElementById('ctl00_ctl00_divLayer');
									var strBuffer = '';
									var intMatch = -1;

									// set our suggestion object to the value returned from the ajax call
									c_objSuggestedLocations = xhttp.value;

									if (xhttp.error)
									{
										// show the error on screen - probably not the best thing to do but for now...
										alert(xhttp.error.description);
									}
									else
									{
										c_intLocationIndex = -1;

										if (c_objSuggestedLocations && c_objSuggestedLocations.length > 0)
										{
											for (intLocationLoop = 0; intLocationLoop < c_objSuggestedLocations.length; intLocationLoop++)
											{
												if (txtSearchText.value.replace(' ', '').toLowerCase() == c_objSuggestedLocations[intLocationLoop].DisplayItem.replace(' ', '').toLowerCase())
												{
													intMatch = intLocationLoop;
												}
												strBuffer += "<div id='divLocation" + intLocationLoop + "' class='unhighlight' onclick='SelectLocation(" + intLocationLoop + ")' onmousemove='Highlight(" + intLocationLoop + ")' alt='" + c_objSuggestedLocations[intLocationLoop].DisplayItem + "' title='" + c_objSuggestedLocations[intLocationLoop].DisplayItem + "'>" + c_objSuggestedLocations[intLocationLoop].DisplayItem + "</div>"
											}

											if (!c_blnCallWaiting)
											{
												if (c_objSuggestedLocations && (!(c_objSuggestedLocations[0].IsPartialPostcode || c_objSuggestedLocations[0].IsPostcode)))
												{//debugger;
													divLayer.innerHTML = strBuffer;
													divLayer.style.left = txtSearchText.style.left;
													divLayer.style.top = txtSearchText.style.top + txtSearchText.style.height;
													divLayer.style.visibility="visible";
													//divLayer.style.width = '310px';
													divLayer.style.height = '200px';
													divLayer.style.overflow = 'auto';
													OnPopupShow();
													//WCH.Apply('ctl00_ctl00_divLayer');
												}

												if (intMatch >= 0)
												{
													if (c_objSuggestedLocations.length == 1)
													{
														SelectLocation(intMatch);
													}
													else
													{
														Highlight(intMatch);
													}
												}
												else
												{
													c_objSelectedLocation = null;
												}
											}
										}
										else
										{
											UnselectLocation();
											divLayer.style.visibility="hidden";
											OnPopupHide();
											//WCH.Discard('ctl00_ctl00_divLayer');
										}
									}

									c_blnCallInProgress = false;

									if (c_blnCallWaiting)
									{
										SuggestLocations();
									}
								}

								function Highlight(intID)
								{
									var txtSearchText = document.getElementById('ctl00_ctl00_txtSearchText');
									var divLocationItems = document.getElementsByTagName('div');
									/*
									for (intHighlightLoop = 0; intHighlightLoop < divLocationItems.length; intHighlightLoop++)
									{
										if (divLocationItems[intHighlightLoop].id.indexOf('divLocation') >= 0)
										{
											divLocationItems[intHighlightLoop].className = "unhighlight";
										}
									}
									*/

									if (c_intLocationIndex > -1)
									{
										document.getElementById("divLocation" + c_intLocationIndex).className = "unhighlight";
									}
									document.getElementById("divLocation" + intID).className = "highlight";
									txtSearchText.value = c_objSuggestedLocations[intID].DisplayItem;
									c_intLocationIndex = intID;
								}

								function SelectLocation(intID)
								{//debugger;
									c_objSelectedLocation = c_objSuggestedLocations[intID];
									wctlLocationSuggestor.GetTheNearestSitecode(c_objSelectedLocation.X, c_objSelectedLocation.Y, NearestSitecode)

								}

								function NearestSitecode(xhttp)
								{//debugger;
									var txtSearchText = document.getElementById('ctl00_ctl00_txtSearchText');
									var divLayer = document.getElementById('ctl00_ctl00_divLayer');
									var hidSelectedLocationValue;
									var objNearestSitecode;

									objNearestSitecode = xhttp.value;

									divLayer.style.visibility = "hidden";
									OnPopupHide();
									//WCH.Discard('ctl00_ctl00_divLayer');
									txtSearchText.value = c_objSelectedLocation.DisplayItem;

									// update the values of the selected location onto the form so that other controls can access if required
									document.getElementById('ctl00_ctl00_hidLocationID').value = c_objSelectedLocation.LocationID;
									document.getElementById('ctl00_ctl00_hidLocationName').value = c_objSelectedLocation.Name;
									document.getElementById('ctl00_ctl00_hidParent').value = c_objSelectedLocation.County;
									document.getElementById('ctl00_ctl00_hidX').value = c_objSelectedLocation.X;
									document.getElementById('ctl00_ctl00_hidY').value = c_objSelectedLocation.Y;
									document.getElementById('ctl00_ctl00_hidDefaultRadius').value = c_objSelectedLocation.DefaultRadius;
									document.getElementById('ctl00_ctl00_hidExtraInfo').value = c_objSelectedLocation.ExtraInfo;
									document.getElementById('ctl00_ctl00_hidIsPartialPostcode').value = c_objSelectedLocation.IsPartialPostcode;
									document.getElementById('ctl00_ctl00_hidIsPostcode').value = c_objSelectedLocation.IsPostcode;
									locationFound = true
									OnItemChanged();
								}

								function UnselectLocation()
								{
									// update the values of the selected location onto the form so that other controls can access if required
									document.getElementById('ctl00_ctl00_hidLocationID').value = '';
									document.getElementById('ctl00_ctl00_hidLocationName').value = '';
									document.getElementById('ctl00_ctl00_hidParent').value = '';
									document.getElementById('ctl00_ctl00_hidX').value = '';
									document.getElementById('ctl00_ctl00_hidY').value = '';
									document.getElementById('ctl00_ctl00_hidDefaultRadius').value = '';
									document.getElementById('ctl00_ctl00_hidExtraInfo').value = '';
									document.getElementById('ctl00_ctl00_hidIsPartialPostcode').value = '';
									document.getElementById('ctl00_ctl00_hidIsPostcode').value = '';
									locationFound = false;
								}

								function OnItemChanged()
								{
								}

								function OnPopupShow()
								{
									if (IE6)
									{
										//hide the select boxes
										document.getElementById('Manufacturers').style.display='none';
										document.getElementById('Models').style.display='none';
										document.getElementById('MaxPrice').style.display='none';
									}
								}

								function OnPopupHide()
								{
									if (IE6)
									{
										//return the select boxes
										document.getElementById('Manufacturers').style.display='block';
										document.getElementById('Models').style.display='block';
										document.getElementById('MaxPrice').style.display='block';
									}
								}
