//schowaj/pokaż
function toggle_visibility(id) {
    var e = document.getElementById(id);
    if(e.style.display == 'block')
        e.style.display = 'none';
    else
        e.style.display = 'block';
}

//menu
var menu=function(){
    var t=15,z=50,s=6,a;
    function dd(n){
        this.n=n;
        this.h=[];
        this.c=[]
        }
    dd.prototype.init=function(p,c){
        a=c;
        var w=document.getElementById(p), s=w.getElementsByTagName('ul'), l=s.length, i=0;
        for(i;i<l;i++){
            var h=s[i].parentNode;
            this.h[i]=h;
            this.c[i]=s[i];
            h.onmouseover=new Function(this.n+'.st('+i+',true)');
            h.onmouseout=new Function(this.n+'.st('+i+')');
        }
    }
    dd.prototype.st=function(x,f){
        var c=this.c[x], h=this.h[x], p=h.getElementsByTagName('a')[0];
        clearInterval(c.t);
        c.style.overflow='hidden';
        if(f){
            p.className+=' '+a;
            if(!c.mh){
                c.style.display='block';
                c.style.height='';
                c.mh=c.offsetHeight;
                c.style.height=0
                }
            if(c.mh==c.offsetHeight){
                c.style.overflow='visible'
                }
            else{
                c.style.zIndex=z;
                z++;
                c.t=setInterval(function(){
                    sl(c,1)
                    },t)
                }
        }else{
            p.className=p.className.replace(a,'');
            c.t=setInterval(function(){
                sl(c,-1)
                },t)
            }
    }
    function sl(c,f){
        var h=c.offsetHeight;
        if((h<=0&&f!=1)||(h>=c.mh&&f==1)){
            if(f==1){
                c.style.filter='';
                c.style.opacity=1;
                c.style.overflow='visible'
                }
            clearInterval(c.t);
            return
        }
        var d=(f==1)?Math.ceil((c.mh-h)/s):Math.ceil(h/s), o=h/c.mh;
        c.style.opacity=o;
        c.style.filter='alpha(opacity='+(o*100)+')';
        c.style.height=h+(d*f)+'px'
    }
    return{
        dd:dd
    }
}();

//ajax indicator
$(function() {
    $("body").append('<div id="ajaxBusy" class="ajax"><p><img src="template/images/ajax.gif"></p></div>');
});

$(document).ajaxStart(function(){
    $('#ajaxBusy').show();
}).ajaxStop(function(){
    $('#ajaxBusy').hide();
});

$.ajaxSetup({
  contentType: "application/x-www-form-urlencoded; charset=iso-8859-2"
});

