(function($) {
	
	
	
	$.cookie = function (key, value, options) {
    
	    // key and at least value given, set cookie...
	    if (arguments.length > 1 && String(value) !== "[object Object]") {
	        options = jQuery.extend({}, options);

	        if (value === null || value === undefined) {
	            options.expires = -1;
	        }

	        if (typeof options.expires === 'number') {
	            var days = options.expires, t = options.expires = new Date();
	            t.setDate(t.getDate() + days);
	        }
        
	        value = String(value);
        
	        return (document.cookie = [
	            encodeURIComponent(key), '=',
	            options.raw ? value : encodeURIComponent(value),
	            options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
	            options.path ? '; path=' + options.path : '',
	            options.domain ? '; domain=' + options.domain : '',
	            options.secure ? '; secure' : ''
	        ].join(''));
	    }

	    // key and possibly options given, get cookie...
	    options = value || {};
	    var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
	    return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
	};
	
	
	
	
	$(document).ready(function(){
		if(( $.cookie('3lvl_type') == null ) || ($.cookie("3lvl_type") == "ada")) {   
			$("#mod_3lvl_menu_category").css('display', 'inline-block');
		} else {
			$("#mod_3lvl_menu_category").css('display', 'none');
		}
		if($.cookie("3lvl_type") == "keyword") {   
			$("#mod_3lvl_menu_keyword").css('display', 'inline-block');
		} else {
			$("#mod_3lvl_menu_keyword").css('display', 'none');
		}
		$("#cat_jump_button").css('display', 'inline-block');
		$(".customfontresize").css('display', 'inline-block');
		$("#3lvl_ada").removeAttr("href").css("cursor","pointer");
		$("#c3lvl_keywordholder").css('display', 'inline-block');

		// Reset Font Size
		var $cookie_name = "textsize";
		var originalFontSize = $('html').css('font-size');
		if($.cookie($cookie_name)) {
			var $getSize = $.cookie($cookie_name);
			$("html").css({fontSize : $getSize + ($getSize.indexOf("px")!=-1 ? "" : "px")});
		} else {
			$.cookie($cookie_name, originalFontSize);
		}
		$(".resetFont").click(function(){
		  	$('html').css('font-size', originalFontSize);
		  	$.cookie($cookie_name, originalFontSize);
		});
		
		// Increase Font Size
		$(".increaseFont").click(function(){
			var currentFontSize = $('html').css('font-size');
			var currentFontSizeNum = parseFloat(currentFontSize, 10);
		 	var newFontSize = currentFontSizeNum*1.2;
			if (newFontSize < 30) {
				$('html').css('font-size', newFontSize);
				$.cookie($cookie_name, newFontSize);
			}
			return false;
		});
		
		// Decrease Font Size
		$(".decreaseFont").click(function(){
			var currentFontSize = $('html').css('font-size');
			var currentFontSizeNum = parseFloat(currentFontSize, 10);
			var newFontSize = currentFontSizeNum*0.8;
			if (newFontSize > 8) {
				$('html').css('font-size', newFontSize);
				$.cookie($cookie_name, newFontSize);
			}
			return false;
		});
		
	});
})(jQuery );

