$.fn.pollmini = function(category,zone) {
    category=category.toUpperCase();
    if (zone)
        zone=zone.toUpperCase();

    // pokaz div z sonda (domyslnie jest niewidoczny)
    $(this).show();
    var identifier = $(this).attr("id");
    $(this).find("form").submit(function() { 
        $(this).ajaxSubmit({ target: '#'+identifier, beforeSubmit: $('#'+identifier).preloader() }); 
        return false; 
    }); 
    // sprawdz czy zmienna pollExists została ustalona
    if (typeof (pollExists)=="undefined") { 
        pollExists=false;
    }
    // jesli nie ma sondy dla biezacej kategorii
    if (!pollExists) {
        // ustalenie domyslnej kategorii w zaleznosci od regionu
        if (category.indexOf("PILKA")!=-1) {
            switch (zone) {
                case "SWI": pollCategory="PILKA01"; break;
                case "RAD": pollCategory="PILKA02"; break;
                case "POD": pollCategory="PILKA03"; break;
                default: pollCategory="PILKA01"; break;
            }
        } else {
            switch (zone) {
                case "SWI": pollCategory="POWIAT01"; break;
                case "RAD": pollCategory="POWIAT02"; break;
                case "POD": pollCategory="POWIAT03"; break;
                default: pollCategory="POWIAT01"; break;
            }
            // ustalenie kategorii innej niż domyslna dla okreslonych grup kategorii
            if (category=="SWIETOKRZYSKIE" || category.indexOf("POWIAT01")!=-1) {
                pollCategory="POWIAT01";
            }
            else if (category=="RADOMSKIE" || category.indexOf("POWIAT02")!=-1) {
                pollCategory="POWIAT02";
            }
            else if (category=="PODKARPACKIE" || category.indexOf("POWIAT03")!=-1) {
                pollCategory="POWIAT03";
            }
            else if (category.indexOf("SPORT08")!=-1) {
                pollCategory="SPORT08";
            }
            else if (category.indexOf("SPORT09")!=-1) {
                pollCategory="SPORT09";
            }
            else if (category.indexOf("SPORT11")!=-1) {
                pollCategory="SPORT11";
            }
        }
        // aktualizacja sondy
        $(this).load("/apps/pbcs.dll/miniquery?NoStat=1&W=280&H=120&Labels=trailing&Kategori=" + pollCategory + "&ObjectClass=-1&GraphColors=BEBEFC,6060E4,2323C4", function(){
            $(this).find("form").submit(function() { 
                $(this).ajaxSubmit({ target: "#"+identifier }); 
                return false; 
            }); 
        });
    }
    return true;
};

$.fn.preloader = function() {
     $(this).html("<img src=\"/images/preloader.gif\" width=\"32\" height=\"32\" alt=\"loading\" id=\"preloader\" />");
};