$(document).ready(function() {


   var $tabs = $('.tabs li');
    $tabs.each(function(element){
        
        $(this).children('a').click(function(e){
            
            var $this = $(this),
                $parent = $this.parent();
            
            if(!$parent.hasClass('active')){
                //console.log('zmiana na active');
                $tabs.removeClass('active');
                $parent.addClass('active');
                //podmien content
                if($parent.attr('id')==='zaloz-konto'){
                    $('#inner-one').show();
                    $('#inner-two').hide();
                }else{
                    $('#inner-one').hide();
                    $('#inner-two').show();
                }
            }
            return false;
        });
    });



    $('#selection > li > .tooltip').hide();
    $('.table-hidden').hide();
    $('.table-hidden2').hide();
    $('#table-unhide').click(function(){
        $('.table-hidden').fadeIn();
        return false;
    })
    $('#table-unhide2').click(function(){
        $('.table-hidden2').fadeIn();
        return false;
    })


    $('#tabela').hide();
	$('#potrzebne_dane').hide();

    $('#table-show').click( function(){

        $('#tabela').fadeIn();

        return false;

    });
	$('#dane-show').click( function(){

        $('#potrzebne_dane').fadeIn();

        return false;

    });

    $('.table-close').click( function(){

        $('#tabela').hide();
		$('#potrzebne_dane').hide();

        return false;

    });   

    $('#selection > li').click( function(){

        if($(this).children().is(':visible')) {

        $(this).children().hide();

        $(this).addClass('normal').removeClass('overflow'); } else {

          $('#selection > li').children().hide();

          $('#selection > li').addClass('normal').removeClass('overflow');

          $(this).children().show();

          $(this).addClass('overflow').removeClass('normal');

        }

    });
	$('#selection > li > .tooltip').mouseout(function() {
		$(this).hide();
		$('#selection > li').addClass('normal').removeClass('overflow')
		});
	
	$('#rules').click( function() {
		$('#agree').attr('checked', true);
	});
	
	$('body').click(function() {
		if (($('#tabela').is(':visible')) || ($('#potrzebne_dane').is(':visible'))) {
		$('#tabela').hide();
		$('#potrzebne_dane').hide();
		}
		});
});
