$(document).ready(function()
{

	$("#gs .v a").bind('click', function (/*Event*/event)
	{
		OpenGame($(this).attr('href'), $(this).attr('rel'));
		event.stopPropagation();
		return false;
	});

	$("#gs div.close img").mousedown(function()
	{
		$("#gs").dialog('close');
	})

	$("#gs .public .v a").attr('rel', '_public');
	$("#gs .comfort .v a").attr('rel', '_comfort');
	$("#gs .vip .v a").attr('rel', '_vip');

	$.each($('.content-holder td.ct a'), function (i, v)
	{
		var a = $(v);
		a.bind('click', function(/* Event */event)
		{
			var gid = new String($(this).attr('href'));
			var g = getGame(gid);
			if (!g || undefined === g.real) {
				alert('game not found ' + gid);
				return;
			}
			if (undefined !== g.external && g.external)
			{
				document.location = g.path;
				return;
			}
			$("#gs .v a").attr('href', gid);
			$("#gs .public .v a").text(g.real._public.t);
			$("#gs .vip .v a").text(g.real._vip.t);
			$("#gs .comfort .v a").text(g.real._comfort.t);

			$('#gs').dialog({
				draggable : false,
				resizable : false,
				title: g.caption,
				width: 360,
				height: 220,//245
				modal: true,
				overlay: {
					opacity: 0.7,
					background: "black"
				}
			});

			event.stopPropagation();
			return false;
		});

//		var nh = new String(a.attr("href"));
//		nh = nh.replace(/.+=(.+)/gi, "$1");
//		a.attr("href", "#" + nh);
	});

});