
countryId = 0;
areaId = 0;
cityId = 0;

    function loadCountries(sel)
    {
        $.getJSON("index.php?module=ajaxm&action=getCountriesList", '' ,
        function(json){
            $('#edit-order-country option').remove();
            $('#edit-order-country').append('<option value="">-- Выберите страну --</option>')

            $.each(json, function()
            {
                $('#edit-order-country').append('<option value="'+this.id+'"'+(this.id==countryId?' selected':'')+'>'+this.name+'</option>')
            }
            );

            loadRegions($('#edit-order-country').val());
        });
    }

    function loadRegions(country_id)
    {
        $.getJSON("index.php?module=ajaxm&action=getRegionsList", { country_id: country_id },
        function(json){
            $('#edit-order-region option').remove();
            $('#edit-order-region').append('<option value="">-- Выберите область --</option>')

            $.each(json, function()
            {
                $('#edit-order-region').append('<option value="'+this.id+'"'+(this.id==areaId?' selected':'')+'>'+this.name+'</option>');
            }
            );

            loadCities($('#edit-order-region').val());
        });
    }

    function loadCities(region_id)
    {
        $.getJSON("index.php?module=ajaxm&action=getCitiesList", { region_id: region_id },
        function(json){
            $('#edit-order-city option').remove();
            $('#edit-order-city').append('<option value="">-- Выберите город --</option>')

            $.each(json, function()
            {
                $('#edit-order-city').append('<option value="'+this.id+'"'+(this.id==cityId?' selected':'')+'>'+this.name+'</option>');
            }
            );

        });
    }


function popupWindow(mypage, myname, w, h, scroll, resizable) {
    var winl = (screen.width - w) / 2;
    var wint = (screen.height - h) / 2;
    winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',toolbars=1,scrollbars='+scroll+', resizable='+(resizable==0?'no':'yes')
    win = window.open(mypage, myname, winprops)
    if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}	    
		    
