/* 获取字符串长度 */
String.prototype.l2 = function(){
	var cArr = this.match(/[^\x00-\xff]/ig);
	return this.length+(cArr==null?0:cArr.length);
}
/*********************************朋友拖拽************************************/
function stopBubble(e) {
	if (!e)
		e = window.event;
	e.cancelBubble = true;
	if (e.stopPropagation)
		e.stopPropagation();
}

function onMouseOut(id){
	var friendDiv = document.getElementById(id);
	friendDiv.style.backgroundColor="#F3F3F3";
}
function onMouseOver(id){
	var friendDiv = document.getElementById(id);
	friendDiv.style.backgroundColor = "#DEE4EB";
	friendDiv.style.cursor="move";
}
/********************************朋友列表管理 by yexin***************************************/

function openOrClose(i){
		if(document.getElementById("group-friends-" + i)!=null) {
			var temp=document.getElementById("group-friends-"+i).style.display;//window.alert(temp);
			if(temp=="none") {
				document.getElementById("group-friends-"+i).style.display='';
			}
			else
			{
				document.getElementById("group-friends-"+i).style.display='none';
			}
		}
}

  function updateFriendList(url, selectedUser) {
  	
  	new Ajax.Updater("friends", 
  	"/friend.do?method=groupList", 
  	{
  		method:"get", 
  		parameters:"url="+url+"&user="+selectedUser
  	}
  	);	
  	
  }

//////////////////

var Obj;
var oMove;
var temp;
var iii;
var tempCursor;
var hasIt;


function onClickFriend(theUrl,uid){//window.alert(theHasIt);
		window.location.href=theUrl+"user="+uid;
}

function filter() {

	var groupNames = document.getElementsByClassName('group-name');
	var friendNames = document.getElementsByClassName('friend-name');
	var key = $('friend-filter').value;
	key=key.strip();
	if (key.length < 1) {
		// filter为空，全部显示
		groupNames.each(
			function(groupName) {
				groupName.style.display = 'block';
				groupName.className = 'group-name';
			}
		);
		friendNames.each(
			function(friendName) {
				friendName.style.display = 'block';
			}
		);
	} else {
		groupNames.each(
			function(groupName) {
				groupName.style.display = 'none';
				groupName.className = 'group-name group-name-collapsed';
			}
		);
		// 隐藏不匹配的朋友
		friendNames.each(
			function(friendName) {
				var child = friendName.firstChild;
				while (child.nodeType != 1)
					child = child.nextSibling;
				if (child.innerHTML.indexOf(key) != -1) {
					// 首先显示组名
					var groupId = friendName.id.split('-')[1];
					if (groupId == '')
						groupId = '-1';
					var groupName = $('group-name-' + groupId);
					groupName.style.display = 'block';
					groupName.className = 'group-name';
					
					friendName.style.display = 'block';
				}
				else
					friendName.style.display = 'none';
			}
		);
	}
}

function manageGroups(){//window.alert("");

	document.getElementById("save").style.display="";
	document.getElementById("add-group").style.display="";

	var groupsDiv = document.getElementById("groups");
	var ii,jj,xx;
	
	for(ii=0;ii<groupsDiv.childNodes.length;ii++){
		var mm = -1;
		if(groupsDiv.childNodes[ii].id!=null)
			mm=groupsDiv.childNodes[ii].id.indexOf("thegroup");
		if(mm!=-1)
		{	
			var child = groupsDiv.childNodes[ii];
			for(jj=0;jj<child.childNodes.length;jj++)
			{
				if(child.childNodes[jj].id!=null)
				{
					var ID = "";
					ID = child.childNodes[jj].id;
					var group = child.childNodes[jj];
					if(ID.indexOf("group-name")!=-1)
					{
						document.getElementById("control-"+ID).style.display = "";
					}
				}
			}
		}
	}
}



function isInOtherGroup(fid,gid){
	var groupsDiv = document.getElementById("groups");
	var ii,jj,xx;
	hasIt=false;
	for(ii=0;ii<groupsDiv.childNodes.length;ii++){
		var mm = -1;
		if(groupsDiv.childNodes[ii].id!=null)
			mm=groupsDiv.childNodes[ii].id.indexOf("group-");
		//window.alert(mm);
		if(mm!=-1)
		{
			var child = groupsDiv.childNodes[ii];
			for(jj=0;jj<child.childNodes.length;jj++)
			{
				if(child.childNodes[jj].id!=null)
				{
					var ID = "";
					ID = child.childNodes[jj].id;
					//window.alert(ID);
					var group = child.childNodes[jj];
					if(ID.indexOf("group-name-")==-1)
					{	//window.alert(ID);
						var groupId = ID.substring(14);
					//	window.alert(groupId);
						if(groupId!=gid){
							for(xx=0;xx<group.childNodes.length;xx++)
							{
								if(group.childNodes[xx].id!=null)
								{
									var friend = new String();
									friend = group.childNodes[xx].id;
									//window.alert("saveChange:"+friend);
									var index = friend.lastIndexOf("-");
									var friendId = friend.substring(index+1);
									if(friendId==fid){
										hasIt=true;
										break;
									}
								}
							}
						}
					}
				}
				if(hasIt==true)
					break;
			}
		}
	}	
}

function changeFriendNum(groupId,num){

	var numSpan = document.getElementById("group-num-"+groupId);
	var number = numSpan.innerHTML;
	var intNumber = parseInt(number);
	intNumber = intNumber+num;
	//window.alert(intNumber);
	number =  intNumber;
	document.getElementById("group-num-"+groupId).innerHTML = number;
	
}


function saveChange(){
	var confirm = window.confirm("确定修改？");
	if(confirm==false)
		return;
	var groupsDiv = document.getElementById("groups");
	var ii,jj,xx;
	var userGroup ="";
	for(ii=0;ii<groupsDiv.childNodes.length;ii++){
		var mm = -1;
		if(groupsDiv.childNodes[ii].id!=null)
			mm=groupsDiv.childNodes[ii].id.indexOf("group-");
		if(mm!=-1)
		{	
			var child = groupsDiv.childNodes[ii];
			for(jj=0;jj<child.childNodes.length;jj++)
			{
				if(child.childNodes[jj].id!=null)
				{
					var ID = "";
					ID = child.childNodes[jj].id;
					var group = child.childNodes[jj];
					if(ID.indexOf("group-name-")==-1)
					{
						var groupId = ID.substring(14);
						if(userGroup=="")
							userGroup=userGroup+groupId;
						else
							userGroup=userGroup+";"+groupId;
						for(xx=0;xx<group.childNodes.length;xx++)
						{
							if(group.childNodes[xx].id!=null)
							{
								if(group.childNodes[xx].id.indexOf("friend-")!=-1){
									var friend = new String();
									friend = group.childNodes[xx].id;
									var index = friend.lastIndexOf("-");
									var friendId = friend.substring(index+1);
									userGroup=userGroup+","+friendId;
								}
							}
						}
					}
				}
			}
		}
	}
	window.location.href = "friend.do?method=changeOrderByUserGroups&usergroups="+userGroup;

}


