﻿function getFriendStatusDetails(id,f_id,user_id,type) {
	var this_id = id;
	var this_user_id = user_id;
	var f_user_id = f_id;
	var this_type = type;
	// show busy icon
	var myElement = 'list_of_friends_busy';
	var elementToShow = document.getElementById(myElement);
	elementToShow.style.visibility = 'visible';
	// switch arrow
	var imageToSwitch = document.getElementById(this_type + "_detail_switch_img_" + this_id);
	imageToSwitch.src = "pics/general/sortarrowdown.gif";
	imageToSwitch.title = "hide details";
	// switch link
	var anchorToSwitch = document.getElementById(this_type + "_detail_switch_a_" + this_id);
	anchorToSwitch.href = "javascript:hideFriendStatusDetails(" + this_id + "," + f_user_id + "," + this_user_id + ",'" + this_type + "')";
	// set up query and url
	var qry = 'js=yes&id=' + this_id + '&user_id=' + this_user_id;
	var url = 'myfriends/getFriendStatusDetails.php';
	// handle ajax object
	var xhri = xhrRequest('html');
	xhr[xhri].open('POST', url, true);
	xhr[xhri].onreadystatechange = function () {
				if (xhr[xhri].readyState == 4 && xhr[xhri].status == 200) {
					var myElement = this_type + '_detail_' + this_id;
					var elementToShow = document.getElementById(myElement);
					elementToShow.innerHTML = xhr[xhri].responseText;
					check_page_height();
				} else {
					try {
						var alertStr = "xhr[xhri].readyState=" + xhr[xhri].readyState + " xhr[xhri].status=" + xhr[xhri].status;
					}
					catch (e) {
						var alertStr = "error getting xhr[xhri].readyState and xhr[xhri].status";
					}
					//alert(alertStr);
				}
			};
	xhr[xhri].setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xhr[xhri].send(qry);
	//set up another query and url
	var qry = 'js=yes&id=' + this_id + '&user_id=' + this_user_id + '&f_user_id=' + f_user_id + '&max_no=3';
	var url = 'myfriends/getFriendsLists.php';
	// handle ajax object
	var xhri2 = xhrRequest('html');
	xhr[xhri2].open('POST', url, true);
	xhr[xhri2].onreadystatechange = function () {
				if (xhr[xhri2].readyState == 4 && xhr[xhri2].status == 200) {
					var myElement = this_type + '_lists_' + this_id;
					var elementToShow = document.getElementById(myElement);
					elementToShow.innerHTML = xhr[xhri2].responseText;
					check_page_height();
				} else {
					try {
						var alertStr = "xhr[xhri2].readyState=" + xhr[xhri2].readyState + " xhr[xhri2].status=" + xhr[xhri2].status;
					}
					catch (e) {
						var alertStr = "error getting xhr[xhri2].readyState and xhr[xhri2].status";
					}
					//alert(alertStr);
				}
				var myElement = 'list_of_friends_busy';
				var elementToShow = document.getElementById(myElement);
				elementToShow.style.visibility = 'hidden';
			};
	xhr[xhri2].setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xhr[xhri2].send(qry);
}

function getFriendsLists(id,f_id,user_id,type,max) {
	this_id = id;
	this_user_id = user_id;
	f_user_id = f_id;
	this_type = type;
	max_no = max;
	//alert("begin");
	//return;
	if (!xmlhttp2) {
		xmlhttp2 = getXmlHttpRequest();
	}
	if (!xmlhttp2) {
		alert("could not create XmlHttpRequest");
		return;
	}
	var myElement = 'list_of_friends_busy';
	var elementToShow = document.getElementById(myElement);
	elementToShow.style.visibility = 'visible';
	var qry = 'js=yes&id=' + this_id + '&user_id=' + this_user_id + '&f_user_id=' + f_user_id + '&max_no=' + max_no;
	var url = 'myfriends/getFriendsLists.php';
	//alert("setup xmlhttp params");
	//return;
	xmlhttp2.open('POST', url, true);
	xmlhttp2.onreadystatechange = printFriendsLists;
	xmlhttp2.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	//alert("send xmlhttp request");
	//return;
	xmlhttp2.send(qry);
}

