if (xhr_enabled()) {

	function addNameList(ido){
		var popup = jQuery('#namelist-popup');
		
		// ie6 can't handle 'fixed' so use 'absolute'
		var IE6 = false /*@cc_on || @_jscript_version < 5.7 @*/;
		var position = IE6 ? 'absolute' : 'fixed';
		
		if (popup.length == 0) {
			jQuery.get('/Names/namelist_pop.php?id=' + ido, function(html){
				// check for login error
				if (html == 'LOGIN_ERROR') {
					// redirect to login page
					window.location.href = '/user/login.php?id=' + ido;
					return;
				}
				
				// otherwise, html is the popup contents
				jQuery('<div id="namelist-popup"></div>').html(html).css({
					position: position,
					top: '250px',
					left: Math.max(0, (window.innerWidth || document.body.clientWidth) - 240),
					width: '200px',
					cursor: 'move',
					'z-index': 10000
				}).draggable({
					// need to maintain fixed positioning
					start: function(){
						jQuery('#dragHelper').css('position', position);
					},
					stop: function(){
						jQuery(this).css('position', position);
					}
				}).appendTo('body');
			});
		}
		else {
			// get the info for that name ID, and add to namelist in the background
			jQuery.getJSON('/assets/scripts/namelist_ajax.php', {
				method: 'addNameByID',
				id: ido
			}, function(data){
				// add row to the table
				var table = jQuery('.namelist-table', popup);
				
				if (data.gender == 'F') 
					var classColor = 'girlpink';
				else 
					if (data.gender == 'M') 
						var classColor = 'boyblue';
					else 
						var classColor = 'either';
				
				var row = jQuery('<tr></tr>').addClass(classColor).appendTo(table);
				jQuery('<td></td>').text(data.name).appendTo(row);
				
			});
		}
	}
	
	function namelist_pop_close(){
		jQuery('#namelist-popup').remove();
		return false;
	}
	
} // xhr_enabled