function changeGroupName(groupId) {
	var inputName = new String();
	inputName = document.getElementById("input-group-name-"+groupId).value;
	if(inputName.length==0 || inputName.length > 32)
		return;
	
	
	var url = "friend.do?method=editGroupName&groupName="+encodeURIComponent(inputName)+"&gid="+groupId;
	new Ajax.Request(
	url + "&" + getDateString(),
	{
		method: 'get',
		onSuccess: function() {
			if ($('input-group-name-' + groupId)) {
				Effect.Fade('input-group-name-' + groupId);
			}
			document.getElementById("group-name-"+groupId).innerHTML = inputName;		
		}		
	}
	);
	
}

function ajaxDelGroup(groupId){
	
	var groupName = document.getElementById("group-name-"+groupId).innerHTML.strip();
	
	var confirm = window.confirm('你确定删除 "' + groupName + '" 组吗?');
	
	if(confirm==false)
		return;
		
	new Ajax.Request(
	"friend.do?method=ajaxDelGroup&gid=" + groupId + "&" + getDateString(),
	{
		method: 'get',
		onSuccess: function() {
			if ($('group-ui-li-' + groupId)) {
				Effect.Fade('group-ui-li-' + groupId);
			}
					
		}		
	}
	);
	
}

function addFriend(fid){
	var div = document.getElementById("groups-"+fid);
	if(div.style.display=="none"){
		div.style.display="block";
	}
	else{
		div.style.display="none";
	}
	
}

function ajaxDelFriend(fName, fid){
	var confirm = window.confirm('你确定从朋友中删除"' + fName + '"吗?  ');
	if(confirm==false)
		return;
		
	new Ajax.Request(
	"/friend.do?method=ajaxDelFriend&fid=" + fid + "&" + getDateString(),
	{
		method: 'get',
		onSuccess: function() {
			if ($('friend-' + fid)) {
				Effect.Fade('friend-' + fid);
			}
			if ($('friends-count')) {
				var count = parseInt($('friends-count').innerHTML) - 1;
				$('friends-count').innerHTML = count;
			}			
		}		
	}
	);
	
}

function delFriend(fid){
	var confirm = window.confirm("从朋友中去掉此人？ ");
	if(confirm==false)
		return;
	window.location.href="/friend.do?method=delFriend&fid="+fid+"&url="+encodeURIComponent(window.location.href);
}

function delFriendFromList(fid){
	var confirm = window.confirm("从朋友列表中删除此人？ ");
	if(confirm==false)
		return;
	window.location.href="/friend.do?method=delFriend&fid="+fid+"&url="+encodeURIComponent(window.location.href);
}

function changeGroup(fid , gid){
	var imgDiv = document.getElementById("img-"+fid+"-"+gid);
	if(imgDiv.src.indexOf("/images/checked.gif")!=-1){
		imgDiv.src="/images/unchecked.gif";
	}
	else{
		imgDiv.src="/images/checked.gif";
	}
}

function chooseFriendByClick(gid,fid,fname){
	var imgDiv = document.getElementById("img-"+gid+"-"+fid);
	var friendList = document.getElementById("friend-list").innerHTML;
	var friends = friendList.split(" ");
	if(imgDiv.src.indexOf("/images/checked.gif")!=-1){
		imgDiv.src="/images/unchecked.gif";
		var ii;
		var len = friends.length;
		for(ii=0;ii<len;ii++){
			if(friends[ii]==fname){
				friends[ii]="";
				break;
			}
		}
		var list = "";
		for(ii=0;ii<len;ii++){
			if(friends[ii]!=""){
				list = list + friends[ii] + " ";
			}
		}
		document.getElementById("friend-list").innerHTML = list;
	}
	else{
		imgDiv.src="/images/checked.gif";
		friendList = friendList + fname + " ";
		document.getElementById("friend-list").innerHTML = friendList;
	}
}

function chooseGroupByClick(gid){
	var groupDiv = document.getElementById("group-friends-"+gid);
	var friendList = document.getElementById("friend-list").innerHTML;
	var friends = friendList.split(" ");
	var imgDiv = document.getElementById("img-"+gid);
	if(imgDiv.src.indexOf("/images/checked.gif")!=-1){
		imgDiv.src="/images/unchecked.gif";
		var ii;
		for(ii=0;ii<groupDiv.childNodes.length;ii++){
			if(groupDiv.childNodes[ii].id!=null)
			{
				if(groupDiv.childNodes[ii].id.indexOf("friend-")!=-1){
				
					var index = groupDiv.childNodes[ii].id.indexOf("-");
					var imgId = "img-"+groupDiv.childNodes[ii].id.substring(index+1);
					var img = document.getElementById(imgId);
					
					if(img.src.indexOf("/images/unchecked.gif")==-1){
						
						img.src="/images/unchecked.gif";
					
						var fname = document.getElementById("name-"+groupDiv.childNodes[ii].id).innerHTML;
						var index2 = fname.indexOf(" (");
						fname = fname.substring(0,index2);
							var jj;
							var len = friends.length;
							for(jj=0;jj<len;jj++){
								if(friends[jj]==fname){
									friends[jj]="";
									break;
								}
							}				
					}	
				}
			}
		}
		var list = "";
		for(ii=0;ii<len;ii++){
			if(friends[ii]!=""){
				list = list + friends[ii] + " ";
			}
		}
		document.getElementById("friend-list").innerHTML = list;	
		
	}
	else{
		imgDiv.src="/images/checked.gif";
		var ii;
		for(ii=0;ii<groupDiv.childNodes.length;ii++){
			if(groupDiv.childNodes[ii].id!=null){
				if(groupDiv.childNodes[ii].id.indexOf("friend-")!=-1){
					var index = groupDiv.childNodes[ii].id.indexOf("-");
					var imgId = "img-"+groupDiv.childNodes[ii].id.substring(index+1);
					var img = document.getElementById(imgId);
					
					if(img.src.indexOf("/images/checked.gif")==-1){
						
						img.src="/images/checked.gif";
						
						var fname = document.getElementById("name-"+groupDiv.childNodes[ii].id).innerHTML;
						var index2 = fname.indexOf(" (");
						fname = fname.substring(0,index2);
						friendList = friendList+fname+" ";		
						document.getElementById("friend-list").innerHTML = friendList;
					}
	
				}
			}
		}	
	}
}


