jQuery("document").ready(function() {

	function checkChatPing()
	{
		jQuery.ajax({
				url: "/chatping.php",
				data: {"action":"checkPing"},
				type: "POST",
				dataType: "json",
				success: function(msg){
					if(msg.msg == "TRUE")
					{	
						var left = (jQuery(window).width()/2) - 110;
						var alertbox = jQuery("<div>");
						alertbox.attr("id", "chat_request");
						alertbox.attr("style", "position: absolute; z-index:2000 bottom:0px; width:220px; height:auto; padding:10px; left:" + left + "px; border:1px solid #000; background:#FFF;");
						alertbox.html(msg.request_from + " has requested you in chat.  <a href='#' onclick='window.open(\""+msg.link+"\",\"Chatter\",\"width=980, height=455\");return false;'>Click here to enter chat!</a>");
						jQuery("body").append(alertbox);
						alertbox.animate({bottom:jQuery(window).height()-70}, 3000, function() {jQuery(this).animate({opacity:0}, 9000, function() {jQuery(this).remove();});});

					}
				}
		});
		setTimeout(function() {
							checkChatPing();
						}, 60000);
		
		
	}
	
	checkChatPing();

});