//wstecz/dalej w edycji ankiety + sprawdzanie
$(document).ready(function() {

    jQuery.validator.messages.required = "";
    /*$(".validateMe").validate({
        invalidHandler: function(form, validator) {
            var errors = validator.numberOfInvalids();
            if (errors) {
                var message = errors == 1
                ? 'Jedno pole jest niepoprawnie wype\u0142nione, zostało pod¶wietlone.'
                : 'Ilo\u015bć niepoprawnie wypełnionych pól: ' + errors + '. Wszystkie z nich zosta\u0142y pod\u015bwietlone.';
                //$("div.error span").html(message);
                //$("div.error").show();
                alert(message)
            }
        },
        errorPlacement: function(error, element) {}
    });*/

    $(".goleft").click( function(e) {
        var $active = $(".active");
        var $next = $active.prev().length ? $active.prev() : $(".reportTable:last");
        var leftId = $next.attr('id');
        //alert(leftId);
        //alert($(".reportTable:last").toSource());
        //alert($active.toSource());

        if(!(leftId == 'finQ')) {
            $active.removeClass('active');
            $active.addClass('inactive');
            $next.addClass('active');
            $next.removeClass('inactive');
        }
        
    });

    $(".goright").click( function(e) {
        if( parseInt($('#x1').val()) == 1 && parseInt($('#x2').val()) == 0) {
            var $active = $(".active");
            var $next = $active.next().length ? $active.next() : $(".reportTable:first");
            var rightId = $next.attr('id');
            var currId = $active.attr('id');

            //alert("Valid: " + $($active).valid());
            //return false;

            // jeżeli wsio gra - idziemy w prawo, wysyłamy request ajaxowy
            if(!(rightId == 'firstQ') && $($active).valid()) {
                //zmienna na dane
                var dataString, v1, v2, v3, v4, v5, v6, v7, v8, v9;
                var pid = $("#pollID").val();

                //ajax
                switch (currId)
                {
                    case 'f1':
                        v1 = $("#x1").val();
                        v2 = $("#x2").val();
                        dataString = 'pid='+pid+'&b=1&v1='+v1+'&v2='+v2;
                        break;
                    case 'f2':
                        v1 = $("#m1").val();
                        v2 = $("#m2").val();
                        v3 = $("#m3").val();
                        v4 = $("#m4").val();
                        v5 = $("#m5").val();
                        v6 = $("#m6").val();
                        v7 = $("#m7").val();
                        dataString = 'pid='+pid+'&b=2&v1='+v1+'&v2='+v2+'&v3='+v3+'&v4='+v4+'&v5='+v5+'&v6='+v6+'&v7='+v7;
                        break;
                    case 'f3':
                        v1 = $("#pre1").val();
                        v2 = $("#pre2").val();
                        v3 = $("#pre3").val();
                        v4 = $("#pre4").val();
                        v5 = $("#pre5").val();
                        v6 = $("#pre6").val();
                        v7 = $("#pre7").val();
                        v8 = $("#pre8").val();
                        dataString = 'pid='+pid+'&b=3&v1='+v1+'&v2='+v2+'&v3='+v3+'&v4='+v4+'&v5='+v5+'&v6='+v6+'&v7='+v7+'&v8='+v8;
                        break;
                     case 'f4':
                        v1 = $("#n11").val();
                        v2 = $("#n12").val();
                        v3 = $("#n13").val();
                        v4 = $("#n14").val();
                        v5 = $("#n15").val();
                        v6 = $("#n16").val();
                        v7 = $("#n17").val();
                        v8 = $("#n18").val();
                        v9 = $("#n19").val();
                        dataString = 'pid='+pid+'&b=4&v1='+v1+'&v2='+v2+'&v3='+v3+'&v4='+v4+'&v5='+v5+'&v6='+v6+'&v7='+v7+'&v8='+v8+'&v9='+v9;
                        break;
                    case 'f5':v1 = $("#n21").val();v2 = $("#n22").val();v3 = $("#n23").val();v4 = $("#n24").val();v5 = $("#n25").val();v6 = $("#n26").val();v7 = $("#n27").val();v8 = $("#n28").val();v9 = $("#n29").val();dataString = 'pid='+pid+'&b=5&v1='+v1+'&v2='+v2+'&v3='+v3+'&v4='+v4+'&v5='+v5+'&v6='+v6+'&v7='+v7+'&v8='+v8+'&v9='+v9;break;
                    case 'f6':v1 = $("#n31").val();v2 = $("#n32").val();v3 = $("#n33").val();v4 = $("#n34").val();v5 = $("#n35").val();v6 = $("#n36").val();v7 = $("#n37").val();v8 = $("#n38").val();v9 = $("#n39").val();dataString = 'pid='+pid+'&b=6&v1='+v1+'&v2='+v2+'&v3='+v3+'&v4='+v4+'&v5='+v5+'&v6='+v6+'&v7='+v7+'&v8='+v8+'&v9='+v9;break;
                    case 'f7':v1 = $("#n41").val();v2 = $("#n42").val();v3 = $("#n43").val();v4 = $("#n44").val();v5 = $("#n45").val();v6 = $("#n46").val();v7 = $("#n47").val();v8 = $("#n48").val();v9 = $("#n49").val();dataString = 'pid='+pid+'&b=7&v1='+v1+'&v2='+v2+'&v3='+v3+'&v4='+v4+'&v5='+v5+'&v6='+v6+'&v7='+v7+'&v8='+v8+'&v9='+v9;break;
                    case 'f8':v1 = $("#n51").val();v2 = $("#n52").val();v3 = $("#n53").val();v4 = $("#n54").val();v5 = $("#n55").val();v6 = $("#n56").val();v7 = $("#n57").val();v8 = $("#n58").val();v9 = $("#n59").val();dataString = 'pid='+pid+'&b=8&v1='+v1+'&v2='+v2+'&v3='+v3+'&v4='+v4+'&v5='+v5+'&v6='+v6+'&v7='+v7+'&v8='+v8+'&v9='+v9;break;
                    case 'f9':v1 = $("#n61").val();v2 = $("#n62").val();v3 = $("#n63").val();v4 = $("#n64").val();v5 = $("#n65").val();v6 = $("#n66").val();v7 = $("#n67").val();v8 = $("#n68").val();v9 = $("#n69").val();dataString = 'pid='+pid+'&b=9&v1='+v1+'&v2='+v2+'&v3='+v3+'&v4='+v4+'&v5='+v5+'&v6='+v6+'&v7='+v7+'&v8='+v8+'&v9='+v9;break;
                    case 'f10':v1 = $("#n71").val();v2 = $("#n72").val();v3 = $("#n73").val();v4 = $("#n74").val();v5 = $("#n75").val();v6 = $("#n76").val();v7 = $("#n77").val();v8 = $("#n78").val();v9 = $("#n79").val();dataString = 'pid='+pid+'&b=10&v1='+v1+'&v2='+v2+'&v3='+v3+'&v4='+v4+'&v5='+v5+'&v6='+v6+'&v7='+v7+'&v8='+v8+'&v9='+v9;break;
                    case 'f11':v1 = $("#n81").val();v2 = $("#n82").val();v3 = $("#n83").val();v4 = $("#n84").val();v5 = $("#n85").val();v6 = $("#n86").val();v7 = $("#n87").val();v8 = $("#n88").val();v9 = $("#n89").val();dataString = 'pid='+pid+'&b=11&v1='+v1+'&v2='+v2+'&v3='+v3+'&v4='+v4+'&v5='+v5+'&v6='+v6+'&v7='+v7+'&v8='+v8+'&v9='+v9;break;
                    case 'f12':v1 = $("#n91").val();v2 = $("#n92").val();v3 = $("#n93").val();v4 = $("#n94").val();v5 = $("#n95").val();v6 = $("#n96").val();v7 = $("#n97").val();v8 = $("#n98").val();v9 = $("#n99").val();dataString = 'pid='+pid+'&b=12&v1='+v1+'&v2='+v2+'&v3='+v3+'&v4='+v4+'&v5='+v5+'&v6='+v6+'&v7='+v7+'&v8='+v8+'&v9='+v9;break;
                    case 'f13':v1 = $("#n101").val();v2 = $("#n102").val();v3 = $("#n103").val();v4 = $("#n104").val();v5 = $("#n105").val();v6 = $("#n106").val();v7 = $("#n107").val();v8 = $("#n108").val();v9 = $("#n109").val();dataString = 'pid='+pid+'&b=13&v1='+v1+'&v2='+v2+'&v3='+v3+'&v4='+v4+'&v5='+v5+'&v6='+v6+'&v7='+v7+'&v8='+v8+'&v9='+v9;break;
                    case 'f14':v1 = $("#n111").val();v2 = $("#n112").val();v3 = $("#n113").val();v4 = $("#n114").val();v5 = $("#n115").val();v6 = $("#n116").val();v7 = $("#n117").val();v8 = $("#n118").val();v9 = $("#n119").val();dataString = 'pid='+pid+'&b=14&v1='+v1+'&v2='+v2+'&v3='+v3+'&v4='+v4+'&v5='+v5+'&v6='+v6+'&v7='+v7+'&v8='+v8+'&v9='+v9;break;
                    case 'f15':v1 = $("#n121").val();v2 = $("#n122").val();v3 = $("#n123").val();v4 = $("#n124").val();v5 = $("#n125").val();v6 = $("#n126").val();v7 = $("#n127").val();v8 = $("#n128").val();v9 = $("#n129").val();dataString = 'pid='+pid+'&b=15&v1='+v1+'&v2='+v2+'&v3='+v3+'&v4='+v4+'&v5='+v5+'&v6='+v6+'&v7='+v7+'&v8='+v8+'&v9='+v9;break;
                    case 'f16':v1 = $("#n131").val();v2 = $("#n132").val();v3 = $("#n133").val();v4 = $("#n134").val();v5 = $("#n135").val();v6 = $("#n136").val();v7 = $("#n137").val();v8 = $("#n138").val();v9 = $("#n139").val();dataString = 'pid='+pid+'&b=16&v1='+v1+'&v2='+v2+'&v3='+v3+'&v4='+v4+'&v5='+v5+'&v6='+v6+'&v7='+v7+'&v8='+v8+'&v9='+v9;break;
                    case 'f17':v1 = $("#n141").val();v2 = $("#n142").val();v3 = $("#n143").val();v4 = $("#n144").val();v5 = $("#n145").val();v6 = $("#n146").val();v7 = $("#n147").val();v8 = $("#n148").val();v9 = $("#n149").val();dataString = 'pid='+pid+'&b=17&v1='+v1+'&v2='+v2+'&v3='+v3+'&v4='+v4+'&v5='+v5+'&v6='+v6+'&v7='+v7+'&v8='+v8+'&v9='+v9;break;
                    case 'f18':v1 = $("#n151").val();v2 = $("#n152").val();v3 = $("#n153").val();v4 = $("#n154").val();v5 = $("#n155").val();v6 = $("#n156").val();v7 = $("#n157").val();v8 = $("#n158").val();v9 = $("#n159").val();dataString = 'pid='+pid+'&b=18&v1='+v1+'&v2='+v2+'&v3='+v3+'&v4='+v4+'&v5='+v5+'&v6='+v6+'&v7='+v7+'&v8='+v8+'&v9='+v9;break;
                    case 'f19':
                        v1 = $("#post1").val();
                        v2 = $("#post2").val();
                        v3 = $("#post3").val();
                        v4 = $("#post4").val();
                        v5 = $("#post5").val();
                        v6 = $("#post6").val();
                        v7 = $("#post7").val();
                        v8 = $("#post8").val();
                        dataString = 'pid='+pid+'&b=19&v1='+v1+'&v2='+v2+'&v3='+v3+'&v4='+v4+'&v5='+v5+'&v6='+v6+'&v7='+v7+'&v8='+v8;
                        break;
                    case 'f20':
                        v1 = $("#fin1").val();
                        v2 = $("#fin2").val();
                        dataString = 'pid='+pid+'&b=20&v1='+v1+'&v2='+v2;
                        break;
                //default:
                    //    document.write("Ups. Popsu\u0142o się.");
                }

                $.ajax({
                    type: "POST",
                    url: "index.php?module=ajax&action=updateAnswers",
                    data: dataString,
                    success: function(/*html*/){
                        //ajax success - idziemy dalej
                        //
                        //$("#comment_form").html(html);
                        //alert (dataString);
                        
                        $active.removeClass('active');
                        $active.addClass('inactive');
                        $next.addClass('active');
                        $next.removeClass('inactive');
                    }
                });
            }
        }
    });

});

