$(document).ready(function () {

    //FAMILY MEMEBER TEXT BOXES
    $('.scroll-pane').jScrollPane();
    $(".textholder").hide();
    $(".textopen").click(function () {
        //$(this).addClass("active");

        var activeText = $(this).find("a").attr("href");
        $(activeText).fadeIn();
        $(this).prev().addClass("active");
        $(this).prev().fadeOut();
        return false;

    });
    $(".textclose").click(function () {
        var activeText = $(this).find("a").attr("href");
        $(activeText).fadeOut();
        $('.active').fadeIn();
        $('.active').removeClass("active");
        return false;
    });
    //TABS FOR FAMILY MEMBERS
    $(".tab_content").hide();
    $("ul.tabs li:nth-child(1)").addClass("active").show();
    $(".tab_content:nth-child(1)").show();

    $("ul.tabs li").click(function () {
        $("ul.tabs li").removeClass("active");
        $(this).addClass("active");
        $(".tab_content").hide();
        var activeTab = $(this).find("a").attr("href");
        $(activeTab).fadeIn('fast');
        return false;
    });
    $(".blog-intro:nth-child(2n+1)").addClass("last");
    $('.blog-intro').ellipsis();
    $('.videolink').ellipsis();

    //FAMILY SLIDE




    //$('.fslandingText').click(landingbuttons);



    //HOMENEWS MODULE
    $(".home-news-main").hover(over, out);
    function over(event) {
        $(this).addClass("newsHover");
    }
    function out(event) {
        $(this).removeClass("newsHover");
    }
    $(".home-news-main").click(function () {
        var readMore = $(this).find("a").attr("href");
        //alert(readMore);
        window.location = readMore;
        return false;
    });
    $('.image-holder img').each(function () {
        var margin = ($(this).parent().height() - $(this).height()) / 2;
        $(this).css({ marginTop: margin });
    });



    //TIMELINE
    var timeline = $('#coda-slider-1');
    if (timeline.length > 0) {
        timeline.codaSlider({
            autoHeight: false,
            dynamicArrows: false,
            autoSlideStopWhenClicked: true
        });
    }


    //TIMELINE PAGINATION
    $('.decade-wrap').hide();
    $('.panel-wrapper :nth-child(1)').show();
    $('.next').click(function () {
        $(this).parent().parent().next().fadeIn();
        $(this).parent().parent().fadeOut();
    });
    $('.prev').click(function () {
        $(this).parent().parent().prev().fadeIn();
        $(this).parent().parent().fadeOut();
    });

    //TIMELINE - HIDE CONTENT WRAPPER
    $(".timehide").click(function () {
        var timeToHide = $(this).attr("href");
        if ($(timeToHide).is(':visible')) {
            $(timeToHide).fadeOut();
            $(this).addClass("active");
        } else {
            $(timeToHide).fadeIn();
            $(this).removeClass("active");
        };
        return false;
    });





});
