function saveCookies(all, settings) {
	var requiredCookies = ['realbonus', 'memory', 'COOKIES', 'ANALYTICS', 'MARKETING'];
	if (!all) {
		if (settings) {
			analytics = document.getElementById('acks').checked ? 1 : 0;
			marketing = document.getElementById('mcks').checked ? 1 : 0;
		} else {
			analytics = marketing = 0; 
		}
	} else {
		analytics = marketing = 1;
		if (settings) {
			document.getElementById('acks').checked = true;
			document.getElementById('mcks').checked = true;
		}
	}
	hostname = window.location.hostname;
	exp = hostname.split('.');
	domain = '.' + exp[1] +'.'+ exp[2];
	document.cookie = 'ANALYTICS='+ analytics +'; max-age=31536000; path=/; domain='+ domain;
	document.cookie = 'MARKETING='+ marketing +'; max-age=31536000; path=/; domain='+ domain;
	document.cookie = 'COOKIES=1; path=/; max-age=31536000; domain='+ domain;
	if (!analytics || !marketing) {
		var cookies = document.cookie.split(';');
		for (var i = 0; i < cookies.length; i++) {
			var cookie = cookies[i];
			var eqPos = cookie.indexOf('=');
			var nm = eqPos > -1 ? cookie.substr(0, eqPos).trim() : cookie;
			var reqCookie = false;
			for (var q = 0; q <= requiredCookies.length; q++) {
				if (requiredCookies[q] == nm) {
					reqCookie = true;
					break;
				}
			}
			if (!reqCookie) {
				document.cookie = nm +'=; Max-Age=0; path=/; domain='+ domain;
			}
		}
	}
	if (settings) var hidepopupIds = ['canvas', 'popup'];
	else var hidepopupIds = ['shortpopup'];
	for (var i = 0; i < hidepopupIds.length; i++) {
		id = hidepopupIds[i];
		obj = document.getElementById('cookies-'+ id);
		addClass(obj, 'hidden');  
	}
	if (analytics) {
		$(head_analytics).appendTo('head');
		$(body_analytics).appendTo('body');
	}
	if (marketing) {
		$(head_marketing).appendTo('head');         	
		$(body_marketing).appendTo('body');
	}
	return true;
}

function ocCookieInfo(id) {
	o = document.getElementById(id +'-cookies');
	if (hasClass(o, 'hidden')) {
		removeClass(o, 'hidden');
	} else {
		addClass(o, 'hidden');
	}
	return true;
}

function ocCookiePopup(hideShort) {
	if (hideShort) {
		short_popup = document.getElementById('cookies-shortpopup');
		addClass(short_popup, 'hidden');
	}
	canvas = document.getElementById('cookies-canvas');
	popup = document.getElementById('cookies-popup');
	if (hasClass(canvas, 'hidden')) {
		removeClass(canvas, 'hidden');
		removeClass(popup, 'hidden');
	} else {
		addClass(canvas, 'hidden');
		addClass(popup, 'hidden');
	}
	window.scrollTo(0, 0);
	return true;
}