var mycarousel_itemList = [
    {img: '/ita/thumbnail.php?h=150&w=150&file=A03-PE960_320.png', title: 'OnePower 960', corpo: 'Smart 960VA/480W UPS', id: 'A03-PE960'}, {img: '/ita/thumbnail.php?h=150&w=150&file=A03-HP851_320.png', title: 'HostPower 851', corpo: 'Line Interactive SineWave 850VA/480W UPS', id: 'A03-HP851'}, {img: '/ita/thumbnail.php?h=150&w=150&file=A02-RA141-WN_320.png', title: 'WebShare 141 WN', corpo: 'Wireless 150 Mbps ADSL2+ router', id: 'A02-RA141-WN'}, {img: '/ita/thumbnail.php?h=150&w=150&file=A03-PS700_320.png', title: 'OnePower 700', corpo: 'Smart 700VA/300W UPS', id: 'A03-PS700'}, {img: '/ita/thumbnail.php?h=150&w=150&file=A03-HP701_320.png', title: 'HostPower 701', corpo: 'Line Interactive SineWave 700VA/360W UPS', id: 'A03-HP701'}, {img: '/ita/thumbnail.php?h=150&w=150&file=A02-AP4-WN_320.png', title: 'NetFly AP4 WN', corpo: 'Wireless N 150Mbps MultiFunction Access Point', id: 'A02-AP4-WN'}, {img: '/ita/thumbnail.php?h=150&w=150&file=A03-P841_320.png', title: 'OnePower 841', corpo: 'Line-Interactive 840VA/420W UPS', id: 'A03-P841'}, {img: '/ita/thumbnail.php?h=150&w=150&file=A02-AP3-W300N_320.png', title: 'NetFly AP3 WN', corpo: 'Wireless N 300Mbps MultiFunction', id: 'A02-AP3-W300N'}, {img: '/ita/thumbnail.php?h=150&w=150&file=A03-PE720_320.png', title: 'OnePower 720', corpo: 'Smart 720VA/360W UPS', id: 'A03-PE720'}, {img: '/ita/thumbnail.php?h=150&w=150&file=A02-PL303-WN_320.png', title: 'NetPower 303 WN', corpo: 'Wireless N 150Mbps PowerLine Adapter', id: 'A02-PL303-WN'}, {img: '/ita/thumbnail.php?h=150&w=150&file=A02-PSU1_320.png', title: 'NetServer PSU1', corpo: 'USB2.0 LPR', id: 'A02-PSU1'}];

function mycarousel_itemVisibleInCallback(carousel, item, i, state, evt)
{
    // The index() method calculates the index from a
    // given index who is out of the actual item range.
    var idx = carousel.index(i, mycarousel_itemList.length);
    var htmlitem = mycarousel_getItemHTML(mycarousel_itemList[idx - 1]);
    
    carousel.add(i, htmlitem);
    $("a.thickbox").unbind();
    tb_init('a.thickbox');
};

function mycarousel_itemVisibleOutCallback(carousel, item, i, state, evt)
{
    carousel.remove(i);
};

/**
 * Item html creation helper.
 */
function mycarousel_getItemHTML(item)
{
    var html = '';
    html = '<div style="margin-top:15px;"><table border="0" cellspacing="2" cellpadding="2" width="260px">';
    html += '<tr>';
    html += '<td><img src="'+item.img+'" border="0"></td>';
    html += '<td><span class="home_prodotti_titolo">'+item.title+'</span><br>';
    html += '<span class="home_prodotti_corpo">'+item.corpo+'</span><br><br>';
    html += '<a class="thickbox" style="padding: 0; margin:0;" href="loadpopupprodotti.php?height=363&width=620&id='+item.id+'"><img src="/img_comuni/dettagli.png" border="0"></a>';
    html += '</td></tr></table></div>';
    return html;
};
