var $mzn = jQuery.noConflict();
$mzn(document).ready(function(){

function populate() {

    if($mzn('#country').val() == 'Indonesia') // Alaska and District Columbia have no counties
    {
       fetch.doPost('viewprovince.php');
    } else {
       $mzn('#county_drop_down').hide();
       $mzn('#no_county_drop_down').show();
    }
}

$mzn('#country').change(populate);

var fetch = function() {
        
var counties = $mzn('#province');
return {
    doPost: function(src) {

    $mzn('#loading_county_drop_down').show(); // Show the Loading...
    $mzn('#county_drop_down').hide(); // Hide the drop down
    $mzn('#no_county_drop_down').hide(); // Hide the "no counties" message (if it's the case)


        if (src) $mzn.post(src, { state_code: $mzn('#country').val() }, this.getCounties);
        else throw new Error('No SRC was passed to getCounties!');
    },
            
    getCounties: function(results) {
        if (!results) return;
        counties.html(results);

    $mzn('#loading_county_drop_down').hide(); // Hide the Loading...
    $mzn('#county_drop_down').show(); // Show the drop down
    }    
}
}();

populate();


});

var $mznkt = jQuery.noConflict();
$mznkt(document).ready(function(){

function populate() {

    if($mznkt('#country').val() == 'Indonesia') // Alaska and District Columbia have no counties
    {
       fetch.doPost('viewkota.php');
    } else {
       $mznkt('#kota_drop_down').hide();
       $mznkt('#no_kota_drop_down').show();
    }
}

$mznkt('#country').change(populate);

var fetch = function() {
        
var counties = $mznkt('#alt_city');
return {
    doPost: function(src) {

    $mznkt('#loading_kota_drop_down').show(); // Show the Loading...
    $mznkt('#kota_drop_down').hide(); // Hide the drop down
    $mznkt('#no_kota_drop_down').hide(); // Hide the "no counties" message (if it's the case)


        if (src) $mznkt.post(src, { state_code: $mznkt('#country').val() }, this.getCounties);
        else throw new Error('No SRC was passed to getCounties!');
    },
            
    getCounties: function(results) {
        if (!results) return;
        counties.html(results);

    $mznkt('#loading_kota_drop_down').hide(); // Hide the Loading...
    $mznkt('#kota_drop_down').show(); // Show the drop down
    }    
}
}();

populate();


});
