
function getTimezones( countryCode, targetCtrlId, currentValue )
{
    var theCtrl = document.getElementById( targetCtrlId );
    var http = getHTTP();
    if( typeof( http ) != "undefined" && http != null )
    {
        var myurl = getBaseURL() + "/TimezoneSearch";
        http.open("GET", myurl + "?country=" + escape( countryCode ), true );
        http.onreadystatechange =
            function ()
            {
                if( http.readyState == 4 )
                {
                    writeTimezoneSearchResult( theCtrl, http.responseXML, currentValue );
                }
            };
        http.send(null);
    }
}

function writeTimezoneSearchResult( theCtrl, theResponse, currentValue )
{
    theCtrl.options.length = 0;

    var result = "";
    var timezones = theResponse.getElementsByTagName("TimeZone");
    if( timezones!= null )
    {
        for( var loop=0; loop < timezones.length; loop++ )
        {
            var timezone = timezones[ loop ];
            var code = timezone.getElementsByTagName("TimeZoneId")[0].firstChild.nodeValue;
            var title = timezone.getElementsByTagName("DisplayName")[0].firstChild.nodeValue;
            theCtrl.options[ theCtrl.options.length ] = new Option( title, code, (loop==0), (code==currentValue));
        }
    }
}
