/* Author: N. Wahlberg

*/
$(function () {
    $("#site-head h1 a").hover(
		function () {
		    $(this).find(".return").fadeIn(400);
		    $(this).find(".title").hide();
		},
		function () {
		    $(this).find(".title").fadeIn(400);
		    $(this).find(".return").hide();
		}
	);

    // get the 'active' item in the thumbnails so that we can move to it later....
    var idx = 0;
    var activeIdx;
    $(".painting-scroll img").each(function () {
        if ($(this).hasClass('active')) activeIdx = idx;
        idx++;
    });

    $(".painting-scroll").scrollable({ circular: true, mousewheel: false, api: true, size: 8 });
    var divNum = (activeIdx / 8);
    var activePosition = Math.ceil(divNum);
    var api = $(".painting-scroll").scrollable();
    if (divNum == Math.round(divNum)) {
        api.seekTo((activePosition), 200);
    } else {
        api.seekTo((activePosition - 1), 200);
    }


    // Click prevent default listeners...
    $("#painting-list .arrow a, .arrow-lt a, .arrow-rt a").click(function (e) { e.preventDefault(); });

    // hover painting thumbs in scroll
    $(".fade").live('mouseover', function () {
        var t = $(this);
        t.fadeOut(100);
    });
    $(".items div a").mouseleave(function () {
        var t = $(this).find('.fade');
        t.fadeIn(300);
    });
});