function printFriendStatusDetails() {
	//alert("begin printFriendStatusDetails");
	//return;
	if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
		var myElement = this_type + '_detail_' + this_id;
		var elementToShow = document.getElementById(myElement);
		//alert(myElement);
		elementToShow.innerHTML = xmlhttp.responseText;
		//var imageToSwitch = document.getElementById(this_type + "_detail_switch_img_" + this_id);
		//var anchorToSwitch = document.getElementById(this_type + "_detail_switch_a_" + this_id);
		//imageToSwitch.src = "pics/general/sortarrowdown.gif";
		//imageToSwitch.title = "hide details";
		//anchorToSwitch.href = "javascript:hideFriendStatusDetails(" + this_id + "," + f_user_id + "," + this_user_id + ",'" + this_type + "')";
		check_page_height();
	} else {
		try {
			var alertStr = "xmlhttp.readyState=" + xmlhttp.readyState + " xmlhttp.status=" + xmlhttp.status;
		}
		catch (e) {
			var alertStr = "error getting xmlhttp.readyState and xmlhttp.status";
		}
		//alert(alertStr);
	}
}

function printFriendsLists() {
	//alert("begin response");
	//return;
	if (xmlhttp2.readyState == 4 && xmlhttp2.status == 200) {
		var myElement = this_type + '_lists_' + this_id;
		var elementToShow = document.getElementById(myElement);
		//alert(myElement);
		elementToShow.innerHTML = xmlhttp2.responseText;
		check_page_height();
	} else {
		try {
			var alertStr = "xmlhttp.readyState=" + xmlhttp.readyState + " xmlhttp.status=" + xmlhttp.status;
		}
		catch (e) {
			var alertStr = "error getting xmlhttp.readyState and xmlhttp.status";
		}
		//alert(alertStr);
	}
	var myElement = 'list_of_friends_busy';
	var elementToShow = document.getElementById(myElement);
	elementToShow.style.visibility = 'hidden';
}

function hideFriendStatusDetails(this_id,f_user_id,this_user_id,this_type) {
	var myElement = this_type + '_lists_' + this_id;
	var elementToShow = document.getElementById(myElement);
	//alert(myElement);
	elementToShow.innerHTML = "";
	myElement = this_type + '_detail_' + this_id;
	elementToShow = document.getElementById(myElement);
	//alert(myElement);
	elementToShow.innerHTML = "";
	var imageToSwitch = document.getElementById(this_type + "_detail_switch_img_" + this_id);
	var anchorToSwitch = document.getElementById(this_type + "_detail_switch_a_" + this_id);
	imageToSwitch.src = "pics/general/sortarrowright.gif";
	imageToSwitch.title = "show details";
	anchorToSwitch.href = "javascript:getFriendStatusDetails(" + this_id + "," + f_user_id + "," + this_user_id + ",'" + this_type + "')";
	check_page_height();
}

