function mycarousel_itemLoadCallback(carousel, state)
{
    // Since we get all URLs in one file, we simply add all items
    // at once and set the size accordingly.
    if (state != 'init')
        return;

    jQuery.get('/?alttemplate=carouselAjax', function(data) {
        mycarousel_itemAddCallback(carousel, carousel.first, carousel.last, data);
    });
     
};

function mycarousel_itemAddCallback(carousel, first, last, data)
{
    // Simply add all items at once and set the size accordingly.
    var items = data.split('|');

    for (i = 0; i < items.length; i++) {
        carousel.add(i+1, mycarousel_getItemHTML(items[i]));
    }

    carousel.size(items.length);
    Cufon.replace('#carousel h2', { fontFamily: 'batterseaMedium' })
    //Cufon.replace('#mycarousel h5', { fontFamily: 'Komika' });
  //$('#mycarousel ul li').mouseover(function() {

//});

  //$('#mycarousel ul li').mouseleave(function() {
  //$(this).children('.carouseRollover').hide();
//});



  //$('#mycarousel').mouseleave(function() {
  //$('.carouseRollover').hide('fast');
//});

};

function mycarousel_initCallback(carousel)
{
    
    jQuery('.jcarousel-control a').bind('click', function() {
carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
return false;
});


    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
    
};


/**
 * Item html creation helper.
 */
function mycarousel_getItemHTML(url)
{
    return url;
};

function mycarousel_itemVisibleInCallbackBeforeAnimation(carousel, item, idx, state) {
    // No animation on first load of the carousel
    if (state == 'init')
        return;

    jQuery('img', item).hide();
    $('.jcarousel-control li a').removeAttr('class');
};

function mycarousel_itemVisibleInCallbackAfterAnimation(carousel, item, idx, state) {
    // No animation on first load of the carousel
    if (state == 'init')
      
        return;
    jQuery('img', item).fadeIn(1500);
    var bId = '#carButton' + idx;
    $(bId).attr('class','selected');
  $('.carouselText').show();
    $('#pos').text(idx);
};


function mycarousel_itemVisibleOutCallbackBeforeAnimation(carousel, item, idx, state) {
    if (state == 'init')
      
        return;    
};



jQuery(document).ready(function() {


jQuery('#littleCarousel').jcarousel({
    scroll: 3,
  animation: 'fast'
}
);




    jQuery('#carousel').jcarousel({
  wrap: 'both',
  scroll: 1,
  auto: 7,
  animation: 0,
  
  
    itemLoadCallback: mycarousel_itemLoadCallback,
   initCallback: mycarousel_initCallback, 
   buttonNextHTML: null,
buttonPrevHTML: null, 
   itemVisibleInCallback: {
            onBeforeAnimation: mycarousel_itemVisibleInCallbackBeforeAnimation,
            onAfterAnimation: mycarousel_itemVisibleInCallbackAfterAnimation
        }
         
        


    });
   
});

