﻿var currentSelectedMember;
function InitializeLavaLamp() {
    $(function () { $(".lavaLamp").lavaLamp({ fx: "swing", speed: 500 }) });
}
function SetResultAreaHeight(height) {
    var searchBarHeight = 0;
    var tweeking = 0;
    if (searchBarSharesContainer === true) {

        if (searchBarDivParent != "") {
            searchBarHeight = $(searchBarDivParent).height();
        }
        else {
            searchBarHeight = 70;
        }
    }
    if ($.browser.msie) {
        tweeking = 90;
    } else {
        tweeking = 20;
    }

    $("#results_list_scroller").height(height - searchBarHeight - tweeking);
}

function GetWindowHeight() {
    return $(window).height();
}


function AdjustWhiteBarPosition(){
 if (GetWindowHeight() / 2 - 187 <= (15 + 74 + 85 + 65)) {
            
            $(".white_bar_backing").css("margin-top", (15 + 74 + 85 + 65 + 10) + "px");
            $(".white_bar_backing").css("top", "0%");
        }
        else {
            $(".white_bar_backing").css("margin-top", "-187px");
            $(".white_bar_backing").css("top", "50%");
        }
}

function CatchWindowResizeEvent() {
    $(window).bind('resize', function () {
        AdjustWhiteBarPosition();
    });
}

function SetCurrentMenu(menu) {
    $(document).ready(function () {
        $(".current").removeClass("current");
        $(menu).addClass("current");
        InitializeLavaLamp();
    });
}

function SetAsCurrentSelectedMember(uid) {
    currentSelectedMember = uid;
    $("." + uid).find(".teamMemImageUselected").removeClass("teamMemImageUselected");
    $("." + uid).removeClass("unselectedMember");
}





var slideWidth = 260;
var arrowWidth = 104;
var currentCount = 0;
var htmlData;
var margin = 0;
var start = 0;



function GetWindowWidth() {
    return $(window).width();
}


function GetVisible() {
    var totalVisibleAllowedCount = ((GetWindowWidth() - (arrowWidth * 2)) / slideWidth);

    if (totalVisibleAllowedCount - Math.floor(totalVisibleAllowedCount) > 0) {
        totalVisibleAllowedCount = Math.floor(totalVisibleAllowedCount);

    }

    //alert(totalVisibleAllowedCount)

    start = 0;
    return totalVisibleAllowedCount;
}

function AnimateTeamMemberBigger(div) {
    if (!$(div).hasClass(currentSelectedMember)) {
        $(div).removeClass("unselectedMember")
        $(div).find('.teamMemImage').removeClass("teamMemImageUselected");
        $(div).find('.teamMemImage').animate({ backgroundColor: '#aa0000', color: '#fff', width: 60, height: 75 }, 300);
        $(div).animate({ backgroundColor: '#aa0000', color: '#fff', width: 60, height: 75 }, 300);
    }
}

function AnimateTeamMemberSmaller(div) {
    if (!$(div).hasClass(currentSelectedMember)) {
        $(div).addClass("unselectedMember")
        $(div).find('.teamMemImage').addClass("teamMemImageUselected");
        $(div).find('.teamMemImage').animate({ backgroundColor: '#fff', color: '#000', width: 40, height: 50 }, 10);
        $(div).animate({ backgroundColor: '#fff', color: '#000', width: 40, height: 50 }, 10);
    }
    
}


function InitializeCarousel() {

    currentCount = GetVisible();
    $(".myCarousel").html("");
    $(".myCarousel").html(htmlData);

    $("#container .myCarousel").jCarouselLite({
        btnNext: "#container .next",
        btnPrev: "#container .prev",
        mouseWheel: true,
        visible: currentCount,
        easing: "easeInOutCubic",
        speed: 1500,
        start: start,
        scroll: 2
        
    });

    //$(".myCarousel").css("margin-left", "104px");
    //$(".myCarousel").css("margin-right", "auto");

}





function InitializeAAT() {
    

        //get the window resize event
        //CatchWindowResizeEvent();

        htmlData = $(".myCarousel").html();

        //This used to make the arrows show when hovering over the carousel
        //        $("div#container").hover(function () {
        //            //show buttons / fade in
        //            $('.prev').add('.next').fadeIn(200);
        //        }, function () {
        //            //hide buttons
        //            $('.prev').add('.next').fadeOut(200);
        //        });

        $(window).resize(function () {
            if (currentCount != GetVisible()) {
                InitializeCarousel();
            }
        });

        InitializeCarousel();

        $(".myCarousel").hide();
        $(".myCarousel").fadeIn(1000);

        // These makes the slides move when hovering over the arrows
        var interval;
        $(".prev").hover(
            function () {
                interval = setInterval($(".prev").trigger('click'), 1)
            }, function () {
                clearInterval(interval);
                //$(".prev").trigger('unclick');
            });

        $(".next").hover(
        function () {
            $(".next").trigger('click');
        }, function () {
            //$(".next").trigger('unclick');
        });

    
}

function roundDivs() {
    if ($.browser.msie && (($.browser.version * 1) < 9)) {
        return;
    }
    $('.main').corner();
    $('.description').corner();
}

function roundDivsVis() {
    if ($.browser.msie && (($.browser.version * 1) < 9)) {
        return;
    }
    $('.mainV').corner();
    $('.descriptionV').corner();
}

function ChangeTitle(newTitle) {
    document.title = newTitle;
}

function Resize() {
    var width = GetWindowWidth();

    var viewportWidth1 = width - (90 + 600 + 90 + 60) - 45;
    var viewportWidth2 = width - (90 + 500 + 90 + 60) - 45;

    if (width >= 1400) {
        $(".main").css("width", "600px");
        $(".description").css("left", "720px");
        $(".viewport").css("width", viewportWidth1);
    }
    else {
        $(".main").css("width", "500px");
        $(".description").css("left", "620px");
        $(".viewport").css("width", viewportWidth2);
    }
}

function ResizeAbout() {
    var width = GetWindowWidth();

    var viewportWidth1 = width - (90 + 90 + 60) - 45;
    var viewportWidth2 = width - (90 + 90 + 60) - 45;

    if (width >= 1400) {
        //$(".aboutMain").css("width", "600px");
        $(".viewport").css("width", viewportWidth1);
    }
    else {
        //$(".aboutMain").css("width", "500px");
        $(".viewport").css("width", viewportWidth2);
    }
}

function ResizeVision() {
    var width = GetWindowWidth();

    var viewportWidth1 = width - (90 + 600 + 90 + 60) - 45;

    if (width >= 1400) {
        $(".mainV").css("width", "980px");
        $(".descriptionV").css("left", "1100px");
        $(".viewport").css("width", "920px");
    }
    else {
        $(".mainV").css("width", "680px");
        $(".descriptionV").css("left", "800px");
        $(".viewport").css("width", "620px");
    }
}
