﻿
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 '<table class="jcarouselTable" cellpadding="0" cellspacing="0"><tr><td class="carousellImage"><img src="' + item.url + '" alt="' + item.title + '" height="' + item.height + '" width="' + item.width + '" /></td><td><p class="text" style="padding-left:5px;"><a href="/content/news/pr.aspx?id=' + item.link + '">' + item.text + '</a></p></td></tr></table>';
};

jQuery(document).ready(function() {
    jQuery('#mycarousel').jcarousel({
        wrap: 'circular',
        itemVisibleInCallback: { onBeforeAnimation: mycarousel_itemVisibleInCallback },
        itemVisibleOutCallback: { onAfterAnimation: mycarousel_itemVisibleOutCallback }
    });
});

/**********ITEMS*********/
//var mycarousel_itemList = [{ url: "/images/news_carousel/USHJA_carousel.jpg", title: "USHJA on HRN", link: "7248", text: "USHJA is now a featured segment on Horse Radio Network (HRN).", width: "65px", height: "65px" },
//{ url: "/images/news_carousel/Keenan_carousel.jpg", title: "2011 USHJA International Hunter Derby", link: "7247", text: "Keenan Coasts To Victory In USHJA International Hunter Derby Finals.", width: "65px", height: "65px" },
//{ url: "/images/news_carousel/Dietrich_carousel.jpg", title: "Dietrich Continues Support", link: "7240", text: "Dietrich Equine Insurance Continues Support of the USHJA International Hunter Derby.", width: "65px", height: "65px" },
//{ url: "/images/news_carousel/Flashpoint1_carousel.jpg", title: "USHJA Press Release", link: "7229", text: "Jumping History unfolds at this year's KENTUCKY CLASSIC.", width: "65px", height: "65px" },
//{ url: "/images/news_carousel/EAP_carousel.jpg", title: "Emerging Athelete Program", link: "7224", text: "Emerging Athletes display seasoned style in Buffalo, NY.", width: "65px", height: "65px" },
//{ url: "/images/news_carousel/WCHR_carousel.jpg", title: "WCHR", link: "7219", text: "WCHR prepares for a warm reception in Wellington.", width: "65px", height: "65px" },
//{ url: "/images/news_carousel/Flashpoint2_carousel.jpg", title: "USHJA Press Release", link: "7212", text: "2011 Hunter Derby Demonstrations at the Kentucky Horse Park", width: "65px", height: "65px" },
//{ url: "/images/news_carousel/USHJA_carousel2.jpg", title: "USHJA News", link: "7211", text: "10 New Rule Submissions that may Change Everything.", width: "65px", height: "65px" },
//{ url: "images/news_carousel/USEF_carousel.jpg", title: "USEF", prid: "0", text: "USEF hosts this year's NAJYRC in Lexington, KY.", width: "65", height: "65"}];
