$(document).ready( function() {
	
	// Changing font size
	$('#fontsize a').click( function () {
		changeFont(this.getAttribute("rel"));
		createCookie('font-size', this.getAttribute("rel"), 365);
		return false;
	});
	function changeFont (fontSize) {
		$('body').removeClass().addClass(fontSize);
	}
	
	// Switching styles	
	$('#switcher a').click(function() {
		switchStylesheet(this.getAttribute("rel"));
		createCookie('style', this.getAttribute("rel"), 365);
		return false;
	});
	function switchStylesheet (styleName) {
		$('link[@rel*=style]').each(function() {
			this.disabled = true;
			if (this.getAttribute('title') == styleName) this.disabled = false;
		});
	}
	
	// Reseting all styles
	$('#reset a').click(function() {
		$('body').removeClass();
		switchStylesheet('original');
		eraseCookie('style');
		eraseCookie('font-size');
		return false;
	});
	
	// Toggling panel
	$('#closepanel').click( function () {
		$('#acc-panel-main').toggle();
		return false;
	});
	
	// Reading the cookies and setting off functions
	var c = readCookie('style');
	var d = readCookie('font-size');
	if (c) switchStylesheet(c);
	if (d) changeFont(d);

	// Fading in panel on load
	$('#acc-panel').hide().fadeIn("slow");
	
});