/*
 * Ensemble de variables / fonctions par rapport à des libellés d'une langue
 */

// Libéllés

function add_childdiv(id, birthday, first_name)
{
	child_div = document.createElement('div');
	child_div.setAttribute('id', 'child_' + id);
								
	childc = $('child_content').appendChild(child_div);

	lib = '<table align="center" cellspacing="0" cellpadding="1" width="450">';
	lib += '<tr valign="middle" height="25">';
	lib += '<td class="cell_left" width="150">&nbsp;</td>';
	lib += '<td class="cell_right">';
	lib += '<b>'+unescape(first_name)+'</b>, n&eacute;(e) le '+unescape(birthday)+'&nbsp;&nbsp;&nbsp;';
	lib += '<a href="#" onclick="ask = confirm(\'Etes-vous sûr  ?\'); if(ask) rm_childdiv('+id+');"><b>Supprimer</b></a>';
	lib += '</td>';
	lib += '</tr>';
	lib += '</table>';

	$(child_div).innerHTML = lib;
}
 
function add_hobbydiv(id, hobby, hobby_description, level)
{
	hobby_div = document.createElement('div');
	hobby_div.setAttribute('id', 'hobby_' + id);
								
	hobbyc = $('hobby_content').appendChild(hobby_div);

	lib = ''
	lib += '<table align="center" cellspacing="0" cellpadding="1" width="550">';
	lib += '<tr valign="middle" height="25">';
	lib += '<td class="cell_left" width="150">&nbsp;</td>';
	lib += '<td class="cell_right">';
	lib += '<u>' + unescape(hobby) + '</u> : <b>' + unescape(hobby_description) + '</b> (' + level + ')&nbsp;&nbsp;&nbsp;';
	lib += '<a href="#" onclick="ask = confirm(\'Etes-vous sûr  ?\'); if(ask) rm_hobbydiv('+id+');"><b>Supprimer</b></a>';
	lib += '</td>';
	lib += '</tr>';
	lib += '</table>';
	
	$(hobby_div).innerHTML = lib;
}

function affiche_hobby(id, hobby, hobby_description, level)
{
	hobby_div = document.createElement('div');
	hobby_div.setAttribute('id', 'hobby_' + id);
								
	hobbyc = $('hobby_content').appendChild(hobby_div);

	lib = ''
	lib += '<u>' + unescape(hobby) + '</u> : <b>' + unescape(hobby_description) + '</b> (' + level + ')&nbsp;&nbsp;&nbsp;';
	
	$(hobby_div).innerHTML = lib;
}

function add_networkdiv(id, social_network, pseudo)
{
	network_div = document.createElement('div');
	network_div.setAttribute('id', 'network_' + id);
								
	networkc = $('network_content').appendChild(network_div);

	lib = '<table align="center" cellspacing="0" cellpadding="1" width="550">';
	lib += '<tr valign="middle" height="25">';
	lib += '<td class="cell_left" width="250">&nbsp;</td>';
	lib += '<td class="cell_right">';
	lib += '<u>' + unescape(social_network) + '</u> : <b>' + unescape(pseudo) + '</b>&nbsp;&nbsp;&nbsp;';
	lib += '<a href="#" onclick="ask = confirm(\'Etes-vous sûr  ?\'); if(ask) rm_networkdiv('+id+');">Supprimer</a>';
	lib += '</td>';
	lib += '</tr>';
	lib += '</table>';
	
	$(network_div).innerHTML = lib;
}

function add_friend(id_user)
{
	au = new Ajax.Request('member.php',
	{
		postBody: $H({'id_user': id_user, 'action': 'add_friend'}).toQueryString(),
		onComplete: function (xhr)
					{
						rep = xhr.responseText;
						
						if(rep == '1')
						{
							lib = '<b>Ami ajout&eacute; !</b>';
							$('member_' + id_user).innerHTML = lib;
						}
					}
	});
}

function friend_receive_infos(id_user)
{
	au = new Ajax.Request('member.php',
	{
		postBody: $H({'id_user': id_user, 'action': 'friend_receive_infos', 'receive_infos': $('friend_receive_infos_' + id_user).checked}).toQueryString(),
		onComplete: function (xhr)
					{
						rep = xhr.responseText;
						
						if(rep == '1')
						{
							lib = 'Infos mis à jour';
							$('member_' + id_user).innerHTML = lib;
							tm = 2000;
							idx = id_user;
							action = "$('member_' + idx).innerHTML = '';";
							wg_timer();
						}
					}
	});
}
