jQuery(document).ready(function() {
	$('.headerNavigation .small a').click(function() {
		// Remove the alternate stylesheet node and cookie, this is the default
		//getCssNode('alternateFontSize', true).attr('href', 'css/font-size-small.css');
		toggleFontSize('small');
		jQuery.cookie('alternateFontSize', 'small', {expires: 0, path: '/'});
	});

	$('.headerNavigation .medium a').click(function() {
		// Set the alternate stylesheet and cookie to medium
		//getCssNode('alternateFontSize', true).attr('href', 'css/font-size-medium.css');
		toggleFontSize('medium');
		jQuery.cookie('alternateFontSize', 'medium', { expires: 0, path: '/' });
	});

	$('.headerNavigation .big a').click(function() {
		// Set the alternate stylesheet and cookie to big
		//getCssNode('alternateFontSize', true).attr('href', 'css/font-size-big.css');
		toggleFontSize('big');
		jQuery.cookie('alternateFontSize', 'big', { expires: 0, path: '/' });
	});

	function toggleFontSize(size) {
		switch(size) {
			case 'small': $('body').css('font-size', '75%'); break;
			case 'medium': $('body').css('font-size', '90%'); break;
			case 'big': $('body').css('font-size', '115%'); break;
		}
	}

	$('.headerNavigation a.colorize').click(function() {
		var body = $('body');
		if(body.hasClass('black')) {
			body.removeClass('black');
			jQuery.cookie('alternateColor', null, { expires: 0, path: '/' });
		} else {
			body.addClass('black');
			jQuery.cookie('alternateColor', 'true', { expires: 0, path: '/' });
		}
	});

	var alternateFontSizeCookieValue = jQuery.cookie('alternateFontSize');
	if(alternateFontSizeCookieValue) {
		$('.headerNavigation .' + alternateFontSizeCookieValue + ' a').click();
	}

	var alternateColorCookieValue = jQuery.cookie('alternateColor');
	if(alternateColorCookieValue) {
		$('body').addClass('black');
	}

	$('.headerNavigation .lang >li').hoverClass('sfHover');
});
function getCssNode(cssId, create) {
	// Get css node
	var cssNode = $('#' + cssId);

	// If this node does not exist in the DOM, create it if requested
	if(cssNode.length == 0 && create) {
		// Create the stylesheet node
		cssNode = jQuery('<link rel="Stylesheet" media="screen" type="text/css" title="Stylesheet" />');
		cssNode.attr('id', cssId);

		// Append the node at the end of the head
		$('head').append(cssNode);
	}

	return cssNode;
}