function acceptFriend(id,user_id) {
	// show busy icon
	var myElement = 'list_of_friends_busy';
	var elementToShow = document.getElementById(myElement);
	elementToShow.style.visibility = 'visible';
	// set up query and url
	var qry = 'js=yes&id=' + id + '&user_id=' + user_id;
	var url = 'myfriends/acceptFriend.php';
	var xhri = xhrRequest('html');
	// handle ajax object
	xhr[xhri].open('POST', url, true);
	xhr[xhri].onreadystatechange = function () {
			if (xhr[xhri].readyState == 4 && xhr[xhri].status == 200) {
				// show busy icon
				var myElement = 'pending_busy';
				var elementToShow = document.getElementById(myElement);
				elementToShow.style.visibility = 'visible';
				// update friends requests
				// set up query and url
				var qry = 'js=yes&id=' + id + '&user_id=' + user_id;
				var url = 'myhome/friends_new_requests.php';
				// handle ajax object
				xhr[xhri].open('POST', url, true);
				xhr[xhri].onreadystatechange = function () {
						if (xhr[xhri].readyState == 4 && xhr[xhri].status == 200) {
							// print update friends requests
							var myElement = 'friends_new_requests';
							var elementToShow = document.getElementById(myElement);
							elementToShow.innerHTML = "";
							elementToShow.innerHTML = xhr[xhri].responseText;
							// update friends list
							updateFriends(id,user_id);
						} else {
							try {
								var alertStr = "xhr[xhri].readyState=" + xhr[xhri].readyState + " xhr[xhri].status=" + xhr[xhri].status;
							}
							catch (e) {
								var alertStr = "error getting xhr[xhri].readyState and xhr[xhri].status";
							}
							//alert(alertStr);
						}
						// hide busy icon
						var myElement = 'pending_busy';
						var elementToShow = document.getElementById(myElement);
						elementToShow.style.visibility = 'hidden';
					};
				xhr[xhri].setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				xhr[xhri].send(qry);
				// update list of friends
				// set up query and url
				var qry = 'js=yes&id=' + id + '&user_id=' + user_id;
				var url = 'myhome/list_of_friends.php';
				// handle ajax object
				var xhri2 = xhrRequest('html');
				xhr[xhri2].open('POST', url, true);
				xhr[xhri2].onreadystatechange = function () {
						if (xhr[xhri2].readyState == 4 && xhr[xhri2].status == 200) {
							var myElement = 'friends_list';
							var elementToShow = document.getElementById(myElement);
							elementToShow.innerHTML = "";
							elementToShow.innerHTML = xhr[xhri2].responseText;
						} else {
							try {
								var alertStr = "xhr[xhri2].readyState=" + xhr[xhri2].readyState + " xhr[xhri2].status=" + xhr[xhri2].status;
							}
							catch (e) {
								var alertStr = "error getting xhr[xhri2].readyState and xhr[xhri2].status";
							}
							//alert(alertStr);
						}
						var myElement = 'list_of_friends_busy';
						var elementToShow = document.getElementById(myElement);
						elementToShow.style.visibility = 'hidden';
					};
				xhr[xhri2].setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				xhr[xhri2].send(qry);
				// update friends head
				// set up query and url
				var qry = 'js=yes&user_id=' + user_id;
				var url = 'myhome/fr_head.php';
				// handle ajax object
				var xhri3 = xhrRequest('html');
				xhr[xhri3].open('POST', url, true);
				xhr[xhri3].onreadystatechange = function () {
						if (xhr[xhri3].readyState == 4 && xhr[xhri3].status == 200) {
							var myElement = 'mh_user_summary_fr_head';
							var elementToShow = document.getElementById(myElement);
							elementToShow.innerHTML = "";
							elementToShow.innerHTML = xhr[xhri3].responseText;
						} else {
							try {
								var alertStr = "xhr[xhri3].readyState=" + xhr[xhri3].readyState + " xhr[xhri3].status=" + xhr[xhri3].status;
							}
							catch (e) {
								var alertStr = "error getting xhr[xhri3].readyState and xhr[xhri3].status";
							}
							//alert(alertStr);
						}
					};
				xhr[xhri3].setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				xhr[xhri3].send(qry);
			} else {
				try {
					var alertStr = "xhr[xhri].readyState=" + xhr[xhri].readyState + " xhr[xhri].status=" + xhr[xhri].status;
				}
				catch (e) {
					var alertStr = "error getting xhr[xhri].readyState and xhr[xhri].status";
				}
				//alert(alertStr);
			}
		};
	xhr[xhri].setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xhr[xhri].send(qry);
}