//sekundnik
jQuery.fn.extend({
    everyTime: function(interval, label, fn, times, belay) {
        return this.each(function() {
            jQuery.timer.add(this, interval, label, fn, times, belay);
        });
    },
    oneTime: function(interval, label, fn) {
        return this.each(function() {
            jQuery.timer.add(this, interval, label, fn, 1);
        });
    },
    stopTime: function(label, fn) {
        return this.each(function() {
            jQuery.timer.remove(this, label, fn);
        });
    }
});

jQuery.extend({
    timer: {
        guid: 1,
        global: {},
        regex: /^([0-9]+)\s*(.*s)?$/,
        powers: {
            // Yeah this is major overkill...
            'ms': 1,
            'cs': 10,
            'ds': 100,
            's': 1000,
            'das': 10000,
            'hs': 100000,
            'ks': 1000000
        },
        timeParse: function(value) {
            if (value == undefined || value == null)
                return null;
            var result = this.regex.exec(jQuery.trim(value.toString()));
            if (result[2]) {
                var num = parseInt(result[1], 10);
                var mult = this.powers[result[2]] || 1;
                return num * mult;
            } else {
                return value;
            }
        },
        add: function(element, interval, label, fn, times, belay) {
            var counter = 0;

            if (jQuery.isFunction(label)) {
                if (!times)
                    times = fn;
                fn = label;
                label = interval;
            }

            interval = jQuery.timer.timeParse(interval);

            if (typeof interval != 'number' || isNaN(interval) || interval <= 0)
                return;

            if (times && times.constructor != Number) {
                belay = !!times;
                times = 0;
            }

            times = times || 0;
            belay = belay || false;

            if (!element.$timers)
                element.$timers = {};

            if (!element.$timers[label])
                element.$timers[label] = {};

            fn.$timerID = fn.$timerID || this.guid++;

            var handler = function() {
                if (belay && this.inProgress)
                    return;
                this.inProgress = true;
                if ((++counter > times && times !== 0) || fn.call(element, counter) === false)
                    jQuery.timer.remove(element, label, fn);
                this.inProgress = false;
            };

            handler.$timerID = fn.$timerID;

            if (!element.$timers[label][fn.$timerID])
                element.$timers[label][fn.$timerID] = window.setInterval(handler,interval);

            if ( !this.global[label] )
                this.global[label] = [];
            this.global[label].push( element );

        },
        remove: function(element, label, fn) {
            var timers = element.$timers, ret;

            if ( timers ) {

                if (!label) {
                    for ( label in timers )
                        this.remove(element, label, fn);
                } else if ( timers[label] ) {
                    if ( fn ) {
                        if ( fn.$timerID ) {
                            window.clearInterval(timers[label][fn.$timerID]);
                            delete timers[label][fn.$timerID];
                        }
                    } else {
                        for ( var fn in timers[label] ) {
                            window.clearInterval(timers[label][fn]);
                            delete timers[label][fn];
                        }
                    }

                    for ( ret in timers[label] ) break;
                    if ( !ret ) {
                        ret = null;
                        delete timers[label];
                    }
                }

                for ( ret in timers ) break;
                if ( !ret )
                    element.$timers = null;
            }
        }
    }
});

