

<!--


<!--
/* opcje dla klas */
options = {
    flash: obj = {
        target: '.flash-obj', // obiekty jQuery ktore beda przerabiane za pomoca swfobject2.1
        flashVersion: '9.0.124' // minimalna wymagana wersja flasha
    },
    datePicker: obj = {
        dayNames: ['Niedziela', 'Poniedziałek', 'Wtorek', 'Środa', 'Czwartek', 'Piątek', 'Sobota'],
        dayNamesMin: ['Ni', 'Po', 'Wt', 'Śr', 'Cz', 'Pt', 'So'],
        dayNamesShort: ['Nie', 'Pon', 'Wto', 'Śro', 'Czw', 'Pią', 'Son'],
        monthNames: ['Styczeń', 'Luty', 'Marzec', 'Kwiecień', 'Maj', 'Czerwiec', 'Lipiec', 'Sierpień', 'Wrzesień', 'Październik', 'Listopad', 'Grudzień'],
        monthNamesShort: ['Sty', 'Lut', 'Mar', 'Kwi', 'Maj', 'Cze', 'Lip', 'Sie', 'Wrz', 'Paź', 'Lis', 'Gru'],
        prevText: '&laquo;',
        nextText: '&raquo;',
        currentText: 'dzisiaj',
        clearText: 'wyczyść',
        closeText: 'zamknij',
        buttonImage: '/_img/layout/ico.data-picker.png',
        showOn: 'both',
        dateFormat: 'yy-mm-dd',
        showAnim: 'fadeIn',
        maxDate: 'yyyy,mm,dd'
    }
}
/* klasa do zarzadzania flashami ! */
flash = {
    ini: function(options){ // inicjalizuje
        if (swfobject.hasFlashPlayerVersion("9.0.124")) {
            $(options.target).each(function(){
                if (/\.swf/.test($(this).find('a:first').attr('href'))) {
                    var attr = flash.getAttr($(this));
                    var flashvars = flash.getFlashVars($(this));
                    var params = flash.getParams($(this));
                    var attributes = {
                        id: attr.id,
                        name: attr.id
                    };
                    if (attr.src == null) 
                        return false;
                    var fixHeight = false;
                    if ($(this).parents('.fixH:first').size() > 0) 
                        fixHeight = true;
                    swfobject.embedSWF(attr.src, attr.id, attr.width, attr.height, options.flashVersion, '', flashvars, params, attributes);
                    if (fixHeight) {
                        fixInterval = setInterval(function(){
                            fix.ini();
                            clearInterval(fixInterval);
                        }, 111);
                    }
                }
            });
        }
        else {
            $(options.target).each(function(){
                $(this).find(".no-flash").css("visibility", "visible");
            })
        }
    },
    getAttr: function(obj){ // pobiera atrybuty podstawowe
        var attributes = {
            height: $(obj).height(),
            width: $(obj).width(),
            src: $(obj).find('a').attr('href'),
            id: $(obj).attr('id')
        }
        return (attributes);
    },
    getFlashVars: function(obj){ // pobiera zmienne flashowe
        var flashVars = {
            json: $(obj).find('a').attr('rel')
        }
        flashVars = flashVars.json;
        if (flashVars == undefined || flashVars == '' || flashVars == null) {
            flashVars = {};
            return flashVars;
        }
        flashVars = flashVars.substr(0, flashVars.lastIndexOf(","));
        flashVars = flashVars + '}';
        flashVars = eval('(' + flashVars + ')');
        return (flashVars);
        
    },
    getParams: function(obj){ // pobiera parametry
        var params = {
            json: $(obj).find('a').attr('rev')
        }
        params = params.json;
        if (params == undefined || params == '' || params == null) {
            params = {};
            return params;
        }
        params = params.substr(0, params.lastIndexOf(","));
        params = params + '}';
        params = eval('(' + params + ')');
        return (params);
    }
}
news = {
    ini: function(){
        if ($('#body.news-container').length > 0) {
            news.fixTables();
        }
    },
    fixTables: function(){
        $('#body.news-container .article table').each(function(){
            $(this).css({
                'margin': '0'
            });
            var w = $(this).parents('.col-2:first').width();
            if ($(this).width() > w) {
                $(this).wrap('<div></div>').parent().css({
                    'overflow': 'auto',
                    'margin-bottom': '11px',
                    'padding': '11px 0'
                });
            }
        });
    }
}
misc = {
    ini: function(){
        misc.selectGoTo();
        misc.bindDatePickers();
    },
    selectGoTo: function(){
        var obj = '#region-select';
        $(obj).change(function(){
            var href = $(this).parents('form:first').attr('action');
            var val = $(this).val();
            $(this).parents('form:first').attr('action', href + '#' + val);
        })
        $(obj).parents('form:first').submit(function(){
            if ($(obj).val() == '') {
                $(obj).focus();
                return false;
            }
            else {
                return true;
            }
        });
    },
    bindDatePickers: function(){
  var tag = '';
        $('.date-picker-from input').datepicker(options.datePicker);
        $('.date-picker-to input').datepicker(options.datePicker);
        $('.archives-controls a').click(function(){
            var href = $(this).parents('.side-box').find('.archives-controls a').attr('href');
            href = href.replace(/\#.*/, '');
            href = href.replace(/\?.*/, '');
            var from = $('.date-picker-from input').val();
            var to = $('.date-picker-to input').val();
            if (to <= from) {
                alert('Podaj poprawny zakres dat');
                href = href + '#';
                $(this).attr('href', href);
                return false;
            }
            var tag_href = '';
            if (tag != '') {
    tag_href = '&tags=' + tag;
   }
            href = href + '?from=' + from + '&to=' + to + tag_href;
            $(this).attr('href', href);
            return true;
        });
    }
}
faq = {
    ini: function(){
        faq.click();
    },
    click: function(){
        $('#faq > dt').click(function(){
            if (!$(this).hasClass('active')) {
                $(this).parent().find('dd').slideUp('fast');
                $(this).siblings().removeClass('active');
                $(this).addClass('active').next('dd').addClass('active').slideDown('fast');
            }
            else 
                $(this).removeClass('active').next('dd').removeClass('active').slideUp('fast');
        });
    }
}
videoApp = {
    ini: function(){
        videoApp.naviFix();
    },
    naviFix: function(){
        $('#body .navi-top .navi li.active').prev().addClass('next-active');
        $('#body .navi-top .navi li:last[class!=last]').addClass('last');
    }
}
commons = {
    ini: function(){
        commons.showExtraContent();
    },
    showExtraContent: function(){
        $('#show-form').click(function(){
            var h = $(this);
            $(h).parents('.content:first').find('.extra-content').show();
            $(h).parent().parent().remove();
            return false;
        });
    }
    
}
fix = {
    ini: function(){
        fix.height(); /* similar boxes */
        fix.height2(); /* main page */
        fix.noFlash();
    },
    height: function(){
        var maxH = 0;
        $('.fixH').each(function(){
            $(this).find('.col-1, .col-half').each(function(){
                $(this).find('.content').css({
                    'height': 'auto'
                });
                $(this).each(function(){
                    if ($(this).height() > maxH) 
                        maxH = $(this).height();
                });
                //   $(this).append('<div style="position: absolute; background: darkgreen; color: white;padding-top: 12px; z-index:1000"> maxH: ' + maxH + '</div>');
            });
            $(this).find('.content').each(function(){
                var ph = $(this).parents('.col-1:first, .col-half:first').height();
                var ch = $(this).height();
                $(this).append('<div style="position: absolute; left:0; background: white; padding: 3px; color: white; z-index:1001">.</div>'); // IE7 fix uh
                var h = maxH - ph + ch;
                var more = $(this).find('ul.more:last');
                var hasFooter = $(this).find('.foot').size();
                if (more.size() > 0 && hasFooter > 0 && $(this).find('ul.more').size() < 2) 
                    more.css({
                        'padding-top': maxH - ph
                    });
                else 
                    $(this).height(h);
            });
        });
    },
    height2: function(){
        $('.fixH2').each(function(){
            var maxH = 0;
            $(this).find('.col-1').each(function(){
                if ($(this).height() > maxH) 
                    maxH = $(this).height();
            });
            $(this).find('.col-1').each(function(){
                var h = $(this).height();
                var ch = $(this).find('.content:first').height();
                if (h < maxH) {
                    if ($(this).find('.mini-ranking-wrapper').size() > 0) {
                        $(this).find('.horizontal-dot-separator:eq(1)').css({
                            'margin-top': maxH - h + 'px'
                        });
                    }
                    else {
                        $(this).find('.content:first').height(ch + maxH - h);
                    }
                }
            });
        });
    },
    noFlash: function(){
        $('.no-flash').hide();
        fixFlash = setInterval(function(){
            $('.no-flash').show();
            clearInterval(fixFlash);
        }, 333);
    }
}
contactForms = {
    ini: function(){
        contactForms.bind();
    },
    activeForm: '',
    activeFormIndex: '',
    bind: function(){
        $('.wyczysc').click(function(){
            $(this).parents('form').each(function(){
                if (confirm("Czy na pewno chcesz wyczyścić formularz?")) {
                    $(this).is('form') && this.reset();
                    $('.error').removeClass('error');
                    $('.error-msg').attr('style', '').find('span').attr('style', '');
                    return false;
                }
                else {
                    return false;
                }
            });
            return false;
        });
        $('#send_form1,#send_form2,#send_form3,#send_form4,#send_form5').submit(function(){
            contactForms.activeForm = $(this).attr('id');
            contactForms.activeFormIndex = contactForms.activeForm.replace(/send_form/gi, '');
            return false
        }).ajaxForm(contactForms.options);
    },
    options: obj = {
        beforeSubmit: function(){
            $('.error').find('.error-msg').attr('style', '');
            $('.error').find('span').attr('style', '');
            $('.error').removeClass('error');
            if (contactForms.activeFormIndex != 1) {
                var cont = $('#send_form' + contactForms.activeFormIndex).find('.content');
                var h = cont.height() + parseInt(cont.css('padding-top')) + parseInt(cont.css('padding-bottom')) + 42;
                var w = cont.width() + parseInt(cont.css('padding-left')) + parseInt(cont.css('padding-right'));
                cont.append('<div class="load-mask"></div>').find('.load-mask').height(h).width(w);
                $('#send_form' + contactForms.activeFormIndex).find('.content');
            }
            else {
                var cont = $('#send_form' + contactForms.activeFormIndex).parents('.contact-consultant');
                var h = cont.height() + parseInt(cont.css('padding-top')) + parseInt(cont.css('padding-bottom'));
                var w = cont.width() + parseInt(cont.css('padding-left')) + parseInt(cont.css('padding-right'));
                cont.append('<div class="load-mask"></div>').find('.load-mask').height(h).width(w);
            }
        },
        success: function(responseText, statusText){
            var response = responseText;
            if (response == 'ok') {
                if (contactForms.activeFormIndex != 1) {
                    var cont = $('#send_form' + contactForms.activeFormIndex).find('.content');
                    cont.append('<div class="msg-mask"><strong></strong></div>');
                    var succMsg = cont.find('.success').html();
                    cont.find('.load-mask').addClass('loaded');
                    cont.find('.msg-mask strong').html(succMsg);
                }
                else {
                    var cont = $('#send_form' + contactForms.activeFormIndex).parents('.contact-consultant');
                    cont.append('<div class="msg-mask"><strong></strong></div>');
                    var succMsg = cont.find('.success').html();
                    cont.find('.load-mask').addClass('loaded');
                    cont.find('.msg-mask strong').html(succMsg);
                }
                return false;
            }
            $('.load-mask').remove();
            $.each(response.validation, function(i, r){
                if (r.status == 1) {
                    $(':input[name=' + r.input + ']').parents('.row:first').addClass('error').find('span').css({
                        'display': 'block'
                    });
                    
                    $(':input[name=' + r.input + ']').parents('div:first').find('.error-msg').attr('style', '').css({
                        'display': 'block',
                        'z-index': '999'
                    });
                    $(':input[name=' + r.input + ']').parents('div:first').find('.span').attr('style', '').css({
                        'display': 'block',
                        'z-index': '999'
                    });
                    
                }
                var ok = 'form' + contactForms.activeFormIndex + '_error';
                var fail = 'form' + contactForms.activeFormIndex + '_backoffice';
                if (r.input == fail && r.status == 1) 
                    $('#send_form' + contactForms.activeFormIndex).find('.failure').addClass('show');
            });
            return false;
        },
        // error: contactForms.errorSubmit(),
        dataType: 'json'
    }
}
$(function(){
    flash.ini(options.flash);
    videoApp.ini();
    faq.ini();
    commons.ini();
    misc.ini();
    news.ini();
    contactForms.ini();
    fix.ini();
    $("#calc-post-input").parents("form").submit(function(){
        var val = $("#calc-post-input").val();
        var valAltered = val.replace(/[^0-9.,]/g, "")
        $("#calc-post-input").val(valAltered);
    })
    $("#searchInput,.calc-fill").inputfill();
    
 if($('#navi .navi-row .active').size() > 0) {
        $.scrollTo({top:'280px'},800);
 }
    
});
//-->
//-->

