
// Set thickbox loading image
tb_pathToImage = "../images/loadingAnimation.gif";

var mycarousel_itemList = [
    {url: "images/master-bedroom2.jpg", title: "Master Bedroom"},
    {url: "images/afternoon_light.jpg", title: "Late Afternoon Light in the Great Room"},
 // {url: "images/north-porch1.jpg", title: "Porch on North Side"},
    {url: "images/great-room1.jpg", title: "The Great Room at Frankie&#8217;s Hideaway"},
    {url: "images/back_porch.jpg", title: "Back Porch"},
    {url: "images/windows.jpg", title: "The Outside Is Inside at Frankie&#8217;s Hideaway"},
    {url: "images/front_porch.jpg", title: "The Perfect Vacation Home in Marathon, Texas"},
    {url: "images/kitchen.jpg", title: "Kitchen/Dining Area"},
    {url: "images/house-front.jpg", title: "Rustic Features in a Newly Renovated House"},
//    {url: "images/west-porch.jpg", title: "West Porch"},
    {url: "images/north-porch.jpg", title: "North Porch"}
];

function mycarousel_itemLoadCallback(carousel, state)
{
    for (var i = carousel.first; i <= carousel.last; i++) {
        if (carousel.has(i)) {
            continue;
        }

        if (i > mycarousel_itemList.length) {
            break;
        }

        // Create an object from HTML
        var item = jQuery(mycarousel_getItemHTML(mycarousel_itemList[i-1])).get(0);

        // Apply thickbox
        tb_init(item);

        carousel.add(i, item);
    }
};

/**
 * Item html creation helper.
 */
function mycarousel_getItemHTML(item)
{
    var url_m = item.url.replace(/_s.jpg/g, '_m.jpg');
//    return '<a href="' + url_m + '" title="' + item.title + '"><img src="' + item.url + '" width="75" height="75" border="0" alt="' + item.title + '" /></a>';
    return '<a href="' + url_m + '" title="' + item.title + '"><img src="' + item.url + '" width="125" height="125" border="0" alt="' + item.title + '" /></a>';
};

jQuery(document).ready(function() {
    jQuery('#mycarousel').jcarousel({
        size: mycarousel_itemList.length,
        itemLoadCallback: {onBeforeAnimation: mycarousel_itemLoadCallback}
    });
});

