$(document).ready(function() {
    $('a[href=#top]').click(function(){
        $('html, body').animate({scrollTop:0}, 'slow');
        return false;
    });
});

$(function(){
	$("ul#ticker01").liScroll({travelocity: 0.05});
});

function slideSwitch() {
    var $active = $('.slideshow div.active');

    if ( $active.length == 0 ) $active = $('.slideshow div:last');

    // use this to pull the divs in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('.slideshow div:first');

    // uncomment below to pull the divs randomly
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 5000 );
});


// Menu Hide
	$(document).ready(function(){
		
		$(".section-container").hide();
	 
		$("div.sectionHeader").click(function(){
			$(this).toggleClass("active").next().slideToggle("slow");
		});
		
		$("p.close").click(function(){
		$(".section-container").hide("slow");
		$("div.sectionHeader.active").removeClass("active").toggle(function(){
			$(this).addClass("active");
			}, function () {
				$(this).removeClass("active");
			});
		});
	 
	});
	
// Return to Top Sticky
$(document).ready(function(){
	var $stickyHeight = 100;
	var $padding = 10;
	var $topOffset = 1340;
	var $footerHeight = 83;
	
	function scrollSticky(){
		if($(window).height() >= $stickyHeight) {
			var aOffset = $('#button-top').offset();
	
			if($(document).height() - $footerHeight - $padding < $(window).scrollTop() + $stickyHeight) {
				var $top = $(document).height() - $stickyHeight - $footerHeight - $padding;
				$('#button-top').attr('style', 'position:absolute; top:'+$top+'px;');
	
			}else if($(window).scrollTop() + $padding > $topOffset) {
				$('#button-top').attr('style', 'position:fixed; top:'+$padding+'px; float:right;');
	
			}else{
				$('#button-top').attr('style', 'position:relative;');
			}
		}
	}
	
	$(window).scroll(function(){
		scrollSticky()
	});

});
