var mycarousel_itemList = [
  {url: '_images/partLogos/plogo_telnz.png', title: 'Telecom New Zealand'},
  {url: '_images/partLogos/plogo_fedx.png', title: 'Fedex'},
  {url: '_images/partLogos/plogo_stchrt.png', title: 'Standard Chartered'},
  {url: '_images/partLogos/plogo_brtfrs.png', title: 'Brittany Ferries'},
  {url: '_images/partLogos/plogo_smns.png', title: 'Siemens New Zealand'},
  {url: '_images/partLogos/plogo_boc.png', title: 'BOC'},
  {url: '_images/partLogos/plogo_ivrtch.png', title: 'IVR Technologies'},
  {url: '_images/partLogos/plogo_msft.png', title: 'Microsoft'}
];

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);
  carousel.add(i, mycarousel_getItemHTML(mycarousel_itemList[idx - 1]));
}

function mycarousel_itemVisibleOutCallback(carousel, item, i, state, evt) {
  carousel.remove(i);
}

/**
 * Item html creation helper.
 */
function mycarousel_getItemHTML(item) {
  return '<img src="' + item.url + '" alt="' + item.title + '" />';
}

jQuery(document).ready(function() {
  if((jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 7 && parseInt(jQuery.browser.version, 10) > 4)) {
    jQuery('#logo').supersleight();
    jQuery('#home-topper').supersleight();
  } else {
    //carousel kills IE6
    jQuery('#carousel').jcarousel({
      auto: 2,
      scroll: 1,
      wrap: 'circular',
      size: mycarousel_itemList.length,
      itemVisibleInCallback: {onBeforeAnimation: mycarousel_itemVisibleInCallback},
      itemVisibleOutCallback: {onAfterAnimation: mycarousel_itemVisibleOutCallback}
    });
  }
});