function showChangeGroup(friendName, friendId) {
	
	
	var popupName = 'group-list-' + friendId;
	var popup = $(popupName);
	if (!popup) {
		var posLeft = 270;
		var posTop = 65;
		var pos = Position.cumulativeOffset($('friend-' + friendId));
		
		popup = document.createElement('div');
		popup.id = popupName;
		popup.style.border = '2px outset #0066CC';
		popup.style.position = 'absolute';
		popup.style.left = pos.left + posLeft + 'px';
		popup.style.top = pos.top + posTop + 'px';
		popup.style.width = '350px';
		popup.style.zIndex = '10';
		//popup.style.textAlign = 'left';
		popup.style.background = '#FFFFFF';
		
		var head = document.createElement('div');
		head.id = popupName + '-head';
		head.style.height = '15px';
		head.style.padding = '5px';
		head.style.color = '#FFFFFF';
		head.style.backgroundColor = '#155FA9';
		head.innerHTML = '<a onclick="Element.hide(\'' + popupName + '\')" class="right hand"><img src="/images/icon_close_window.gif"　alt="关闭" title="关闭"／></a>调整'+ friendName+'所属组</div>';
		popup.appendChild(head);
		
		var body = document.createElement('div');
		body.id = popupName + '-body';
		//body.style.height = '400px';
		//body.style.overflow = 'auto';
		body.style.background = '#FFFFFF';
		body.style.padding = '5px';

		body.innerHTML = '<div class="working-img"></div>';
		popup.appendChild(body);
		

		var foot = document.createElement('div');
		foot.id = popupName + '-foot';
		foot.style.paddingBottom = '8px';
		foot.style.background = '#FFFFFF';
		foot.style.textAlign = 'center';
		foot.innerHTML = '<a href="javascript:confirmFriendGroups(' + friendId + ')">' +
			'<img src="/images/button_ok.gif" /></a>' +
			'<div style="color:green;display:none"	id="success-' + friendId +'">调整成功</div>'
		popup.appendChild(foot);

		document.body.appendChild(popup);
		
		new Ajax.Request(
			'/friend.do?method=ajaxChooseFriendGroup&friendId=' + friendId + '&' + getDateString(),
			{
				method: 'get',
				onSuccess: function(request) {
					$(body.id).innerHTML = request.responseText;
				}
			}
		);
		
		
		
	} else {
		
		popup.style.display = 'block';
	}
	
	Event.observe(document, 'click', function(e) {
		var clicked = Event.element(e);
		if (!(clicked.descendantOf(popup) || clicked == popup))
				Element.hide(popup);
			});
}

function filterToChooseFriend(){

	var groupNames = document.getElementsByClassName('yexin-group-name');
	var friendNames = document.getElementsByClassName('yexin-friend-name');
	var key = $('friend-filter').value;
	key=key.strip();
	//key._caseSensitive = false;
	if (key.length < 1) {
		// filter为空，全部显示
		groupNames.each(
			function(groupName) {
				var id = groupName.id.substring(11);
				var img = document.getElementById("img-"+id);
				
				if (img) {
					img.style.display = 'block';
				}
				groupName.style.display = '';
				groupName.className = 'yexin-group-name';
			}
		);
		friendNames.each(
			function(friendName) {
				friendName.style.display = 'block';
			}
		);
	} else {
		groupNames.each(
			function(groupName) {
				var id = groupName.id.substring(11);
				var img = document.getElementById("img-"+id);
				
				if (img) {
					img.style.display = 'none';
				}
				groupName.style.display = 'none';
				groupName.className = 'yexin-group-name';
			}
		);
		// 隐藏不匹配的朋友
		friendNames.each(
			function(friendName) {
				var friendId = friendName.id;//window.alert("key.toLowerCase()");
				if(document.getElementById("name-"+friendId).innerHTML.toLowerCase().indexOf(key.toLowerCase())!=-1){
				
					var groupId = friendName.id.split('-')[1];
					if (groupId == '')
						groupId = '-1';
					var groupName = $('group-name-' + groupId);
					
					var img = $("img-"+groupId);
					if (img) {
						img.hide();
					}
					
					groupName.style.display = 'block';
					groupName.className = 'yexin-group-name';
					
					friendName.style.display = 'block';
				}
				else
					friendName.style.display = 'none';
			}
		);
	}	
}

function filterFriend(){

	var groupNames = document.getElementsByClassName('yexin-group-name');
	var friendNames = document.getElementsByClassName('yexin-friend-name');
	var key = $('friend-filter').value;
	key=key.strip();
	//key._caseSensitive = false;
	if (key.length < 1) {
		// filter为空，全部显示
		groupNames.each(
			function(groupName) {
				var id = groupName.id.substring(11);
				groupName.style.display = '';
				groupName.className = 'yexin-group-name';
			}
		);
		friendNames.each(
			function(friendName) {
				friendName.style.display = 'block';
			}
		);
	} else {
		groupNames.each(
			function(groupName) {
				var id = groupName.id.substring(11);
				groupName.style.display = 'none';
				groupName.className = 'yexin-group-name';
			}
		);
		// 隐藏不匹配的朋友
		friendNames.each(
			function(friendName) {
				var friendId = friendName.id;//window.alert("key.toLowerCase()");
				if(document.getElementById("name-"+friendId).innerHTML.toLowerCase().indexOf(key.toLowerCase())!=-1){
				
					var groupId = friendName.id.split('-')[1];
					if (groupId == '')
						groupId = '-1';
					var groupName = $('group-name-' + groupId);
					groupName.style.display = 'block';
					groupName.className = 'yexin-group-name';
					friendName.style.display = 'block';
				}
				else
					friendName.style.display = 'none';
			}
		);
	}	
}
function listAllChecked(){
	document.getElementById("all-checked").style.display="none";
	document.getElementById("all-friends").style.display="";
	var friendNames = document.getElementsByClassName('yexin-friend-name');
	
		friendNames.each(
			function(friendName) {
				var id = friendName.id.substring(7);
				var img = document.getElementById("img-"+id);
				
				if(img.src.indexOf("/images/checked.gif")!=-1){
					friendName.style.display = '';
				}
				else{
					friendName.style.display = 'none';
				}
			}
		);
}
function uncheckAllFriends() {
	var friendNames = document.getElementsByClassName('yexin-friend-name');
	$('friend-list').innerHTML = '';
	
	friendNames.each(
		function(friendName) {
			var id = friendName.id.substring(7);
			var img = document.getElementById("img-"+id);
			
			img.src = "/images/unchecked.gif";
		}
	);
	
	var groupNames = document.getElementsByClassName('yexin-group-name');
	groupNames.each(
		function(groupName) {
			var img = groupName.parentNode.previousSibling;
			while (img.nodeType != 1)
				img = img.previousSibling;
			img.src = "/images/unchecked.gif";
		}
	);
}
function listAllFriends(){
	document.getElementById("all-checked").style.display="";
	document.getElementById("all-friends").style.display="none";
	var friendNames = document.getElementsByClassName('yexin-friend-name');
	
		friendNames.each(
			function(friendName) {
				friendName.style.display = '';
			}
		);
}

