function loadItemHandler(carousel, start, last, available)
{
    if (!available) {
        for (var i = start; i <= last; i++) {
            if (i > itemList.length) {
                break;
            }

            var item = carousel.add(i, getItemHTML(itemList[i - 1]));


			item.each(function() {
				// Urgh...ThickBox should provide a function for that
				jQuery("a.thickbox", this).bind("click", function() {
					var t = this.title || this.name || null;
					var g = this.rel || false;
					TB_show(t,this.href,g);
					this.blur();
					return false;
				});
			});
        }
    }
    // Trigger loaded
    carousel.loaded();
};

function getItemHTML(url)
{
    return '<a href="'+ url + '" class="thickbox"><img src="' + url + '" width="' + 76 + '" height="' + 75 + '" /></a>';
};

// Next-Button handling...
var nextOver = function() {
    jQuery(this).attr("src", "/includes/common_includes/js/jcarousel/img/wg-buttons/next-over.gif");
};

var nextOut = function() {
    jQuery(this).attr("src", "/includes/common_includes/js/jcarousel/img/wg-buttons/next.gif");
};

var nextDown = function() {
    jQuery(this).attr("src", "/includes/common_includes/js/jcarousel/img/wg-buttons/next-down.gif");
};

function nextButtonStateHandler(carousel, button, enabling)
{
    if (enabling) {
        jQuery(button).attr("src", "/includes/common_includes/js/jcarousel/img/wg-buttons/next.gif")
                      .bind("mouseover", nextOver)
                      .bind("mouseout", nextOut)
                      .bind("mousedown", nextDown);
    } else {
        jQuery(button).attr("src", "/includes/common_includes/js/jcarousel/img/wg-buttons/next-disabled.gif")
                      .unbind("unmouseover", nextOver)
                      .unbind("unmouseout", nextOut)
                      .unbind("unmousedown", nextDown);
    }
}

// Prev-Button handling
var prevOver = function() {
    jQuery(this).attr("src", "/includes/common_includes/js/jcarousel/img/wg-buttons/prev-over.gif");
};

var prevOut = function() {
    jQuery(this).attr("src", "/includes/common_includes/js/jcarousel/img/wg-buttons/prev.gif");
};

var prevDown = function() {
    jQuery(this).attr("src", "/includes/common_includes/js/jcarousel/img/wg-buttons/prev-down.gif");
};

function itemVisibleOutHandlerBeforeAnimation(carousel, li, idx, state) {
    jQuery("img", li).hide("slow");
}

/**
 * This is the callback function which receives notification
 * when an item becomes the first one in the visible range.
 * Triggered before animation.
 */
function itemVisibleInHandlerBeforeAnimation(carousel, li, idx, state) {
    // No animation on first load of the carousel
    if (state == "init")
        return;

    jQuery("a img", li).hide();
    jQuery("a img", li).show("slow");
}


function prevButtonStateHandler(carousel, button, enabling)
{
    if (enabling) {
        jQuery(button).attr("src", "/includes/common_includes/js/jcarousel/img/wg-buttons/prev.gif")
                      .bind("mouseover", prevOver)
                      .bind("mouseout", prevOut)
                      .bind("mousedown", prevDown);
    } else {
        jQuery(button).attr("src", "/includes/common_includes/js/jcarousel/img/wg-buttons/prev-disabled.gif")
                      .unbind("unmouseover", prevOver)
                      .unbind("unmouseout", prevOut)
                      .unbind("unmousedown", prevDown);
    }
}
