﻿$(function() {
// Homepage - Image slider (Slides)
$('#slides').slides({
        preload: true,
        play: 5000,
        pause: 2500,
        hoverPause: true,
        animationStart: function(current) {
            $('.caption').animate({
                bottom: -90
            }, 100);
            if (window.console && console.log) {
                // example return of current slide number
                console.log('animationStart on slide: ', current);
            };
        },
        animationComplete: function(current) {
            $('.caption').animate({
                bottom: 50
            }, 200);
            if (window.console && console.log) {
                // example return of current slide number
                console.log('animationComplete on slide: ', current);
            };
        },
        slidesLoaded: function() {
            $('.caption').animate({
                bottom: 50
            }, 200);
        }
    });


    // homepage twitter feed
    var twitterFeed = $('.twitterFeed').each(function() {
        $(this).jTweetsAnywhere({
            username: $(this).find('.userName').attr('href').split('/')[3],
            count: 1,
            showTweetFeed: {
                showUserScreenNames: true
            },

            showProfileImages: false,
            tweetTimestampDecorator: function(tweet, options) {
                var screenName =
                   tweet.user ? tweet.user.screen_name : false || tweet.from_user;
                var date = new Date(formatDate(tweet.created_at));

                var dateString =

                   (date.getMonth() + 1) + '/' +
                   date.getDate() + '/' +
                   date.getFullYear() + ', ' +
                   date.getHours() + ':' +
                   (date.getMinutes() < 10 ? '0' : '') +
                   date.getMinutes()
                   ;

                var html =
                    '<span class="jta-tweet-timestamp">' +
                    '<a class="jta-tweet-timestamp-link" href="http://twitter.com/' +
                    screenName + '/status/' + tweet.id + '">' +
                    dateString + '</a></span>';

                return html;
            }
        });
    });
    
});


