(function($){
	$.cookie = function(key, value, options) {
		if(arguments.length > 1) {
			var o = $.extend({}, $.cookie.defaults, options);
	        if (value === null || value === undefined) {
	            value = '';
	            o.expires = -1;
	        }
	        if (o.expires.constructor != Date) {
				var today = new Date();
				today.setDate(today.getDate() + o.expires);
				o.expires = today;
			}
			// Converts options to Strings
			o.expires = '; expires=' + o.expires.toUTCString();
			o.path = o.path? '; path=' + (o.path) : '';
			o.domain = o.domain? '; domain=' + (o.domain) : '';
			o.secure = o.secure? '; secure' : '';
			document.cookie = [key, '=', encodeURIComponent(value), o.expires, o.path, o.domain, o.secure].join('');		        
		} else {
			if(result = new RegExp(key+"=(.*?)(?:;|$)").exec(document.cookie))
				return decodeURIComponent(result[1]);
			return false;
		}
	};
	$.cookie.defaults = {
		expires: 365,
		path: '/'
	}
})(jQuery);