try {
	var AdminChat = new Class({
	
			initialize: function() {
				
			},			
			setRequest : function()
			{ 
					new Ajax(	"?ac=adminchat&typ=check&isajax=y", {
								method: 'get',
								autoCancel: true,
								evalScripts: true,
								onRequest: function(){
									//$('mdhmaincontent').setHTML( $("mdhmaincontent").innerHTML );
									},
								onSuccess: function(txt){
									if($('admin_chat') != null) {
									$('admin_chat').setHTML( txt );
									
									if(txt != "")
									{
										var Chat = new AdminChat;
										Chat.startbox();
									}
									}
								}	
								}).request();
								
							
			},
			
			getMessages : function(uid , aid )
			{
				var message = $("message");
					new Ajax(	"?ac=adminchat&typ=getmsg&isajax=y&aid=" + aid +"&ua_id=" + uid, {
								method: 'get',
								
								autoCancel: true,
								evalScripts: true,
								onRequest: function()
								{							
									//$('message').setHTML( $("message").innerHTML );
								},
								onSuccess: function(txt){
								
									var fr  = new Element('div', {'class': 'message'});
									fr.innerHTML = txt;
									fr.inject(message);
									
									var scroll = new Fx.Scroll($("message"));
		
									scroll.toBottom(); //go to the top 
								}
								}).request();
			},
			startbox : function()
			{								
					var Chat = new AdminChat();
					this.getMessages($('uid').value , $('aid').value);
					
					var a = $('uid').value;
					intervall = setInterval("getmsg('" + a + "' , '" + a+ "')", 5000);
				
					$('msg').addEvent('focus', function(e) {
						
						if($('msg').value == "Bitte hier die Nachricht reinschreiben...." || $('msg').value == "schrijven hier een bericht...." || $('msg').value == "Type in youre message here....")
						{
							$('msg').value = "";
						}
					});			
										
					$('writeForm').addEvent('keydown', function(event)
					{ 
						var key = event.which;
						
						if(key == 13 && $('msg').value.length > 1)
						{
							Chat.writeMsg($('msg') , $('uid') , $('aid'));
						}
					});
					
					$('writeForm').addEvent('submit', function(e) {
						
						new Event(e).stop();
						
						Chat.writeMsg($('msg') , $('uid') , $('aid'));
					});
					
					var draggableOptions = {
						handle : $("adminchat_drag"),
					    onStart:function()
					    {
					      
					    },
					    onComplete:function()
					    {
		
					    }
					};
							
					$('support_contact').makeDraggable(draggableOptions);	
										
										
					
			},
			writeMsg : function(txt , uid ,  aid)
			{
				if(txt.value.length != 0) 
				{  
				
					new Ajax(	"?ac=adminchat&typ=writemsg&isajax=y", {
								method: 'post',
								autoCancel: true,
								evalScripts: true,
								data: "msg=" + txt.value + "&ua_id=" + uid.value + "&aid=" + aid.value,
								onRequest: function()
								{							
									//$('message').setHTML( $("message").innerHTML );
								},
								onSuccess: function(txt){
								
									
								}
								}).request();
				
					txt.value = "";
					
					//this.getMessages(uid.value , aid.value);
				}
			}					
		});
		
		
	function getmsg(uid , aid)
	{
		var Chat = new AdminChat();
		Chat.getMessages(uid , aid);
	}		
}
catch(err) {}
