var currentProduct = 0;
var currentHeader = "";
var currentDescription = "";

function ShowProduct(index) {

    var boxes = $("#circle .info .info_box");
    var boxCount = boxes.length;
    var j = 0;

    // Fade old header out
    if($.browser.msie && parseInt($.browser.version) <= 8) {
        boxes.hide();
        $("#circle .info #info_" + index).show();
    } else {
        boxes.fadeOut(200, function () {
            j++;
            if (j == boxCount) {
                // Fade new header in
                $("#circle .info #info_" + index).fadeIn(500);
            }
        });
    }

    // IMAGES
    var productID = $("#circle .info #info_" + index).attr("class").substring(9, 10);

    if (currentProduct != productID) {
        var images = $("#circle .images img");
        var imageCount = images.length;
        var i = 0;

        // Slide old images up
        images.animate({ 'top': '-250px' }, {
            duration: 200,
            easing: 'easeInCubic',
            complete: function () {
                i++;
                if (i == imageCount) {
                    // Slide new images in
                    var product = $("#circle .images .aerocatch" + productID);

                    product.find("img.left").animate({ 'top': '30px' }, {
                        duration: 800, easing: 'easeOutElastic'
                    });

                    product.find("img.right").delay(100).animate({ 'top': '30px' }, {
                        duration: 800, easing: 'easeOutElastic'
                    });
                }
            }
        });

        currentProduct = productID;
    }

}

$(function () {

    // Run Galleria
    $('#galleria').galleria();

});
