// JavaScript Document

var ss = new Array;
ss[0]=1; ss[1]=9; ss[2]=25; ss[3]=35; ss[4]=41; ss[5]=46; ss[6]=52; ss[7]=57; ss[8]=62; ss[9]=-1; ss[10]=64; ss[11]=-1; ss[12]=67; ss[13]=75; ss[14]=77; ss[15]=79; ss[16]=-1; ss[17]=87; ss[18]=92; ss[19]=100; ss[20]=-1; ss[21]=-1; ss[22]=105; ss[23]=-1; ss[24]=-1; ss[25]=-1; ss[26]=108;
function BlankTypeBox() {
    document.sForm.Sub.value = '';
}
function RemoveSelects() {
    for (; document.sForm.Suburb.selectedIndex != -1;) {
        document.sForm.Suburb.options[document.sForm.Suburb.selectedIndex].selected = false;
    }
}
var limit = 10;
function LimitSelected() {
    var current = 0;
    for (var i = 0; i < document.sForm.Suburb.length; ++i) {
        if (document.sForm.Suburb.options[i].selected) {
            if (++current > limit) {
                document.sForm.Suburb.options[i].selected = false;
            }
        }
    }
    if (current > limit) {
        alert('You have selected '+current+' suburbs\nPlease select no more than '+limit);
    }
}
function UpdateSuburbs() {
    var entry = document.sForm.Sub.value.toUpperCase();
    var first = entry.charCodeAt(0) - 65;
    RemoveSelects();
    if (entry.length == 0) {
        document.sForm.Suburb.options[0].selected = true;
    } else if (ss[first] > 0) {
        var stop = ss[first+1];
        for (var i = first+2; stop < 0; ++i) {
            stop = ss[i];
        }
        for (var i = ss[first]; i < stop; ++i) {
            if (document.sForm.Suburb.options[i].text.indexOf(entry,0) == 0) {
                document.sForm.Suburb.options[i].selected = true;
                document.sForm.Suburb.options[0].selected = false;
                break;
            }
        }
    }
}