if (jQuery.browser.msie)
    jQuery(window).one("unload", function() {
        var global = jQuery.timer.global;
        for ( var label in global ) {
            var els = global[label], i = els.length;
            while ( --i )
                jQuery.timer.remove(els[i], label);
        }
    });


$(function() {
    var active1 = false;
    $('#t1Start').css("cursor", "pointer").click(function() {
        if (!active1) {
            active1 = true;

            var ilosc = parseInt($('#n19').val());

            if(ilosc > 0) {
                $("#n19").everyTime(1000, 'controlled', function(i) {
                    $(this).val(ilosc+i);
                    //$("#n19").attr('value', ilosc+i);
                });
            }
            else {
                $("#n19").everyTime(1000, 'controlled', function(i) {
                    $(this).val(i);
                    //$("#n19").attr("value", i);
                });
            }
        }
    });

    $('#t1Stop').css("cursor", "pointer").click(function() {
        if (active1) {
            active1 = false;
            $("#n19").stopTime('controlled');
        }
    });

    var active2 = false;$('#t2Start').css("cursor", "pointer").click(function() {if (!active2) {active2 = true;var ilosc = parseInt($('#n29').val());if(ilosc > 0) {$("#n29").everyTime(1000, 'controlled', function(i) {$(this).val(ilosc+i);});} else {$("#n29").everyTime(1000, 'controlled', function(i) {$(this).val(i);});}}});$('#t2Stop').css("cursor", "pointer").click(function() {if (active2) {active2 = false;$("#n29").stopTime('controlled');}});
    var active3 = false;$('#t3Start').css("cursor", "pointer").click(function() {if (!active3) {active3 = true;var ilosc = parseInt($('#n39').val());if(ilosc > 0) {$("#n39").everyTime(1000, 'controlled', function(i) {$(this).val(ilosc+i);});} else {$("#n39").everyTime(1000, 'controlled', function(i) {$(this).val(i);});}}});$('#t3Stop').css("cursor", "pointer").click(function() {if (active3) {active3 = false;$("#n39").stopTime('controlled');}});
    var active4 = false;$('#t4Start').css("cursor", "pointer").click(function() {if (!active4) {active4 = true;var ilosc = parseInt($('#n49').val());if(ilosc > 0) {$("#n49").everyTime(1000, 'controlled', function(i) {$(this).val(ilosc+i);});} else {$("#n49").everyTime(1000, 'controlled', function(i) {$(this).val(i);});}}});$('#t4Stop').css("cursor", "pointer").click(function() {if (active4) {active4 = false;$("#n49").stopTime('controlled');}});
    var active5 = false;$('#t5Start').css("cursor", "pointer").click(function() {if (!active5) {active5 = true;var ilosc = parseInt($('#n59').val());if(ilosc > 0) {$("#n59").everyTime(1000, 'controlled', function(i) {$(this).val(ilosc+i);});} else {$("#n59").everyTime(1000, 'controlled', function(i) {$(this).val(i);});}}});$('#t5Stop').css("cursor", "pointer").click(function() {if (active5) {active5 = false;$("#n59").stopTime('controlled');}});
    var active6 = false;$('#t6Start').css("cursor", "pointer").click(function() {if (!active6) {active6 = true;var ilosc = parseInt($('#n69').val());if(ilosc > 0) {$("#n69").everyTime(1000, 'controlled', function(i) {$(this).val(ilosc+i);});} else {$("#n69").everyTime(1000, 'controlled', function(i) {$(this).val(i);});}}});$('#t6Stop').css("cursor", "pointer").click(function() {if (active6) {active6 = false;$("#n69").stopTime('controlled');}});
    var active7 = false;$('#t7Start').css("cursor", "pointer").click(function() {if (!active7) {active7 = true;var ilosc = parseInt($('#n79').val());if(ilosc > 0) {$("#n79").everyTime(1000, 'controlled', function(i) {$(this).val(ilosc+i);});} else {$("#n79").everyTime(1000, 'controlled', function(i) {$(this).val(i);});}}});$('#t7Stop').css("cursor", "pointer").click(function() {if (active7) {active7 = false;$("#n79").stopTime('controlled');}});
    var active8 = false;$('#t8Start').css("cursor", "pointer").click(function() {if (!active8) {active8 = true;var ilosc = parseInt($('#n89').val());if(ilosc > 0) {$("#n89").everyTime(1000, 'controlled', function(i) {$(this).val(ilosc+i);});} else {$("#n89").everyTime(1000, 'controlled', function(i) {$(this).val(i);});}}});$('#t8Stop').css("cursor", "pointer").click(function() {if (active8) {active8 = false;$("#n89").stopTime('controlled');}});
    var active9 = false;$('#t9Start').css("cursor", "pointer").click(function() {if (!active9) {active9 = true;var ilosc = parseInt($('#n99').val());if(ilosc > 0) {$("#n99").everyTime(1000, 'controlled', function(i) {$(this).val(ilosc+i);});} else {$("#n99").everyTime(1000, 'controlled', function(i) {$(this).val(i);});}}});$('#t9Stop').css("cursor", "pointer").click(function() {if (active9) {active9 = false;$("#n99").stopTime('controlled');}});
    var active10 = false;$('#t10Start').css("cursor", "pointer").click(function() {if (!active10) {active10 = true;var ilosc = parseInt($('#n109').val());if(ilosc > 0) {$("#n109").everyTime(1000, 'controlled', function(i) {$(this).val(ilosc+i);});} else {$("#n109").everyTime(1000, 'controlled', function(i) {$(this).val(i);});}}});$('#t10Stop').css("cursor", "pointer").click(function() {if (active10) {active10 = false;$("#n109").stopTime('controlled');}});
    var active11 = false;$('#t11Start').css("cursor", "pointer").click(function() {if (!active11) {active11 = true;var ilosc = parseInt($('#n119').val());if(ilosc > 0) {$("#n119").everyTime(1000, 'controlled', function(i) {$(this).val(ilosc+i);});} else {$("#n119").everyTime(1000, 'controlled', function(i) {$(this).val(i);});}}});$('#t11Stop').css("cursor", "pointer").click(function() {if (active11) {active11 = false;$("#n119").stopTime('controlled');}});
    var active12 = false;$('#t12Start').css("cursor", "pointer").click(function() {if (!active12) {active12 = true;var ilosc = parseInt($('#n129').val());if(ilosc > 0) {$("#n129").everyTime(1000, 'controlled', function(i) {$(this).val(ilosc+i);});} else {$("#n129").everyTime(1000, 'controlled', function(i) {$(this).val(i);});}}});$('#t12Stop').css("cursor", "pointer").click(function() {if (active12) {active12 = false;$("#n129").stopTime('controlled');}});
    var active13 = false;$('#t13Start').css("cursor", "pointer").click(function() {if (!active13) {active13 = true;var ilosc = parseInt($('#n139').val());if(ilosc > 0) {$("#n139").everyTime(1000, 'controlled', function(i) {$(this).val(ilosc+i);});} else {$("#n139").everyTime(1000, 'controlled', function(i) {$(this).val(i);});}}});$('#t13Stop').css("cursor", "pointer").click(function() {if (active13) {active13 = false;$("#n139").stopTime('controlled');}});
    var active14 = false;$('#t14Start').css("cursor", "pointer").click(function() {if (!active14) {active14 = true;var ilosc = parseInt($('#n149').val());if(ilosc > 0) {$("#n149").everyTime(1000, 'controlled', function(i) {$(this).val(ilosc+i);});} else {$("#n149").everyTime(1000, 'controlled', function(i) {$(this).val(i);});}}});$('#t14Stop').css("cursor", "pointer").click(function() {if (active14) {active14 = false;$("#n149").stopTime('controlled');}});
    var active15 = false;$('#t15Start').css("cursor", "pointer").click(function() {if (!active15) {active15 = true;var ilosc = parseInt($('#n159').val());if(ilosc > 0) {$("#n159").everyTime(1000, 'controlled', function(i) {$(this).val(ilosc+i);});} else {$("#n159").everyTime(1000, 'controlled', function(i) {$(this).val(i);});}}});$('#t15Stop').css("cursor", "pointer").click(function() {if (active15) {active15 = false;$("#n159").stopTime('controlled');}});

});

