/* On click event for the suburb select box. When clicked it populates the suburb entry field then deselects the clicked suburb. Focus is returned to the suburb entry field.*/
function selTownArea () { if (!document.getElementById) return; var text   = document.getElementById('interestedin'); var select = document.getElementById('areaschoice'); // An IE bug means we need another event before select.selectedIndex // will update from -1. Since we need to swap the focus anyway we'll // do it before we look at what was clicked in the select box. text.focus(); var suburb = select.options[select.selectedIndex]; // short circuit on 'show all suburbs' //if (select.selectedIndex == 0) { //text.value = ''; //return true; //}

 var newcleartxt = suburb.text;
 if (newcleartxt == 'Clear Town/Area Selections') { text.value = ''; return true; }

 //var newclearpotxt = suburb.text;
 //var textFrSuburbs = text.value.split(', ');
 //if (newclearpotxt == 'Remove Last Town') {
 // textFrSuburbs.pop(); // textFrSuburbs.join(',');
 // newclearpotxt = textFrSuburbs + ',';
 //text.value = newclearpotxt; //return true;
 //} var newSuburb = suburb.text; var result = newSuburb.match(/^\*{3} KBA (.*) LACTFRE \*{3}$/); if (result != null) { newSuburb = result[1]; } // see if the selected suburb is in the list already var textSuburbs = text.value.split(/\s*,\s*/); if (!textSuburbs) return; var pattern = new RegExp('\s*' + newSuburb + '\s*$'); for (var i = 0; i < textSuburbs.length; i++) { // if it's in the list don't do anything if (pattern.exec(textSuburbs[i])) return; } // its not in the list so add it replacing any incomplete words var newvalue = text.value.replace( /(^|,)([^,]*)$/, "$1 " + newSuburb + ', ' ).replace(/^\s*/, ''); text.value = newvalue;} function sfsBuildIndex () { if (!document.getElementById) return; var select = document.getElementById('areaschoice'); for (var i = select.options.length; i--;) { sfsIndex[select.options[i].text.toUpperCase().charAt(0)] = i; } sfsIndex.populated = true;}