// Javascript for Social Widgets Carousel on Home Page
// Copyright 2010, Bob Wadholm
// Licensed MIT and GPL

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();
    });
};

jQuery(document).ready(function() {
	// Initialize the social widgets carousel
    jQuery('#myCarousel').jcarousel({
        auto: 15,
        wrap: 'circular',
		easing: 'easeOutCubic',
		animation: 1000,
        initCallback: mycarousel_initCallback
    });
	
	// Add images to each widget header
	$('.socialWidget').each(function(){
		var addSocialImage = $(this).attr('id');
		$('#'+ addSocialImage +' h3').append('<span class="socialImage"><img src="/wp-content/themes/Kuna-Life-Church/img/'+ addSocialImage +'.png" alt="'+ addSocialImage +'" /></span>');
	});	
	
	$('#featurePics ul').cycle({ 
			fx:    'fade', 
			speed:  2000,
			timeout: 6000,
			delat: -3000,
			random: 1,
			pause: 0			
	});
	$('#featurePics ul').fadeIn(500);
});
