var startSlide = Math.floor(Math.random()*3);

$(document).ready(function() {
	
	$('#slider_bg').cycle({
		fx: 'scrollHorz',
		timeout: 0,
		startingSlide: startSlide,
		pause: true,
        prev:    '.leftArrow',
        next:    '.rightArrow',
        before: function() {
        	slideNum = $(this).attr('rel');
        	switchView.view(slideNum);
        }
	});
	$("input").labelify({ text: "label" });

    $('#factboxInfo').cycle({
		fx: 'none',
		timeout: 9000,
		startingSlide: startSlide,
		before: updateBG,
		pause: true
	});


});


function updateBG()
{
	// console.log(this.id);
	
	if(this.id === 'fact4') {
		$("#factboxBG").css('background', '#7BC143');
	} else {
		$("#factboxBG").css('background', '#807f83')
	}
}


var switchView = {
	
	clear: function() {
		$(".calloutContainer").hide();
		// $(".factContainer").hide();
	},
	
	view: function(i) {
		//console.log(i)
		switchView.clear();
		
		$("#callout"+i).show();
		//$("#fact"+i).show();
        //$('#factboxInfo').cycle(i);
	}

}
