<!--
function add_label(obj, pm) {
	var holder = ajax_box();
	var pos = get_position(obj.parentNode);
	holder.style.width = '170px';
	holder.style.top = (pos[0]+10)+'px';
	holder.style.left = (pos[1] - 110)+'px';
	form_str = "<form name=\"add_label_form\" onsubmit=\"return add_label_submit("+ pm +");\"><span style=\"float: left;\"><span class=\"title\">Add Label</span><br /><input type=\"text\" name=\"label\" size=\"20\" /><br /><input type=\"button\" onclick=\"add_label_submit("+ pm +");\" value=\"Add Label\" /><input type=\"button\" value=\"Cancel\" onclick=\"show_hide('ajax_box');\" /></span>";
	if(get('user_labels', ID)) {
		holder.style.left = (pos[1] - 210)+'px';
		holder.style.width = '300px';
		labels = get('span', TAG, get('user_labels', ID));
		label_str = "";
		for(l=0; l<labels.length; l++) {
			label_name = labels.item(l).innerHTML;
			label_str += "<a href=\"javascript:void(0);\" onclick=\"document.add_label_form.label.value = '"+ label_name +"';\">"+ label_name +"</a><br />";
		}
		form_str += "<span style=\"float: right;\">"+ label_str +"</span>";
	}
	form_str += "</form>";
	holder.innerHTML = form_str;
	return false;
}
function add_label_submit(pm) {
	label = document.add_label_form.label.value;
	show_hide('ajax_box');
	dataRequest("/action/add_label/pm/"+ escape(pm) +"/label/"+ escape(label) +"/conn/" + vf_conn);
	return false;
}
function add_label_show(pm, label) {
	if(get('pm-labels-'+pm, ID)) {
		get('pm-labels-'+pm, ID).innerHTML = label;
	}
	return false;
}
function remove_label(obj, pm, label) {
	var object = obj.parentNode.parentNode;
	var parent = object.parentNode;
	if(confirm('Are you sure you wish to delete this label?')) {
		if(pm) {
			dataRequest("/action/remove_label/pm/" + pm + "/label/" + label+"/conn/" + vf_conn);
		} else {
			dataRequest("/action/remove_label/label/"+ label +"/conn/" + vf_conn);
		}
		object.parentNode.removeChild(object);
		if(!parent.firstChild) {
			parent.innerHTML = "<i>None</i>";
		}
	}
	return false;
}
function add_participant(obj, pm) {
	var holder = ajax_box();
	var pos = get_position(obj);
	holder.style.width = '250px';
	holder.style.top = (pos[0] + 10)+'px';
	holder.style.left = (pos[1] + 10)+'px';
	form_str = "<form name=\"add_participant_form\" onsubmit=\"return add_participant_submit("+ pm +");\"><span style=\"float: left;\"><span class=\"title\">Add Participants</span><br /><input type=\"text\" id=\"pm_to\" name=\"participant\" size=\"20\" onkeyup=\"lookup_username()\" onblur=\"setTimeout('hide_username_suggestions()', 200);\" /><br /><input type=\"button\" onclick=\"add_participant_submit("+ pm +");\" value=\"Add Participant(s)\" /><input type=\"button\" value=\"Cancel\" onclick=\"show_hide('ajax_box');\" /></span>";
	form_str += "</form>";
	holder.innerHTML = form_str;
	get('sugested_username', ID).style.marginTop = '-5px';
	get('sugested_username', ID).style.marginLeft = '15px';
	get('sugested_username', ID).style.zIndex = '300';
	return false;
}
function add_participant_submit(pm) {
	participant = document.add_participant_form.participant.value;
	show_hide('ajax_box');
	dataRequest("/action/add_participant/pm/"+ escape(pm) +"/participant/"+ escape(participant) +"/conn/" + vf_conn);
	return false;
}
function add_participant_show(participant) {
	if(get('pm-participants', ID)) {
		get('pm-participants', ID).innerHTML = participant;
	}
	return false;
}
function remove_participant(obj, pm, user) {
	var object = obj.parentNode.parentNode;
	var parent = object.parentNode;
	var confirm_message = (user == vf_username)? 'Are you sure you wish to leave this conversation?' : 'Are you sure you wish to remove this participant?';
	if(confirm(confirm_message)) {
		dataRequest("/action/remove_participant/pm/" + pm + "/participant/" + user +"/conn/" + vf_conn);
		object.parentNode.removeChild(object);
		if(user == vf_username) {
			location.href = "/action/pm";
		}
	}
	return false;
}
function show_usernames(arr, non) {
	var pm_to = get('pm_to', ID);
	var current_send_to = pm_to.value.replace(/\s/, '').split(/,/);
	var txt = "";
	for(t=0; t<arr.length; t++) {
		var already_listed = false;
		for(c=0; c<current_send_to.length; c++) {
			if(current_send_to[c] == arr[t][0]) {
				already_listed = true;
				break;
			}
		}
		if(!already_listed) {
			if(txt != "") {
				txt += "<br />";
			}
			txt += "<a href=\"#\" onclick=\"set_username('"+ arr[t][0] +"'); return false;\">"+ arr[t][1] +" ("+ arr[t][0] +")</a>";
		}
	}
	if(txt != "") {
		var pos = get_position(pm_to);
		var suggest_holder = get('sugested_username', ID);
		suggest_holder.style.display = 'block';
		suggest_holder.style.top = (pos[0] + 20) + 'px';
		suggest_holder.style.left = (pos[1] + (pm_to.value.length * 8)) + 'px';
		suggest_holder.innerHTML =  txt;
	}
}
function lookup_username() {
	if("undefined" != typeof event && event.keyCode) {
		if(event.keyCode == '32' || event.keyCode == '44' || event.keyCode == '188') {
			hide_username_suggestions();
			return false;
		}
	}
	var pm_to = get('pm_to', ID);
	var pm_to_username = (pm_to.value.match(/(,|\s|^|\t)((\w|\d)+)$/))? RegExp.$2 : false;
	if(pm_to_username && pm_to_username.length >= 2) {
		dataRequest('/action/usernamelookup/conn/'+ vf_conn +'/il/1/user/'+pm_to_username, true);
	}
}
function set_username(username) {
	var pm_to = get('pm_to', ID);
	pm_to.value = pm_to.value.replace(/(,|\s|^|\t)((\w|\d)+)$/, "$1"+username);
	hide_username_suggestions();
}
function hide_username_suggestions() {
	if(get('sugested_username', ID)) {
		get('sugested_username', ID).style.display = 'none';
	}
}
//-->