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]));
    if(state=='next' || state=='init') {
        carousel.get(i-2).css({'filter': 'alpha(opacity=40)', 'opacity':'0.4','z-index':'0', 'cursor': 'default'});
        carousel.get(i).css({'filter': 'alpha(opacity=40)', 'opacity':'0.4','z-index':'0', 'cursor': 'default'});
        carousel.get(i-1).css({'filter': 'alpha(opacity=100)', 'opacity':'1','z-index':'2000000', 'position':'relative', 'cursor': 'pointer'});
        carousel.get(i-1).hover(
          function () {
             carousel.get(i-1).find('div:nth-child(3)').css({'display': 'block'});          
          }, 
          function () {
             carousel.get(i-1).find('div:nth-child(3)').css({'display': 'none'});                  
          }
        );
        carousel.get(i).unbind('mouseenter mouseleave');   
        carousel.get(i-2).unbind('mouseenter mouseleave');           
        carousel.get(i-1).find('div:nth-child(2)').css({'display': 'block'});          
        carousel.get(i-2).find('div:nth-child(2)').css({'display': 'none'});          
    }
    else {
        carousel.get(i+2).css({'filter': 'alpha(opacity=40)', 'opacity':'0.4','z-index':'0', 'cursor': 'default'});
        carousel.get(i).css({'filter': 'alpha(opacity=40)', 'opacity':'0.4','z-index':'0', 'cursor': 'default'});
        carousel.get(i+1).css({'filter': 'alpha(opacity=100)', 'opacity':'1','z-index':'2000000', 'position':'relative', 'cursor': 'pointer'});
        carousel.get(i+1).hover(
          function () {
             carousel.get(i+1).find('div:nth-child(3)').css({'display': 'block'});          
          }, 
          function () {
             carousel.get(i+1).find('div:nth-child(3)').css({'display': 'none'});                  
          }
        );
        carousel.get(i).unbind('mouseenter mouseleave');   
        carousel.get(i+2).unbind('mouseenter mouseleave');   
        carousel.get(i+1).find('div:nth-child(2)').css({'display': 'block'});
        carousel.get(i+2).find('div:nth-child(2)').css({'display': 'none'});
    }
};
function mycarousel_itemVisibleOutCallback(carousel, item, i, state, evt)
{
    carousel.remove(i);
};


function mycarousel_getItemHTML(item)
{
    return '<div style="width:437px;height:165px;background-image:url(' + item.url + ');background-position:-17px 0px;"></div><div class="description">' + item.description + '</div><div class="mouseovertext" onclick="javascript:window.location=\'' + item.click + '\';">' + item.title + '</div>';
};

function itemVisibleIn(carousel, item, i, state, evt)
{
    $(item).addClass('active');
}

jQuery(document).ready(function() {
    jQuery('#coverfid').jcarousel({
        wrap: 'circular',
        itemVisibleInCallback: {
            onBeforeAnimation: mycarousel_itemVisibleInCallback
        },
        itemVisibleOutCallback: {onAfterAnimation: mycarousel_itemVisibleOutCallback},
        buttonNextHTML: '<img title="Nęste" alt="Nęste" src="/guide/sg4/kkgraphics/caserotate_next.gif" alt="Nęste" onmouseover=javascript:this.src="/guide/sg4/kkgraphics/caserotate_next_mo.gif" onmouseout=javascript:this.src="/guide/sg4/kkgraphics/caserotate_next.gif" />',
        buttonPrevHTML: '<img title="Forrige" alt="Forrige" src="/guide/sg4/kkgraphics/caserotate_prev.gif" alt="Forrige" onmouseover=javascript:this.src="/guide/sg4/kkgraphics/caserotate_prev_mo.gif" onmouseout=javascript:this.src="/guide/sg4/kkgraphics/caserotate_prev.gif" />',
        scroll:1,
        start: mycarousel_startIndex,
        offset: 1
    });
});    