function addToGroupForSearch(fid){
	var groups = document.getElementsByClassName("the-friend-group-img-"+fid);
	var groupList="";
	groups.each(
		function(group) {			
			if(group.src.indexOf("/images/checked.gif")!=-1){
				var index = group.id.lastIndexOf("-");
				var id = group.id.substring(index+1);
				if(groupList.length!=0)
					groupList=groupList+","+id;
				else
					groupList=id;
			}
		}
	);
	var message = "no";
	var content = "";
	var src = document.getElementById("message-yes"+"-"+fid).src;
	if(src.indexOf("/images/checked.gif")!=-1){
		message = "yes";
		content = document.getElementById("message-input"+"-"+fid).value;
	}
	if(groupList.length==0)
		window.location.href="/friend.do?method=addToGroups&uid="+fid+"&gid=-1&message="+message+"&content="+content+"&url="+encodeURIComponent(window.location.href)+ '&' + getDateString();
		//window.location.href="/friend.do?method=add&uid="+fid+"&gid=-1"+"&message="+message+"&content="+content+"&url="+encodeURIComponent(window.location.href)+ '&' + getDateString();
	else
		window.location.href="/friend.do?method=addToGroups&uid="+fid+"&gid="+groupList+"&message="+message+"&content="+content+"&url="+encodeURIComponent(window.location.href)+ '&' + getDateString();
}
/******************************add_friend and del_friend***************************************************/
function addToWhichGroup(event){
		var element = Event.element(event);
		var pos = Position.cumulativeOffset(element); // pos: [offsetLeft, offsetTop]
		var dimms = Element.getDimensions(element);

	var accessDiv = $("friend-group");

	if(accessDiv.style.display == "none") {
		accessDiv.style.left = pos[0] + 'px';
		accessDiv.style.top = (pos[1]+50) + dimms.height;
		accessDiv.style.display = "block"
	} else {
		accessDiv.style.display = "none"
	}
}

function chooseGroup(gid){
	var div = document.getElementById("img-"+gid);
	if(div.src.indexOf("unchecked.gif")!=-1){
		div.src="/images/checked.gif";
	}
	else{
		div.src="/images/unchecked.gif";
	}
}
function delFriendAtHomePage(fid){
	var confirm = window.confirm("从朋友圈中去掉此人？");
	if(confirm==true){		
		new Ajax.Request(
		 "/friend.do?method=delFriend&fid=" + fid + "&" + getDateString(),
		{
			method: 'get',
			onSuccess: function() {
				window.location.reload();
			}
		}
	);	
	}
}
function leaveMessage(confirm){
	 document.getElementById("message-"+confirm).src = "/images/checked.gif";
	if(confirm=="yes"){
	 	document.getElementById("message-no").src = "/images/unchecked.gif";
	 	document.getElementById("message-div").style.display = "block";
	 }
	 else{
	 	document.getElementById("message-yes").src = "/images/unchecked.gif";
	 	document.getElementById("message-div").style.display = "none";
	 }
}
function leaveMessageForSearch(confirm,fid){
	 document.getElementById("message-"+confirm+"-"+fid).src = "/images/checked.gif";
	if(confirm=="yes"){
	 	document.getElementById("message-no"+"-"+fid).src = "/images/unchecked.gif";
	 	document.getElementById("message-div"+"-"+fid).style.display = "block";
	 }
	 else{
	 	document.getElementById("message-yes"+"-"+fid).src = "/images/unchecked.gif";
	 	document.getElementById("message-div"+"-"+fid).style.display = "none";
	 }
}
/****************************************for manage_group_list and drag_group_list_deta*****************************/
function toggleGroup(prefix, id){
	if(document.getElementById(prefix + "group-friends-" + id)!=null) {
		var temp=document.getElementById(prefix + "group-friends-"+id).style.display;//window.alert(temp);
		if(temp!="none") {
			document.getElementById(prefix + "group-friends-"+id).style.display="none";
			document.getElementById(prefix + "group-img-"+id).src="/images/icon_open.gif";
		}
		else
		{
			document.getElementById(prefix + "group-friends-"+id).style.display="block";
			document.getElementById(prefix + "group-img-"+id).src="/images/icon_close.gif";
		}
	}	
}
function showEditBox(groupId){
	var display = document.getElementById("input-group-name-" + groupId).style.display;
	if(display=="none"){
		document.getElementById("input-group-name-" + groupId).style.display="";
		var groupName = document.getElementById("group-name-"+groupId).innerHTML.strip();
		document.getElementById("input-group-name-" + groupId).value = groupName;
		document.getElementById("input-group-name-" + groupId).select();
		document.getElementById("input-group-name-" + groupId).focus();
	}
	else
		document.getElementById("input-group-name-" + groupId).style.display="none";
}


function delFromGroup(uid,gid){	
	if(document.getElementById("group-list-"+gid+"-"+uid).style.display=="none")
		document.getElementById("group-list-"+gid+"-"+uid).style.display="block";
	else
		document.getElementById("group-list-"+gid+"-"+uid).style.display="none";
	/*if(confirm==true){ 
		window.location.href="/friend.do?method=changeGroup&uid="+uid+"&oldgid="+gid+"&newgid=-1"+"&url="+encodeURIComponent(window.location.href)+ '&' + getDateString();
	}*/
}
function delFriendFromAll(uid,gid){
	var confirm = window.confirm("从朋友圈中去掉此人？");
	if(confirm==true){ 
		new Ajax.Request(
		 "/friend.do?method=delFriend&fid=" + uid + "&" + getDateString(),
		{
			method: 'get',
			onSuccess: function() {
				document.getElementById("friend-"+gid+"-"+uid).style.display="none";
			}
		}
	);	

	}
}
function chooseGroupForFriend(id){
	var img = document.getElementById(id);
	if(img.src.indexOf("/images/checked.gif")!=-1){
		img.src = "/images/unchecked.gif";
	}
	else
		img.src = "/images/checked.gif";
}

