$.fn.delay = function(time, callback){
    // Empty function:
    jQuery.fx.step.delay = function(){};
    // Return meaningless animation, (will be added to queue)
    return this.animate({delay:1}, time, callback);
}
function hideDescription(){
    $("div#divWearing").animate({right: 0, opacity:0},200,"swing");
}
function showDescription(){
    $("div#divWearing").animate({right: "-150px", opacity:1},500,"swing");
}
function toggleWearingLnk(){
    $("a#lnkWearing").toggle();
}
function swapMainImg(imgIDX){
    $("a#lnkWearing").fadeOut("fast");
    $("div#dvContent").html(imgBlock[imgIDX].content);
    $("div#mainImg > img").fadeOut("fast", function(){
        $(this)
            .attr("src", imgBlock[imgIDX].image)
            .attr("alt", imgBlock[imgIDX].alt)
            .delay(500).fadeIn("fast");
    });
    hideDescription();
    $("a#lnkWearing").delay(500).fadeIn("fast");
}
$(function(){
    $("div#divWearing").css("opacity", "0");
    $("table#lookbookPaging").jFlow({
        slides: "#sliders",
        width: "480px",
        height: "470px",
        duration: 600,
        prev: ".lnkPrev",
        next: ".lnkNext",
        easing: "swing"
    });
    $("a#lnkWearing").click(function(){//fly out the description
        showDescription();
        return false;
    });
    $("a#closeWearing, a.jFlowControl, a.lnkNext, a.lnkPrev").click(function(){//hide the description when clicking these
        hideDescription();
        return false;
    });
    $("div#sliders a").click(function(){
        var imgIDX = $(this).attr("id").replace("thumbID_", "");
        swapMainImg(imgIDX);
        return false;
    });
});