$(document).ready(function(){
  
  var clickToggle = false;
  $('.sitemaplink').click(function(){
		
		//console.log($("sitemap:first").is(":hidden"));

		$("#sitemap").slideToggle(400, function () {
      		if(clickToggle)
			{
				clickToggle = false;
			}
			else
			{
				clickToggle = true;
				$("html,body").animate({ scrollTop: $(document).height() }, "slow");
			}
    	});
		
	  return false;
  
  });
	//Random bg image
	bgImageTotal=2;
	randomNumber = Math.round(Math.random()*(bgImageTotal-1))+1;
	imgPath=('images/etusivu-bg-'+randomNumber+'.jpg');
	$('#frontpage-content').css('background-image', ('url("' + imgPath + '")'));
  
  // Reset Font Size
  var originalFontSize = $('#text-content p').css('font-size');
  $(".resetFont").click(function(){
    $('#text-content p').css('font-size', originalFontSize);
  });
 
 // Increase Font Size
  $(".increaseFont").click(function(){
    var currentFontSize_p = $('#text-content p').css('font-size');
    var currentFontSizeNum_p = parseFloat(currentFontSize_p, 10);
	var newFontSize_p = currentFontSizeNum_p * 1.2;
	
	if (newFontSize_p < 20)
	{
		$('#text-content p').css('font-size', newFontSize_p);
	}
	
	var currentFontSize_h2 = $('#text-content h2').css('font-size');
    var currentFontSizeNum_h2 = parseFloat(currentFontSize_h2, 10);
	var newFontSize_h2 = currentFontSizeNum_h2 * 1.2;
	
	if (newFontSize_h2 < 22)
	{
		$('#text-content h2').css('font-size', newFontSize_h2);
	}
	return false;
  });
  
  // Decrease Font Size
  $(".decreaseFont").click(function(){
    var currentFontSize_p = $('#text-content p').css('font-size');
    var currentFontSizeNum_p = parseFloat(currentFontSize_p, 10);
	var newFontSize_p = currentFontSizeNum_p * 0.8;
	
	if (newFontSize_p > 9)
	{
		$('#text-content p').css('font-size', newFontSize_p);
	}
	
	var currentFontSize_h2 = $('#text-content h2').css('font-size');
    var currentFontSizeNum_h2 = parseFloat(currentFontSize_h2, 10);
	var newFontSize_h2 = currentFontSizeNum_h2 * 0.8;
	
	if (newFontSize_h2 > 12)
	{
		$('#text-content h2').css('font-size', newFontSize_h2);
	}
	
	return false;
  });
  
  $("#footer .nappi").click(function() {
	    $('#footer .sites').slideToggle();
		return false;
	});
});


