$(document).ready(function(){
	
	var logoheight = $('#header .leftside .logo img').height();

	$('#header .leftside .links').css('height', logoheight + 'px');
	$('#header .leftside .links a').css('line-height', logoheight + 'px');

	$('#header .rightside .form .unameinput input').click(function() {
		if(this.value === 'Käyttäjätunnus' || this.value === 'Username') {
			this.value = '';
		}
	});	
	$('#header .rightside .form .passinput input').click(function() {
		if(this.value === 'Salasana' || this.value === 'Password') {
			this.value = '';
		}
	});

	var h2toppadding = $('h2').css('padding-top');
	if(h2toppadding)
		$('#content .middle .kuva').css('margin-top', (parseInt(h2toppadding.substring(0, (h2toppadding.length - 2))) + 3) + 'px');

	// Set fontsize
	  var newFontSize = $.cookie('FontSize_Cookie');
	  if(newFontSize == null)
		newFontSize = $('body').css('font-size');

	  $('body').css('font-size', newFontSize);
	  
	  // Increase Font Size
	  $("#increase").click(function(){

		var currentFontSize = $.cookie('FontSize_Cookie');
	
		if(currentFontSize == null)
			currentFontSize = $('body').css('font-size');

		var currentFontSizeNum = parseFloat(currentFontSize, 10);
		if(currentFontSizeNum < 16) { 
				var newFontSize = currentFontSizeNum+1;
			$('body').css('font-size', newFontSize);
			leaveCookie();
		}
		return false;
	  });


	  // Decrease Font Size
	  $("#decrease").click(function(){

		var currentFontSize = $.cookie('FontSize_Cookie');
		if(currentFontSize == null)
			currentFontSize = $('body').css('font-size');

		var currentFontSizeNum = parseFloat(currentFontSize, 10);
		if(currentFontSizeNum > 10) { 
				var newFontSize = currentFontSizeNum-1;
			$('body').css('font-size', newFontSize);
			leaveCookie();
		}
		return false;
	  });


	  // Reset Font Size
	  $("#resetFont").click(function(){
		$('body').css('font-size', '12px');
	  });


	  // Set current fontsize to cookie
	  function leaveCookie() {
		var FontSize = $('body').css('font-size');

			var options = { 
			path: '/', 
			expires: 30 
		};
					
			$.cookie('FontSize_Cookie', FontSize, options);
			return false;
	  }


});
