/***Pre-load Game Images***/
  pic1= new Image(158,158); 
  pic1.src="./images/games-home-AgAcrossAmerica.png"; 
  
  pic2= new Image(158,158); 
  pic2.src="./images/games-home-Grains.png"; 
  
  pic3= new Image(158,158); 
  pic3.src="./images/games-home-FarmersMarket.png"; 
  
  pic4= new Image(158,158); 
  pic4.src="./images/games-home-FindersKeepers.png"; 
  
  pic5= new Image(158,158); 
  pic5.src="./images/games-home-HarvestThis.png"; 
  
  pic6= new Image(158,158); 
  pic6.src="./images/games-home-keys.png"; 
  
  pic7= new Image(158,158); 
  pic7.src="./images/games-home-Tasty.png"; 
  
  pic8= new Image(158,158); 
  pic8.src="./images/games-home-MyAgMe.png"; 
  
  pic9= new Image(158,158); 
  pic9.src="./images/games-home-Spin_n_Solve.png"; 
  
  pic10= new Image(158,158); 
  pic10.src="./images/games-home-ThatsLife.png"; 
  
  pic11= new Image(158,158); 
  pic11.src="./images/games-home-WhereInTheWorld.png"; 
  
  pic12= new Image(158,158); 
  pic12.src="./images/games-home-WildWater.png";
  
  pic13= new Image(158,158); 
  pic13.src="./images/games-home-Equipment.png";
  
  //pic14= new Image(158,158); 
  //pic14.src="./images/games-home-UltimateChallenge.png";
  
  pic15= new Image(158,158); 
  pic15.src="./images/games-home-Memory.png";
  
  pic16= new Image(158,158); 
  pic16.src="./images/games-home-FairyTale.png";

var mycarousel_itemList = [
    {url: 'images/games-home-AgAcrossAmerica.png', title: 'Ag Across America', game: 'games/ag_across_america'},
    {url: 'images/games-home-Grains.png', title: 'Amazing Grains', game: 'games/amazing_grains'},
	{url: 'images/games-home-Equipment.png', title: 'Equipment Engineer', game: 'games/equipment_engineer'},
	{url: 'images/games-home-FairyTale.png', title: 'Fact or FairyTale', game: 'games/fairy_tale'},
	{url: 'images/games-home-FarmersMarket.png', title: 'Farmers Market Challenge', game: 'games/farmers_market_challenge'},
	{url: 'images/games-home-FindersKeepers.png', title: 'Finders Keepers', game: 'games/finders_keepers'},
	{url: 'images/games-home-HarvestThis.png', title: 'Harvest This', game: 'games/harvest_this'},
	{url: 'images/games-home-keys.png', title: 'Keys to Stewardship', game: 'games/keys_to_stewardship'},
	{url: 'images/games-home-Tasty.png', title: 'Let\'s Make Something Tasty', game: 'games/lets_make_something_tasty'},
	{url: 'images/games-home-Memory.png', title: 'Memory Match', game: 'games/memory_match'},
    {url: 'images/games-home-MyAgMe.png', title: 'My Little Ag Me', game: 'games/my_little_ag_me'},
	{url: 'images/games-home-Spin_n_Solve.png', title: 'Ag Spin \'n Solve Challenge', game: 'games/spin_n_solve'},
	{url: 'images/games-home-ThatsLife.png', title: 'That\'s Life', game: 'games/thats_life'},
	//{url: 'images/games-home-UltimateChallenge.png', title: 'Ultimate Challenge', game: 'games/ultimate_challenge'},
	{url: 'images/games-home-WhereInTheWorld.png', title: 'Where in the World', game: 'games/where_in_the_world'},
	{url: 'images/games-home-WildWater.png', title: 'Wild Water Adventures', game: 'games/wild_water_adventures'}
];

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 '<a href ="' + item.game + '"><img src=\"' + item.url + '" width="158" height="158" alt="' + item.title + '" /></a>';
};

jQuery(document).ready(function() {
    jQuery('#mycarousel').jcarousel({
        wrap: 'circular',
        itemVisibleInCallback: {onBeforeAnimation: mycarousel_itemVisibleInCallback},
        itemVisibleOutCallback: {onAfterAnimation: mycarousel_itemVisibleOutCallback}
    });
});
