 $(document).ready(function(){
	//On all expanders, except Articles, hide toggle containers on load, except the first one
	if ($(".expandable:first").parents('div:eq(0)').attr('class') != 'articles') {
		$(".expandable:first").click();
		$("div.trigger:first").addClass("active");
		$(".expandable:not(:first)").hide(); 
		
		//Switch the "Open" and "Close" state per click
		$("div.trigger:not(:first)").toggle(function(){
			$(this).addClass("active");
			}, function () {
			$(this).removeClass("active");
		});
		
		//Switch the "Open" and "Close" state per click
		$("div.trigger:first").toggle(function(){
			$(this).removeClass("active");
			}, function () {
			$(this).addClass("active");
		});
		
	} else {
		$(".expandable").hide(); 
		
		//Switch the "Open" and "Close" state per click
		$("div.trigger").toggle(function(){
			$(this).addClass("active");
			}, function () {
			$(this).removeClass("active");
		});
	}
	
	//Slide up and down on click
	$("div.trigger").click(function(){
		$(this).next(".expandable").slideToggle(300);
	});
		
 });


// Sticky footer
$(window).bind("load", function() { 
	
	   var footerHeight = 0,
	       footerTop = 0,
	       $footer = $("#footer");
	
	   positionFooter();
	
	   function positionFooter() {
	      footerHeight = $footer.outerHeight();
	      footerTop = ($(window).scrollTop()+$(window).height()-footerHeight)+"px";
	      if ( ($(document.body).height()+footerHeight) < $(window).height()) {
	         $footer.css({
	              position: "absolute",
	              top: footerTop
	         });
	      } else {
	         $footer.css({
	              position: "static"
	         });
	      }
	   };
	   $(window)
	    .scroll(positionFooter)
	    .resize(positionFooter);	
});
