$(document).ready(function(){
	// billboards
	loadBillboards();
});

function loadBillboards(){
	// default billboard
	var billboardId = "billboards-spacedecon";
	var children = [];
	
	// the children of this billboard
	children = $("#" + billboardId + "> div");
	
	// create the cycle plugin
	$("#" + billboardId).cycle({
		fx: "fade",
		speed: 2000,
		timeout:6000,
		pager: "#bbnav-pages",
		next: "#bbnav-next",
		prev: "#bbnav-previous"
	});	

	/*
	 * We have the id of the billboard we need to load
	 * make sure we have more than 1 image, if not there is no reason to show the paging toolbar
	 */	 
	if(children.length > 1){
		$("#bbnav-container").show();
	} else {
		$("#bbnav-container").hide();
	}
	
	// event listeners for our other buttons
	$("#bbnav-previous").click(previous);
	$("#bbnav-pause").click(pause);
	$("#bbnav-play").click(play);		
	$("#bbnav-next").click(next);		
}
function pause(){
	$(".billboards").cycle('pause');
	$("#bbnav-pause").toggle();
	$("#bbnav-play").toggle();
}
function play(){
	$(".billboards").cycle('resume');
	$("#bbnav-play").toggle();	
	$("#bbnav-pause").toggle();
}	
function next(){
	$(".billboards").cycle('pause');
}
function previous(){
	$(".billboards").cycle('pause');
}

function onAccordionChange(event,ui){
	var solutionsId = ui.newHeader[0].id;
	var id = solutionsId.split("-")[1];
	swapBillboards(id);
}