//x.6 warunkuje x.2
$(document).ready(function() {

    $("#n16").change(function() {
        if($("#n16").val() == '0') {
            $("#n12 option[value='5']").attr('selected', 'selected');
        }
    }).change();

    $("#n26").change(function() {if($("#n26").val() == '0') {$("#n22 option[value='5']").attr('selected', 'selected');}}).change();
    $("#n36").change(function() {if($("#n36").val() == '0') {$("#n32 option[value='5']").attr('selected', 'selected');}}).change();
    $("#n46").change(function() {if($("#n46").val() == '0') {$("#n42 option[value='5']").attr('selected', 'selected');}}).change();
    $("#n56").change(function() {if($("#n56").val() == '0') {$("#n52 option[value='5']").attr('selected', 'selected');}}).change();
    $("#n66").change(function() {if($("#n66").val() == '0') {$("#n62 option[value='5']").attr('selected', 'selected');}}).change();
    $("#n76").change(function() {if($("#n76").val() == '0') {$("#n72 option[value='5']").attr('selected', 'selected');}}).change();
    $("#n86").change(function() {if($("#n86").val() == '0') {$("#n82 option[value='5']").attr('selected', 'selected');}}).change();
    $("#n96").change(function() {if($("#n96").val() == '0') {$("#n92 option[value='5']").attr('selected', 'selected');}}).change();
    $("#n106").change(function() {if($("#n106").val() == '0') {$("#n102 option[value='5']").attr('selected', 'selected');}}).change();
    $("#n116").change(function() {if($("#n116").val() == '0') {$("#n112 option[value='5']").attr('selected', 'selected');}}).change();
    $("#n126").change(function() {if($("#n126").val() == '0') {$("#n122 option[value='5']").attr('selected', 'selected');}}).change();
    $("#n136").change(function() {if($("#n136").val() == '0') {$("#n132 option[value='5']").attr('selected', 'selected');}}).change();
    $("#n146").change(function() {if($("#n146").val() == '0') {$("#n142 option[value='5']").attr('selected', 'selected');}}).change();
    $("#n156").change(function() {if($("#n156").val() == '0') {$("#n152 option[value='5']").attr('selected', 'selected');}}).change();

});

