function scroll() {
    window.scrollTo(0, 1);
}

$(function () {

    setTimeout(scroll, 100);

    /* email reformat*/
    $('.email').each(function(){
        $text = $(this).text();
        $text = $text.replace('[zavináč]', '@');
        $text = $text.replace('[tečka]', '.');

        $(this).text($text);
    });

    /* Homepage slider */
    $slider = $('#slider');

    if ($slider.length > 0 && jQuery().slides){

        $slider.prepend(
              '<div class="slider-arrows">'
            + '<a class="arrow prev" href="#">Předchozí</a>'
            + '<a class="arrow next" href="#">Další</a>'
            + '</div>'
        );

        $slider.slides({
            generatePagination: false,
            hoverPause: true,
            pause: 2500,
            play: 8000,
            slideSpeed: 500
            
        });
    }

    /* Contact */
    $contactForm = $('#frm-contactForm');

    if ($contactForm.length > 0) {

        /* autoresize */
        if (jQuery().autoResize) {
            $('#frm-text').autoResize({
                // On resize:
                onResize : function() {
                    $(this).css({opacity:0.8});
                },
                // After resize:
                animateCallback : function() {
                    $(this).css({opacity:1});
                },
                // Quite slow animation:
                animateDuration : 300,
                // More extra space:
                extraSpace : 0,
                limit: 500
            });
        }

        /* Validation */
        if (jQuery().validate) {
            $contactForm.validate({
                rules: {
                    email: {
                        required: true,
                        email: true
                    },
                    text: {
                        required: true,
                        minlength: 3
                    }
                },
                messages: {
                    email: {
                        required: "Prosím vyplňte Vaši emailovou adresu.",
                        email: "Prosím zadejte platný formát Vaší emailové adresy."
                    },
                    text: {
                        required: "Prosím zadejte text Vaší zprávy.",
                        minlength: "Minimální délka zprávy je 3 znaky."
                    }
                }
            });
        }
    }

    console.info('Pokud chceš vědět víc o mém portfoliu, zkus /humans.txt');
});