function confirmFriendGroups(uid){
	
	var groupList="";
	//var groupId = str.substring(0,str.lastIndexOf("-"));
	var className = "my-group-img-"+uid;
	var imgs = document.getElementsByClassName(className);
	if (imgs==null || imgs.length==0){
		if ($('group-list-' + uid))
			Effect.Fade($('group-list-' + uid));
		return;
	}
	
	imgs.each(
		function(img) {
			if(img.src.indexOf("/images/checked.gif")!=-1){
				var id = img.id;
				var index = id.lastIndexOf("-");
				if(groupList.length!=0)
					groupList = groupList+","+id.substring(index+1);
				else
					groupList = groupList+id.substring(index+1);
				
			}
		}
	);
	
	new Ajax.Request('friend.do?method=updateGroups&uid='+uid+'&groups='+groupList,
		{
			method: 'post',
			onSuccess: function(request){
				if ($('success-'+uid)){
					$('success-'+uid).style.display="block";
					setTimeout("$('success-"+uid+"').style.display='none'", 1200);
					if ($('group-list-' + uid))
						Element.hide($('group-list-' + uid));
				}
			}	
			
		}
	);
	
}


/***********************************************for add_group*******************************************/
function chooseFriendIdByClick(gid,fid){
	var imgDiv = document.getElementById("img-"+gid+"-"+fid);
	var friendList = document.getElementById("friend-list").innerHTML;
	if(imgDiv.src.indexOf("/images/checked.gif")!=-1){
		imgDiv.src="/images/unchecked.gif";
	}
	else{
		imgDiv.src="/images/checked.gif";

	}
}
function chooseGroupIdByClick(gid){

	var groupDiv = document.getElementById("group-friends-"+gid);
	var friendList = document.getElementById("friend-list").innerHTML;
	var imgDiv = document.getElementById("img-"+gid);
	if(imgDiv.src.indexOf("/images/checked.gif")!=-1){
		imgDiv.src="/images/unchecked.gif";
		var ii;
		for(ii=0;ii<groupDiv.childNodes.length;ii++){
			if(groupDiv.childNodes[ii].id!=null)
			{
				if(groupDiv.childNodes[ii].id.indexOf("friend-")!=-1){
				
					var index = groupDiv.childNodes[ii].id.indexOf("-");
					var imgId = "img-"+groupDiv.childNodes[ii].id.substring(index+1);
					var img = document.getElementById(imgId);
					
					if(img.src.indexOf("/images/unchecked.gif")==-1){
						
						img.src="/images/unchecked.gif";
					}
				}
			}
		}
	}
	else{
		imgDiv.src="/images/checked.gif";
		var ii;
		for(ii=0;ii<groupDiv.childNodes.length;ii++){
			if(groupDiv.childNodes[ii].id!=null){
				if(groupDiv.childNodes[ii].id.indexOf("friend-")!=-1){
					var index = groupDiv.childNodes[ii].id.indexOf("-");
					var imgId = "img-"+groupDiv.childNodes[ii].id.substring(index+1);
					var img = document.getElementById(imgId);
					
					if(img.src.indexOf("/images/checked.gif")==-1){
						
						img.src="/images/checked.gif";
					}
				}
			}
		}	
	}
}

function addGroup(){
	var gName = document.getElementById("form").groupName.value;
	var gName = document.getElementById("form").groupName.value;
	gName = gName.strip();
	if( gName==null || gName.length==0 )
	{	
		window.alert("组名不能为空");
		document.form.groupName.focus();
		return false;
	}
	if(gName.length >=32){
		window.alert("组名长度不能超过32个字符");
		
		document.form.groupName.select();
		document.form.groupName.focus();
		return false;
	}
	
	var confirm = window.confirm('你确定添加 "' + gName + ' "组吗?');
	if(confirm==false)
		return false;
	
	
	var friends = Element.getElementsBySelector('friend-tree', 'input[class="check-friend"]');
	var friendList ="";// document.getElementById("friend-list").innerHTML;
	friends.each(
		function(friend) {
			if(friend.checked){
				friendList += friend.value + ",";
			}
		}
	);
	if (friendList.length > 0) {
		friendList = friendList.substring(0, friendList.length - 1);
	}
	document.getElementById("form").friendIds.value = friendList;
	//window.alert(document.getElementById("form").friendIds.value);
	return true;
}

