if (!nbeCal)
	var nbeCal = new Array();
var detShow = new Array();

Agenda = {
	update: function(btn, action, id) {
		function getAnswer(req) {
			if (req.responseText) {
				if (req.responseText == 'nonabo')
					showError(_str['ErrUpdate']);
				else
					setMessage(req.responseText);
			}
		}
		function setMessage(msg) {
			var details = msg.split('|');
			if ($('addCal_'+id))
			{
				$((action == 'del' ? 'del' : 'add')+'Cal_'+id).style.display = 'none';
				$((action == 'del' ? 'add' : 'del')+'Cal_'+id).style.display = 'block';
				if (details[2])
				{
					if ($('abo_'+id))
						show('abo_'+id);
					if (detShow[id]) {
						$W('det_'+id, details[2]);
						$('det_'+id).className = 'cConcertDetailsFull';
					}
				}
				else
				{
					hide('abo_'+id);
					$('tr_'+id+'_3').innerHTML = '&nbsp;';
				}
				if ($('abonb_'+id))
					$W('abonb_'+id, details[1] != 0 ? details[1] : '');
				if (!details[1])
					Agenda.abonnes(id);
			}
			else
			{
				hide('tr_'+id+'_1');
				hide('tr_'+id+'_2');
				hide('tr_'+id+'_3');
				$('details_'+id).id = '';
			}
			if (details[3] && nbeCal[details[3]]) {
				nbeCal[details[3]]--;
				if ($('j'+details[3]) && nbeCal[details[3]] == 0) {
					var re = /(sel)/i;
					$('j'+details[3]).className = $('j'+details[3]).className.replace(re, "$1", "");
				}
			}
		}
		if (!$('aboId'))
			showError(_str['ErrUpdate']);
		else
			Request.send('/outils/agenda_update.php5', getAnswer, 'action='+action+'&id='+id);
	},
	avis: function(id) {
		function displayAvis(req) {
			if (req.responseText)
			{
				if (req.responseText == 'nonabo')
					showError(_str['ErrAvis']);
				else
					tempo();
			}
		}
		Request.send('/outils/avis_display.php5', displayAvis, 'id='+id)
	},
	abonnes: function(id) {
		function showAbonnes(req) {
			if (req.responseText)
			{
				$W('det_'+id, req.responseText);
				$('det_'+id).className = 'cConcertDetailsFull';
				detShow[id] = true;
			}
		}
		function hideAbonnes() {
			$W('det_'+id, '');
			$('det_'+id).className = 'cConcertDetails';
			detShow[id] = false;
		}
		if (!trim($('det_'+id).innerHTML))
			Request.send('/outils/abonnes_liste.php5', showAbonnes, 'id='+id);
		else
			hideAbonnes();
	}
}
