// JavaScript Document



function mycarousel_initCallback(carousel) {
    jQuery('.jcarousel-control a').bind('click', function() {
        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
        return false;
    });
 
    jQuery('.jcarousel-clip').css('overflow', 'hidden');

	// Disable autoscrolling if the user clicks the prev or next button.
    /*carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
		carousel.next();
        return false;
    });
 
    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
		carousel.prev();
        return false;
    });*/
 
    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
	
    jQuery('.jcarousel-scroll select').bind('change', function() {
        carousel.options.scroll = jQuery.jcarousel.intval(this.options[this.selectedIndex].value);
        return false;
    });
 
    jQuery('#mycarousel-next').bind('click', function() {
		carousel.startAuto(0);
        carousel.next();
        return false;
    });
 
    jQuery('#mycarousel-prev').bind('click', function() {
        carousel.startAuto(0);
		carousel.prev();
        return false;
    });
};
 
jQuery(document).ready(function() {
								
	jQuery("#mycarousel").jcarousel({
		auto: 3,
		scroll: 1,
		animation: 500,
		wrap: 'circular',
        initCallback: mycarousel_initCallback,
        // This tells jCarousel NOT to autobuild prev/next buttons
        buttonNextHTML: null,
        buttonPrevHTML: null
    });
	
	jQuery('.ad-gallery').adGallery();
	
	jQuery("a[rel=image_group]").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
});