/**************************************************************************************************/
function openAll(){
	var groupNames = document.getElementsByClassName('friendlist-th');
	document.getElementById("close-1").style.display="";
	document.getElementById("close-2").style.display="";
	document.getElementById("open-1").style.display="none";
	document.getElementById("open-2").style.display="none";	
	groupNames.each(
		function(group) {
			var groupId = group.id.substring(11);
			document.getElementById("group-img-"+groupId).src="/images/icon_close.gif";
			document.getElementById("group-friends-"+groupId).style.display="";
		}
	);
}
function closeAll(){
	var groupNames = document.getElementsByClassName('friendlist-th');
	document.getElementById("close-1").style.display="none";
	document.getElementById("close-2").style.display="none";
	document.getElementById("open-1").style.display="";
	document.getElementById("open-2").style.display="";
	groupNames.each(
		function(group) {
			var groupId = group.id.substring(11);
			document.getElementById("group-img-"+groupId).src="/images/icon_open.gif";
			document.getElementById("group-friends-"+groupId).style.display="none";
		}
	);
}
function newOpenAll(prefix){
	var groupNames = $(prefix + 'friend-tree').getElementsByClassName('friendlist-th');
	$(prefix + "close-1").style.display="";
	$(prefix + "open-1").style.display="none";
	groupNames.each(
		function(group) {
			var groupId = group.id.substring(prefix.length + 11);
			$(prefix + "group-img-"+groupId).src="/images/icon_close.gif";
			$(prefix + "group-friends-"+groupId).style.display="";
		}
	);
}
function newCloseAll(prefix){
	var groupNames = $(prefix + 'friend-tree').getElementsByClassName('friendlist-th');
	$(prefix + "close-1").style.display="none";
	$(prefix + "open-1").style.display="";
	groupNames.each(
		function(group) {
			var groupId = group.id.substring(prefix.length + 11);
			$(prefix + "group-img-" + groupId).src="/images/icon_open.gif";
			$(prefix + "group-friends-" + groupId).style.display="none";
		}
	);
}
/************************************个性化设置***********************************************/
function editInput(id,showId , editId){
	var value = document.getElementById(id).innerHTML;
	value = value.strip();
	document.getElementById(showId).style.display="none";
	document.getElementById(editId).style.display="";
	document.getElementById(editId).value=value;

	
}
function editInputDone(id,showId , editId){
	var value=document.getElementById(editId).value;
	document.getElementById(id).innerHTML=value;
	document.getElementById(showId).style.display="";
	document.getElementById(editId).style.display="none";
	new Ajax.Request(
		"/user.do?method=ajaxEditNickName&nick=" + encodeURIComponent(value),
		{
			method: 'get',
			onSuccess: function(request) {
			}
		}
	);
}
function sortByOnline(){
	var groupNames = document.getElementsByClassName('friendlist-th');
	groupNames.each(
		function(groupName) {
			var groupId = groupName.id.substring(11);
			var group = document.getElementById("group-friends-"+groupId);
			var ii,count = 0;
			var sortDiv = document.getElementById("sort-"+groupId);
			for(ii=0;ii<group.childNodes.length;ii++){
				if(group.childNodes[ii].id!=null){
					if(group.childNodes[ii].id.indexOf("friend-")!=-1){
						var div = group.childNodes[ii];
						var index = div.id.lastIndexOf("-");
						var friendId = div.id.substring(index+1);
						var onlineImg = document.getElementById("online-"+groupId+"-"+friendId);
						if(onlineImg.src.indexOf("icon_online.gif")!=-1){
							group.insertBefore(div,sortDiv);
						}
					}
				}
			}
			group.insertBefore(sortDiv,group.firstChild);
		}
	);	
	document.getElementById("sort-online").style.display = "none";
	document.getElementById("sort-init").style.display = "";
}

function showOnline(){
	var groupNames = document.getElementsByClassName('friendlist-th');
	groupNames.each(
		function(groupName) {
			var groupId = groupName.id.substring(11);
			var group = document.getElementById("group-friends-"+groupId);
			var ii,count = 0;
			for(ii=0;ii<group.childNodes.length;ii++){
				if(group.childNodes[ii].id!=null){
					if(group.childNodes[ii].id.indexOf("friend-")!=-1){
						var div = group.childNodes[ii];
						var index = div.id.lastIndexOf("-");
						var friendId = div.id.substring(index+1);
						var onlineImg = document.getElementById("online-"+groupId+"-"+friendId);
						if(onlineImg.src.indexOf("icon_online.gif")==-1){
							div.style.display='none';
						}
					}
				}
			}
		}
	);	
	document.getElementById("show-online").style.display = "none";
	document.getElementById("show-all").style.display = "";
}
function showAll(){
	var groupNames = document.getElementsByClassName('friendlist-th');
	groupNames.each(
		function(groupName) {
			var groupId = groupName.id.substring(11);
			var group = document.getElementById("group-friends-"+groupId);
			var ii,count = 0;
			for(ii=0;ii<group.childNodes.length;ii++){
				if(group.childNodes[ii].id!=null){
					if(group.childNodes[ii].id.indexOf("friend-")!=-1){
						var div = group.childNodes[ii];
							div.style.display='';
					}
				}
			}
		}
	);	
	document.getElementById("show-online").style.display = "";
	document.getElementById("show-all").style.display = "none";
}
function showOnlineForUserFriend(){
	var friendNames = document.getElementsByClassName('friendlist-tr');
	friendNames.each(
		function(friendName) {
			var friendId = friendName.id.substring(7);
			
			var onlineImg = document.getElementById("online-"+friendId);
			if(onlineImg.src.indexOf("icon_online.gif")==-1){
				friendName.style.display='none';
			}
		}
	);	
	document.getElementById("show-online").style.display = "none";
	document.getElementById("show-all").style.display = "";	
}
function showAllForUserFriend(){
	var friendNames = document.getElementsByClassName('friendlist-tr');
	friendNames.each(
		function(friendName) {
			friendName.style.display='';
		}
	);	
	document.getElementById("show-online").style.display = "";
	document.getElementById("show-all").style.display = "none";	
}

function showFriendChange(){
	new Ajax.Updater("change", 
  	"/change.do?method=recentChange"+ '&' + getDateString(), 
  	{
  		method:"get"
  	}
  	);	
}
function showUserFriendChange(userName){
	new Ajax.Updater("friend-change", 
  	"/change.do?method=userFriendRecentChange&user="+userName+ '&' + getDateString(), 
  	{
  		method:"get"
  	}
  	);	
}

function showPublicChange(){
	new Ajax.Updater("change", 
  	"/change.do?method=publicChange"+ '&' + getDateString(), 
  	{
  		method:"get",
  		evalScripts:true
  	}
  	);	
}

function showNickList(uid)
{
	new Ajax.Updater("nick", 
  	"/change.do?method=recentNick&uid="+uid+ '&' + getDateString(), 
  	{
  		method:"get"
  	}
  	);	
}
function showMyNickList()
{
	new Ajax.Updater("nick", 
  	"/change.do?method=recentNick"+ '&' + getDateString(), 
  	{
  		method:"get"
  	}
  	);	
}

function requestFriend(userName) {
	new Ajax.Updater(
		'request-friend',
		'/friend.do?method=doRequestFriend&user=' + userName,
		{method: 'get'}
	);
}

function processSelfReco(id, accept) {
	var url = '/friend.do?method=processSelfReco&id=' + id;
	if (accept)
		url += '&accept';
	new Ajax.Request(
		url,
		{
			method: 'get',
			onSuccess: function(request) {
				highlightDelete('self-reco');
			}
		}
	);
}
function saveGroupOrder(){
	var ids="";
	var groupsIds = document.getElementsByClassName('friend-ids');
	groupsIds.each(
		function(groupIds) {
			if(ids.length==0)
				ids = ids + groupIds.innerHTML.strip();
			else
				ids = ids + ";" + groupIds.innerHTML.strip();
		}
	);	
	new Ajax.Request(
		 "/friend.do?method=changeGroupOrder&ids="+ids,
		{
			method: 'get',
			onSuccess: function() {
				var date = new Date()
				var div = document.getElementById("tip");
				div.innerHTML = "修改已保存 "+date.getFullYear()+"年"+(date.getMonth()+1)+"月"+date.getDate()+"日"+date.getHours()+"时"+date.getMinutes()+"分";
			}
		}
	);	
}

