$(function() {
	// initialize tab 1 as scrollable
	$("#tabBox1.scrollable").scrollable(
		{
			speed: 700, 
			circular: true,
			next: "#tab1next",
			prev: "#tab1prev"
		}
	);

	// initialize tab 2 as scrollable
	$("#tabBox2.scrollable").scrollable(
		{
			speed: 700, 
			circular: true,
			next: "#tab2next",
			prev: "#tab2prev"
		}
	)
	
	// initialize tab 3 as scrollable
	$("#tabBox3.scrollable").scrollable(
		{
			speed: 700, 
			circular: true,
			next: "#tab3next",
			prev: "#tab3prev"
		}
	);
	
	// Initialize tabs
	$("#tabBoxNav").tabs(".tabBox", {
		event:'mouseover'
	});
	
	var randomNum = Math.floor( ( Math.random()*$("#homeBannerImages > li").length) ) ;
	
	$("#homeBannerBtns").tabs("#homeBannerImages > li", {
		// Randomize banner
		initialIndex: randomNum,

		// Allow mouseover to open next banner
		event:'mouseover',
			
		// enable "cross-fading" effect
		effect: 'fade',
		fadeOutSpeed: "slow",
		clickable: false,
		
		// start from the beginning after the last tab
		rotate: true
	});
	
	// Setup scrolling for Company icons (need window.onload for Chrome to work properly
	$("#whoUsesDMIcons.scrollable").css('height', $("#whoUsesDMIcons.scrollable .items table").height());
	$(window).load(function() {
		
		
		$("#whoUsesDMIcons.scrollable").css('height', $("#whoUsesDMIcons.scrollable .items table").height());
		$("#whoUsesDMIcons.scrollable").scrollable({
			speed: 1000, 
			circular: true,
			// here is a callback function that is called before the tab is clicked
			onBeforeSeek: function(event, scrollIndex) {
				var el = $("#whoUsesDMIcons.scrollable .items table")[scrollIndex + 1];
				//alert (scrollIndex);
				var height = $(el).height();
				$("#whoUsesDMIcons.scrollable").css('height', height);
			}
		}).autoscroll({ 
			interval: 5000
		});
	});
	
	
});
