// Carousel Config Javascript for Alcatel-Lucent Unified Communications Solutions Landing Page

(function ($) {
// VERTICALLY ALIGN FUNCTION
$.fn.vAlign = function() {
	return this.each(function(i){
	var ah = $(this).height();
	var ph = $(this).parent().height();
	var mh = (ph - ah) / 2;
	if(mh>9){
		$(this).css('margin-top', mh);
	} else {
		$(this).css('margin-top', 9);
	}
	});
};
})(jQuery);

// Set Up Controls - Resources
function resources_carousel_initCallback(carousel) {
	
	$("#container").vAlign();
	
	$(window).bind('resize', function(){
		$("#container").vAlign();
	});
	
    jQuery('#btn_resource_widget_next').bind('click', function() {
        carousel.next();
        return false;
    });

    jQuery('#btn_resource_widget_prev').bind('click', function() {
        carousel.prev();
        return false;
    });
};


function resources_buttonNextCallback(carousel, button, enabled) {
	if(!enabled){
    	jQuery('#btn_resource_widget_next').addClass("disabled");
	} else {
		jQuery('#btn_resource_widget_next').removeClass("disabled");
	}
};

function resources_buttonPrevCallback(carousel, button, enabled) {
	if(!enabled){
    	jQuery('#btn_resource_widget_prev').addClass("disabled");
	} else {
		jQuery('#btn_resource_widget_prev').removeClass("disabled");
	}
};


// Set Up Controls - News

jQuery(document).ready(function() {
	
    jQuery('#resources_carousel').jcarousel({
		scroll: 1,
		auto: 8,
		wrap: "both",
		animation: "slow",
		initCallback: resources_carousel_initCallback,
		buttonNextCallback:   resources_buttonNextCallback,
		buttonPrevCallback:   resources_buttonPrevCallback
    });

});