function fixContainerHeight() {
	var container = $('change-container')
	var dimms = Element.getDimensions(container);
	var refDimms = Element.getDimensions('change-sidebar');
	if (dimms.height < refDimms.height) {
		container.style.height = refDimms.height + 'px';
	}
}

function forwardFriend(gId,id) {
	var pos = Position.cumulativeOffset($('friend-' + gId + "-" + id));
	var left = pos[0] + 200;
	var top = pos[1] - 200;
	if (top < 0) {
		top = 100;
	}
	
	var popup = $('forward-list');
	if (!popup) {
		popup = document.createElement('div');
		popup.id = 'forward-list';
		popup.style.border = '2px solid #cccccc';
		popup.style.position = 'absolute';
		popup.style.left = left + 'px';
		popup.style.top = top + 'px';
		popup.style.width = '250px';
		popup.style.zIndex = '500';
		popup.style.textAlign = 'left';
		popup.style.background = '#FFFFFF';
		
		var head = document.createElement('div');
		head.id = 'forward-list-head';
		head.style.height = '15px';
		head.style.padding = '5px';
		head.style.color = '#FFFFFF';
		head.style.backgroundColor = '#155FA9';
		head.innerHTML = '<a onclick="closeForwardList()" class="right hand"><img src="/images/icon_close_window.gif"　alt="关闭" title="关闭"／></a>选择推荐给哪些好友</div>';
		popup.appendChild(head);
		
		var body = document.createElement('div');
		body.id = 'forward-list-body';
		body.style.height = '400px';
		body.style.overflow = 'auto';
		body.style.padding = '10px';
		body.innerHTML = '<div class="working-img"></div>';
		popup.appendChild(body);
		
		var foot = document.createElement('div');
		foot.id = 'forward-list-foot';
		foot.style.height = '25px';
		foot.style.borderTop = '2px solid #CCCCCC';
		foot.style.padding = '5px';
		foot.innerHTML = '<a onclick="doForwardFriend(' + id + ')" class="right hand"><img src="/images/button_send.gif" alt="OK" /></a>';
		popup.appendChild(foot);
		
		document.body.appendChild(popup);
		
		new Ajax.Request(
			'/friend.do?method=chooseFriend&' + getDateString(),
			{
				method: 'get',
				onSuccess: function(request) {
					$(body.id).innerHTML = request.responseText;
				}
			}
		);
	} else {
		popup.style.left = left + 'px';
		popup.style.top = top + 'px';
		$('forward-list-head').innerHTML = '<a onclick="closeForwardList()" class="right hand"><img src="/images/icon_close_window.gif"　alt="关闭" title="关闭"／></a>选择推荐给哪些好友</div>';
		$('forward-list-body').style.display = 'block';
		$('forward-list-foot').style.display = 'block';
		uncheckAllFriends();
		popup.style.display = 'block';
	}
}

function doForwardFriend(id) {
	var friendNames = $('friend-list').innerHTML;
	var popup = $('forward-list');
	
	new Ajax.Request(
		'/friend.do?method=forward&id=' + id + '&fn=' + encodeURIComponent(friendNames),
		{
			method: 'get',
			onSuccess: function(request) {
				$('forward-list-foot').style.display = 'none';
				$('forward-list-body').style.display = 'none';
				$('forward-list-head').innerHTML = '<b>推荐成功</b>';
				setTimeout("closeForwardList()", 1000);
			}
		}
	);

}

function closeForwardList() {
	$('forward-list').style.display = 'none';
}

var addFriendCallback = null;
function ajaxAddFriend(e, friendId, callback) {
	var id = 'add-friend-form';
	var element = Event.element(e);
	var position = Position.cumulativeOffset(element);
	if (!$(id)) {
		var div = document.createElement('div');
		div.id = id;
		with (div.style) {
			position = 'absolute';
			backgroundColor = '#FFFFFF';
			zIndex = '500';
			width = '200px';
			display = 'none';
			border = '3px outset #0066CC';
			padding = '10px';
		}
		div.innerHTML = '<div class="working-img"></div>';
		document.body.appendChild(div);
		div.style.left = position[0] + 'px';
		div.style.top = position[1] + 'px';
		div.style.display = 'block';
		new Ajax.Request(
			'/friend.do?method=ajaxAddFriend&' + getDateString(),
			{
				method: 'get',
				onSuccess: function(transport) {
					div.innerHTML = transport.responseText;
					$('add-friend-name').value = friendId;
				}
			}
		);
	} else {
		var addForm = $(id);
		addForm.style.left = position[0] + 'px';
		addForm.style.top = position[1] + 'px';
		addForm.style.display = 'block';
		$('add-friend-name').value = friendId;
	}
	addFriendCallback = callback;
}


function addToGroup(){
	var fid = $('add-friend-name').value;
	Element.hide('add-friend-form');
	var groups = document.getElementsByClassName("the-friend-group-img");//window.alert("jh");
	var groupList="";
	groups.each(
		function(group) {			
			if(group.src.indexOf("/images/checked.gif")!=-1){
				var id = group.id.substring(4);
				if(groupList.length!=0)
					groupList=groupList+","+id;
				else
					groupList=id;
			}
		}
	);
	var message = "no";
	var content = "";
	var src = document.getElementById("message-yes").src;
	if(src.indexOf("/images/checked.gif")!=-1){
		message = "yes";
		content = encodeURIComponent(document.getElementById("message-input").value);
	}
	if(groupList.length==0){
		new Ajax.Request(
			 "/friend.do?method=addToGroups&uid="+fid+"&gid=-1&message="+message+"&content="+content+ "&" + getDateString(),
			{
				method: 'get',
				onSuccess: function() {
					if (addFriendCallback) {
						addFriendCallback();
					} else {
						window.location.reload();
					}
				}
			}
		);	

	}else{
		new Ajax.Request(
			 "/friend.do?method=addToGroups&uid="+fid+"&gid="+groupList+"&message="+message+"&content="+content+ "&" + getDateString(),
			{
				method: 'get',
				onSuccess: function() {
					if (addFriendCallback) {
						addFriendCallback();
					} else {
						window.location.reload();
					}
				}
			}
		);	
	}
}

var checkFriendInfoID = 'check-friend';
function addFriendChangeDisplay() {
	var checkFriendSpan = $(checkFriendInfoID);
	
	if (checkFriendSpan) {
		checkFriendSpan.innerHTML = '<img width="16" height="16" src="/images/icon_friend.gif"/> 已是朋友';
		new Effect.Highlight(checkFriendSpan);
	}
	
}

