/* retrieves the correct username via RPC, based on the fe_user_id or user_id, or whatever exists in the relevant scopes */
$(function(){
	$.getJSON("/applications/rpc/getusername.rm", function(data){
	
		if(data.username.length){
			$('#digichatPlaceholder').html('<p>We are automatically logging you into the chat rooms, please be patient.</p><applet name="DigiChat" codebase="http://www.stroke.org.uk/applications/digichat/DigiClasses/" code="com.diginet.digichat.client.DigiChatApplet" archive="Client_5_1_0_2.jar" id="digichatApplet" height="100" width="200" mayscript><param name="browserClose" value="false"><param name="siteid" value="1000"><param name="background" value="FFFFFF"><param name="textcolor" value="000000"><param name="LeftAlignLogo" value="true"><param name="HttpServlet" value="http://www.stroke.org.uk/tunnel"><param name="preferredPort" value="8080"><param name="Nickname" value="' + data.username + '"></applet>');
		}else{
			$('#digichatPlaceholder').html('<p>Please enter a nickname by which you wish to be known.</p><applet name="DigiChat" codebase="http://www.stroke.org.uk/applications/digichat/DigiClasses/" code="com.diginet.digichat.client.DigiChatApplet" archive="Client_5_1_0_2.jar" id="digichatApplet" height="100" width="200" mayscript><param name="browserClose" value="false"><param name="siteid" value="1000"><param name="background" value="FFFFFF"><param name="textcolor" value="000000"><param name="LeftAlignLogo" value="true"><param name="HttpServlet" value="http://www.stroke.org.uk/tunnel"><param name="preferredPort" value="8080"></applet>');
		}
	});
});
