﻿/* check if suburb is selected on the static search page */
function CheckIfSuburbSelected() {
    var subdd = document.getElementById('ctl00_ContentPlaceHolder1_cddSuburb_ClientState');
    if (subdd == null || subdd.value == null) return false;
    if (subdd.value == ':::' || subdd.value == '::::::' || subdd.value == '') {
        alert('Please choose a suburb to search from the dropdown lists provided.');
        return false;
    }
    showBusyWindow();
    __doPostBack('SearchOnSuburb', '');
    return false;
}

function CheckForAdvertId() {
    var aid = document.getElementById('ctl00_ContentPlaceHolder1_txtAdvertId');
    if (aid == null || aid.value == null) return false;
    if (aid.value == '') {
        alert('Please specify the advert id to search for or use one of the other search methods provided.');
        return false;
    }
    showBusyWindow();
    __doPostBack('SearchOnAdvertId', '');
    return false;
}

function CheckForPostalCode() {
    var aid = document.getElementById('ctl00_ContentPlaceHolder1_txtPostalCode');
    if (aid == null || aid.value == null) return false;
    if (aid.value == '') {
        alert('Please specify the postal code to search for or use one of the other search methods provided.');
        return false;
    }
    showBusyWindow();
    __doPostBack('SearchOnPostCode', '');
    return false;
}

/* Set property type fields*/
function SetPropTypeFields(obj) {
    if (obj == null || obj.value == null) return;

    if (obj.id == 'ctl00_ContentPlaceHolder1_cboSubType') {
        if (obj.value == 'r') {
            document.getElementById('SubCommercial').style.display = 'none';
            document.getElementById('SubResidential').style.display = 'inline';
        }
        else {
            document.getElementById('SubCommercial').style.display = 'inline';
            document.getElementById('SubResidential').style.display = 'none';
        }
    }

    if (obj.id == 'ctl00_ContentPlaceHolder1_cboPcType') {
        if (obj.value == 'r') {
            document.getElementById('PcCommercial').style.display = 'none';
            document.getElementById('PcResidential').style.display = 'inline';
        }
        else {
            document.getElementById('PcCommercial').style.display = 'inline';
            document.getElementById('PcResidential').style.display = 'none';
        }
    }
}


