    function getCenters(query) {
        if (VEGlobal.zip.length == 0)return;
        document.getElementById('tblDirections').style.display = 'none';
        document.getElementById('tblResult').style.display = 'none';
        document.getElementById('tblLoading').style.display = 'inline';

        if (!VEGlobal.map) {
            VEGlobal.map = new VEMap('divMap');
            var initLatLong = new VELatLong(53.7141478406381, -1.69011163382114, 0, VEAltitudeMode.Default);
            VEGlobal.map.LoadMap(initLatLong);
            VEGlobal.map.SetScaleBarDistanceUnit(VEDistanceUnit.Kilometers)
        }
        VEGlobal.map.DeleteAllShapes();

        var pl = new SOAPClientParameters();
        pl.add("XmlParams", query);
        SOAPClient.invoke(VEGlobal.urlWS, "GetAResultPage", pl, true, populateResult);

    }
   
    function doSearch() {
    // 2/10/2009    Dermalogica   implement post code validation
        if (document.forms[0].zip.value.replace(/ /g,'').length == 0) return;
        var postCode = document.forms[0].zip.value.replace(/ /g,''); // strip all spaces
        postCode = postCode.toUpperCase(); // upper case
        // insert space at right position
        if (postCode.length == 5)
            postCode = postCode.substr(0,2) + ' ' + postCode.substr(2);
        else
            if (postCode.length == 6)
                postCode = postCode.substr(0,3) + ' ' + postCode.substr(3);
            else
                if (postCode.length == 7)
                    postCode = postCode.substr(0,4) + ' ' + postCode.substr(4);
                else {
                    alert('Postal Code not in a correct format');
                    return;
                }
        document.forms[0].zip.value = postCode;
        // pattern match with 6 kwnown formats
        var re1 = /[A-Z][0-9] [0-9][A-Z][A-Z]/;
        var re2 = /[A-Z][0-9][0-9] [0-9][A-Z][A-Z]/;
        var re3 = /[A-Z][0-9][A-Z] [0-9][A-Z][A-Z]/;
        var re4 = /[A-Z][A-Z][0-9] [0-9][A-Z][A-Z]/;
        var re5 = /[A-Z][A-Z][0-9][0-9] [0-9][A-Z][A-Z]/;
        var re6 = /[A-Z][A-Z][0-9][A-Z] [0-9][A-Z][A-Z]/;
        var ret = postCode.match(re1);
        if (ret == null) {
            ret = postCode.match(re2);
            if (ret == null) {
                ret = postCode.match(re3);
                if (ret == null) {
                    ret = postCode.match(re4);
                    if (ret == null) {
                        ret = postCode.match(re5);
                        if (ret == null) {
                            ret = postCode.match(re6);
                        }
                    }
                }
            }
        }
        if (ret == null) {
            alert('Postal Code not in a correct format');
            return;
        }
        
        // save entered address in global VEGlobal object
        VEGlobal.zip = postCode;
        VEGlobal.country = 'United Kingdom';
        getCenters(buildQueryXml(1));
    }
    function ShowChannelIslandCenters() {
        document.getElementById('tblDirections').style.display = 'none';
        document.getElementById('tblResult').style.display = 'none';
        document.getElementById('tblLoading').style.display = 'inline';

        VEGlobal.map = new VEMap('divMap');
        var initLatLong = new VELatLong(49.1912580439582, -2.10731271509533, 0, VEAltitudeMode.Default);
        VEGlobal.map.LoadMap(initLatLong);
        VEGlobal.map.DeleteAllShapes();

        var pl = new SOAPClientParameters();
        SOAPClient.invoke(VEGlobal.urlWS, "GetChannelIsland", pl, true, populateCIResult);
        return false;
    }
    function populateCIResult(r){
   // the result returned by the web service is a string, a "end record" is represented by \n\n
   // a field is delimited by |
   // layout of a record (representing a skin care center)
   // center_no|center_name|center_address|address_2|center_city|center_state|center_zip|center_phone|
   // center_distance
   
       clearResultTable();
       //alert('result: ' + r);
       if (r == null) {
            document.getElementById('tblResult').style.display = 'inline';
            document.getElementById('tblLoading').style.display = 'none';
            return;
       }
       var regX = /{~}/g; // escaped the | in the data, restore it here
       var res = r.replace(regX, '|');
       VEGlobal.aryLines = res.split('\n\n');
       var tblBRes = document.getElementById('tblBodyResult');
       
       var tr = document.createElement('tr');
       tblBRes.appendChild(tr);
       var td = document.createElement('td');
       tr.appendChild(td);
       td.colSpan = '3';
       td.vAlign = 'top';
       td.className = 'style11';
       td.innerHTML = 'Skin treatment centers,salons or spas in the English Channel Islands';
       
       for (var l = 0; l < VEGlobal.aryLines.length; l++) {
           var aryFld = VEGlobal.aryLines[l].split('|');
           if (aryFld.length < 2) break;
           // row center number and name, address
           tr = document.createElement('tr');
           tblBRes.appendChild(tr);
           // cell center number
           td = document.createElement('td');
           tr.appendChild(td);
           td.vAlign = 'top';
           td.innerHTML = '<div style="background-image:url(images/results.gif); ' +
                        'color:white; font-family:Arial; ' +
                        'width:20px; height:17px; font-size:12px;font-weight: normal; ' +
                        'text-decoration: none; padding-top:3px; ' +
                        'vertical-align: middle; text-align: center;">' +
                        aryFld[0] + '</div>';
                                
            // cell center name
           td = document.createElement('td');
           tr.appendChild(td);
           td.innerHTML =  '<span class="style25">' + aryFld[1] + '</span><br/><span class="style29">' +
            aryFld[2] + '<br/>' + 
            aryFld[3] + ', ' + aryFld[4] + ' ' + aryFld[5] + '<br/>' +
            aryFld[6] + '</span>';
            // cell icons
           td = document.createElement('td');
           tr.appendChild(td);
           td.style.width = '130px';
            // separator row
           tr = document.createElement('tr');
           tblBRes.appendChild(tr);
           td = document.createElement('td');
           tr.appendChild(td);
           td = document.createElement('td');
           tr.appendChild(td);
           td.colSpan = 2;
           td.className = 'style13';
           td.innerHTML = '.................................................................................';
       }
        document.getElementById('tblResult').style.display = 'inline';
        document.getElementById('tblLoading').style.display = 'none';

   }
