function mycarousel_initCallback(carousel)
{
	// Disable autoscrolling if the user clicks the prev or next button.
	carousel.buttonNext.bind('click', function() {
		carousel.startAuto(0);
	});
	
	carousel.buttonPrev.bind('click', function() {
		carousel.startAuto(0);
	});
	
	// Pause autoscrolling if the user moves with the cursor over the clip.
	carousel.clip.hover(function() {
		carousel.stopAuto();
	}, function() {
		carousel.startAuto();
	});
}; 

$(document).ready(function($) {
	$('a[rel*=facebox]').facebox(); 
	
	 // Anything Slider
	 $('#anythingSlider').anythingSlider({
		easing: "easeInOutExpo",        // Anything other than "linear" or "swing" requires the easing plugin
        autoPlay: true,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not
        startStopped: false,            // If autoPlay is on, this can force it to start stopped
        delay: 5000,                    // How long between slide transitions in AutoPlay mode
        animationTime: 600,             // How long the slide transition takes
        hashTags: false,                // Should links change the hashtag in the URL?
        buildNavigation: true,          // If true, builds and list of anchor links to link to each slide
        pauseOnHover: false,            // If true, and autoPlay is enabled, the show will pause on hover
        startText: "Start",             // Start text
        stopText: "Stop",               // Stop text
        navigationFormatter: null       // Details at the top of the file on this use (advanced use)

	 });
	 
	  $.fn.sortElements = (function(){
 
			var sort = [].sort;
		 
			return function(comparator, getSortable) {
		 
				getSortable = getSortable || function(){return this;};
		 
				var placements = this.map(function(){
		 
					var sortElement = getSortable.call(this),
						parentNode = sortElement.parentNode,
		 
						// Since the element itself will change position, we have
						// to have some way of storing its original position in
						// the DOM. The easiest way is to have a 'flag' node:
						nextSibling = parentNode.insertBefore(
							document.createTextNode(''),
							sortElement.nextSibling
						);
		 
					return function() {
		 
						if (parentNode === this) {
							throw new Error(
								"You can't sort elements if any one is a descendant of another."
							);
						}
		 
						// Insert before flag:
						parentNode.insertBefore(this, nextSibling);
						// Remove flag:
						parentNode.removeChild(nextSibling);
		 
					};
		 
				});
		 
				return sort.call(this, comparator).each(function(i){
					placements[i].call(getSortable.call(this));
				});
		 
			};
		 
		})();
		
		$('#mycarousel li').sortElements(function(a, b){
			var numRand = Math.floor(Math.random()*101);
			return numRand > 50 ? 1 : -1;
		});
	 
	 $('#mycarousel').jcarousel({
			auto: 2,
			wrap: 'circular',
			scroll: 1,
			visible: 1,
			animation: 'slow',
			initCallback: mycarousel_initCallback
		}); 
	$('.blue-gradient .prev').hide();
	$('.blue-gradient .next').hide();
});

