function swapperdeswap(afb){
	document.getElementById('detailafb').src='images/fotogallery/'+afb;	
}

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

            carousel.add(i, getItemHTML(itemList[i - 1]));
        }
    }

    // Trigger loaded
    carousel.loaded();
};

function swappie(foo){
	this.document.getElementById('headerimage').src="images/fotogallery/"+foo;
	}

function getItemHTML(url)
{
	var url2 = "images/fotogallery/thumbnails/"+ url;
    return '<a href="javascript:swappie(\'' + url + '\')";><img src="' + url2 + '"  width="' + 75 + '" height="' + 75 + '" border="' + 0 + '"/>';
};

// Next-Button handling...
var nextOver = function() {
    jQuery(this).attr("src", "img/horizontal-ie7/next-over.gif");
};

var nextOut = function() {
    jQuery(this).attr("src", "img/horizontal-ie7/next.gif");
};

var nextDown = function() {
    jQuery(this).attr("src", "img/horizontal-ie7/next-down.gif");
};

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

// Prev-Button handling
var prevOver = function() {
    jQuery(this).attr("src", "img/horizontal-ie7/prev-over.gif");
};

var prevOut = function() {
    jQuery(this).attr("src", "img/horizontal-ie7/prev.gif");
};

var prevDown = function() {
    jQuery(this).attr("src", "img/horizontal-ie7/prev-down.gif");
};

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

// Ride the carousel...
jQuery(document).ready(function() {
    jQuery("#mycarousel").jcarousel({
		orientation:"vertical",
        itemVisible: 4,
        itemScroll: 2,
        wrap: true,
        loadItemHandler: loadItemHandler,
        nextButtonStateHandler: nextButtonStateHandler,
        prevButtonStateHandler: prevButtonStateHandler
    });
});

