tb_pathToImage = "http://greatcentralplastics.com/industrial-dev/images/loading-thickbox.gif";

var mycarousel_itemList = [
    {url: "products/car-letters.jpg", title: "S V L  - Chrome plated nameplates for the Automotive industry."},
    {url: "products/cap.jpg", title: "Steering wheel centre moulding for tractor. (Automotive)"},
    {url: "products/bracket.jpg", title: "Fixing bracket for handrail system (Construction)"},
    {url: "products/clip.jpg", title: "Satin plated fixing bracket for decking system. (Construction)"},
    {url: "products/lego.jpg", title: "Water Manifold block for hot tub. (Leisure)"},
    {url: "products/inhaler.jpg", title: "Executive chrome plated case for inhaler. (Medical)"},
    {url: "products/fitting.jpg", title: "Adjustable spindle housing. (Construction)"},
    {url: "products/aqua.jpg", title: "Impellor housing for water pump. (Plumbing)"},
    {url: "products/clip2.jpg", title: "Un- plated version of image 4. (Construction)"},
    {url: "products/plugs.jpg", title: "Suction valve for endoscope. (Medical)"},
	{url: "products/box.jpg", title: "100mm square post cover with removable screw cap. (Construction)"}
];

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');
	var url_t = url_m.substring(9,100);
    return '<a href="/industrial-dev/products/large/' + url_t + '" title="' + item.title + '"><img src="' + item.url + '" width="237" height="151" border="0" alt="' + item.title + '" /></a>';
};

jQuery(document).ready(function() {
    jQuery('#mycarousel').jcarousel({
        size: mycarousel_itemList.length,
        itemLoadCallback: {onBeforeAnimation: mycarousel_itemLoadCallback}
    });
});
