$(document).ready(function() {
			var interval;
			
			$('li').focus(function() {
				$(this).find('div.more').fadeIn(400);
			}).blur(function() {
				$(this).find('div.more').fadeOut(100);
			});
			
			$('div#vinkkiHeader').hide();
			$('div#vinkkiText').hide();
			$('div#header').hide();
			
			$('div#header').fadeIn(1000, function() {
				$('div#vinkkiHeader').delay(800).fadeIn(1000, function() {
					$('div#vinkkiText').fadeIn(600);
				});
			});
			
			$('div#headerTopic').hide();
			$('div#headerText').hide();
			
			$('div#headerTopic').delay(500).fadeIn(1000, function() {
			 	$('div#headerText').fadeIn(1000);
			});

			
			$(".button").click(function() {
		// validate and process form here
		
		var name = $("input#name").val();
		if (name == "") {
			$("input#name").focus().addClass("red");
			return false;
		} else {
			$("input#name").removeClass("red");
		}
		
		var email = $("input#email").val();
		if (email == "") {
			$("input#email").focus().addClass("red");
			return false;
		} else {
			$("input#email").removeClass("red");
		}
		
		var phone = $("input#phone").val();
		if (phone == "") {
			$("input#phone").focus().addClass("red");
			return false;
		} else {
			$("input#phone").removeClass("red");
		}
		
		var text = $("textarea#text").val();
		if (text == "") {
			$("textarea#text").focus().addClass("red");
			return false;
		} else {
			$("textarea#text").removeClass("red");
		}
	
		$.ajax({
			type: "POST",
			url: "process.php",
			data: ({name: name, email: email, phone: phone, text: text}),
			success: function() {
			 	var width = $('#contact_form').height();
				$('#contact_form').html("<h1>Viesti lähetetty!</h1>").css("height", width);
			}
		});
		return false;
      
    });

			

			$('ul#banneri')
				.roundabout({
				 	minOpacity: 0.8,
			         minScale: 0.75
			    })
				.hover(
					function() {
						// on
						clearInterval(interval);
					},
					function() {
						// off
						interval = startAutoPlay();
					}
				);
			
				// start rotation
				interval = startAutoPlay();
			});
			
			function startAutoPlay() {
				return setInterval(function() {
					$('ul').roundabout_animateToNextChild();
				}, 5000);
			}
