//AGENDA START
function ag_changeserveurs() {
		plang = $('#agendaserverlang').val();    	
		$.ajax({ 
			   type: "POST", 
			   url: "ajax/set_events.php", 
			   data: "action=serveur&plang=" + plang, 
			   dataType: "xml", 
			   success: function(xml){
					var _id_serveur = "";
					var _serveurname = "";
					var options = '';
					$("/setperso/serverlist/serveur", xml).each(function(){
					_id_serveur = $("id_serveur", this).text();
					_serveurname = $("serveurname", this).text();
        			options += '<option value="' + _id_serveur + '">' + _serveurname + '</option>';
					});
					$("select#agendaserver").html(options);
					($('#agendaserver')[0]).selectedIndex = 0;
				}
		
		});		
}


function affiche_events() {
		xlang = $('#agendaserverlang').val();    	
		xserver = $('#agendaserver').val();
		xfaction = $('#agendafaction').val();
		xuser = $('#agendauser').val();
		xmdj = $('#agendamdj').val();
		xadm = $('#agendaadm').val();
		$.ajax({ 
			   type: "POST", 
			   url: "ajax/set_events.php", 
			   data: "action=affevents&xlang=" + xlang + "&xserver=" + xserver + "&xfaction=" + xfaction + "&xuser=" + xuser + "&xmdj=" + xmdj + "&xadm=" + xadm, 
			   dataType: "xml", 
			   async: false,
			   success: function(xml){			   
				eventlist = '';
				eventlist += "<table cellspacing=\"0\" cellpadding=\"0\" width=\"100%\">";

				$("/setevent/eventlist/event", xml).each(function(){
					_id_event = $("id_event", this).text();
					_eventname = $("eventname", this).text();
					_INSTANCE_NAME = $("INSTANCE_NAME", this).text(); 
					_objectifperso = $("objectifperso", this).text();
					_id_user = $("id_user", this).text();
					_username = $("username", this).text();
					_id_raid = $("id_raid", this).text();
					_id_group = $("id_group", this).text();
					_Tdatetxt = $("Tdatetxt", this).text();
					_Tstarttxt = $("Tstarttxt", this).text();
					_Tendtxt = $("Tendtxt", this).text();
					_raidname = $("raidname", this).text();
					_statuscolorcode = $("statuscolorcode", this).text();
					_status = $("status", this).text();
					_registered = $("registered", this).text();
					_linecolor = $("linecolor", this).text();
					_icoinfo = $("icoinfo", this).text();
					_icoedit = $("icoedit", this).text();
					_icoedit_link = $("icoedit_link", this).text();
					_icoedit_alt = $("icoedit_alt", this).text();
					_F_ico_run = $("F_ico_run", this).text();
					_F_alt_run = $("F_alt_run", this).text();
					_objectifname = $("objectifname", this).text();
					eventlist += "<tr class=\"agendaline"+ _linecolor + "\">";
					eventlist += "<td><div><span class=\"agenda_date\">" + _Tdatetxt + "&nbsp;&nbsp;&nbsp;" + _Tstarttxt +"</span></div>";
					eventlist += "<div class=\"agenda_objectif\">" + _objectifname + "</div></td>";
					eventlist += "<td class=\"agenda_status\"><font style=\"color:#" + _statuscolorcode + "\">" + _status + "</font></td>";
					eventlist += "<td class=\"agenda_ico\"><a href=\"http://www.lacrimaedraconis.org/LDseti/" + _id_raid + "/viewevent.html\"><img src=\"" + _F_ico_run + "\" alt=\"" + _F_alt_run + "\"/></a></td>";
					eventlist += "</tr>";
				
				});

					eventlist += "<tr class=\"agendalineend\"><td></td></tr></table>";
					$(".agenda_list").html(eventlist);
				}
		
		});		
}



//AGENDA END




$(document).ready(function(){
affiche_events();

//AGENDA START
	$('#agendafaction').change(function(){
	affiche_events();								   
	});
	$('#agendaserverlang').change(function(){
	ag_changeserveurs();
	affiche_events()
	});
	$('#agendaserver').change(function(){
	affiche_events()
	});

//AGENDA END



	$('[@id^=newstitle_]').click(function(){	
		_idselected = $(this).attr("id");
		_objectclick = this;
		_strlength = _idselected.length;
		_idselected = _idselected.substring(10, _strlength);

	if ($('#imgnewsarb_' + _idselected).attr("src") == "images/tree3.gif") {
		$('#imgnewsarb_' + _idselected).attr({ src: "images/tree4.gif" });
		$('#newslinecont_' + _idselected).slideDown("normal");
	} else {
		$('#imgnewsarb_' + _idselected).attr({ src: "images/tree3.gif" });
		$('#newslinecont_' + _idselected).slideUp("normal");
	}
	});




});






