﻿// Set thickbox loading image
tb_pathToImage = "skins/Skin_3/images/loading-thickbox.gif";

var mycarousel_itemList = [
	{url: "skins/Skin_3/images/gallery/polyjet-rapid-prototype-20101217-01.jpg", title: "PolyJet Rapid Prototype - PolyJet White"},
	{url: "skins/Skin_3/images/gallery/sls-rapid-prototype-20101217-01.jpg", title: "SLS Rapid Prototype - SLS White"},
	{url: "skins/Skin_3/images/gallery/polyjet-rapid-prototype-20101217-04.jpg", title: "SLA Rapid Prototype - SLA White"},
	{url: "skins/Skin_3/images/gallery/polyjet-rapid-prototype-20101217-07.jpg", title: "PolyJet Rapid Prototype - PolyJet HD Blue"},
	{url: "skins/Skin_3/images/gallery/polyjet-rapid-prototype-20101217-03.jpg", title: "PolyJet Rapid Prototype - PolyJet HD Blue and PolyJet White"},
	{url: "skins/Skin_3/images/gallery/polyjet-rapid-prototype-20101217-05.jpg", title: "PolyJet Rapid Prototype - PolyJet HD Blue"},
	{url: "skins/Skin_3/images/gallery/polyjet-rapid-prototype-20101217-06.jpg", title: "PolyJet Rapid Prototype - PolyJet HD Blue"},
	{url: "skins/Skin_3/images/gallery/polyjet-rapid-prototype-20101217-02.jpg", title: "PolyJet Rapid Prototype - PolyJet White"},
	{url: "skins/Skin_3/images/gallery/polyjet-rapid-prototype-20101217-08.jpg", title: "PolyJet Rapid Prototype - PolyJet White"},
	{url: "skins/Skin_3/images/gallery/polyjet-rapid-prototype-20101217-09.jpg", title: "PolyJet Rapid Prototype - PolyJet HD Blue and PolyJet White"},
	{url: "skins/Skin_3/images/gallery/polyjet-rapid-prototype-20101217-10.jpg", title: "PolyJet Rapid Prototype - PolyJet HD Blue"},
	{url: "skins/Skin_3/images/gallery/polyjet-rapid-prototype-20101217-11.jpg", title: "PolyJet Rapid Prototype - PolyJet White"}
];

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="90" height="90" border="0" alt="' + item.title + '" /></a>';
};

jQuery(document).ready(function() {
	jQuery('#mycarousel').jcarousel({
		size: mycarousel_itemList.length,
		itemLoadCallback: {onBeforeAnimation: mycarousel_itemLoadCallback}
	});
});
