$(function(){
	/*Preload Images for Letterbox*/
	var image1 = $('<img />').attr('src', assets+'images/overlay_b2b-tag-0.png');
	var image2 = $('<img />').attr('src', assets+'images/overlay_b2b-tag-1.png');
	var image3 = $('<img />').attr('src', assets+'images/overlay_b2b-tag-2.png');
	var image4 = $('<img />').attr('src', assets+'images/overlay_b2b-tag-3.png');
	
	$("div.rotate").cycle({
		timeout: 7000,
		speed: 1000,
		before: function(curr, next){
			index = $("div.rotate img").index($(this));
			$("body#home .video-links li").removeClass("active");
			$("body#home .video-links li").eq(index).addClass("active");
			$("body#home .main-photo .photo-stamp").css("background-image","url("+assets+"images/overlay_b2b_tag-"+index+".png)")
		}
		
	});
	
	$("body#home .video-links li").hover(function(){
		index = $("body#home .video-links li").index($(this));
		$("body#home .video-links li").removeClass("active");
		$("body#home .video-links li").eq(index).addClass("active");
		
		$('div.rotate').cycle(index);
		$("div.rotate").cycle("pause");
	});
	/*},function(){
		//$(this).removeClass("active");
		//$("div.rotate").cycle("resume");
	});*/
	
	/*Set up horizontal scrolling for thumbnail strip*/
	$("body#home #slide-container #sponsor-slides").cycle(
	{
		fx: "scrollHorz",
		speed: 1000,
		timeout: 5000
	});
	
	$(".sidebar-slides .slide-container").cycle(
	{
		fx: "scrollHorz",
		cleartype: false,
		speed: 700,
		timeout: 6000,
		pager: ".sidebar-slides ul.slide-pager",
		pagerAnchorBuilder: function(idx, slide)
		{
			return '<li><a href="#">' + slide + '</a></li>'; 
		}
	});
	
	$("body#inside #sponsor-slides").cycle();
});
