$(document).ready(function(){
	//if( $.browser.msie && '6.0' == $.browser.version ) {
	//	alert("本聊天室不支持 MSIE6.0!\nOur chat room DO NOT support MSIE6.0!");
	//}

	emotion =new Array();
	emotion[1] = ":)";
	emotion[2] = ":>";
	emotion[3] = ":]";
	emotion[4] = ":P";
	emotion[5] = ";P";	
	emotion[6] = ";)";
	emotion[7] = ":|";
	emotion[8] = ":(";
	emotion[9] = ":[";	
	
	function sendcommand(send_mes)
	{
		$.post(
			   'senddata.php',
			   {
			   'login':'',
			   'datatype': datatype,
			   'private_id': private_id,
			   'room': room,
			   'msg': send_mes
			   },
			   function(){}
		);	
		return false;
	}	
	function getCookie(cookie_name)
	{
		var allcookies = document.cookie;
		var cookie_pos = allcookies.indexOf(cookie_name);
		
		if (cookie_pos != -1)
		{
			cookie_pos += cookie_name.length + 1;
			var cookie_end = allcookies.indexOf(";", cookie_pos);
			
			if (cookie_end == -1)
			{
			cookie_end = allcookies.length;
			}
			
			var value = unescape(allcookies.substring(cookie_pos, cookie_end));
		}
		
		return value;
	}

	var cookie_val = getCookie("LTChart_user_rights");
	
	
	$("#exit_button").click(function(){
		sendcommand('/exit');
		return false;
	});
	
	$("#clear_button").click(function(){
		sendcommand('/clear');
		return false;
	});

	$(".emotions").click(function(){
		var click_id = $(this).attr("id").substr(5);
		$("#message").val( $("#message").val() + ' ' + emotion[click_id] + ' ' ).focus();
		return false;
	});

	if (cookie_val != "Guest")
	{
		$("#select_avatar").show();
		$("#com_kick").show();
		$("#select_avatar").show();
		$("#kick_user_str").show();
	}
	
	$("#select_avatar").click(function(){
		sendcommand('/avatar');
	});	
	
	$("#com_kick").click(function(){
		var kick_user_str = $("#kick_user_str").val();
		if ('' != kick_user_str)
		{
			sendcommand('/kick ' + kick_user_str + ' blocked');	
		}
		$("#kick_user_str").val("");
	})	

});
