$(function() {
	jQuery('#pictureCarousel').jcarousel({
      	scroll: 4,
        wrap: 'circular',
        itemVisibleInCallback: {onBeforeAnimation: pictureCarousel_itemVisibleInCallback},
        itemVisibleOutCallback: {onAfterAnimation: pictureCarousel_itemVisibleOutCallback}
    });


});



var pictureCarousel_itemList = [
    {url: '/js/thickbox/images/Picture-or-Video-009_t.jpg', title: 'Scott as goalie', href:'/js/thickbox/images/Picture-or-Video-009.jpg', width:'600',height:'450',thickbox:'yes'},
    {url: '/js/thickbox/images/pantano-stretching_t.jpg', title: 'Pantano stretching', href:'/js/thickbox/images/pantano-stretching.jpg', width:'600',height:'450',thickbox:'yes'},
    {url: '/js/thickbox/images/IMG_1046_t.jpg', title: 'plant3', href:'/js/thickbox/images/IMG_1046.jpg',width:'600',height:'450',thickbox:'yes'},
    
    {url: '/js/thickbox/images/IMG_1061_t.jpg', title: 'plant1', href:'/js/thickbox/images/IMG_1061.jpg', width:'600',height:'450',thickbox:'yes'},
    {url: '/js/thickbox/images/IMG_1070_t.jpg', title: 'plant2', href:'/js/thickbox/images/IMG_1070.jpg', width:'600',height:'450',thickbox:'yes'},
    {url: '/js/thickbox/images/IMG_1071_t.jpg', title: 'plant3', href:'/js/thickbox/images/IMG_1071.jpg',width:'600',height:'450',thickbox:'yes'},

    {url: '/js/thickbox/images/freddy-pushing-sled_t.jpg', title: 'plant3', href:'/js/thickbox/images/freddy-pushing-sled.jpg',width:'600',height:'450',thickbox:'yes'}

    
   
];

function pictureCarousel_itemVisibleInCallback(carousel, item, i, state, evt){
    var idx = carousel.index(i, pictureCarousel_itemList.length);
 
   var thisItemHTML = pictureCarousel_getItemHTML(pictureCarousel_itemList[idx - 1]) ;    

	var DOMitem = jQuery(thisItemHTML).get(0);

	tb_init(DOMitem);
 
 
 //carousel.add(i, pictureCarousel_getItemHTML(pictureCarousel_itemList[idx - 1]));
 
 	carousel.add(i, DOMitem);

 
 
};

function pictureCarousel_itemVisibleOutCallback(carousel, item, i, state, evt){carousel.remove(i);};





function pictureCarousel_getItemHTML(item){
	var isPopup=item.popup;
	var isPopup=item.popup;
	var thisHTML="";

  

if (isPopup=='yes'){


    return  '<a href="#" onclick="displayWindow(\''+ item.href+'\',320,800,1)"><img src="' + item.url + '" width="100" height="75" alt="' + item.title + '" /><p>' +item.title+'</p></a>';
	//if you want to do this, look at the old code for the itsallhere js file
	//    return  '<a href="'+item.href+'?width=320&height=500" class="thickbox"><img src="' + item.url + '" width="94" height="88" alt="' + item.title + '" /><p>' +item.title+'</p></a>';
	//tb_init(DOMitem);


}else{

    thisHTML=  '<a href="'+item.href+'"><img src="' + item.url + '" width="100" height="75" alt="' + item.title + '" /><p>' +item.title+'</p></a>';

}



return thisHTML;

};