function declineFriend(id,user_id,nickname) {
	var theQuestion = "Are you sure you want to decline the request for friendship from " + nickname + "?";
	if (confirm(theQuestion)) {
		var myElement = 'pending_busy';
		var elementToShow = document.getElementById(myElement);
		elementToShow.style.visibility = 'visible';
		var qry = 'js=yes&id=' + id + '&user_id=' + user_id;
		var url = 'myfriends/declineFriend.php';
		// handle ajax object
		var xhri = xhrRequest('html');
		xhr[xhri].open('POST', url, true);
		xhr[xhri].onreadystatechange = function () {
				// update friends requests
				// set up query and url
				var qry = 'js=yes&id=' + id + '&user_id=' + user_id;
				var url = 'myhome/friends_new_requests.php';
				// handle ajax object
				xhri = xhrRequest('html');
				xhr[xhri].open('POST', url, true);
				xhr[xhri].onreadystatechange = function () {
						if (xhr[xhri].readyState == 4 && xhr[xhri].status == 200) {
							// print update friends requests
							var myElement = 'friends_new_requests';
							var elementToShow = document.getElementById(myElement);
							elementToShow.innerHTML = "";
							elementToShow.innerHTML = xhr[xhri].responseText;
							// update friends list
							updateFriends(id,user_id);
						} else {
							try {
								var alertStr = "xhr[xhri].readyState=" + xhr[xhri].readyState + " xhr[xhri].status=" + xhr[xhri].status;
							}
							catch (e) {
								var alertStr = "error getting xhr[xhri].readyState and xhr[xhri].status";
							}
							//alert(alertStr);
						}
						// hide busy icon
						var myElement = 'pending_busy';
						var elementToShow = document.getElementById(myElement);
						elementToShow.style.visibility = 'hidden';
					};
				xhr[xhri].setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				xhr[xhri].send(qry);
				// update friends head
				// set up query and url
				var qry = 'js=yes&user_id=' + user_id;
				var url = 'myhome/fr_head.php';
				// handle ajax object
				var xhri3 = xhrRequest('html');
				xhr[xhri3].open('POST', url, true);
				xhr[xhri3].onreadystatechange = function () {
						if (xhr[xhri3].readyState == 4 && xhr[xhri3].status == 200) {
							var myElement = 'mh_user_summary_fr_head';
							var elementToShow = document.getElementById(myElement);
							elementToShow.innerHTML = "";
							elementToShow.innerHTML = xhr[xhri3].responseText;
						} else {
							try {
								var alertStr = "xhr[xhri3].readyState=" + xhr[xhri3].readyState + " xhr[xhri3].status=" + xhr[xhri3].status;
							}
							catch (e) {
								var alertStr = "error getting xhr[xhri3].readyState and xhr[xhri3].status";
							}
							//alert(alertStr);
						}
					};
				xhr[xhri3].setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				xhr[xhri3].send(qry);
			};
		xhr[xhri].setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xhr[xhri].send(qry);
	}
}

function endFriendship(id,user_id,nickname) {
	var theQuestion = "Are you sure you want to end your friendship with " + nickname + "?";
	if (confirm(theQuestion)) {
		var myElement = 'list_of_friends_busy';
		var elementToShow = document.getElementById(myElement);
		elementToShow.style.visibility = 'visible';
		var qry = 'js=yes&id=' + id + '&user_id=' + user_id;
		var url = 'myfriends/endFriendship.php';
		// handle ajax object
		var xhri = xhrRequest('html');
		xhr[xhri].open('POST', url, true);
		xhr[xhri].onreadystatechange = function () {
				// update list of friends
				// set up query and url
				var qry = 'js=yes&id=' + id + '&user_id=' + user_id;
				var url = 'myhome/list_of_friends.php';
				// handle ajax object
				var xhri2 = xhrRequest('html');
				xhr[xhri2].open('POST', url, true);
				xhr[xhri2].onreadystatechange = function () {
						if (xhr[xhri2].readyState == 4 && xhr[xhri2].status == 200) {
							var myElement = 'friends_list';
							var elementToShow = document.getElementById(myElement);
							elementToShow.innerHTML = "";
							elementToShow.innerHTML = xhr[xhri2].responseText;
						} else {
							try {
								var alertStr = "xhr[xhri2].readyState=" + xhr[xhri2].readyState + " xhr[xhri2].status=" + xhr[xhri2].status;
							}
							catch (e) {
								var alertStr = "error getting xhr[xhri2].readyState and xhr[xhri2].status";
							}
							//alert(alertStr);
						}
						var myElement = 'list_of_friends_busy';
						var elementToShow = document.getElementById(myElement);
						elementToShow.style.visibility = 'hidden';
					};
				xhr[xhri2].setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				xhr[xhri2].send(qry);
				// update friends head
				// set up query and url
				var qry = 'js=yes&user_id=' + user_id;
				var url = 'myhome/fr_head.php';
				// handle ajax object
				var xhri3 = xhrRequest('html');
				xhr[xhri3].open('POST', url, true);
				xhr[xhri3].onreadystatechange = function () {
						if (xhr[xhri3].readyState == 4 && xhr[xhri3].status == 200) {
							var myElement = 'mh_user_summary_fr_head';
							var elementToShow = document.getElementById(myElement);
							elementToShow.innerHTML = "";
							elementToShow.innerHTML = xhr[xhri3].responseText;
						} else {
							try {
								var alertStr = "xhr[xhri3].readyState=" + xhr[xhri3].readyState + " xhr[xhri3].status=" + xhr[xhri3].status;
							}
							catch (e) {
								var alertStr = "error getting xhr[xhri3].readyState and xhr[xhri3].status";
							}
							//alert(alertStr);
						}
					};
				xhr[xhri3].setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				xhr[xhri3].send(qry);
			};
		xhr[xhri].setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xhr[xhri].send(qry);
	}
}

