﻿jQuery(document).ready(function($){
	$("#back-top").hide();
	// fade in #back-top
	$(function () {
		$(window).scroll(function () {
			if ($(this).scrollTop() > 100) {
				$('#back-top').fadeIn();
			} else {
				$('#back-top').fadeOut();
			}
		});
		// scroll body to 0px on click
		$('#back-top a').click(function () {
			$('body,html').animate({
				scrollTop: 0
			}, 800);
			return false;
		});
	});
	
	var topNewsCount = $("#top-news h2").length;
	if(topNewsCount > 0){
		switchTopNews();
	}else{
		$("#top-news ul").html("<li><h2><span class='bigQuotes'>&lsquo;&lsquo;</span>Ei kuumia uutisaiheita tällä hetkellä.<span class='bigQuotes'>&rsquo;&rsquo;</span></h2></li>");
	}
	
	function switchTopNews(){
		$("#top-news").carousel( {
			direction: "vertical",
			loop: true,
			pagination: false, // setting this to true adds the pagination 1, 2, 3 etc.
			autoSlide: true,
			autoSlideInterval: 4000, // how long in miliseconds till next rotation
			delayAutoSlide: 3000 // how long to pause on each banner
		 } );
		 
	};
 });

