//*******************************************
// This function preloads images that are
//  used within the site.
//*******************************************
function preloader() {
    var fldr = "./images/buttons/";

    // create object
    var imageObj = new Image();

    // set image list
    var images = [];
    images[0] = fldr + "btnATM.gif";
    images[1] = fldr + "btnBranch.gif";    
    images[2] = fldr + "btnATMSelected.gif";
    images[3] = fldr + "btnBranchSelected.gif";    

    // start preloading
    var l = images.length - 1;
    for (var i = 0; i <= l; i++) {
        imageObj.src = images[i];
    }
}
window.onload = preloader;

//*******************************************
// This function will clear the input field
//  text when it receives focus (mode=1) or
//  it will reset the value to default if
//  it is blank (mode==2)
//*******************************************


function cleanseValue(obj, mode) {
    if (mode == 1) {
        obj.value = '';
    } else if (mode == 2 && obj.value == '') {
        obj.value = 'Suburb or Postcode';
    }
}

//*******************************************
// This function changes the graphic displayed 
//  on a filter and stores the correct setting
//*******************************************


function changeFilter(obj, type) {
    var hEle = document.getElementById('hid' + type);
    if (hEle.value == '1') {
        // item is ticked, let's untick
        hEle.value = '0';
        switch (type.toLowerCase()) {
        case "atm":
            obj.src = "./images/buttons/btnATM.gif";
            break;
        case "branch":
            obj.src = "./images/buttons/btnBranch.gif";
            break;
        }
    } else {
        // item is not ticked, let's tick
        hEle.value = '1';
        switch (type.toLowerCase()) {
        case "atm":
            obj.src = "./images/buttons/btnATMSelected.gif";
            break;
        case "branch":
            obj.src = "./images/buttons/btnBranchSelected.gif";
            break;
        }
    }
}

//onclick event for panel search


function hide_search() {
    $('#pnlSearch').hide("slide", {
        direction: "right"
    }, 1000);
}
