$(document).ready(function() {

	// Make round corners
	$('.primaryMenu').find('a').corner("8px");
	$('#homeRegister, #homeDonate').corner("5px");
	$('.galleryHome').find('span').corner("5px top");
        $('#galleryList').find('span').corner("5px top");
        $('.galleryInterior').find('span').corner("5px top");
	
	// Initialize accordion
	if (0 != $(".accordion").length) {
	
		$(".accordion").accordion({
			active: false,
			collapsible: true,
			header: "h2"
		});
	}

	// Weather
	$.simpleWeather({
		zipcode: '81427',
		//location: 'Ouray, Colorado',
		unit: 'f',
		success: function(weather) {
			$("#weather").append('<li><img src="'+weather.image+'"></li>');
			$("#weather").append('<li><span id="weatherConditions">' + weather.currently + '&nbsp;'+weather.temp+'&deg;</span></li>');
		},
		error: function(error) {
			$("#weather").append('<li>Sorry, an elk stepped on our thermometer!</li>');
		}
	});

	// Initialize Colorbox
	$(".video a").colorbox({iframe:true, innerWidth:425, innerHeight:344});
		// Initialize Colorbox for newsletter form
	$(".newsletter").colorbox({iframe:true, innerWidth:600, innerHeight:400});
	
	// Testimonials
	$("#testimonials ul").cycle({
		fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		random: 1,	// randomly select a starting slide
		pause: 1	// pause slideshow when mouse is hovering
	});

	// Add quote graphic
	$("#testimonials p").prepend('<img src="media/images/website_graphics/quote.png">');
	
	// Show testimonials once they are being cycled
	$("#testimonials").removeClass("hidden");

	
// HOMEPAGE ONLY 

	// Initialize homepage slider
	$('#coda-slider-1').codaSlider({
		autoSlide: true,
		autoSlideInterval: 0,
		autoSlideStopWhenClicked: true,
		crossLinking: true,
		dynamicArrows: false,
		dynamicTabs: false,
		slideEaseDuration: 10000,
		slideEaseFunction: 'easeInOutCirc'
	});
	
	// Retrieve Blog posts
	$('#news').rssfeed('http://blog.campchiefouray.org/feed/rss', {
		limit: 2, header:false, date:false
	});


	// Load tabbed content
	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content

	//On Click Event
	$("ul.tabs li").click(function() {

		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content

		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active ID content
		return false;
	});

});