function blockFriend(id,user_id) {
	this_id = id;
	this_user_id = user_id;
	if (!xmlhttp) {
		xmlhttp = getXmlHttpRequest();
	}
	if (!xmlhttp) {
		alert("could not create XmlHttpRequest");
		return;
	}
	var qry = 'js=yes&id=' + this_id + '&user_id=' + this_user_id;
	var url = 'myfriends/blockFriend.php';
	//alert("setup xmlhttp params");
	//return;
	xmlhttp.open('POST', url, true);
	xmlhttp.onreadystatechange = updatePendingFriends;
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	//alert("send xmlhttp request");
	//return;
	xmlhttp.send(qry);
}

function unblockFriend(id,user_id) {
	this_id = id;
	this_user_id = user_id;
	if (!xmlhttp) {
		xmlhttp = getXmlHttpRequest();
	}
	if (!xmlhttp) {
		alert("could not create XmlHttpRequest");
		return;
	}
	var qry = 'js=yes&id=' + this_id + '&user_id=' + this_user_id;
	var url = 'myfriends/unblockFriend.php';
	//alert("setup xmlhttp params");
	//return;
	xmlhttp.open('POST', url, true);
	xmlhttp.onreadystatechange = updatePendingFriends;
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	//alert("send xmlhttp request");
	//return;
	xmlhttp.send(qry);
}

function updatePendingFriends() {
	//alert("start updatePendingFriends");
	if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
		var myElement = 'pending_busy';
		var elementToShow = document.getElementById(myElement);
		elementToShow.style.visibility = 'visible';
		var qry = 'js=yes&id=' + this_id + '&user_id=' + this_user_id;
		var url = 'myhome/friends_new_requests.php';
		//alert("setup xmlhttp params");
		//return;
		//alert("send xmlhttp request (updatePendingFriends)");
		xmlhttp.open('POST', url, true);
		xmlhttp.onreadystatechange = printPendingFriends;
		xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		//alert("send xmlhttp request");
		//return;
		xmlhttp.send(qry);
	} else {
		try {
			var alertStr = "xmlhttp.readyState=" + xmlhttp.readyState + " xmlhttp.status=" + xmlhttp.status;
		}
		catch (e) {
			var alertStr = "error getting xmlhttp.readyState and xmlhttp.status";
		}
		//alert(alertStr);
	}
}

function printPendingFriends() {
	//alert("start printPendingFriends");
	if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
		//var myElement = 'report_friends';
		//var elementToShow = document.getElementById(myElement);
		//alert(myElement);
		//elementToShow.innerHTML = "";
		var myElement = 'friends_new_requests';
		var elementToShow = document.getElementById(myElement);
		//alert(myElement);
		elementToShow.innerHTML = "";
		elementToShow.innerHTML = xmlhttp.responseText;
		updateFriends(this_id,this_user_id);
		//updateBlockedFriends(this_id,this_user_id);
	} else {
		try {
			var alertStr = "xmlhttp.readyState=" + xmlhttp.readyState + " xmlhttp.status=" + xmlhttp.status;
		}
		catch (e) {
			var alertStr = "error getting xmlhttp.readyState and xmlhttp.status";
		}
		//alert(alertStr);
	}
	var myElement = 'pending_busy';
	var elementToShow = document.getElementById(myElement);
	elementToShow.style.visibility = 'hidden';
}

function updateFriends(this_id,this_user_id) {
	if (!xmlhttp) {
		xmlhttp = getXmlHttpRequest();
	}
	if (!xmlhttp) {
		alert("could not create XmlHttpRequest");
		return;
	}
	var myElement = 'list_of_friends_busy';
	var elementToShow = document.getElementById(myElement);
	elementToShow.style.visibility = 'visible';
	var qry = 'js=yes&id=' + this_id + '&user_id=' + this_user_id;
	var url = 'myhome/list_of_friends.php';
	//alert("setup xmlhttp params");
	//return;
	xmlhttp.open('POST', url, true);
	xmlhttp.onreadystatechange = printFriends;
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	//alert("send xmlhttp request");
	//return;
	xmlhttp.send(qry);
}

