function ProcessUserSystemNotification(HTTPResponse){
	//alert('function CheckUserSystemNotification()');
	//alert('HTTPResponse = '+HTTPResponse+'');
	
	if(HTTPResponse!=''){
		SystemNotification=HTTPResponse.split('<!-- Record Separator -->');
		
		for(SystemNotificationCounter=0; SystemNotificationCounter<SystemNotification.length; SystemNotificationCounter++){
			ThisSystemNotification=SystemNotification[SystemNotificationCounter];
			//alert('ThisSystemNotification = '+ThisSystemNotification+'');
			
			Field=ThisSystemNotification.split('<!-- Field Separator -->');
			//alert('ThisSystemNotification = '+ThisSystemNotification+'\n\nField.length = '+Field.length+'');
			
			SystemNotificationTypeName=Field[7];
			
			if(SystemNotificationTypeName == 'Chat request'){
				Detail=Field[4].split('\n');
				
				ChatRoomID=Detail[0].split('=');
				ChatRoomID=ChatRoomID[1];
				
				ChatRoomUUID=Detail[4].split('=');
				ChatRoomUUID=ChatRoomUUID[1];
				
				UserNameRequested=Detail[2].split('=');
				UserNameRequested=UserNameRequested[1];
				
				UserSystemNotificationResponse=confirm(''+UserNameRequested+' wants to talk to you.\n\nDo you want to go to the chat room?');
				if(UserSystemNotificationResponse)ChatRoomWindow=OpenChatWindow(ChatRoomID, ChatRoomUUID, 'ChatRoomWindow');

				HTTPRequest('./acknowledgeusersystemnotification.php?MainContentOnly&UserSystemNotificationID='+Field[0]+'&UserSystemNotificationUUID='+Field[1]+'&UserSystemNotificationResponse='+UserSystemNotificationResponse+'', 'get', true, null);
			}
			
			if(SystemNotificationTypeName == 'Session timed out'){
				alert('Session timed out');
				window.location.href='./home.php';

				HTTPRequest('./acknowledgeusersystemnotification.php?MainContentOnly&UserSystemNotificationID='+Field[0]+'&UserSystemNotificationUUID='+Field[1]+'&UserSystemNotificationResponse=', 'get', true, null);
			}
		}
	}
}

function CheckUserSystemNotification(){
	//alert('function CheckUserSystemNotification()');
	URL='./checkusersystemnotification.php?MainContentOnly&'+Math.floor(Math.random()*99999999);
	//prompt('URL', URL);
	HTTPRequest(URL, 'get', true, ProcessUserSystemNotification);
}

