/*
*	JS	to	do	some	action.
*/

$(document).ready(function() {
	
	//Liikkuvat sanat
	var add = 60;
	var adjust = (parseInt($(window).width()) / 2) + add;

	$("#left_word").css('left',-adjust+'px');
	$("#right_word").css('right',-adjust+'px');
	
	setTimeout("animoiSanat()",400);
	
	
	
	
	//Valikon animointi
	$("#menu li a").hover(function() {
		$(this).animate({
		paddingTop: "+=8px"
		
		}, "fast");

	}, function() {
		$(this).animate({
		paddingTop: "-=8px"
		}, "fast");
	});
	
	
	// Contact-button
	$("#open_dialog").show();
	$("#open_dialog").hover(function() {
		$(this).animate({
		right: "0px"
		
		}, "fast");

	}, function() {
		$(this).animate({
		right: "-5px"
		}, "fast");
	});
	
	// Fancybox
	$("#open_dialog a").fancybox();
	$("a.iframe").fancybox({
		'width'		: 930,
		'height'	: 670
	});
	
	
});

function animoiSanat() {
	$("#left_word").animate( {
		left: "-130px"
	}, laskeNopeus());
	
		$("#right_word").animate( {
		right: "-130px"
	}, laskeNopeus());
	
}

function laskeNopeus() {
	var default_speed = 100;
	var default_width = 800;
	var current_width = parseInt($(window).width()) / 2;
	
	return parseInt((current_width/default_width) * default_speed);
	
}

