jQuery.fn.init_carousel = function() {


	// set globals
	$.yuna_carousel = {};
	$.yuna_carousel.intCurrentIndex = 0;
	$.yuna_carousel.intDelay = 7000; // (milisec)

	$('.imageSliderLink').show();

 	// set handlers on the navigation
 	$('.imageSliderLink').each(function(intIndex){
 		$(this).click(function(){
 			$.yuna_carousel.intCurrentIndex = intIndex;
 			show_content();
 			return false;
 		});
 	});

 	// show the first box
	show_content($.yuna_carousel.intCurrentIndex);
	return(this);
}


// show the content for the given index
function show_content(){

	 // loop through the navigation
	 // edit the active link
	 // remember the correct one
	 $('.imageSliderLink').each(function(intIndex){
	 	if(intIndex==$.yuna_carousel.intCurrentIndex){
			$(this).attr("class","imageSliderLink active");
			$.yuna_carousel.jqActiveLink = $(this);
	 	} else {
	 	    $(this).attr("class","imageSliderLink inactive");
	 	}
	 });


	 // loop through the content boxes, turn them all off
	 $('.headerContentBox').each(function(intIndex){
	 	$(this).css("display","none");
//	 	$(this).fadeOut("slow");
	 });


	 // get the rel item from the active link
	 var strBoxId = $.yuna_carousel.jqActiveLink.attr("rel");
	 // set the active content parts
	 var objContentBox =  $('#'+strBoxId);
	 var objContentText =  $('#'+strBoxId+' .textPart')
	 var objContentImage =  $('#'+strBoxId+' .imagePart')


	 //display the entire box
	 objContentBox.css("display","block");
	 // display the text part
	 objContentText.css("display","block");
	 // fade in the image
	 objContentImage.css("display","none");
	 objContentImage.fadeIn("slow");

	 // set a new interval
	 clearInterval($.yuna_carousel.intTimeoutId);
	 $.yuna_carousel.intTimeoutId= setInterval("show_next_content();",$.yuna_carousel.intDelay);
}


/*
* circulate
* called from interval
*/
function show_next_content(){
	// get the total amount of boxes
	var arrContent = $('.imageSliderLink');
	var intCarouselLength = arrContent.length;

	// increment the index
	$.yuna_carousel.intCurrentIndex++;

	// circulate the index
	if($.yuna_carousel.intCurrentIndex >= intCarouselLength){
		$.yuna_carousel.intCurrentIndex = 0;
	}
	//set the active one
	show_content();
}
