

<!--

var flashPlayer = {};
var cities = {};
function pokazWojewodztwo(name, val){
    $("#" + name + "cont dl.province select").val(val);
    refreshSelect($("#" + name + "cont dl.province select").eq(0).attr("id"));
    zmienWojewodztwo(name, val);
}
function pokazMiasto(name, val){
    $("#" + name + "cont dl.city select").val(val);
    refreshSelect($("#" + name + "cont dl.city select").attr("id"));
    zmienMiasto(name, val);
}
function przelaczPos(name){
    //alert(name);
    //Temporary work around - flash calls this function with starange args
    if (name.indexOf("/") == -1) {
        $("div.pos").not("#pos" + name).hide();
        $("#pos" + name).show();
        // $("div.map dl.province select").not("#" + name + "cont dl.province select").val("-").change();
    }
}
function zmienWojewodztwo(name, val){
    //alert(name);
    //Temporary work around - flash calls this function with starange args
    if (name.indexOf("/") == -1) {
        przelaczPos(name);
        var id = $("#" + name + "cont dl.city select").eq(0).attr("id");
        $("#" + id).empty().append('<option value="-">Wybierz miasto</option>');
        if (val != '-') {
            var cit = cities[name];
            var arr = cit[val];
            for (var i = 0; i < arr.length; i++) {
                $("#" + id).append('<option value="' + arr[i] + '">' + arr[i] + '</option>');
            }
            $("#" + id).removeAttr("disabled");
            refreshSelect(id);
            $("#pos" + name).ajaxSubmit({
                type: 'post',
                url: $("#" + name + "cont .selectcont").attr("rel") + toStrict(val) + ".html",
                target: "#pos" + name,
                beforeSubmit: function(){
                    $("#pos").empty();
                },
                success: function(){
                    if ($("#" + name + "cont").attr("title") != null) {
                        $("#pos" + name).prepend('<h2>' + $("#" + name + "cont").attr("title") + '</h2>');
                    }
                }
            });
        }
        else {
            $("#" + id).attr("disabled", "disabled");
            refreshSelect(id);
            $("#pos" + name).empty();
        }
    }
}
function zmienMiasto(name, val){
    //alert(val);
    //console.info(name);
    //console.info(val);
    przelaczPos(name);
    if (val != '-') {
        $("#pos" + name).children().hide();
        $("#pos" + name + " h2").show();
        $("#pos" + name + " strong").each(function(){
            if ($(this).text() == val) {
                $(this).show();
                $(this).next("ul").show();
                return false;
            }
        });
    }
    else {
        $("#pos" + name).children().show();
    }
}
function getMovieName(movieName){
    if (window.document[movieName]) {
        return window.document[movieName];
    }
    if (navigator.appName.indexOf("Microsoft Internet") == -1) {
        if (document.embeds && document.embeds[movieName])
            return document.embeds[movieName];
    }
    else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
    {
        return document.getElementById(movieName);
    }
}
function flashReady(name){
    if (flashPlayer[name] != null)
        return;
    flashPlayer[name] = getMovieName(name);
  buildCities(name)
}
function wyslijWojewodztwo(name, val){
    if (flashPlayer[name] != null) {
        getMovieName(name).showProvince(val);
    }
}
function initSelect(name){
    var id = $("#" + name + "cont dl.province select").eq(0).attr("id");
    for (i in cities[name]) {
        $("#" + id).append('<option value="' + i + '">' + i + '</option>');
    }
    $("#" + id).removeAttr("disabled");
    refreshSelect(id);
    $("#poscont").append('<div id="pos' + name + '" class="pos"></div>');
}
function refreshSelect(id){
    setTimeout(function(){
        $("#" + id).parent().hide();
        $("#" + id).selectbox();
        $("#" + id).parent().show();
    }, 1);
}
$(document).ready(function(){
    $("dl.province select").change(function(){
        wyslijWojewodztwo($(this).parents('.map').attr("rel"), $(this).val());
        zmienWojewodztwo($(this).parents('.map').attr("rel"), $(this).val());
        // refreshSelect($(this).attr("id"));
    });
    $("dl.city select").change(function(){
        zmienMiasto($(this).parents(".map").attr("rel"), $(this).val());
        refreshSelect($(this).attr("id"));
    });
});
function buildCities(name) {
    var ps = $('.map[rel="'+name+'"] .selectcont');
    $(ps).ajaxSubmit({
        dataType: 'json',
        type: 'post',
        url: $(ps).attr("rel") + "cities.json",
        success: function(re, st){
            cities[name] = re;
   if (cities[name] != null) {
     initSelect(name);
   }
        }
    });
}
function toStrict(str){
    var mapHash = {
        'ą': 'a',
        'ć': 'c',
        'ę': 'e',
        'ł': 'l',
        'ń': 'n',
        'ś': 's',
        'ł': 'l',
        'ń': 'n',
        'ó': 'o',
        'ś': 's',
        'ź': 'z',
        'ż': 'z',
        ' ': '_'
    };
    $.each(mapHash, function(ogonek, bezogonek){
        str = str.replace(new RegExp(ogonek, 'g'), bezogonek);
    });
    return str;
}
//-->


