
	function open_chat(x,noedit){ /* x is the SID of the Chatroom */
		if(noedit==undefined) noedit=0;
		$.post("ajax/aj_chat.php", { 
			sid: x , option: 'setup',noedit: noedit
			},function(data) {
				//alert(data);
				scrollTo(0,0);
		   		$("#chat_popup").html(data);
		   		$("#chat_popup").fadeIn('1000');
		   		$("#chat_popup").draggable({containment:"body", handle: "#top_bar"});
		 });
	}
	
	function close_chat(){
		$("#chat_popup").fadeOut('1000');
		$("#chat_popup").html('');
		$.post("ajax/aj_chat.php", { 
			option: 'leave_room'
			},function(data) {
				//alert(data);
		 });
	}
	
	function send_message(){
		$.post("ajax/aj_chat.php", { 
			option: 'send', msg: $("#chat_send").val()
			},function(data) {
				//alert(data);
		   		chat_reload();
		   		$("#chat_send").val('');
		 });
	}
	
	function chat_reload(x){
		if(x==undefined){ var x='current';}
		$.post("ajax/aj_chat.php", { 
			option: 'reload', type: x
			},function(data) {
				//alert(data);
				if(data != undefined && data !='')
					$("#current_messages").html(data);
		 });
	}
	
	function del_msg(x,y){
		$.post("ajax/aj_chat.php", { 
			option: 'remove', msgsid: x
			},function(data) {
				//alert(data);
		   		chat_reload(y);
		 });
	}
	
	function load_curmems(x){
		$.post("ajax/aj_chat.php", { 
			option: 'reload_mems', sid: x
			},function(data) {
				//alert(data);
		   		$("#who_is_here").html(data);
		 });
	}
	
/*ADMIN ONLINE DATE ARCHIVE*/
	function archive_view_msg(x){ /* x is the SID of the Message */
		$.post("ajax/aj_chat.php", { 
			sid: x , option: 'show_message'
			},function(data) {
				//alert(data);
				scrollTo(0,0);
		   		$("#archive_msg_popup").html(data);
		   		$("#archive_msg_popup").fadeIn('1000');
		   		$("#archive_msg_popup").draggable({containment:"body", handle: "#top_bar"});
		 });
	}
	
	function archive_msg_close(){
		$("#archive_msg_popup").fadeOut('1000');
		$("#archive_msg_popup").html('');
	}

