function addFavorite(user_id) {
	var req = new DataRequestor();
	req.addArg(_GET, "action", "add_favorite");
	req.addArg(_GET, "user_id", user_id);
	req.getURL("index.php?name=Dashboard&file=ajax");

	req.onLoad = function (data) {
		document.getElementById('msg').style.visibility = 'visible';
		document.getElementById('msg').style.display = '';
		document.getElementById('msg_text').innerHTML = data;
	}
}

function sendKiss(user_id) {
	var req = new DataRequestor();
	req.addArg(_GET, "action", "send_kiss");
	req.addArg(_GET, "user_id", user_id);
	req.getURL("index.php?name=Dashboard&file=ajax");

	req.onLoad = function (data) {
		document.getElementById('msg').style.visibility = 'visible';
		document.getElementById('msg').style.display = '';
		document.getElementById('msg_text').innerHTML = data;
	}
}

function showModNotes(user_id) {
	var req = new DataRequestor();
	req.addArg(_GET, "action", "show_mod_notes");
	req.addArg(_GET, "user_id", user_id);
	req.getURL("index.php?name=Dashboard&file=ajax");

	req.onLoad = function (data) {
		document.getElementById('mod_notes').innerHTML = data;
	}
}
function hideDiv(div) {
	document.getElementById(div).style.visibility = 'hidden';
	document.getElementById(div).style.display = 'none';
}

function showDiv(div) {
	document.getElementById(div).style.visibility = 'visible';
	document.getElementById(div).style.display = '';
}

function saveNote(user_id, note_body) {
	if(user_id == '' || note_body == '') {
		return false;
	}
	var req = new DataRequestor();
	req.addArg(_GET, "action", "save_mod_notes");
	req.addArg(_GET, "user_id", user_id);
	req.addArg(_GET, "note_body", URLEncode(note_body));
	req.getURL("index.php?name=Dashboard&file=ajax");

	req.onLoad = function (data) {
		showModNotes(user_id);
	}
}

function URLEncode(plaintext)
{
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
			    alert( "Unicode Character '" 
                        + ch 
                        + "' cannot be encoded using standard URL encoding.\n" +
				          "(URL encoding only supports 8-bit characters.)\n" +
						  "A space (+) will be substituted." );
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for

	return encoded;
};

