/**
 * Functions and callbacks for JLM Press Page
 * Created on Dec 8, 2008
 * @author Dave Ross <dave@xenomedia.com>
 * @copyright Copyright (c)2008 Xeno Media, Inc.
  */

/**
 * Add the next item to the carousel when there's an opening
 * @see http://sorgalla.com/projects/jcarousel/#Dynamic-Content-Loading
 */
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]));
};

/**
 * Remove the item from the carousel when it scrolls off the side
 * @see http://sorgalla.com/projects/jcarousel/#Dynamic-Content-Loading
 */
function mycarousel_itemVisibleOutCallback(carousel, item, i, state, evt)
{
    carousel.remove(i);
};

/**
 * Item html creation helper.
 * @see http://sorgalla.com/projects/jcarousel/#Dynamic-Content-Loading
 */
function mycarousel_getItemHTML(item)
{
    return '<a href="' + item.url + '"><img src="' + item.thumbnail + '" alt="' + item.title + '" /><p class="press_media_title">' + item.publication_name + '<br />' + item.issue + '</p></a>';
};
