var initialised var arrData var sourceCtl, targetCtl //index of last selected city var lastCity = 0 //initialise search engine function initSearchEng() { //frm.city.onchange = cityChange sourceCtl = "" targetCtl = "" arrLoading = new Array("loading... ") arrData = new Array() arrData["city"] = new Array() //arrData["suburb"] = new Array() initialised = false //extract default country, city and suburb from cookie var cookieArray = document.cookie.split("|") for (var i=0; i< cookieArray.length; i++) { if (cookieArray[i] == "SearchEng") { defCountry = cookieArray[i+1] defCity = cookieArray[i+2] //defSuburb = cookieArray[i+3] break } } //lock form controls setAccess(false, frm.country, frm.city) //display "loading..." in the controls that will be repopulated populateSelect(frm.country, arrLoading, false, false) populateSelect(frm.city, arrLoading, false, false) //get remote data objRS.busy = true objRS.getData("GetCountriesOnly", disabled, affID) } //set select box text function setText(ctl, newText) { for (var i=0; i< ctl.length; i++) { if (ctl[i].text == newText) { ctl[i].selected = true ctl.selectedIndex = i return true } } return false } //get select box's text function getText(selBox) { return selBox[selBox.selectedIndex].text } //get select box's value function getValue(selBox) { return selBox[selBox.selectedIndex].value } //handle country-change event function countryChange(ctl) { //repopulate cities sourceCtl = ctl targetCtl = frm.city lastCity = 0 ctlChange("GetCitiesOnly") } //handle city-change event function cityChange(ctl) { if (getValue(frm.city).substr(1, 3) == "---") { frm.city.selectedIndex = lastCity return } sourceCtl = ctl targetCtl = frm.suburb lastCity = frm.city.selectedIndex ctlChange("HCSearchEngineGetSuburbs") } //handle control-change event function ctlChange(func) { var selArray = arrData[targetCtl.name][getValue(sourceCtl)] if (typeof(selArray) == "undefined") { //lock form controls setAccess(false, frm.country, frm.city) //display "loading..." in the controls that will be repopulated populateSelect(targetCtl, arrLoading, false, false) //get remote data objRS.busy = true //alert(getText(sourceCtl)) objRS.getData(func, disabled, affID, getValue(sourceCtl)) } else rsCallBack(selArray) } //remote scripting callback function function rsCallBack(data) { //for ... Netscape 6 if (typeof(initialised) == "undefined") return //stas 24/01/2002 if (!initialised) { //unlock form controls setAccess(true, frm.country, frm.city) objRS.busy = false initialised = true //populate countries populateSelect(frm.country, data, false, true) setValue(frm.country, defCountry) countryChange(frm.country) return } //save downloaded data to data array arrData[targetCtl.name][getValue(sourceCtl)] = data //populate target select box populateSelect(targetCtl, data, false, true) //unlock form controls setAccess(true, frm.country, frm.city) objRS.busy = false } //populate select box with data function populateSelect(ctl, data, startBlank, pairs) { var startNum = 0 ctl.length = 0 if (startBlank) { ctl[0] = new Option('') startNum = 1 } if (pairs) { for (var i=0; i< data.length/2; i++) ctl[i+startNum] = new Option(data[2*i+1], data[2*i]) } else { for (var i=0; i< data.length; i++) ctl[i+startNum] = new Option(data[i]) } ctl[0].selected = true ctl.selectedIndex = 0 //set default and clear it after first use if (ctl.name == "city") { if (setValue(ctl, defCity)) defCity = "" } } //set select box value function setValue(ctl, newValue) { for (var i=0; i