$(document).ready(function() {
	// menu
	$('#nav li').hover(
		function () {
			//show its submenu
			$('ul', this).slideDown(0);

		}, 
		function () {
			//hide its submenu
			$('ul', this).slideUp(50);			
		}
	);
}); 

$(window).load(function() {
	// run calendar
	$("#calendar").compactCal({
	 offsetLeft: 100,   
	 offsetTop: -10      
	});
		
	$.ajax({
        type: "GET",
		url: "/xml/sb_burnettfellowship/rotatingStory1.xml?_nc= " + Math.random(),
		dataType: "xml",
		success: function(slide_xml) {
			setupHTMLandSlideshow(slide_xml);
		}
	});  

});        

function setupHTMLandSlideshow(slide_xml) {
	// setup html                       
	var newHTML = "";
	var storyCount = 0;
	$(slide_xml).find('story').each(function(){
		newHTML += "<div><a href='" + $(this).attr('pageLink') + "'><img src='" + $(this).attr('imageLink') + "' /></a></div>";
		storyCount++;
	});                                                                                                          
	
	$("#slider").html(newHTML);
	$("#slider").cycle({
		fx: "fade", pager: "#slideshow_controls_list", speed: 1000, timeout: 3000, pause: 1
	});                                      
	var newControlWidth = $(".slideshow_controls").width() * storyCount;
	$(".slideshow_controls").css("width", newControlWidth + "px");   
}     

/*
var home_slideCount = 0;

function setupHTMLandSlideshow(slide_xml) {
	// setup html                       
	var newHTML = "";
	$(slide_xml).find('story').each(function(){
		newHTML += "<div><a href='" + $(this).attr('pageLink') + "'><img src='" + $(this).attr('imageLink') + "' /></a></div>";
		home_slideCount++;
	});                                                                                                                     
		
	$("#home_slider").html(newHTML);
	$("#home_slider").cycle({
		fx: "fade", prev: "#home_slideshow .prev", next: "#home_slideshow .next", speed: 1000, timeout: 5000, pause: 1, before: slideUpdated
	});                                                                                                  
	$("#home_slideshow .num").html("1/" + home_slideCount);
	
}                                            

function slideUpdated(a, b, opts) {
	$("#home_slideshow .num").html((opts.nextSlide + 1) + "/" + home_slideCount);
}
*/
