$(document).ready(function(){

    /**
     * slideshow
     */
    var textFade = 200;
    var imgFade = 1000; 
    
    var timer = setInterval( showNext, 5000);
    
    $('.top_slides_box .top_slides_box_slide').hide();
    $('.top_slides_box_slide_dynamic').css({'bottom':'-30px'});
    $('.top_slides_box').each(function(el){
        $(this).children(".top_slides_box_slide:first").show();
        $(this).children(".top_slides_box_slide:first").addClass('active');
    });
    $(".top_slides_box_slide_dynamic").animate({'bottom':'0px'},textFade);

    function showNext() {
        i=0;
        $(".top_slides_box_slide_dynamic").animate({'bottom':'-30px'},textFade);
        $('.top_slides_box .active').each(function(){
            $(this).fadeOut(imgFade)
            $(this).removeClass('active');
            if ($(this).next().length){
                $(this).next().fadeIn(imgFade);
                $(this).next().addClass('active');
            }else{
                $(this).parent().children(".top_slides_box_slide:first").addClass('active');
                $(this).parent().children(".top_slides_box_slide:first").fadeIn(imgFade);
            }
        });
        $(".top_slides_box_slide_dynamic").animate({'bottom':'-30px'},imgFade,function(){
            $(".top_slides_box_slide_dynamic").animate({'bottom':'0px'},textFade);
        });
    }


    /**
     * szukajki
     */
    var sVal = $('input[name=s]').val();
    $('input[name=s]').click(function(){
        if (sVal == $(this).val()) $(this).val('');
    });
    
    $('input[name=s]').blur(function(){
        if ('' == $(this).val()) $(this).val(sVal);
    });
    
    var neVal = $('input[name=ne]').val();
    $('input[name=ne]').click(function(){
        if (neVal == $(this).val()) $(this).val('');
    });
    
    $('input[name=ne]').blur(function(){
        if ('' == $(this).val()) $(this).val(neVal);
    });
    
    /**
     * powiekszanie treści
     */
    
    $('.top_opt_pow a').click(function(){
        var size = $(this).attr('href').substring(1);
        $('.content_right .post, .content_right .post p ').css('fontSize',size+'px');
        size = parseInt(size)+8;
        $('.content_right .post, .content_right .post p ').css('lineHeight',(size)+'px');
        return false;
    });
});