var checkFriendInfoSmallID = 'check-friend';
function addFriendChangeSmallDisplay() {
	var checkFriendSpan = $(checkFriendInfoSmallID);
	
	if (checkFriendSpan) {
		checkFriendSpan.innerHTML = '<img src="/images/icon_already_friend.gif" alt="已是朋友" align="absmiddle" />';
		new Effect.Highlight(checkFriendSpan);
	}
	
}

var checkFriendInfoClassName = 'check-friend';
function addFriendChangeSmallDisplayList() {
	var checkFriendSpans = document.getElementsByClassName(checkFriendInfoClassName);
	
	if (checkFriendSpans) {
		for (var i=0;i<checkFriendSpans.length;i++){
			checkFriendSpans[i].innerHTML = '<img src="/images/icon_already_friend.gif" alt="已是朋友" align="absmiddle" />';
			new Effect.Highlight(checkFriendSpans[i]);
		}
	}
	
}
/* 引荐朋友 */

/**
 * 隐藏fromId，显示toId
 */
function transfer(fromId, toId) {
	$(fromId).style.display = 'none';
	$(toId).style.display = 'block';
	Element.scrollTo('header');
}

/**
 * 选中或取消一组朋友
 */
function checkGroup(groupCheckbox) {
	// 取得该组朋友列表的父节点
	var ul = groupCheckbox.parentNode.nextSibling;
	while (ul.nodeType != 1) {
		ul = ul.nextSibling;
	}
	
	checks = Element.getElementsByClassName(ul, 'check-friend');
	
	if (groupCheckbox.checked) {
		checks.each(
			function(friendNode) {
				friendNode.checked = true;
			}
		);
	} else {
		checks.each(
			function(friendNode) {
				friendNode.checked = false;
			}
		);
	}
}

// 给Array扩展一个方法：如果data不存在，添加到末尾，返回true，否则不添加，返回false
Array.prototype.addUnique = function(data) {
	for (var ii = 0; ii < this.length; ii++)
		if (this[ii] == data)
			return false;
	this[ii] = data;
	return true;
}

// 用户提交前将表单的hidden元素设置为正确值，并且给用户显示报告
function prepareSubmit() {
	var toShare = $('friend-tree').getElementsByClassName('check-friend');
	var shareWith = $('share-friend-tree').getElementsByClassName('check-friend');
	
	var idsToShare = new Array();
	var idsShareWith = new Array();
	
	// 第三步里的两个ul
	var ulToShare = $('to-share');
	ulToShare.innerHTML = '';
	var ulShareWith = $('share-with');
	ulShareWith.innerHTML = '';
	
	toShare.each(
		function(checkbox) {
			if (checkbox.checked) {
				if (idsToShare.addUnique(checkbox.value))
					ulToShare.innerHTML += '<li>' + checkbox.parentNode.lastChild.innerHTML + '</li>';
			}
		}
	);
	
	shareWith.each(
		function(checkbox) {
			if (checkbox.checked) {
				if (idsShareWith.addUnique(checkbox.value))
					ulShareWith.innerHTML += '<li>' + checkbox.parentNode.lastChild.innerHTML + '</li>';
			}
		}
	);
	
	$('share-form').friendsToShare.value = idsToShare.join(',');
	$('share-form').shareWith.value = idsShareWith.join(',');
	$('group-name-label').innerHTML = $('share-form').groupName.value;
}

/**
 * 检查是否可以提交共享朋友的表单
 */
function canShare() {
	if ($('share-form').friendsToShare.value != '' && $('share-form').shareWith.value != '')
		return true;
	else {
		alert('您还没有选人呢');
		return false;
	}
}

///////////////////////////////
// below is for accepting share
///////////////////////////////

/**
 * 用户选择、填写完毕，点击“添加”
 */
function acceptFriends() {
	var form = $('accept-form');
	
	var toShare = document.getElementsByClassName('to-share');
	var idsToShare = new Array();
	toShare.each(
		function(checkbox) {
			if (checkbox.checked) {
				idsToShare.addUnique(checkbox.value);
			}
		}
	);
	
	// 如果用户没有选择任何朋友，提醒一下
	if (idsToShare.length < 1) {
		var result = ("提交后，您不会添加其中任何朋友");
		if (result == false)
			return;
	}
	
	if (form.newOrExisting[0].checked) {
		// 用户要添加到新组
		if (form.groupName.value.strip() == '') {
			alert("您选择了添加到新组，需要填写组名");
			return;
		}
	}
	
	form.friendsToShare.value = idsToShare.join(',');
	form.submit();
}

function discardFriends() {
	var really = confirm('真的要拒绝吗？');
	if (really == true) {
		document.getElementsByClassName('to-share').each(
			function(name) {
				name.checked = false;
			}
		);
		acceptFriends();
	}
}
/**
 * 显示或隐藏分享信息详细内容
 */
function toggleShareDetail(shareId) {
	var detail = $('detail-' + shareId);
	var icon = $('img-' + shareId)
	if (detail.style.display != 'none') {
		detail.style.display = 'none';
		icon.src = "/images/icon_open.gif";
		return;
	}
	
	detail.style.display = 'block';
//	icon.src = "/images/icon_close.gif";
//	if (detail.innerHTML.strip() != "") {
//		return; // 内容已经取出
//	}
//	
//	detail.innerHTML = "<div class='working-img'></div>";
//	new Ajax.Updater(
//		"detail-" + shareId,
//		"/share_friends.do",
//		{
//			method:"get",
//			parameters:"method=shareDetail&id=" + shareId + '&' + getDateString()
//		}
//	);
}

/**
 * 禁用Enter键提交
 */
function preventKeySubmit(e) {
  var e = (e) ? e : ((event) ? event : null);
  var node = (e.target) ? e.target : ((e.srcElement) ? e.srcElement : null);
  if ((e.keyCode == 13) && (node.type == "text" || node.type == "checkbox" || node.type == "radio"))  {return false;}
}

document.onkeypress = preventKeySubmit;

function highlightGroup(groupName) {
	var groups = $('friend-groups').select('span');
	for (var ii = 0; ii < groups.length; ii++) {
		var group = groups[ii];
		if (group.innerHTML.strip() == groupName) {
			group.style.color = '#FFFFFF';
			group.style.backgroundColor = '#0066CC';
			group.style.fontWeight = 'bold';
			group.style.textDecoration = 'none';
			group.style.border = '2px solid #0066CC';
			return;
		}
	}
}

