// checks if 18+ cookie was set
function is18() {
	return $.cookie('confirm_18') == "yes";
}

// set up 18+ cookie
function set18() {
	var date = new Date();
	date.setTime(date.getTime() + (24 * 60 * 60 * 1000));	
	$.cookie("confirm_18", "yes", { expires: date, path: '/' });
}

function showDialog(d, b, c) {
	$.dialog('<div id="noticeHolder" style="margin: 0pt auto; z-index: 9999; position: relative; top: 78.5px;"><div id=""><div class="dialog ageDialog"><h2>' + d + '</h2><div class="content">' + b + "</div></div></div></div>", function () {
		var g = this,
		h = g.content,
		f = h.find("a, input:visible, select, textarea"),
		e = f.get(0),
		i = f.slice(-1).get(0);
		e.focus();
		h.keydown(function (k) {
			switch (k.keyCode) {
				case 27:
				c.apply(Livesex.global, [null, g]);
				k.preventDefault();
				k.stopPropagation();
				return false;
				case 13:
				if ($(document.activeElement).not("textarea, .button").length) {
					$("#accept-btn").click();
					k.preventDefault();
					k.stopPropagation();
					return false;
				}
				return true;
				case 9:
				if (k.metaKey || k.altKey) {
					return true
				}
				k.preventDefault();
				k.stopPropagation();
				var j = document.activeElement;
				if (j === e && k.shiftKey) {
					i.focus()
				} else {
					if (j === i && !k.shiftKey) {
						e.focus()
					} else {
						f.get(f.index(document.activeElement) + (k.shiftKey ? -1 : 1)).focus()
					}
				}
				return false;
				default:
			}
		});

		$("#accept-btn", h).click(function (j) {
			return c.apply(this, [j, g])
		});
		$('#deny-btn').click(function() { document.location = "http://google.com/"; return false;});
	}, {
		opacity: '0.5'
	});
}
