$(document).ready(
	function(){
		window.setInterval(
			function(){
				$.get("notif_chat.php", function(data){
					if(data.length>0){
						if(true){
							if(confirm("Une personne aimerait discuter avec vous par tchat. Voulez-vous accepter la conversation ?")){
								$.get("notif_chat.php?supp=" + data);
								setTimeout(function(){
									window.open("chat.php?SAL_ID="+data,'Chat','menubar=no, status=no, scrollbars=no, menubar=no, width=640, height=500');
								},1000);
							}
						}
					}
				});
			}
		,10000
		);


		window.setInterval(
			function(){
				$.get("notif_messagerie.php", function(data){
					if(data.length>0 && isNumeric(data)){
						if(true){
							if(confirm("Vous avez reçu un nouveau message. Voulez-vous accepter le voir ?")){
								setTimeout(function(){
									window.location = "messagerie.php";
								},1000);
							}
						}
					}
				});
			}
		,10000
		);


	}
);
function isNumeric(x) {
	var RegExp = /^(-)?(\d*)(\.?)(\d*)$/; // Note: this WILL allow a number that ends in a decimal: -452.
	var result = x.match(RegExp);
	return result;
}

