$(function() {
	var playArea = $('#playarea'),
		register = $('#register');
	
	playArea.jqm({ajax: '/inc/showgame.php?g=' + $('a.playGame').attr('id'), trigger: 'a.playGame',
			target: $('#playarea div#hiddendiv'),
			modal: true,
			overlay: 90,
			onShow: function(h) {
			/* callback executed when a trigger click. Show notice */
			h.w.css('opacity',1).fadeIn( ); 
				// Ajax time
				$(document).everyTime(60000,function(i){
					jQuery.ajax({
					  url: "/inc/getgames.php?field=stillplaying&gid=" + $('a.playGame').attr('id'),
					  cache: false,
					  success: function(html){
						// Do nothing right now
					  }
					})
				})


			},

			onHide: function(h) {
			h.w.fadeOut("slow",function() { if(h.o) h.o.remove(); });
			jQuery.get('/inc/getgames.php?field=stillplaying&gid='+ 0);
			$(document).stopTime();
			}


	});
	
	// Horizontall center
	playArea.css({marginLeft : (playArea.width()/2)*(-1)});
	
	register.jqm({ajax: '/register.php', trigger: 'a.registerlink',
					target: $('#register div#registerhidden'),
					modal: true,
					overlay: 80,
					onShow: function(h) {
					/* callback executed when a trigger click. Show notice */
					h.w.css('opacity',1).fadeIn( ); 
					},
					
					onHide: function(h) {
						h.w.fadeOut("slow",function() { if(h.o) h.o.remove(); });
					}
	});
	
	// Horizontall center
	register.css({marginLeft : (register.width()/2)*(-1)});

});
