var clientBoxes;
var clientBoxHeights = new Array();
var currentClientIdx = 0;

function prepare_clients()
{
    // get the client boxes
    clientBoxes = $(".client_box");
    // get their heights
    clientBoxes.each(function(i) {
        clientBoxHeights[i] = $(this).height();
    });

    // remove the client list
    $(".box_list").remove();
    
    // display the first client
    $("#client_display").append(clientBoxes.first().clone());
    $(".client_box").hide(0, function() {
        $(this).fadeIn(500);
    });
    
    // change the behaviour of the client links
    $(".client_link").each(function(i) {
        // set href to '#' to do nothing
        $(this).attr("href", "#");
        // set click event handler
        $(this).click(function() {
            if (i == currentClientIdx)
            {
                return;
            }
            currentClientIdx = i;
            var incomingBox = clientBoxes.eq(i);
            var duration = 500;
            $(".client_title_about_logo").fadeOut(duration);
            $(".client_box").children(".inner_box").fadeOut(duration);
            $(".client_box").animate({
                height: clientBoxHeights[i]
            }, duration, function() {
                $(".client_title_about_logo").replaceWith(incomingBox.children(".client_title_about_logo").clone());
                $(".client_box").children(".inner_box").replaceWith(incomingBox.children(".inner_box").clone());
                $(".client_title_about_logo").hide(0, function() {
                    $(this).fadeIn(500);
                });
                $(".client_box").children(".inner_box").hide(0, function() {
                    $(this).fadeIn(500);
                });
            });
        });
    });
    
    
}
