// JavaScript Document


/**
 * This is the callback function which receives notification
 * about the state of the next button.
 */
function mycarousel_buttonNextCallback(carousel, button, enabled) {
    display('Next button is now ' + (enabled ? 'enabled' : 'disabled'));
	var before=idx-1;
	var after=idx+1;
	 $(".jcarousel-item-"+before).animate({"opacity": "0.2"}, "slow");
	  $(".jcarousel-item-"+after).animate({"opacity": "0.2"}, "slow" );
	  
	
  $(".jcarousel-item-"+idx).fadeTo('slow', 1);
    display('Item #' + idx + ' is now visible');
	
	  
	  
	  

};

/**
 * This is the callback function which receives notification
 * about the state of the prev button.
 */
function mycarousel_buttonPrevCallback(carousel, button, enabled) {
    display('Prev button is now ' + (enabled ? 'enabled' : 'disabled'));
	
	var before=idx-1;
	var after=idx+1;
	 $(".jcarousel-item-"+before).animate({"opacity": "0.2"}, "slow" );
	  $(".jcarousel-item-"+after).animate({"opacity": "0.2"}, "slow");
	  
	  
	 
  $(".jcarousel-item-"+idx).fadeTo('slow', 1);
    display('Item #' + idx + ' is now visible');
	
};

/**
 * This is the callback function which receives notification
 * right after initialisation of the carousel
 */
function mycarousel_initCallback(carousel, state) {
	jQuery('.jcarousel-control a').bind('click', function() {
        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
        return false;
    });

	
	
    if (state == 'init')
        display('Carousel initialised');
    else if (state == 'reset')
        display('Carousel reseted');
};

/**
 * This is the callback function which receives notification
 * right after reloading of the carousel
 */
function mycarousel_reloadCallback(carousel) {
    display('Carousel reloaded');
};

/**
 * This is the callback function which receives notification
 * when an item becomes the first one in the visible range.
 */
function mycarousel_itemFirstInCallback(carousel, item, idx, state) {
    display('Item #' + idx + ' is now the first item');
};

/**
 * This is the callback function which receives notification
 * when an item is no longer the first one in the visible range.
 */
function mycarousel_itemFirstOutCallback(carousel, item, idx, state) {
    display('Item #' + idx + ' is no longer the first item');
					    $(".jcarousel-item-"+idx).fadeTo('slow', 0.2);

};

/**
 * This is the callback function which receives notification
 * when an item becomes the first one in the visible range.
 */
function mycarousel_itemLastInCallback(carousel, item, idx, state) {
    display('Item #' + idx + ' is now the last item');
};

/**
 * This is the callback function which receives notification
 * when an item is no longer the first one in the visible range.
 */
function mycarousel_itemLastOutCallback(carousel, item, idx, state) {
    display('Item #' + idx + ' is no longer the last item');
				    $(".jcarousel-item-"+idx).fadeTo('slow', 0.2);

};

/**
 * This is the callback function which receives notification
 * when an item becomes the first one in the visible range.
 * Triggered before animation.
 */
function mycarousel_itemVisibleInCallbackBeforeAnimation(carousel, item, idx, state) {
    // No animation on first load of the carousel
    if (state == 'init')
        return;

    $('img', item).fadeTo('slow');
};

/**
 * This is the callback function which receives notification
 * when an item becomes the first one in the visible range.
 * Triggered after animation.
 */
function mycarousel_itemVisibleInCallbackAfterAnimation(carousel, item, idx, state) {
	//alert(idx);
	//alert($(".jcarousel-item-"+idx).html);
	
	 
	  

		
	var before=idx-1;
	var after=idx+1;
	 $(".jcarousel-item-"+before).animate({"opacity": "0.2"}, "slow");
	  $(".jcarousel-item-"+after).animate({"opacity": "0.2"}, "slow" );
	  
	  
	  					 
    display(after);

 $('.jcarousel-control a').each(function(index) {
 						$(this).removeClass("active");  
 					});
  
				   
				   
		                $('#button-'+idx).addClass("active");
	 
  $(".jcarousel-item-"+idx).fadeTo('slow', 1);
    display('Item #' + idx + ' is now visible');
	
//	alert($(".jcarousel-item-"+idx+" img").attr('alt'));
	  $("#home_carousel .home_over").empty().append($(".jcarousel-item-"+idx+" img").attr('alt')+"<div class='arrow'></div>");
	
	
	
};

/**
 * This is the callback function which receives notification
 * when an item is no longer the first one in the visible range.
 * Triggered before animation.
 */
function mycarousel_itemVisibleOutCallbackBeforeAnimation(carousel, item, idx, state) {
    $('img', item).fadeTo('slow',0.2);
		//    $(".jcarousel-item-"+idx).fadeTo('slow', 0.2);

};

/**
 * This is the callback function which receives notification
 * when an item is no longer the first one in the visible range.
 * Triggered after animation.
 */
function mycarousel_itemVisibleOutCallbackAfterAnimation(carousel, item, idx, state) {
   // display('Item #' + idx + ' is no longer visible');
	 $(".jcarousel-item-"+idx).fadeTo('slow', 0.2);

};

/**
 * Helper function for printing out debug messages.
 * Not needed for jCarousel.
 */
var row = 1;
function display(s) {
    // Log to Firebug (getfirebug.com) if available
    if (window.console != undefined && typeof window.console.log == 'function')
       console.log(s);

    if (row >= 1000)
        var r = row;
    else if (row >= 100)
        var r = '&nbsp;' + row;
    else if (row >= 10)
        var r = '&nbsp;&nbsp;' + row;
    else
        var r = '&nbsp;&nbsp;&nbsp;' + row;

   // $('#display').html($('#display').html() + r + ': ' + s + '<br />').get(0).scrollTop += 10000;

    row++;
};
                    
      $(document).ready(function() {
	
		$(".jcarousel-prev").css('opacity', 0);
$(".jcarousel-next").css('opacity', 0);
		
		
		
		
		
		$(".jcarousel-item").hover(
  function () {
	

$(".jcarousel-prev").stop().fadeTo('slow', 1);
$(".jcarousel-next").stop().fadeTo('slow', 1);

  }
);

		$(".jcarousel-prev, .jcarousel-next").hover(
  function () {
	

$(".jcarousel-prev").css('visibility', 1).css('opacity', 1);
$(".jcarousel-next").css('visibility', 1).css('opacity', 1);

  }
);

	
	
	
			$(".jcarousel-prev,.jcarousel-next").hover(
  function () {
	

$(".jcarousel-prev").fadeTo('slow', 1);
$(".jcarousel-next").fadeTo('slow', 1);

  }
);

	
	
	
	
		
    });

