
/*overstate*/
$(document).ready(function () {
    $(".menuoverstate").each(function (i) {

        var filetype = ".jpg"

        if (this.src.indexOf(".png") != -1) {
            filetype = ".png";
        }

        preload_image = new Image();
        preload_image.src = this.src.replace(filetype, "_o" + filetype);

        $(this).hover(
            function () {
                if (this.src.indexOf("_o" + filetype) == -1) {
                    this.src = this.src.replace(filetype, "_o" + filetype);
                }

            },

            function () {
                this.src = this.src.replace("_o" + filetype, filetype);

            });

    }
        );

    //quicklinks    
    $(".quicklink").hover(function () {
        $(this).find(".quicklink-hide").stop(true, true).slideToggle();
    });

    $("#slideshow-wrapper").hover(function () {
        $(this).find(".slide-hide").stop(true, true).slideToggle();
    });

    $(".product").hover(function () {
        $(this).find(".product-hide").stop(true, true).slideToggle();
    });

    //slideshow
    $('#slideshow').cycle({
        fx: 'fade',
        timeout: 0,
        pause: 1,
        next: '#slide-right',
        prev: '#slide-left'
    });


    //team members
    $('#team-members > div:nth-child(4n)').css('margin-right', '0px');
    $(".tooltip-member-wrapper").hide();
    $(".team-link").hover(function () {
        $(this).parent().children(".tooltip-member-wrapper").stop(true, true).fadeIn();
    }, function () {
        $(this).parent().children(".tooltip-member-wrapper").stop(true, true).fadeOut();
    });

    $(".tooltip-member-wrapper-small").hide();
    $(".team-member").hover(function () {
        $(this).children().children(".tooltip-member-wrapper-small").stop(true, true).fadeIn();
    }, function () {
        $(this).children().children(".tooltip-member-wrapper-small").stop(true, true).fadeOut();
    });

    $('#team-rotate div > div:nth-child(4n)').css('margin-right', '0px');

    $('#team-rotate').cycle({
        fx: 'scrollHorz',
        timeout: 0,
        pause: 1,
        next: '#rotate-right',
        prev: '#rotate-left',
        after: rescaleContainer
    });

    function rescaleContainer(curr, next, opts, fwd) {
        var index = opts.currSlide;
        //get the height of the current slide
        var ht = jQuery(this).height();
        //set the container's height to that of the current slide
        jQuery(this).parent().animate({ height: ht + 100 });
    }



    $('.more-case-studies > a:nth-child(3n)').css('margin-right', '0px');

    //partners
    $('#partners-rotate-top').cycle({
        fx: 'scrollHorz',
        timeout: 0,
        pause: 1,
        next: '#rotate-right',
        prev: '#rotate-left'
    });

    $('#partners-rotate-bottom').cycle({
        fx: 'scrollHorz',
        timeout: 0,
        pause: 1,
        next: '#rotate-right2',
        prev: '#rotate-left2',
        after: rescaleContainer
    });

    $('#partners-rotate-top div > div:nth-child(3n)').css('margin-right', '0px');
    $('#partners-rotate-bottom div > div:nth-child(3n)').css('margin-right', '0px');
    $('#product-rotate div > div:nth-child(3n)').css('margin-right', '0px');

    $('#product-rotate').cycle({
        fx: 'scrollHorz',
        timeout: 0,
        pause: 1,
        next: '#rotate-right',
        prev: '#rotate-left'
    });

    //product
    $('#product-slideshow').cycle({
        fx: 'scrollHorz',
        timeout: 0,
        pause: 1,
        next: '#product-nav-right',
        prev: '#product-nav-left'
    });

    //documents

    /*
    $('.document').hover(function () {
        $(this).find('.document-icon img').each(function () {
            $(this).attr("src", $(this).attr("src").replace(".png", "_o.png"));
        })
    }, function () {
        $(this).find('.document-icon img').each(function () {
            $(this).attr("src", $(this).attr("src").replace("_o.png", ".png"));
        })
    });
    */

    $('.document').hover(function () {
        $(this).find(".document-text span").css('color', '#fff');
    }, function () {
        $(this).find(".document-text span").css('color', '#0d5cab');
    });

    //people

    //documents

    $('.people').hover(function () {
        $(this).find('.people-left img').each(function () {
            $(this).attr("src", $(this).attr("src").replace(".png", "_o.png"));
        })
    }, function () {
        $(this).find('.people-left img').each(function () {
            $(this).attr("src", $(this).attr("src").replace("_o.png", ".png"));
        })
    });

    $('.people').hover(function () {
        $(this).find(".people-right span").css('color', '#fff');
    }, function () {
        $(this).find('.people-hide').slideUp();
        $(this).find(".people-right span").css('color', '#0d5cab');
    });

    $('.people').click(function () {
        $(this).find('.people-hide').slideToggle();
    });

});

