// JavaScript Document
$(function() {
	$("#nav_top .paamenu").hover(
		function() {
			$(this).find(".subnav").stop(true, true).show("normal");
		},
	
		function() {
			$(this).find(".subnav").hide("normal");
		}
	);
	
		$("#nav_bottom .paamenu").hover(
		function() {
			$(this).find(".subnav").stop(true, true).css('top', -70).show();
		},
	
		function() {
			$(this).find(".subnav").hide();
		}
	);
	
	//Kalenterin tulevat ja menneet
	
	$("#menneet").css("color","#ccc");
	$("#tulevat").live('click', function (e) {
	e.preventDefault();
	$(this).css("color","#fff");
	$("#menneet").css("color","#ccc");
	$("#cal_menneet").stop().fadeOut('fast', function () {							  
	$("#cal_tulevat").stop().fadeIn('fast');
	});
	});
	$("#menneet").live('click', function (e) {
	e.preventDefault();
	$(this).css("color","#fff");
	$("#tulevat").css("color","#ccc");
	$("#cal_tulevat").stop().fadeOut('fast', function () {								  
	$("#cal_menneet").stop().fadeIn('fast');							  
	});
	});
	
	//Päämenun klikin disablointi jos alamenuja
	$('.paamenu a').click(function(e) {
	var sib = $(this).siblings().size();
	if (sib > 0) {
	e.preventDefault();
	}
	});

$(window).load(function(){
	$('.thumb').each(function () { 
    var image_height = $(this).children().height();  
    var top_margin = (161 - image_height)/2;    
    $(this).children().css( 'margin-top' , top_margin);  
	});
});
$(window).load(function(){
	$('.thumb').each(function () { 
    var image_width = $(this).children().width();  
    var left_margin = (161 - image_width)/2;    
    $(this).children().css( 'margin-left' , left_margin); 
	$(this).css('visibility', 'visible');
	});
});
	var height = $(document).height();
	if (height > 1300) {
	$(".blog_tree").show();	
	}
	else {
	$(".blog_tree").hide();	
	}

});
