/* * * * * * * * * * * * * * * * * * * * * * * * *
 *			Seir Anphin User Library             *
 *			 Copyright Darrel Grant	             *
 *			  http://www.anphin.com	             *
 * * * * * * * * * * * * * * * * * * * * * * * * */

user = {

	init : function() {
		// Add a keyup listener for the PM compose page
		if ($('search_field')) {
			dom.addEvent($('search_field'), 'keyup', user.init_user_search, false);
		}

		// Add an event to Bio tab on user profiles.
		// Other tabs use inline javascript 'cuz we can't
		// add their listeners here without knowing
		// which blocks are installed.
		if ($('profile_bio')) {
			dom.addEvent($('profile_bio'), 'click', user.linkBio, false);
		}
	},

	linkBio : function(e) {
		sa2.copyInnerHTML('bio', 'user_contents', 'profile_bio');
		dom.stopDefault(e);
	},

	init_user_search : function() {
		setTimeout('user.search_users()', 800);
	},

	search_users : function() {
		var url = "index.php?m=index&op=search_users&str=" + $('search_field').value + "&limit=5";

		ajax.init();
		ajax.targetId = 'user_search_results';
		ajax.makeRequest('GET', url, ajax.silentLoader);
	}
}

sa2.onLoad(user.init);

