var ListeFiche;
var BaseImg="/images/skins/skin_01/images/";
var TimeEnd;
var ladate = new Date();
function ds_getleft(el) {
	var tmp = el.offsetLeft;
	el = el.offsetParent
	while(el) {
		tmp += el.offsetLeft;
		el = el.offsetParent;
	}
	return tmp;
}

function Init2(){

	var Noeuds = new Array('titre');
	var time = ladate.getMilliseconds();
	var myAjax = "";

	myAjax = new Ajax.Request(
      '/exports/xml_catalogue.asp?start=0&limit=3&sid=c6b29c2e4df4a06a35db4718a2e628c2&date='+time,
      {
        method: 'get',
        parameters: {},
        onSuccess: function (xhr)
          {
			ListeFiche = new Array();
			var xml = xhr.responseXML;
			var nodeExports=xml.getElementsByTagName('export')[0];
			var Fiches = nodeExports.getElementsByTagName('fiche');
			for(var i=0;i<Fiches.length;i++)
			{

				var Indice = ListeFiche.length;
				var Fiche = Fiches[i];
				var attributes = Fiche.attributes;
				ListeFiche[i] = new Array();
				for(var j=0;j<attributes.length;j++)
				{
					ListeFiche[Indice][attributes[j].name]= attributes[j].nodeValue;
				}
				for(var j=0;j<Noeuds.length;j++)
				{
					
					ListeFiche[Indice][Noeuds[j]] = typeof(Fiche.getElementsByTagName(Noeuds[j])[0].text)=="undefined"?Fiche.getElementsByTagName(Noeuds[j])[0].textContent:Fiche.getElementsByTagName(Noeuds[j])[0].text;
				}
			}

			buildIt2();

		 },
		onFailure: function(xhr)
		{

			buildIt2();
		}
      }
    );
};

function buildIt2()
{
	var container = $('hp_news_box2');
	
	container.innerHTML = "";
	
	for(var i=0;i<ListeFiche.length;i++)
	{


		var div = el("div",container);
		div.addClassName("hp_txt_news");

		var a =el("a",div);
		a.href = "/index.asp?ID=387&IDF="+ListeFiche[i]['id'];
		a.innerHTML = "<span style=\"color: rgb(16, 167, 143);\">&raquo;</span>&nbsp;"+ListeFiche[i]['titre'];

	}
}


function getTime()
{
	return ladate.getTime();
}

function in_array(val,array)
{
	for(var i=0;i<array.length;i++)
		if(val==array[i])
			return true;
	return false;
}

function el(type,attach)
{
	var el = document.createElement(type);
	Element.extend(el);
	if(typeof(attach)!="undefined")
		attach.appendChild(el);
	return el;
}
setTimeout("Init2()",200);