function printFriends() {
	if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
		var myElement = 'friends_list';
		var elementToShow = document.getElementById(myElement);
		//alert(myElement);
		elementToShow.innerHTML = "";
		elementToShow.innerHTML = xmlhttp.responseText;
	} else {
		try {
			var alertStr = "xmlhttp2.readyState=" + xmlhttp.readyState + " xmlhttp2.status=" + xmlhttp.status;
		}
		catch (e) {
			var alertStr = "error getting xmlhttp.readyState and xmlhttp.status";
		}
		//alert(alertStr);
	}
	var myElement = 'list_of_friends_busy';
	var elementToShow = document.getElementById(myElement);
	elementToShow.style.visibility = 'hidden';
}

function updateFriendsHead() {

}

function updateBlockedFriends(this_id,this_user_id) {
	if (!xmlhttp2) {
		xmlhttp2 = getXmlHttpRequest();
	}
	if (!xmlhttp2) {
		alert("could not create XmlHttpRequest");
		return;
	}
		var qry = 'js=yes&id=' + this_id + '&user_id=' + this_user_id;
		var url = 'myfriends/blocked_friendships.php';
		//alert("setup xmlhttp params");
		//return;
		xmlhttp2.open('POST', url, true);
		xmlhttp2.onreadystatechange = printBlockedFriends;
		xmlhttp2.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		//alert("send xmlhttp request");
		//return;
		xmlhttp2.send(qry);
}

function printBlockedFriends() {
	if (xmlhttp2.readyState == 4 && xmlhttp2.status == 200) {
		var myElement = 'blocked_friendships';
		var elementToShow = document.getElementById(myElement);
		//alert(myElement);
		elementToShow.innerHTML = "";
		elementToShow.innerHTML = xmlhttp2.responseText;
	} else {
		try {
			var alertStr = "xmlhttp2.readyState=" + xmlhttp2.readyState + " xmlhttp2.status=" + xmlhttp2.status;
		}
		catch (e) {
			var alertStr = "error getting xmlhttp2.readyState and xmlhttp2.status";
		}
		//alert(alertStr);
	}
}

function report_friend_abuse(user_id,f_id,f_user_id,action,this_form) {
	show_floating_box('list_of_friends','350');
	var xhri = xhrRequest('html');
	if (action == "report_friend") {
		var qry = 'js=yes&user_id=' + user_id + '&f_id=' + f_id + '&f_user_id=' + f_user_id + '&action=' + action;
	} else if (action == "do_report_friend") {
		var reported_user_name = this_form.reported_user_name.value;
		var reason = this_form.reason.value;
		var qry = 'js=yes&user_id=' + user_id + '&f_id=' + f_id + '&f_user_id=' + f_user_id + '&action=' + action + '&reported_user_name=' + reported_user_name + '&reason=' + reason;
	}
	var url = 'myhome/reportFriend.php';
	xhr[xhri].open('POST', url, true);
	xhr[xhri].onreadystatechange = function () {
			if (xhr[xhri].readyState == 4 && xhr[xhri].status == 200) {
				var theElementId = 'floating_box';
				var elementToShow = document.getElementById(theElementId);
				elementToShow.innerHTML = fb_close_link() + xhr[xhri].responseText;
				xi[xhri] = 1;
 				xhr[xhri] = null;
			} else {
				try {
					var alertStr = "xhr[xhri].readyState=" + xhr[xhri].readyState + " xhr[xhri].status=" + xhr[xhri].status;
				}
				catch (e) {
					var alertStr = "error getting xhr[xhri].readyState and xhr[xhri].status";
				}
				//alert(alertStr);
			}
		};
	xhr[xhri].setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xhr[xhri].send(qry);
}

function friend_func_warn(form) {
	if (!form.mll_friends.checked) {
		var myElement = 'floating_box';
		var elementToShow = document.getElementById(myElement);
		elementToShowPos = findPos(form.mll_friends);
		elementToShow.style.visibility = 'visible';
		elementToShow.style.top = elementToShowPos[1];
		elementToShow.style.left = elementToShowPos[0];
		elementToShow.style.width = '200px';
	} else {
		form.mll_friends_messages.checked = true;
		form.mll_friends_emails.checked = true;
	}
}

function friend_func_warn_confirm(response) {
	var myElement = 'floating_box';
	var elementToShow = document.getElementById(myElement);
	elementToShow.style.visibility = 'hidden';
	if (response) {
		document.profile.mll_friends_messages.checked = false;
		document.profile.mll_friends_emails.checked = false;
	} else {
		document.profile.mll_friends.checked = true;
	}
}

