/* nraibaud */
// on recupere le profil
var profilID = Cookie.get('profil');
if(profilID == "") profilID  = 0;



/************* Les classes des boites outils de navigation horizontale sur la home page et de la barre de droite dans les pages internes ************/
var docCenter = { 
	name : 'DocCenter',
	lien : config_docs.link_xml,
	nameDiv : 'conteneur_global_doccenter',
	bool_first :0,
	config : config_docs,
	cookie_first_time:0
}
	 
var myMag = {
	name :'MyMag',
	lien : config_mymag.link_xml,
	nameDiv : 'conteneur_global_myMag',
	bool_first :0,
	config : config_mymag,
	cookie_first_time:0
}

var glossary = {
	name :'Glossary',
	lien : config_glossary.link_xml,
	nameDiv : 'conteneur_global_glossary',
	config : config_glossary
}
	
var bookmarks = {
	name :'Bookmarks',
	nameDiv : 'conteneur_global_bookmarks_short',
	config : config_bookmarks
}

var tab_link = config_calendar.link_xml.split(',');
var calendrier = {
	name : 'Calendar',
	lien : tab_link[0],
	nameDiv : 'conteneur_global_calendar',
	laTab : [],
	laTabAdd : function(val){ this.laTab.push(val)},
	laTabEmpty : function(){ this.laTab = []},
	laTabBool : 'vide_le',
	bool_first :0,
	config : config_calendar,
	id_event_long :'', // sers pour l ouil calendrier long
	first_event : 0,
	cookie_first_time : 0 
	}
	
var xml_press = config_press.link_xml.split(',');
	
var press_releases = {
	name :'Press releases',
	lien : xml_press[1],
	nameDiv : 'conteneur_global_Cp',
	bool_first :0,
	config : config_press,
	cookie_first_time : 0 
	}

var products = {
	name :'Product and Services',
	nameDiv :'conteneur_global_products',
	config : config_hightlights
	}

var highlight = {
	name :'Hightlight',
	nameDiv :'outil_highlight',
	config : config_hightlights
	}
	
var news = {
	name :'News',
	nameDiv :'outil_news',
	config : config_news
	}
var jobs = {
	name :'Job Board',
	lien : config_jobs.link_xml,
	nameDiv :'outil_job',
	config : config_jobs
	}

var share = {
	name :'Share Price',
	nameDiv : 'outil_share',
	config : config_share
	}

var media  = {
	name :'media center',
	nameDiv : 'outil_media',
	config : config_media
	}
	
var flash = {
	name :'flash card',
	lien : config_flash.link_xml,
	nameDiv :'outil_flash',
	config :config_flash
	}

var poll = {
	name: 'sondages',
	lien: config_poll_int.link_xml,
	id_sondage: config_poll_int.libelle_defaut,
	nameDiv: 'outil_poll',
	nameDivInterne: 'outil_poll_int',
	nameDivMoodal: 'outil_poll_moodal',
	config: config_poll_int
}


var sites = {
	name: 'sites',
	nameDiv: 'outil_sites',
	nameDivInterne: 'outil_sites_int',
	nameDivMoodal: 'outil_sites_moodal',
	config : config_sites
}

//080115 : La variable contenant la moodalbox ouverte est commune ? toutes les pages afin de tester sa valeur
var moodalboite = "undefined";

	var link_open="";	
	
	//Alexis 080214 : Fondu du texte de r?ponse du glossaire lorsque le message d'erreur s'affiche
var fade_glossaire;

var transition_finie = true;

var boites_edit_ouvertes = 0;

//Fonction de chargement des modules communs ? la home page et aux pages internes
function loadBoxNavigation(myBox) {
	if(boxExist(docCenter.nameDiv))
	{
		this.initConfig(docCenter.config);
		this.initEvent_docCenter();
		//this.sendRequest(docCenter.lien,"GET",docCenter_init);
		this.sendRequest(docCenter.lien,"GET",docCenter_form);
		$('form_docCenter').addEvent('click',function(){boites_edit_ouvertes--; docCenter.bool_first =1,sendRequest(docCenter.lien,"GET",affichage_data_xml);});
	}
	if(boxExist(myMag.nameDiv))
	{
		this.initConfig(myMag.config);
		this.initEvent_myMag();
		//this.sendRequest(myMag.lien,"GET",myMag_init);
		this.sendRequest(myMag.lien,"GET",myMag_form);
		$('form_myMag').addEvent('click',function(){boites_edit_ouvertes--; myMag.bool_first = 1,sendRequest(myMag.lien,"GET",affichage_data_xml_myMag);});
	}
	if(boxExist(glossary.nameDiv))
	{
		this.initConfig(glossary.config);
		this.sendRequest(glossary.lien,"GET",initTheme_glossary);
		this.sendRequest(glossary.lien,"GET",autoImplemente);
		$('valide_go_glossary').addEvent('click',function(){sendRequest(glossary.lien,"GET",affichage_data_xml_glossary);});
	}
	if(boxExist(bookmarks.nameDiv))
	{
		this.initConfig(bookmarks.config);
		//this.sendRequest(bookmarks.lien,"GET",affichage_data_xml_bookmarks);
		this.affiche_mybookmarks();
	}
	
	if(boxExist(calendrier.nameDiv))
	{
		this.initConfig(calendrier.config);
		this.displayCalendar('w0');
		this.sendRequest(calendrier.lien,"GET",init_formCalendar);
		this.initEvent_calendar();
		this.init_clean_calandar();
                
		$('tout').addEvent('click',function(){selectall(document.myformu_calendar.tout,document.myformu_calendar.choix);});
		$('valid_go_calendar').addEvent('click',function(){boites_edit_ouvertes--; calendrier.bool_first=1,sendRequest(calendrier.lien,"GET",affichage_data_xml_calendar);});
		if(calendrier.first_event == 0)
		{
			calendrier.first_event++;
			$('cal_m_01').addEvent('click',function(){incrementTheMonth()});
			$('cal_m_00').addEvent('click',function(){decrementTheMonth()});
		}
		//calendar.cmonth = 1;
		//fillCalendar();
	}
	
	if(boxExist('outil_calendar_long'))
	{
		this.displayCalendar('w0');
		this.initConfig(calendrier.config);
		this.sendRequest(calendrier.lien,"GET",init_formCalendar_long);
		this.sendRequest(calendrier.lien,"GET",init_content_day_long);
		this.initEvent_calendar_long();
		this.init_clean_calandar();
		$('valid_go_calendar').addEvent('click',function(){boites_edit_ouvertes--;calendrier.bool_first=1,sendRequest(calendrier.lien,"GET",affichage_data_xml_calendar_long);});
		$('cal_m_01').addEvent('click',function(){incrementTheMonth_long()});
		$('cal_m_00').addEvent('click',function(){decrementTheMonth_long()});
	}
	
	if(boxExist(press_releases.nameDiv))
	{
		if(typeof(outil_presse_new_xml) != 'undefined'){
			if(outil_presse_new_xml !=""){
				press_releases.lien = outil_presse_new_xml;
			}
		}
		this.initConfig(press_releases.config);
		this.initEvent_press_releases();
		//this.sendRequest(press_releases.lien,"GET",press_releases_init);
		this.sendRequest(press_releases.lien,"GET",press_releases_form);
		this.sendRequest(press_releases.lien,"GET",affichage_data_xml_press_releases);
		$('form_Cp').addEvent('click',function(){boites_edit_ouvertes--;press_releases.bool_first = 1,sendRequest(press_releases.lien,"GET",affichage_data_xml_press_releases);initEvent_press_releases();});
	}
	
	if(boxExist(products.nameDiv))
	{
		this.initConfig(products.config);
		/*this.sendRequest(products.lien,"GET",initSelect_products_countries);
		$('select_country').addEvent('change',function(){sendRequest(products.lien,"GET",initSelect_products_services_link);})
		$('select_services').addEvent('change',function(){sendRequest(products.lien,"GET",select_services);}) 
		$('select_websites').addEvent('change',function(){sendRequest(products.lien,"GET",select_websites);})
		$('valide_go_products').addEvent('click',function(){sendRequest(products.lien,"GET",valide_link_product);})
		this.addMessage_tools();*/
	}
	
	if(boxExist(news.nameDiv))
	{
		this.initConfig(news.config);
	}
	if(boxExist(highlight.nameDiv))
	{
		this.initConfig(highlight.config);
	}
	if(boxExist(jobs.nameDiv))
	{
		this.initConfig(jobs.config);
		//this.sendRequest(jobs.lien,"GET",job_init);
	}	
	if(boxExist(share.nameDiv))
	{
		this.initConfig(share.config);
		$('iframe_share').setAttribute('src', sCheminPageStock);
	}
	if(boxExist(media.nameDiv))
	{
		this.initConfig(media.config);
		//var FO = { movie:"http://www.dailymotion.com/swf/1jT7tWUFP0vvCaL32", width:"285", height:"133", majorversion:"8", build:"0", xi:"true"};
		//UFO.create(FO, "mediacenter");
	}
	if(boxExist(flash.nameDiv))
	{
		//alert("img_flash.src = "+$('img_flash').getAttribute('src'));
		this.initConfig(flash.config);
		//this.sendRequest(flash.lien,"GET",flash_init_form);
		//$('valide_go_flashcard').addEvent('click',function(e){e = new Event(e).stop(); sendRequest(flash.lien,"GET",flashcard_affichage_xml);})
	}
	
	if(boxExist(poll.nameDiv) || boxExist(poll.nameDivInterne) || boxExist(poll.nameDivMoodal))
	{
		//boxes_sur_scene += poll.nameDiv+"\n";
		if (boxExist(poll.nameDivInterne)) {
			poll.config = config_poll_int;
			poll.id_sondage = config_poll_int.libelle_defaut;
		} else if (boxExist(poll.nameDivMoodal)) {
			poll.config = config_poll_moodal;
			poll.id_sondage = config_poll_moodal.libelle_defaut;
		}    
		if (typeof(outil_poll_new_filtre)!= 'undefined') {
            poll.id_sondage = outil_poll_new_filtre;
        }
		this.initConfig(poll.config);
		
		//Ajout des cellules contenant les diff�rents messages de notification
		var div_sondage = $('sondage');
		var div_wait = new Element('div', {'id':'poller_waitMessage'+poll.id_sondage});
		var tab_results = new Element('div', {'id':'poller_results'+poll.id_sondage, 'class':'tab_poller_results'});
		
		div_sondage.appendChild(div_wait);
		div_sondage.appendChild(tab_results);
		
		if(useCookiesToRememberCastedVotes){
			var cookieValue = Poller_Get_Cookie('dhtmlgoodies_poller_'+poll.id_sondage);
			
			if(cookieValue && cookieValue.length>0) {
				displayResultsWithoutVoting(poll.id_sondage);
			} else {
				this.sendRequest(poll.lien+"view?view="+poll.id_sondage,"GET",poll_init_question);
			}
		} else {
			this.sendRequest(poll.lien+"view?view="+poll.id_sondage,"GET",poll_init_question);
		}
	}
	
	if(boxExist(sites.nameDiv))
	{
		//boxes_sur_scene += sites.nameDiv+"\n";
		this.initConfig(sites.config);
		affichage_contenu_sites();
	}
	
}

function poll_init_question(responseXML) {
    var id_sondage = 1;
	
    var xml_sondages = responseXML.getElementsByTagName("sondage");
    
    var xml_sondage = $A(xml_sondages)[0];
    
    var id_sondage = xml_sondage.getAttribute('id');
    
    var question = xml_sondage.getAttribute("question"); 
    
    var reponses = $A(xml_sondage.childNodes);
    
    var div_question = $('poller_question');
    
    div_question.setAttribute('id','poller_question'+id_sondage);
    
    //Ajout des cellules contenant les diff�rents messages de notification
    var div_sondage = $('sondage');
    var div_wait = new Element('div', {'id':'poller_waitMessage'+id_sondage});
    var div_results = new Element('div', {'id':'poller_results'+id_sondage});
    div_sondage.appendChild(div_wait);
    div_sondage.appendChild(div_results);
    
    var tabQuestion = new Element("table", {'style':'width:100%'});
    var trQuestion = new Element("tr");
    var trReponse = new Element("tr");
    var tdQuestion = new Element("td", {'colspan':'2'});
    var tdReponse = new Element("td");
    var tdButton = new Element("td",  {'class':'pollerButton'});
    
    //Insertion de la question d�finie dans le xml du sondage
    var p_question = new Element("p", {'class':'pollerTitle'});
    div_question.appendChild(p_question);
    p_question.innerHTML = question;
    tdQuestion.appendChild(p_question);
    trQuestion.appendChild(tdQuestion);
    
    //Insertion du bouton "go"
    var lien_send = new Element('a', {'id':'vote','href':'#'});
    var img_send = new Element('img', {'src':'/images/btn_ok.jpg', 'alt':'send my vote'});
    lien_send.appendChild(img_send);
    tdButton.appendChild(lien_send);
    
    //Ajout de l'action sur le lien de vote
    lien_send.addEvent('click', function() {
       castMyVote(id_sondage,document.getElementsByName('form_sondage')[0]);
    });
   
    //Contruction du tableau
    trReponse.appendChild(tdReponse);
    trReponse.appendChild(tdButton);
   
    tabQuestion.appendChild(trQuestion);
    tabQuestion.appendChild(trReponse);
    
    //Insertion des r�ponses au sondage (radio boutons)
    reponses.each(function(reponse, index) {
        var p_reponse = new Element('p');
        var id_reponse = reponse.getAttribute("id");
        var texte_reponse = reponse.childNodes[0].nodeValue;
        p_reponse.innerHTML = "<input type=\"radio\" value=\""+id_reponse+"\" name=\"vote["+id_sondage+"]\" ><label for=\"pollerOption"+id_reponse+"\" id=\"optionLabel"+id_reponse+"\" >"+texte_reponse+"</label>";
        p_reponse.className="pollerOption";
        tdReponse.appendChild(p_reponse);
    });
    
    //Ajout du tableau dans le div conteneur
    div_question.innerHTML = "<table style='width:100%'>" + tabQuestion.innerHTML + "</table>";
    
    //Ajout de l'action sur le lien de vote
    $('vote').addEvent('click', function() {
        castMyVote(id_sondage,document.getElementsByName('form_sondage')[0]);
    });
}

/******************************* Les fonctions n?cessaires au requete AJAX *************************/
function getRequeteHttp() 
{ 
	var requeteHttp;
	if(window.XMLHttpRequest)
	{ // Mozilla 
		requeteHttp=new XMLHttpRequest(); 
		if (requeteHttp.overrideMimeType)
		{ // probl?me firefox 
			requeteHttp.overrideMimeType('text/xml'); 
		} 
	} else { 
	  		if (window.ActiveXObject)
			{ // C'est Internet explorer < IE7 
				try 
				{ 
					requeteHttp=new ActiveXObject("Msxml2.XMLHTTP"); 
				} 
				catch(e) 
				{ 
					try
					{ 
						requeteHttp=new ActiveXObject("Microsoft.XMLHTTP");
					} 
					catch(e) 
					{ 
						requeteHttp=null;
					} 
				} 
			}
		}	
	return requeteHttp;
}

function sendRequest(url,method,fx,fx_param) 
{
	var requeteHttp=getRequeteHttp() 
	if (requeteHttp==null) 
	{ 
		alert("Impossible d'utiliser Ajax sur ce navigateur");
	} 
	else 
	{ 
		if ( arguments[1] == 'GET')
		{
			requeteHttp.open(arguments[1],url,true); 
			requeteHttp.onreadystatechange= function(){getResponse(requeteHttp,fx);}
			requeteHttp.send(null); 
		}
			else if ( arguments[1] =='POST')
			{
				requeteHttp.open(arguments[1],url,true); 
				requeteHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
				requeteHttp.onreadystatechange= function(){getResponse(requeteHttp,fx);}
				var sendParam= fx_param();
				//alert(sendParam);
				requeteHttp.send(sendParam); 	
			}
			else
			{
				//alert('erreur methode');	
			}
	} 
	return;
}

function getResponse(requeteHttp,fx)
{
	if( 4 == requeteHttp.readyState && requeteHttp.status == 200)
	{
		var xhr = clean(requeteHttp.responseXML.documentElement);
		fx(xhr);
	}
	if (4 == requeteHttp.readyState && requeteHttp.status == 404) {
		fx(null);
	}
}

function ajaxpage(url, containerid)
{
	var page_request = getRequeteHttp();
	page_request.onreadystatechange=function()
	{
		loadpage(page_request, containerid)
	}		
	page_request.open('GET', url, true)
	page_request.send(null)
}

function loadpage(page_request, containerid)
{
	if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
	//document.getElementById(containerid).innerHTML += page_request.responseText
	 containerid.innerHTML += page_request.responseText;
}

/******************************* Les fonctions de l'outil DocCenter *************************/

function initTheme_docCenter()
{
	var laSelect = $('form_edit_short');
	
	if(typeof(outil_doccenter_new_filtre) == 'undefined') // si le filtre forcer existe pas
	{
			if(typeof(home_filtre_outil_doccenter) != 'undefined' 
			  && home_filtre_outil_doccenter !='' )
			{
				laSelect.value = home_filtre_outil_doccenter ;
			}
				else
				{
					if(Cookie.get(tools['docs_center_element'])
							&& String(getValueCookie(tools['docs_center_element'],4)) != 'undefined' 
								&& getValueCookie(tools['docs_center_element'],4) !=null
									&& getValueCookie(tools['docs_center_element'],4) !="")
					{
						docCenter.cookie_first_time = 1;
						laSelect.value = getValueCookie(tools['docs_center_element'],4)[0];
							
					}
					else if(docCenter.config.libelle_defaut !="" && docCenter.cookie_first_time == 0  )
					{
						docCenter.cookie_first_time = 1;
						laSelect.value = docCenter.config.libelle_defaut ;
					}
					else if(docCenter.config.libelle_defaut =="" && docCenter.cookie_first_time == 0)
					{
						docCenter.cookie_first_time = 1;
						laSelect.value = laSelect.options[0].value;
					}
					else
					{
						laSelect.value = laSelect.options[0].value;
					}
				}
	}
		else
		{	
			laSelect.value = outil_doccenter_new_filtre; // si le filtre forcer existe
		}
}
function initEvent_docCenter()
{
		var div_doc = new Fx.Styles('conteneur_global_doccenter', {duration:750, wait:false});
		var div_doc_edit = new Fx.Styles('edit_box_doc', {duration:200, wait:false});
		
		//ajouter evenement fermeture : sifr r?activ?
		
		$('link_edit_docCenter').addEvent('click', function(){
				boites_edit_ouvertes++;
				//if (navigator.appName=="Netscape") rollbackSIFR();
				div_doc.start({'opacity':0.3});
				//div_doc.start_edits({'visibility':'visible'});
				$('edit_box_doc').setStyle( 'display', 'block' )
		 });
}

function affichage_data_xml(responseXML) 
{
	var laSelect = document.getElementById('form_edit_short');
	var div_docCenter = document.getElementById('docCenter_contenu');
	var xml_docs = responseXML.getElementsByTagName("doc");
	xml_docs = $A(xml_docs);
	//var table = $('table_docCenter');
	var index = 0 ;
	while(index < div_docCenter.childNodes.length  )
	{
		div_docCenter.removeChild(div_docCenter.childNodes[index]);
	}
	if(Cookie.get(tools['docs_center_element'])) // si le cookie exite  on save le theme dans la cookie
	{
	//alert('cookie');
		var tab = [laSelect.value];
		setParamCookie(tools['docs_center_element'],tab);
	}		
		var i ,j,tmp  = 0;
		var en_desordre = true;
        for(i = 0 ; (i < xml_docs.length) && en_desordre; i++)
        {
                en_desordre = false;
                for(j = 1 ; j < xml_docs.length - i ; j++)
                {
                        if(xml_docs[j].childNodes[1].firstChild.nodeValue < xml_docs[j-1].childNodes[1].firstChild.nodeValue)
                        {
                                tmp = xml_docs[j-1];
                                xml_docs[j-1] = xml_docs[j];
                                xml_docs[j] = tmp;
                                en_desordre = true;
                        }
                }
        }
		
		var space = new Element('br');
		//CLEGEB
		//table.appendChild(space);
		
		//080623 : Cr�ation de la liste � puce des fichiers � t�l�charger pour �tre plus lisible par une synth�se vocale
        var elem_ul = new Element('ul', {'class':'liste_docs'});
		
		compteur = 0 ;
		xml_docs.reverse();
		xml_docs.each(function(item,index){
							   	if(laSelect.value == item.parentNode.attributes.getNamedItem('name').nodeValue )
							   	{
									if(compteur < 4 )
									{
										var file = item.childNodes[2].firstChild.nodeValue;
										var sType = Right(item.childNodes[2].attributes.getNamedItem('type').nodeValue,3);
										/*var elem_tbody = new Element('tbody');
										var elem_tr = new Element('tr');
										var elem_td = new Element('td',{'valign':'top','height':'20','width':'25'});*/
										
										//080623 : Element puce � ajouter � la liste des documents
					                    var elem_li = new Element('li', {'class':'puce_document_'+sType});
					                    
					                    var elem_a = new Element('a',{'href':file});
                              var texteAll = item.childNodes[0].firstChild.nodeValue + ((item.childNodes[2].attributes.getNamedItem('size').nodeValue) ? " (" + affiche_poids(item.childNodes[2].attributes.getNamedItem('size').nodeValue) + ")" : "");
					                    elem_a.setHTML(texteAll);
                    
										/*switch(sType)
										{
										case 'xls':
											var elem_img = new Element('img',{'src':base+'/images/xls.gif','width':'17','height':'16'});
											break;    
										case 'ppt':
											var elem_img = new Element('img',{'src':base+'/images/ppt.gif','width':'17','height':'16'});
											break;    
										case 'pdf':
											var elem_img = new Element('img',{'src':base+'/images/pdf.gif','width':'17','height':'16'});
											break;    
										case 'doc':
											var elem_img = new Element('img',{'src':base+'/images/doc.gif','width':'17','height':'16'});
											break;    
										default:
											var elem_img = new Element('img',{'src':base+'/images/vide.gif','width':'17','height':'16'});
											break;    
										}*/
										
										//elem_a.appendChild(elem_img);
                    
					                    elem_li.appendChild(elem_a);
					                    /* var elem_td2 = new Element('td');
					                    var elem_a2 = new Element('a',{'href':file});
					                    elem_a2.setHTML(item.childNodes[0].firstChild.nodeValue);
					                    elem_td2.appendChild(elem_a2);
					                    
					                    elem_tr.appendChild(elem_td);
					                    elem_tr.appendChild(elem_td2);
					                    elem_tbody.appendChild(elem_tr);*/
					                    elem_ul.appendChild(elem_li);
					                    compteur++;
									}
							   	}
							   });
							   
    div_docCenter.appendChild(elem_ul);							   	
							   	
	if(laSelect.value =='all')
	{
		sendRequest(docCenter.lien,"GET",docCenter_init);
	}
	if(	docCenter.bool_first !=0)
	{
		var div_doc = new Fx.Styles('conteneur_global_doccenter', {duration:750, wait:false});
		var div_doc_edit = new Fx.Styles('edit_box_doc', {duration:200, wait:false});
		if (navigator.appName =="Netscape") div_doc.addEvent('onComplete', function() {if (boites_edit_ouvertes==0)initSIFR();});
		div_doc.start({'opacity':1});							
		$('edit_box_doc').setStyle( 'display', 'none' );
		docCenter.bool_first =1;
	}
}


function affiche_poids(filesize) {
  var sizefinale = "";

  if(filesize == 0) {
    sizefinale = "0 oct";
  } else if(filesize <= 1024) {
    sizefinale = Math.round(filesize) + " oct";
  } else if(filesize <= (10*1024)) {
    sizefinale = Math.round((filesize/1024)) + " ko";
  } else if(filesize <= (100*1024)) {
    sizefinale = Math.round((filesize/1024)) + " ko";
  } else if(filesize <= (1024*1024)) {
    sizefinale = Math.round((filesize/1024)) + " ko";
  } else if(filesize <= (10*1024*1024)) {
    sizefinale = Math.round((filesize/(1024*1024))) + " Mo";
  } else if(filesize <= (100*1024*1024)) {
    sizefinale = Math.round((filesize/(1024*1024))) + " Mo";
  } else {
    sizefinale = Math.round((filesize/(1024*1024))) + " Mo";
  }

  return sizefinale;
}


function docCenter_form(responseXML)
{
	var xml_topics = responseXML.getElementsByTagName("topic");
	var select_form = document.getElementById('form_edit_short');
	var index=0;
			//supression de tout les noeuds
	while(index < select_form.childNodes.length  )
	{
		select_form.removeChild(select_form.childNodes[index]);
	}
	
	var elem_option = new Element('option',{value:'all'});
	elem_option.setHTML(libelle_all_doccenter);
	select_form.appendChild(elem_option);	
	var i=0;
	while( i< xml_topics.length )
	{
		topic=document.createElement("option"); //cr?ation de de l option
		data_topic=xml_topics.item(i); 	//recup?ration du i element
		
		data_topic_name=data_topic.attributes.getNamedItem('name').nodeValue;  //r?cup?ration du name
		data_topic_id=data_topic.attributes.getNamedItem('id').nodeValue;		//r?cup?ration de l'id
		
		topic.setAttribute("value",data_topic_name);		
		topic.setAttribute("id",data_topic_id);
		topic.appendChild(document.createTextNode(data_topic_name));
		select_form.appendChild(topic);
		i++;
	}	
	this.initTheme_docCenter();
	this.sendRequest(docCenter.lien,"GET",affichage_data_xml);
}

function docCenter_init(responseXML)
{
		var xml_docs = responseXML.getElementsByTagName("doc");
		xml_docs = $A(xml_docs);
		var div_docCenter = document.getElementById('docCenter_contenu');
		var index=0;
		while(index < div_docCenter.childNodes.length  )
		{
			div_docCenter.removeChild(div_docCenter.childNodes[index]);
		}
		
		var i ,j,tmp  = 0;
		var en_desordre = true;
        for(i = 0 ; (i < xml_docs.length) && en_desordre; i++)
        {
                en_desordre = false;
                for(j = 1 ; j < xml_docs.length - i ; j++)
                {
                        if(xml_docs[j].childNodes[1].firstChild.nodeValue < xml_docs[j-1].childNodes[1].firstChild.nodeValue)
                        {
                                tmp = xml_docs[j-1];
                                xml_docs[j-1] = xml_docs[j];
                                xml_docs[j] = tmp;
                                en_desordre = true;
                        }
                }
        }
		
		xml_docs.reverse();
				var space = new Element('br');
		//CLEGEB
		//table.appendChild(space);
		
		//080623 : Cr�ation de la liste � puce des fichiers � t�l�charger pour �tre plus lisible par une synth�se vocale
        var elem_ul = new Element('ul', {'class':'liste_docs'});
		
		var compteur = 0;
		xml_docs.each(function(item, index){
					var title_doc =item.childNodes[0].firstChild.nodeValue ;
						if(compteur <4)
						{		
							var file = item.childNodes[2].firstChild.nodeValue;
							var sType = Right(item.childNodes[2].attributes.getNamedItem('type').nodeValue,3);
              var texteAll = title_doc + ((item.childNodes[2].attributes.getNamedItem('size').nodeValue) ? " (" + affiche_poids(item.childNodes[2].attributes.getNamedItem('size').nodeValue) + ")" : "");
						//1er td
							var lien = document.createElement( "a" );
							lien.setAttribute('href', file);
							
							lien.innerHTML = texteAll;
                            
                            var span_titre = new Element('span', {'class':'titre_doc'});
                            
                            var elem_li = new Element('li', {'class':'puce_document_'+sType});
                            
                            elem_li.addEvent('click', function() {
                                document.location.href = file;
                            });
							
							switch(sType)
							{
							case 'xls':
								var image = document.createElement( "img" );
								image.setAttribute('src',base+'/images/xls.gif');
								image.setAttribute('width','17');
								image.setAttribute('height','16');
								break;    
							case 'ppt':
								var image = document.createElement( "img" );
								image.setAttribute('src',base+'/images/ppt.gif');
								image.setAttribute('width','17');
								image.setAttribute('height','16');
								break;    
							case 'pdf':
								var image = document.createElement( "img" );
								image.setAttribute('src',base+'/images/pdf.gif');
								image.setAttribute('width','17');
								image.setAttribute('height','16');
								break;    
							case 'doc':
								var image = document.createElement( "img" );
								image.setAttribute('src',base+'/images/doc.gif');
								image.setAttribute('width','17');
								image.setAttribute('height','16');
								break;    
							default:
								var image = document.createElement( "img" );
								image.setAttribute('src',base+'/images/vide.gif');
								image.setAttribute('width','17');
								image.setAttribute('height','16');
								break;
							}
							
                            elem_li.appendChild(lien);
                            //lien.appendChild(image);
                            //newcol.appendChild(lien);
                                                            
                                            //2eme td
                            /*var newcol_data = document.createElement( "td" );                     
                            var lien_data = document.createElement( "a" );
                            lien_data.setAttribute('href',file);                            
                            lien_data.innerHTML = title_doc;    
                            newcol_data.appendChild(lien_data);                     
                            newRow.appendChild(newcol);
                            newRow.appendChild(newcol_data);
                            tbody.appendChild(newRow);*/
                            elem_ul.appendChild(elem_li);
                            ++compteur
						}
				}); 
				
				div_docCenter.appendChild(elem_ul);
					/*	var elem_tr_all = new Element('tr');
						var elem_tbody_all = new Element('tbody');
						var elem_td_all = new Element('td',{'colspan':'2'});
						var elem_a = new Element('a',{'href':'#','id':'more_outil_doccenter'});
						elem_td_all.setHTML(elem_a);
						elem_tr_all.appendChild(elem_td_all)
						elem_tbody_all.appendChild(elem_tr_all);
						table.appendChild(elem_tbody_all); */
}
/******************************* Les fonctions de l'outil myMag *************************/

function initTheme_myMag()
{
	var laSelect = $('form_edit_short_myMag');
	
	if(typeof(outil_mymag_new_filtre) == 'undefined') // si le filtre forcer existe pas
	{
			if(typeof(home_filtre_outil_mymag) != 'undefined' 
			  && home_filtre_outil_mymag !='' )
			{
				laSelect.value = home_filtre_outil_mymag ;
			}
				else
				{
					if(Cookie.get(tools['mymag_element'])
							&& String(getValueCookie(tools['mymag_element'],4)) != 'undefined' 
								&& getValueCookie(tools['mymag_element'],4) !=null
									&& getValueCookie(tools['mymag_element'],4) !="")
					{
						myMag.cookie_first_time = 1;
						laSelect.value = getValueCookie(tools['mymag_element'],4)[0];
							
					}
					else if(myMag.config.libelle_defaut !="" && myMag.cookie_first_time == 0  )
					{
						myMag.cookie_first_time = 1;
						laSelect.value = myMag.config.libelle_defaut ;
					}
					else if(myMag.config.libelle_defaut =="" && myMag.cookie_first_time == 0)
					{
						myMag.cookie_first_time = 1;
						laSelect.value = laSelect.options[0].value;
					}
					else
					{
						laSelect.value = laSelect.options[0].value;
					}
				}
	}
		else
		{	
			laSelect.value = outil_mymag_new_filtre; // si le filtre forcer existe
		}
}

function initEvent_myMag()
{
		var div_doc = new Fx.Styles('conteneur_global_myMag', {duration:750, wait:false});
		var div_doc_edit = new Fx.Styles('edit_box_myMag', {duration:200, wait:false});
		$('link_edit_myMag').addEvent('click', function(){
												boites_edit_ouvertes++;
												//if (navigator.appName=="Netscape") rollbackSIFR();
												div_doc.start({'opacity':0.3});
												//div_doc.start_edits({'visibility':'visible'});
												$('edit_box_myMag').setStyle( 'display', 'block' )
															 });
}

function myMag_form(responseXML)
{
	var xml_magazines = responseXML.getElementsByTagName("magazine");
	var select_form = document.getElementById('form_edit_short_myMag');
	var index=0;
			//supression de tout les noeuds
	while(index < select_form.childNodes.length  )
	{
		select_form.removeChild(select_form.childNodes[index]);
	}

	var elem_option = new Element('option',{value:'all'});
	elem_option.setHTML(libelle_all_mymag);
	select_form.appendChild(elem_option);
	var i=0;
	while( i< xml_magazines.length )
	{
		magazine=document.createElement("option"); //cr?ation de de l option
		data_magazine=xml_magazines.item(i); 	//recup?ration du i element
		
		data_magazine_name=data_magazine.attributes.getNamedItem('name').nodeValue;  //r?cup?ration du name
		data_magazine_id=data_magazine.attributes.getNamedItem('id').nodeValue;		//r?cup?ration de l'id
		
		magazine.setAttribute("value",data_magazine_name);		
		magazine.setAttribute("id",data_magazine_id);
		magazine.appendChild(document.createTextNode(data_magazine_name));
		select_form.appendChild(magazine);
		i++;
	}	
	this.initTheme_myMag();
	this.sendRequest(myMag.lien,"GET",affichage_data_xml_myMag);
	
}

function affichage_data_xml_myMag(responseXML)
{
	var xml_magazines = responseXML.getElementsByTagName("magazine");
	var laSelect = $('form_edit_short_myMag');
	var i =0;
	var data ='';
	var compteur=0;
	var div_contenu_myMag = $('contenu_text_droit_myMag');
	
	if(Cookie.get(tools['mymag_element'])) // si le cookie exite  on save le theme dans la cookie
	{
		var tab = [laSelect.value];
		setParamCookie(tools['mymag_element'],tab);
	}
	
	if(laSelect.value != 'all')
	{
		while( i< xml_magazines.length )
		{
			name_select = xml_magazines.item(i).attributes.getNamedItem('name').nodeValue;
			if( name_select == laSelect.value)
			{
				
				var index=0;
			//supression de tout les noeuds
				while(index < div_contenu_myMag.childNodes.length  )
				{
					div_contenu_myMag.removeChild(div_contenu_myMag.childNodes[index]);
				}
				
				var space = new Element('br');
				//CLEGEB
				//div_contenu_myMag.appendChild(space);
				
				//Index de parcours utilis? pour les issues d'un magazine (tri et affichage)
				var j = 0;
				//Index de parcours de
				var k = 0;
				//07 11 13 : Alexis Tri des magazines par date
				var en_desordre = true;
				//
				var issues_mag = xml_magazines.item(i).childNodes;
		        for(j = 0 ; (j < issues_mag.length) && en_desordre; j++)
		        {
		                en_desordre = false;
		                for(k = 1 ; k < issues_mag.length - j ; k++)
		                {
		                        if(issues_mag[k].firstChild.nodeValue < issues_mag[k-1].firstChild.nodeValue)
		                        {
		                                tmp = issues_mag[k-1];
		                                issues_mag[k-1] = issues_mag[k];
		                                issues_mag[k] = tmp;
		                                en_desordre = true;
		                        }
		                }
		        }
		     	issues_mag = $A(issues_mag);
		        issues_mag.reverse();
				
				//Affichage des num?ros (issues) du magazine concern?
				for(j=0 ; j < issues_mag.length ; ++j)
				{
						var leFils = issues_mag[j]; // issues
							if(compteur < 3 ) // nombre d'element par outils
							{
								//stockage de tout les noeuds dans une variable
								var myDate = new Date(); //date pour la conversion du timeStamp
	
								var numero = leFils.childNodes[0].firstChild.nodeValue;
								var date = leFils.childNodes[1].firstChild.nodeValue;
								myDate.setTime(date);
								var title = leFils.childNodes[2].firstChild.nodeValue;
								var summary = leFils.childNodes[3].firstChild.nodeValue;
								var lien = leFils.childNodes[4].attributes.getNamedItem('href').nodeValue;
								var file = leFils.childNodes[6].firstChild.nodeValue;
								//cr?ation des elements 
								leSpan = document.createElement("span");
								leSpan.setAttribute("class","couleur_orange");
								leSpan.setAttribute("className","couleur_orange");
								
								leSpan.innerHTML = 	getDateString_fr(myDate,0);
								laBalise_a = document.createElement("a");
								laBalise_a.setAttribute("href",file);
								laBalise_a.innerHTML = title;
								
								leBr = document.createElement("br");
								leBr2 = document.createElement("br");
								div_contenu_myMag.appendChild(leSpan);
								div_contenu_myMag.appendChild(leBr2);
								div_contenu_myMag.appendChild(laBalise_a);
								div_contenu_myMag.appendChild(leBr);

								++compteur;
							}
				
				}
			}
			++i
		}
	}
	else if(laSelect.value =='all')
	{
		//alert("myMag = "+myMag);
		//alert("myMag.lien= "+myMag.lien);
		this.sendRequest(myMag.lien,"GET",myMag_init);
	}
	
		if(myMag.bool_first != 0) // 1ere fois qu on va sur page
		{
			var div_doc = new Fx.Styles('conteneur_global_myMag', {duration:750, wait:false});
			var div_doc_edit = new Fx.Styles('edit_box_myMag', {duration:200, wait:false});
			if (navigator.appName =="Netscape") div_doc.addEvent('onComplete', function() {if(boites_edit_ouvertes==0) initSIFR();});
			div_doc.start({'opacity':1});							
			$('edit_box_myMag').setStyle( 'display', 'none' );
			myMag.bool_first = 1 ;
		}
}

function myMag_init(responseXML)
{
	var tab_mag_recent = [];
	var tab_mag_recent_data =$A([]);
	var xml_issues = responseXML.getElementsByTagName("issue");
	xml_issues = $A(xml_issues);
	var div_contenu_myMag = $('contenu_text_droit_myMag');
	div_contenu_myMag.empty();
	var space = new Element('br');
	//CLEGEB
	//div_contenu_myMag.appendChild(space);
	var i=0;
	var j =0;
	xml_issues.each(function(item,index){
						tab_mag_recent_data.include(item.childNodes[1].firstChild.nodeValue);
						var issue = {
										mydate :item.childNodes[1].firstChild.nodeValue,
										title : item.childNodes[2].firstChild.nodeValue,
										lien : item.childNodes[4].attributes.getNamedItem('href').nodeValue,
										file :item.childNodes[6].firstChild.nodeValue
									}
						var myDate = new Date();
						var date = issue.mydate;
						myDate.setTime(date);

						//alert("issue "+index+" : "+getDateString_fr(myDate, 0)+" - "+issue.title);
						tab_mag_recent.include(issue)
				 })

	

	tab_mag_recent_data.sort();
		
	var compteur = 0 ;
	for(i= tab_mag_recent_data.length-1 ; i >(tab_mag_recent_data.length-4)  ; i-- )
	{
		tab_mag_recent.each(function(item,index){
										
										if(tab_mag_recent_data[i]==item.mydate)
										{
											if(compteur < 3)
											{
												var myDate = new Date();
												var date = item.mydate
												myDate.setTime(date);
												
												//alert("after sort issue "+index+" : "+getDateString_fr(myDate, 0)+" - "+item.title);
												
												leSpan = document.createElement("span");
												leSpan.innerHTML = getDateString_fr(myDate,0);
												leSpan.setAttribute("class","couleur_orange");
												leSpan.setAttribute("className","couleur_orange");
												laBalise_a = document.createElement("a");
												laBalise_a.setAttribute("href",item.file);
												laBalise_a.innerHTML =item.title;
							
												leBr = document.createElement("br");
												leBr2 = document.createElement("br");
							
												div_contenu_myMag.appendChild(leSpan);
												div_contenu_myMag.appendChild(leBr2);
												div_contenu_myMag.appendChild(laBalise_a);
												div_contenu_myMag.appendChild(leBr);
												++compteur;
											}
										}
									
							})
	}
}

/******************************* Les fonctions de l'outil Glossary *************************/

function initTheme_glossary(responseXML)
{
	// traitement du filtre , r?cup?ration de id
	var word ='';
	if(typeof(home_filtre_outil_glossary) != 'undefined' 
			  && home_filtre_outil_glossary !='' )
	{
			word = home_filtre_outil_glossary ;
	}
		else
		{
		}
		
	//affichage
	var xml_words = responseXML.getElementsByTagName("word");
	xml_words = $A(xml_words)
	var addContenu = $('contenu_text_glossary');
	var index = 0;
	while(index < addContenu.childNodes.length)
	{
		addContenu.removeChild(addContenu.childNodes[index]);
	}
	fade_glossaire = new Fx.Styles(addContenu, {
			duration: 300,
			wait: false
		});
		
		var elem_br = document.createElement('br');
		
		//Alexis 080214 : Initialisation du message du glossaire
		var msg_init = new Element('span');
		msg_init.innerHTML = sMsgGlossaire[sLangSite];
		addContenu.appendChild(elem_br);
		addContenu.appendChild(msg_init);
	if(word !='')
	{
		xml_words.each(function(item,index){
							
								if(item.attributes.getNamedItem('id').nodeValue == word ){
									var resultRecherche = item.childNodes[0].nodeValue;
									var name_result = item.attributes.getNamedItem('name').nodeValue
									elem_span = new Element('span',{'class':'couleur_orange'});
									elem_span.setHTML(name_result);
									elem_span2 = new Element('span');
									elem_span2.setHTML(resultRecherche);
									addContenu.appendChild(elem_span);
									addContenu.appendChild(elem_br);
									addContenu.appendChild(elem_span2);
								}
							});
	}
	
}

function affichage_data_xml_glossary(responseXML)
{
	var xml_words = responseXML.getElementsByTagName("word");
	var laRecherche = $('text_go').value;	
	var addContenu = $('contenu_text_glossary');
	var i = 0 ;
	var index = 0;
	var bool = 0;
	var leBr = document.createElement("br");

	while (index < addContenu.childNodes.length) {
		addContenu.removeChild(addContenu.childNodes[index]);
	}
		//080214 Alexis : si quelque chose a ?t? saisi, le message d'accueil du glossaire laisse place ? la d?finition
		while (i < xml_words.length) {
			var xml_word = xml_words.item(i).attributes.getNamedItem('name').nodeValue // nom de la recherche
			if (laRecherche.toLowerCase() === xml_word.toLowerCase()) {
				//ajout du contenu ici
				//Pinouf 16/01/2008 modif//
				var resultRecherche = xml_words.item(i).childNodes[0].nodeValue;
				leSpan = document.createElement("span");
				leSpan.setAttribute("className", "couleur_orange");
				leSpan.setAttribute("class", "couleur_orange");
				leSpan2 = new Element('span', {
					'class': 'glossary_text'
				});
				leSpan.innerHTML = xml_word;
				leSpan2.innerHTML = resultRecherche;
				addContenu.appendChild(leSpan);
				addContenu.appendChild(leBr);
				addContenu.appendChild(leSpan2);
				bool = 1;
			}
			++i;
		}
		//Pinouf 16/01/2008 // 
		if (laRecherche != "" && bool == 0) {
			
			$('valide_go_glossary').disabled = true;
			
			leSpan2 = new Element('span', {
				'class': 'glossary_text'
			});
			leSpan2.innerHTML = glossary_empty_message;
			addContenu.appendChild(leBr);
			addContenu.appendChild(leSpan2);
			
			//Alexis 080214 : fonction d'effacement du message d'erreur en fondu apr?s quelques secondes et Retour au message d'accueil
			var myTimer = (function(){
				fade_glossaire.addEvent("onComplete", function(){
					
					if (!transition_finie) {
						transition_finie = true;
						
						while (index < addContenu.childNodes.length) {
							addContenu.removeChild(addContenu.childNodes[index]);
						}
					
						var msg_init = new Element('span');
						msg_init.innerHTML = sMsgGlossaire[sLangSite];
						addContenu.appendChild(leBr);
						addContenu.appendChild(msg_init);
						
						this.start({
							'opacity': 1
						});
					} else {
						$('valide_go_glossary').disabled = false;
					}
				});
				transition_finie = false;
				fade_glossaire.start({
					'opacity': 0
				});
			}).delay(2000);
			
			//fonction de retour au message d'accueil sans transition
			/*var myTimer = (function(){
				while (index < addContenu.childNodes.length) {
					addContenu.removeChild(addContenu.childNodes[index]);
				}
				var msg_init = new Element('span');
				msg_init.innerHTML = sMsgGlossaire[sLangSite];
				addContenu.appendChild(leBr);
				addContenu.appendChild(msg_init);
			}).delay(1500);*/
		//
		} else if (laRecherche == "") {
			//Alexis 080214 : Initialisation du message du glossaire lorsque le champ est vid?
			
			while (index < addContenu.childNodes.length) {
				addContenu.removeChild(addContenu.childNodes[index]);
			}
			var msg_init = new Element('span');
			msg_init.innerHTML = sMsgGlossaire[sLangSite];
			addContenu.appendChild(leBr);
			addContenu.appendChild(msg_init);
		}
}

function autoImplemente(responseXML)
{
	//var el =$ES('input','#text_go')
	var el =$('form_autoImple').getElements('input[id=text_go]') 
	var tokens =convert_xml_en_tab(responseXML);
	var completer1 = new Autocompleter.Local(el[0], tokens, {
			'delay': 100,
			'filterTokens': function() {
					var regex = new RegExp('^' + this.queryValue.escapeRegExp(), 'i');
					return this.tokens.filter(function(token){
						return (regex.test(token[0]) || regex.test(token[1]));
					});
				},
				'injectChoice': function(choice) {
					var el = new Element('li')
						.setHTML(this.markQueryValue(choice[0]))
						.adopt(new Element('span', {'class': 'example-info'}).setHTML(this.markQueryValue(choice[1])));
					el.inputValue = choice[0];
					this.addChoiceEvents(el).injectInside(this.choices);
				}
			});
}

function convert_xml_en_tab(responseXML)
{
	var tab_autoImplemente = [];
	var xml_words = responseXML.getElementsByTagName("word");
	xml_words = $A(xml_words);
	xml_words.each(function(item,index){
							var petit_tableau = [];
							var xml_word =item.attributes.getNamedItem('name').nodeValue;
							var xml_word_decouper = decoupe_word(xml_word);
							petit_tableau.include(xml_word);
							petit_tableau.include("");
							tab_autoImplemente.include(petit_tableau);
							})
	var blanc =['',''];
	tab_autoImplemente.include(blanc)
	return tab_autoImplemente;
}

function decoupe_word(mot)
{
	tab_d=mot.split('');
	var chaine = tab_d[0]+tab_d[1];
	return chaine;
}

/******************************* Les fonctions de l'outil Bookmarks *************************/

function affiche_mybookmarks()
{
	var contenu_bookmarks = $('contenu_bookmarks');
	
	contenu_bookmarks.empty();

	if(Cookie.get('myBookmarks'))
	{
		var mycookie = Cookie.get('myBookmarks');
		var tab_bookmarks = mycookie.split('*');
		var tab_bookmark = $A([])
		tab_bookmarks.each(function(item,index){
									if(index >0)
									{
										tab_bookmark.include(item);
									}
								}) 

		var index=0;
		while(index < contenu_bookmarks.childNodes.length  )
		{
			contenu_bookmarks.removeChild(contenu_bookmarks.childNodes[index]);
		}
		
		tab_bookmark.each(function(item,index){
		   var tab_cookie_data = item.split('@');
		   var url = tab_cookie_data[0];
		   var title = tab_cookie_data[1];
		   var elem_img_fleche = new Element('img',{src:base+'/images/fleche_orange_bas.gif','alt':''});							   
		   var elem_a = new Element('a',{'class':'couleur_orange_link lien_fleche','href':url});
			// Ajout GEB suite au nouvelle box 02/01/08
		   var elem_div= new Element('div',{'class':'pt15'});

			// Modification GEB suite au nouvelle box 02/01/08
		   //var elem_br = new Element('br');
		   elem_a.setHTML(title);

			// Ajput GEB suite au nouvelle box 02/01/08
		   contenu_bookmarks.appendChild(elem_div);
		   //contenu_bookmarks.appendChild(elem_img_fleche);
		   contenu_bookmarks.appendChild(elem_a);
			// Modification GEB suite au nouvelle box 02/01/08
		   //contenu_bookmarks.appendChild(elem_br);
		});
	
	}
		else
		{
			var elem_p = new Element('p');
			var elem_br = new Element('br');
			elem_p.setHTML(bookmarks_message_default[sLangSite]);
			contenu_bookmarks.appendChild(elem_br);
			contenu_bookmarks.appendChild(elem_p);
		}
}

/******************************* Les fonctions de l'outil Calendar *************************/
function initTheme_calendar()
{
	var laSelect = $$('input.check_calendar');

	//laSelect.each(function(item,index){
		//	alert("InitTheme calendar 1 : item checkbox "+$(item).value+" checked : "+$(item).checked);});

        
	if(typeof(outil_calendar_new_filtre) == 'undefined') // si le filtre forcer existe pas
	{

		if(typeof(home_filtre_outil_calendar) != 'undefined' 
		  && home_filtre_outil_calendar !='' )
		{
                    
			calendrier.cookie_first_time = 1;
			var	chaine = home_filtre_outil_calendar;
			
			//alert("R?cup?ration des cases coch?es forc?es dans la page");
			if(chaine == "all" || chaine =="")
			{
				$('tout').checked=true;
				selectall(document.myformu_calendar.tout,document.myformu_calendar.choix); 
			}
			else
			{ 
				var	tab = chaine.split(',');
				tab.each(function(item,index){
					$(item.toLowerCase()+'_cal').checked = true;
				})
				$('tout').checked=false;
			}
		} else if(Cookie.get(tools['calendar_element']) ) {
                    
			var cookie_filtre = String(getValueCookie(tools['calendar_element'],4));
			if(cookie_filtre != 'undefined')
			{
				calendrier.cookie_first_time = 1;
				var	tab_chaine_cookie = getValueCookie(tools['calendar_element'],4);
				if (tab_chaine_cookie != null && tab_chaine_cookie !='' ) {
					if (tab_chaine_cookie.length >= (laSelect.length+1)) {

					$('tout').checked=true;
					selectall(document.myformu_calendar.tout,document.myformu_calendar.choix); 
					}else{
						
						$('tout').checked=false;
						tab_chaine_cookie.each(
						function(item,index) {
							if($(item+'_cal')!=null){
								$(item+'_cal').checked = true;
							}
						});
					}
				}
			}
			
			else if(cookie_filtre == 'undefined' && typeof(home_filtre_outil_calendar) != 'undefined' &&
						home_filtre_outil_calendar =='' && calendrier.cookie_first_time ==1)
			{		
						$('tout').checked=true;
						selectall(document.myformu_calendar.tout,document.myformu_calendar.choix);

			}
			else
			{
				if(calendrier.config.libelle_defaut !="" && calendrier.cookie_first_time ==0){	
				calendrier.cookie_first_time = 1;
				//alert("recherche des cases coch?es dans la config par d?faut");
					if(calendrier.config.libelle_defaut == "all"){
						$('tout').checked=true;
						selectall(document.myformu_calendar.tout,document.myformu_calendar.choix); 
					}
						else{
							chaine = calendrier.config.libelle_defaut;
							tab = chaine.split(',');
							tab.each(function(item,index){
					  	$(item+'_cal').checked = true;
							  });
					$('tout').checked=false;
						}
				}
					else{
                                                $('tout').checked=true;
						selectall(document.myformu_calendar.tout,document.myformu_calendar.choix); 
					}
			}
		} else {
                $('tout').checked=true;
		selectall(document.myformu_calendar.tout,document.myformu_calendar.choix);
            }
	} else {
		var	chaine = outil_calendar_new_filtre;
		if(chaine == "all")
		{
			//alert("1");
			$('tout').checked=true;
			selectall(document.myformu_calendar.tout,document.myformu_calendar.choix); 
		} else {
			$('tout').checked=false;
			var	tab = chaine.split(',');
                        //console.debug(tab);
			tab.each(function(item,index){
				$(item+'_cal').checked = true;
			})
		}
	}
}

function init_formCalendar(responseXML)
{
	var xml_themes = responseXML.getElementsByTagName("theme"); 
	xml_themes = $A(xml_themes)
	var table = $('table_');
	var index=0;
			//supression de tout les noeuds
	while(index < table.childNodes.length  )
	{
		table.removeChild(table.childNodes[index]);
	}
	var elem_tbody = new Element('tbody');
	var elem_tr = new Element('tr');
	var elem_td = new Element('td',{'valign':'top','height':20});
	var elem_input = new Element('input',{'value':'all','id':'tout','class':'check_calendar_all','name':'tout','type':'checkbox'});
	var elem_td2 = new Element('td',{'valign':'middle'});
	 elem_td2.setHTML(libelle_all_calendar);
	 elem_td.appendChild(elem_input);
	 elem_tr.appendChild(elem_td);
	 elem_tr.appendChild(elem_td2);
	 elem_tbody.appendChild(elem_tr);
	 table.appendChild(elem_tbody);
	xml_themes.each(function(item,index){
							 var name = item.attributes.getNamedItem('name').nodeValue;
							 var elem_tbody = new Element('tbody');
							 var elem_tr = new Element('tr');
							 var elem_td = new Element('td',{'valign':'top','height':20});
							 var elem_input = new Element('input',{'class':'check_calendar','name':'choix','type':'checkbox','value':name,'id':name+'_cal'});
							 var elem_td2 = new Element('td',{'valign':'middle'});
							 elem_td2.setHTML(name);
							 elem_td.appendChild(elem_input);
							 elem_tr.appendChild(elem_td);
							 elem_tr.appendChild(elem_td2);
							 elem_tbody.appendChild(elem_tr);
							 table.appendChild(elem_tbody);
							 });
	$('tout').addEvent('click',function(){selectall(document.myformu_calendar.tout,document.myformu_calendar.choix);});
	initTheme_calendar();
	selectOne(calendrier.name.toLowerCase());
	this.sendRequest(calendrier.lien,"GET",affichage_data_xml_calendar); 
}

function initEvent_calendar()
{
	var div_doc = new Fx.Styles('conteneur_global_calendar', {duration:750, wait:false});
	
	$('link_edit_calendar').addEvent('click', function(){
										boites_edit_ouvertes++;
									//	if (navigator.appName=="Netscape") rollbackSIFR();
										div_doc.start({'opacity':0.3});
										//div_doc.start_edits({'visibility':'visible'});
										$('shortedit_boite_calendar2').setStyle('display', 'block' )
										});	
}

function affichage_data_xml_calendar(responseXML)
{
	
	//alert("contenu xml calendar");
	
	var xml_themes = responseXML.getElementsByTagName("theme"); 
	var xml_themes = $A(xml_themes); // transformation de la collection en tableau
	//$$('.Tips3').each(function(item,index){alert(item);})
	
	
	init_clean_calendar_grise();
	init_clean_calandar();
	$$('td.active').each(function(item,index){
								  //alert(item.firstChild.childNodes[0].nodeValue);
								 	 item.className='case_Date'; 
									 if(item.childNodes.length !=0)
									  {
										  if(item.firstChild.childNodes.length != 0)
										  {
									  		var savedata = item.firstChild.childNodes[0].nodeValue;	
											item.removeChild(item.firstChild);
										    item.innerHTML=savedata;
										  }
									  }
								  }) // changement de class
	var lesEvents = []; //cr??ation tableau pr stock?? les check coch??
		$$('input.check_calendar').each(function(item,index){
			var bool = item.checked ? lesEvents.include(item.value) : false;
			//if (item.checked) alert(item.value);
			})
			
			//alert("lesEvents dans calendar : "+lesEvents);
			if(Cookie.get(tools['calendar_element']))
			{
				setParamCookie(tools['calendar_element'],lesEvents)
			}
		
			//lesEvents.each(function(item,index){alert("calendar item = "+item)});
			
	xml_themes.each(function(item,index){ 
			if(lesEvents.contains(item.attributes.getNamedItem('name').nodeValue)) // Si les cases coch??s existent dans le xml
			{
				if(item.childNodes.length != 0)  // Si pour le themes existant , il existe au moins un events
				{
					var  xml_events = item.childNodes; // Events
					var  nb_xml_events = xml_events.length ; // nb de Events
					var k = 0 ;
					while( k < nb_xml_events)
					{
						var xml_event = xml_events[k]; // l'evenement
						var xml_event_title = xml_event.childNodes[0].firstChild.nodeValue; 
						var xml_event_date = xml_event.childNodes[1].firstChild.nodeValue; //timestamp js en mili/ xml fourni en s
						//var xml_event_link = xml_event.childNodes[3].firstChild.nodeValue; 
						var laDate = new Date();
						laDate.setTime(xml_event_date);
						//alert(getDateString(laDate,1)) //le mois de xml
						//alert(getDateString(laDate,2)) //lann??e de xml
						//alert(obtenirMois(calendar.cmonth)); //mois du calendar
						//alert(calendar.cyear); 				// ann??e du calendar
						
						
							if(getDateString(laDate,1) == obtenirMois(calendar.cmonth) && 
										getDateString(laDate,2) == calendar.cyear) // meme mois et ann??e
							{
								calendar.cday =  clean_day(getDateString(laDate,3)); // le jour dans le fichier xmls
							
								//alert(getDateString(laDate,7));
							
								//alert("calendar.cday = "+calendar.cday+" new String(laDate) = "+laDate+" xml_event_date = "+(xml_event_date));
								
								var lesTD = $A($$('td.case_Date')); //r??cupere tout les les jours 
								
								lesTD.each(function(item,index){
									if(item.childNodes.length == 1)
									{
										
										
										if(item.childNodes[0].nodeValue == calendar.cday)
										{
											item.className='active';
											item.innerHTML="";
											baliseA = document.createElement("a");
											
											var chaine = getDateString(laDate,0).split('&nbsp;');
											var nb = Number(obtenirMois_int(chaine[1]));
											
											var lachaine =  chaine[0]+'&nbsp;'+Obenir_mois_fr(nb)+'&nbsp;'+chaine[2];
											//alert("lachaine = "+lachaine);
											baliseA.setAttribute("href","#");
											baliseA.setAttribute("title",lachaine+"::"+ xml_event_title);
											baliseA.setAttribute("class","Tips3");
											baliseA.setAttribute("className","Tips3");
											baliseA.innerHTML=calendar.cday;
											item.appendChild(baliseA);
											
											item.date = laDate.getTime();
											
											//alert("baliseA.innerHTML"+baliseA.innerHTML);
											
											item.addEvent('click',function(){window.location.href = config_calendar.the_link+"?d="+this.date});
										}
									}});
							}
						++k;
					}
				}
			}
	})
	
	// Pinouf // 16/01/2008 //
	//modif sur laffichage de certaines date du tool Tips
	var Tips4 = new Tips($$('.Tips3'), {className: 'bulle_calendar','fixed':true,'maxTitleChars':50});
	if(calendrier.bool_first != 0)
	{
		var div_doc = new Fx.Styles('conteneur_global_calendar', {duration:750, wait:false});
		if (navigator.appName =="Netscape") div_doc.addEvent('onComplete', function() {if (boites_edit_ouvertes==0) initSIFR();});
		div_doc.start({'opacity':1});
		$('shortedit_boite_calendar2').setStyle( 'display', 'none' );
		calendrier.bool_first = 1;
	}
}

function incrementTheMonth()
{
	incrementMonth();
	sendRequest(calendrier.lien,"GET",affichage_data_xml_calendar);
}

function decrementTheMonth()
{
	decrementMonth();
	sendRequest(calendrier.lien,"GET",affichage_data_xml_calendar);
}

function selectall(cas,choix)
{
  //test si on a plusieur ligne
  if(choix.length>0){
    if (cas.checked){
      for (var i=0; i<choix.length;i++){
        choix[i].checked=true
      }
    }
    else{
      for (var i=0; i<choix.length;i++){
        choix[i].checked=false
      }
    }
  }
  else{
    if (cas.checked){
      choix.checked=true
    }
    else{
      choix.checked=false
    }
  }
}

function selectOne(nom_outil)
{
	var case_tout = $('tout');
	if (nom_outil=='sites') {
		case_tout = $('tout_sites');
	}
	
	$$('input.check_'+nom_outil).each(function(item,index){
		item.addEvent('click',function(){			
			if(case_tout.checked=true)
			{	
				case_tout.checked=false;
			}
		});
	})
}

function init_clean_calandar()
{
	$A($$('td.case_Date')).each(function(item,index){
								if(item.childNodes.length==0)
								{
									item.className='case_vide';
								}
							})
}

function init_clean_calendar_grise()
{
		$A($$('td.case_vide')).each(function(item,index){
									item.className='case_Date';
							})
	
}
/******************************* Les fonctions de l'outil Calendar Long *************************/

function initEvent_calendar_long()
{
	var div_doc = new Fx.Styles('outil_calendar_long', {duration:750, wait:false});
       
		$('link_edit_calendar').addEvent('click', function(){
												boites_edit_ouvertes++;
											//	if (navigator.appName=="Netscape") rollbackSIFR();
												div_doc.start({'opacity':0.3});
												//div_doc.start_edits({'visibility':'visible'});
												$('shortedit_boite_calendar2').setStyle('display', 'block' )
															 });	
}

function init_content_day_long(responseXML)
{
	var div_content = $('content_calendar_long');
	div_content.empty();
	var more = $('more_outil_calendar');
	var day_today =String(calendar.day);
	if(day_today.split('').length==1){day_today = '0'+day_today}
	var month_today =String(calendar.month);
	if(month_today.split('').length==1){month_today = '0'+month_today}
	var year_today = calendar.year;
	var xml_events = responseXML.getElementsByTagName("event"); 
	var chaine_date_today = day_today+'/'+month_today+'/'+year_today;
	xml_events = $A(xml_events);
    var compteur =0;
	
	var elem_div = new Element('div',{'class':'detail_cal_title'});
	var elem_p = new Element('p');
	elem_div.setHTML(chaine_date_today);
	//Le message par d?faut des jours sans ?v?nement est r?cup?r? dans le config tools
	var no_event = calendar_noevent_libelle[sLangSite];
	//var no_event = xml_events[0].parentNode.parentNode.attributes.getNamedItem('lbl_no_event').nodeValue;
	
	elem_p.setHTML(no_event);
	div_content.appendChild(elem_div);
	div_content.appendChild(elem_p);
	more.setProperty('href',config_calendar.the_link);
	
	xml_events.each(function(item,index){
							 var title = item.childNodes[0].firstChild.nodeValue;
							 var xml_date = item.childNodes[1].firstChild.nodeValue;
							 var laDate = new Date();
							 laDate.setTime(xml_date);
							 var mois =obtenirMois_int(getDateString(laDate,1));
							 var an = getDateString(laDate,2);
						     var jour = getDateString(laDate,3);
							 if(jour.split('').length == 1 && jour.split('')[0] !=0){jour ='0'+jour}
							 var chaine_date = jour+'/'+mois+'/'+an; 
							 	if(chaine_date_today == chaine_date && compteur == 0 ){
									div_content.empty();
									compteur++;
									var elem_div = new Element('div',{'class':'detail_cal_title'});
									var elem_p = new Element('p');
									elem_div.setHTML(chaine_date);
									elem_p.setHTML(title);
									div_content.appendChild(elem_div);
									div_content.appendChild(elem_p);
									//05/11/07 Alexis : La date en param?tre est pass?e au format d=timestamp par souci d'universalit?
									//14/01/2008 Pinouf: correction du passage de parametre (ms)
									more.setProperty('href',config_calendar.the_link+'?d='+xml_date+'000');
								}
							 })
	
}

function init_formCalendar_long(responseXML)
{
	var xml_themes = responseXML.getElementsByTagName("theme"); 
	xml_themes = $A(xml_themes);
       
	var table = $('table_');
	var index=0;
			//supression de tout les noeuds
	while(index < table.childNodes.length  )
	{
		table.removeChild(table.childNodes[index]);
	}
	var elem_tbody = new Element('tbody');
	var elem_tr = new Element('tr');
	var elem_td = new Element('td',{'valign':'top','height':20});
	var elem_input = new Element('input',{'value':'all','id':'tout','class':'check_calendar_all','name':'tout','type':'checkbox'});
	var elem_td2 = new Element('td',{'valign':'middle'});
	 elem_td2.setHTML(libelle_all_calendar);
	 elem_td.appendChild(elem_input);
	 elem_tr.appendChild(elem_td);
	 elem_tr.appendChild(elem_td2);
	 elem_tbody.appendChild(elem_tr);
	 table.appendChild(elem_tbody);
	xml_themes.each(function(item,index){
            
							 var name = item.attributes.getNamedItem('name').nodeValue;
							 var elem_tbody = new Element('tbody');
							 var elem_tr = new Element('tr');
							 var elem_td = new Element('td',{'valign':'top','height':20});
							 var elem_input = new Element('input',{'class':'check_calendar','name':'choix','type':'checkbox','value':name,'id':name+'_cal'});
							 var elem_td2 = new Element('td',{'valign':'middle'});
							 elem_td2.setHTML(name);
							 elem_td.appendChild(elem_input);
							 elem_tr.appendChild(elem_td);
							 elem_tr.appendChild(elem_td2);
							 elem_tbody.appendChild(elem_tr);
							 table.appendChild(elem_tbody);
							 });
                                                      
	$('tout').addEvent('click',function(){selectall(document.myformu_calendar.tout,document.myformu_calendar.choix);});
	initTheme_calendar();
	selectOne(calendrier.name.toLowerCase());
        //alert(calendrier.lien);
	this.sendRequest(calendrier.lien,"GET",affichage_data_xml_calendar_long); 
}


function affichage_data_xml_calendar_long(responseXML)
{
	//alert("contenu xml calendar long");
	fillCalendar();
	var xml_themes = responseXML.getElementsByTagName("theme"); 
	var xml_themes = $A(xml_themes); // transformation de la collection en tableau
       
	$$('td.calendar_pointer').each(function(item,index){ item.setProperty('class','case_Date'); })
	init_clean_calendar_grise();
	init_clean_calandar();
		$$('td.active').each(function(item,index){
								  //alert(item.firstChild.childNodes[0].nodeValue);
								 	 item.className='case_Date'; 
									 if(item.childNodes.length !=0)
								  {
									  if(item.firstChild.childNodes.length != 0)
									  {
								  		var savedata = item.firstChild.childNodes[0].nodeValue;	
										item.removeChild(item.firstChild);
									    item.innerHTML=savedata;
									  }
								  }
								  }) // changement de class  
	var lesEvents = []; //cr??ation tableau pr stock?? les check coch??
	
		$$('input.check_calendar').each(function(item,index){
			//alert("item checkbox "+item.value+" checked : "+item.checked);
			var bool = item.checked ? lesEvents.include(item.value) : false;

			});
			
			//alert("lesEvents calendar long = "+lesEvents);
			//alert("1. Cookie.get(tools['calendar_element']) = "+Cookie.get(tools['calendar_element']));
			if(Cookie.get(tools['calendar_element']))
			{
				setParamCookie('b_calendar.html',lesEvents)
				//alert("2. Cookie.get(tools['calendar_element']) = "+Cookie.get(tools['calendar_element']));

			}

			//lesEvents.each(function(item,index){alert("calendar long item = "+item)});
	xml_themes.each(function(item,index){ 
			if(lesEvents.contains(item.attributes.getNamedItem('name').nodeValue)) // Si les cases coch??s existent dans le xml
			{
				if(item.childNodes.length != 0)  // Si pour le themes existant , il existe au moins un events
				{
					var xml_events = item.childNodes; // Events
					var nb_xml_events = xml_events.length ; // nb de Events
					var k = 0 ;
					while( k < nb_xml_events)
					{
						var xml_event = xml_events[k]; // l'evenement
						var xml_event_title = xml_event.childNodes[0].firstChild.nodeValue; 
						var xml_id = xml_event.attributes.getNamedItem('id').nodeValue;
						var xml_event_date = xml_event.childNodes[1].firstChild.nodeValue;  // timestamp js en mili/ xml fourni en s
					//	var xml_event_link = xml_event.childNodes[3].firstChild.nodeValue; 
						var laDate = new Date();
						laDate.setTime(xml_event_date);
						//alert(getDateString(laDate,1)) //le mois de xml
						//alert(getDateString(laDate,2)) //lann??e de xml
						//alert(obtenirMois(calendar.cmonth)); //mois du calendar
						//alert(calendar.cyear); 				// ann??e du calendar	
						
							
							if(getDateString(laDate,1) == obtenirMois(calendar.cmonth) && 
										getDateString(laDate,2) == calendar.cyear) // meme mois et ann??e
							{
								
								calendar.cday =  clean_day(getDateString(laDate,3)); // le jour dans le fichier xmls
								
								var lesTD = $A($$('td.case_Date')); //r??cupere tout les les jours 
								
								lesTD.each(function(item,index){
													if(item.childNodes.length == 1)
													{
													
														if(item.childNodes[0].nodeValue == calendar.cday)
														{
															item.className='active';
															item.innerHTML="";
															var chaine = getDateString(laDate,0).split('&nbsp;');
															var nb = Number(obtenirMois_int(chaine[1]));
															var lachaine =  chaine[0]+'&nbsp;'+Obenir_mois_fr(nb)+'&nbsp;'+chaine[2];
															//var lachaine =  getDateString(laDate,5);

															var elem_a = new Element('a',{'href':'#calendar','id':xml_id,'class':'Tips3','className':'Tips3'})
															elem_a.setHTML(calendar.cday);
															
															
														//	var elem_a2 = new Element('a',{'href':'#calendar','title':lachaine+"::"+ xml_event_title,'id':xml_id,'class':'Tips3','className':'Tips3'})
														//	elem_a2.setHTML("&nbsp;")
														
															item.appendChild(elem_a);
														//	item.appendChild(elem_a2);
															elem_a.addEvent('click',function(e){affiche_event_day_detail_long(this)});

														}
													}})
							}
						++k;
					}
				}
			}
	}) 

		//var Tips4 = new Tips($$('.Tips3'), {className: 'bulle_calendar'});
		if(calendrier.bool_first != 0)
		{
                        
			var div_doc = new Fx.Styles('outil_calendar_long', {duration:750, wait:false});
			if (navigator.appName =="Netscape") div_doc.addEvent('onComplete', function() {if (boites_edit_ouvertes==0) initSIFR();});
			div_doc.start({'opacity':1});							
			$('shortedit_boite_calendar2').setStyle( 'display', 'none' );
			calendrier.bool_first = 1;
		}
	
}



function affiche_event_day_detail_long(elem)
{
	// r?cup?ration de tout les class
	$$('a.link_pointer').each(function(item,index){ item.setProperty('class','Tips3'); })
	$$('td.calendar_pointer').each(function(item,index){ item.setProperty('class','active'); })
	
	id_event_long = elem.attributes.getNamedItem('id').nodeValue;
	$(id_event_long).setProperty('class','link_pointer');
	var td = $(id_event_long).parentNode ;
	td.setProperty('class','calendar_pointer');
	sendRequest(calendrier.lien,"GET",affichage_event_calendar_long);
}

function affichage_event_calendar_long(responseXML)
{
	var xml_events = responseXML.getElementsByTagName('event');
	xml_events = $A(xml_events);
	var div_content = $('content_calendar_long');
	var more = $('more_outil_calendar');
	var compteur = 0;
	div_content.empty();
	xml_events.each(function(item,index){
							 	if(item.attributes.getNamedItem('id').nodeValue == 	id_event_long 
																&& compteur == 0){
									compteur++;
										var xml_date = item.childNodes[1].firstChild.nodeValue;
										var laDate = new Date();
										laDate.setTime(xml_date);
										var mois =obtenirMois_int(getDateString(laDate,1));
										var an = getDateString(laDate,2);
										var jour = getDateString(laDate,3);
										if(jour.split('').length == 1 && jour.split('')[0] !=0){jour ='0'+jour}
										var chaine_date = jour+'/'+mois+'/'+an;
										var title = item.childNodes[0].firstChild.nodeValue;
										var elem_div = new Element('div',{'class':'detail_cal_title'});
										var elem_p = new Element('p');
										elem_div.setHTML(chaine_date);
										elem_p.setHTML(title);
										div_content.appendChild(elem_div);
										div_content.appendChild(elem_p);
										//05/11/07 Alexis : La date en param?tre est pass?e au format d=timestamp par souci d'universalit?
										//14/01/2008 Pinouf: correction du passage de parametre (ms)
										more.setProperty("href",config_calendar.the_link+"?d="+xml_date+'000');
									}
							   });
}

function incrementTheMonth_long()
{
	incrementMonth();
	sendRequest(calendrier.lien,"GET",affichage_data_xml_calendar_long);
}

function decrementTheMonth_long()
{
	decrementMonth();
	sendRequest(calendrier.lien,"GET",affichage_data_xml_calendar_long);
}

/******************************* Les fonctions de l'outil Press Releases *************************/

function initTheme_press()
{
	var laSelect = $('form_edit_short_Cp');
	if(typeof(outil_press_new_filtre) == 'undefined') // si le filtre forcer existe pas
	{
			if(typeof(home_filtre_outil_presse) != 'undefined' 
			  && home_filtre_outil_presse !='' )
			{
				laSelect.value = home_filtre_outil_presse ;
			}
				else
				{
					if(Cookie.get(tools['curiculum-vitae_element'])
							&& String(getValueCookie(tools['curiculum-vitae_element'],4)) != 'undefined' 
								&& getValueCookie(tools['curiculum-vitae_element'],4) !=null
									&& getValueCookie(tools['curiculum-vitae_element'],4) !="")
					{
						press_releases.cookie_first_time = 1;
						laSelect.value = getValueCookie(tools['curiculum-vitae_element'],4)[0];
							
					}
					else if(press_releases.config.libelle_defaut !="" && press_releases.cookie_first_time == 0  )
					{
						press_releases.cookie_first_time = 1;
						laSelect.value = press_releases.config.libelle_defaut ;
					}
					else if(press_releases.config.libelle_defaut =="" && press_releases.cookie_first_time == 0)
					{
						press_releases.cookie_first_time = 1;
						laSelect.value = laSelect.options[0].value;
					}
					else
					{
						laSelect.value = laSelect.options[0].value;
					}
				}
	}
		else
		{	
			laSelect.value = outil_press_new_filtre; // si le filtre forcer existe
		}
}

function initEvent_press_releases()
{
		var div_cp = new Fx.Styles('conteneur_global_Cp', {duration:750, wait:false});
		
		if(boxExist('croix_close')){
		$('croix_close').addEvent('click', function(){
			if (moodalboite != "undefined") {
				closeModalBox();
			} else {
				ferme_box('press_releases_element');
			}
		});
		}
		
		$('link_edit_Cp').addEvent('click', function(){
				boites_edit_ouvertes++;
				//if (navigator.appName=="Netscape") rollbackSIFR();
				div_cp.start({'opacity':0.3});
				//div_doc.start_edits({'visibility':'visible'});
				$('edit_box_Cp').setStyle( 'display', 'block' );
				$('link_edit_Cp').removeEvents();
				if(boxExist('croix_close')){
					$('croix_close').removeEvents();
				}
		 });
}

function press_releases_form(responseXML)
{
	//initialisation de la select box filtr? par themes
	var xml_themes = responseXML.getElementsByTagName("theme");
	var xml_themes= $A(xml_themes); 
	var xml_themes_sans_doublons = [];
	var form_cp = $('form_edit_short_Cp');
	
	var index=0;
			//supression de tout les noeuds
	while(index < form_cp.childNodes.length  )
	{
		form_cp.removeChild(form_cp.childNodes[index]);
	}
	
	var elem_option = new Element('option',{value:'all'});
	elem_option.setHTML(libelle_all_press);
	form_cp.appendChild(elem_option);
	xml_themes.each(function(item,index){						
							 xml_themes_sans_doublons.include(item.firstChild.nodeValue);
							 });
	xml_themes_sans_doublons.each(function(item,index){
											var theme = document.createElement("option");
											theme.setAttribute("value",item);
											theme.setAttribute("id",item +"_select");
											theme.innerHTML= item;
											form_cp.appendChild(theme);
											});
	initTheme_press();
}

function press_releases_init(responseXML)
{
	var content_outil_cp = $('press_table');
	var index=0;
	var xml_articles_trier = [];
	while(index < content_outil_cp .childNodes.length  )
	{
		content_outil_cp.removeChild(content_outil_cp.childNodes[index]);
	}
	var xml_articles = responseXML.getElementsByTagName("article");
	xml_articles = $A(xml_articles);
	xml_articles.each(function(item,index){
			xml_articles_trier.push(item);
   })
	
	//05/11/07 Alexis : Tri des articles par date de parution. Le tri est neutralis? car le xml source doit ?tre d?j? tri
    var i ,j,tmp  = 0;
	var en_desordre = true;
    for(i = 0 ; (i < xml_articles_trier.length) && en_desordre; i++)
    {
            en_desordre = false;
            for(j = 1 ; j < xml_articles_trier.length - i ; j++)
            {
                    if(xml_articles_trier[j].childNodes[2].firstChild.nodeValue < xml_articles_trier[j-1].childNodes[2].firstChild.nodeValue)
                    {
                            tmp = xml_articles_trier[j-1];
                            xml_articles_trier[j-1] = xml_articles_trier[j];
                            xml_articles_trier[j] = tmp;
                            en_desordre = true;
                    }
            }
    }
	
	//alert(xml_dates_trier.length);
	//xml_dates_trier.firstChild.sort(sortNumber);
	var content_outil_cp = $('press_table');
	xml_articles_trier.reverse();
	var compteur=0;
	
	/*
	* 071107 Alexis : Adaptation du nombre d'articles ? l'espace en hauteur laiss? dans la boite (height dans le style css)
	*		Le premier article est dispos? dans tous les cas. Pour les suivants, on divise la hauteur de la boite par la hauteur d'un article.
	*		Et on place nb_art-1 articles dans l'espace restant.
	*		ATTENTION : 
	*		1.L'algorithme se r?f?re aux donn?es des ?l?ments de la feuille de style main_styles.css,
	*		aux classes div.lien_cp et div.contenu_text_droit_Cp. 
	*		2.Les donn?es css de hauteur doivent ?tre en PIXELS (px)
	*		3.Un changement de hauteur sur div.lien_cp implique un changement de hauteur des classes div.boite_contenu_gauche_middle2 et .s_contenu_sroll2
	*/
	
	//Premier article dispos? en haut de la box
	var item = xml_articles_trier[0];
	var link_ = item.childNodes[3].firstChild.nodeValue;
 	/*var elem_tbody = new Element('tbody');
 	var elem_tr = new Element('tr',{'class':'case_gray'});*/
	var elem_br = new Element('br');
	var elem_img = new Element('img',{'src':base+'/images/fleche_orange_bas.gif','alt':''});
	var elem_div = new Element('div',{'class':'content_case_press case_gray'});
 	var mydate = new Date();
 	mydate.setTime(item.childNodes[2].firstChild.nodeValue);
 	/*var elem_td = new Element('td',{'class':'date_cp_box', 'valign':'top'});*/
 	var elem_span = new Element('span',{'class':'couleur_orange'}).setHTML(getDateString_fr(mydate,0));
 	//var elem_td2 = new Element('td',{'valign':'top'});
 	//071107 Alexis : Ajout d'une div de hauteur fixe pour garder le m?me espace pour tous
 	
 	var chaine_cp = item.childNodes[1].firstChild.nodeValue;
	//Calcul de la hauteur de la div ? afficher
	var h_div = getHauteurDivForChars(chaine_cp.length);
	//
	if (chaine_cp.length > vNbCharsByLine) {
		chaine_cp = getShorterString(chaine_cp);
	}
	
	//alert("chaine_cp = "+chaine_cp);
 	
 	var div_lien_art = new Element('div',  {'class':'titre_cp_box', 'styles':{'height':h_div}});
 	var elem_link = new Element('a',{'href':link_,'class':'hover_orange lien_fleche'}).setHTML(chaine_cp);
 	div_lien_art.appendChild(elem_link);

 	elem_div.appendChild(elem_span);
	elem_div.appendChild(elem_br);
	//elem_div.appendChild(elem_img);
	elem_div.appendChild(elem_link);
	
 	/*elem_td.appendChild(elem_div);
 	elem_tr.appendChild(elem_td);
 	elem_tbody.appendChild(elem_tr);*/
 	content_outil_cp.appendChild(elem_div);

 	
 	/*r?cup?ration de la hauteur d?finie par le style du premier article, et de sa marge basse*/
	var h_titre_cp = div_lien_art.getStyle('height');
	var margin_bas_titre_cp = div_lien_art.getStyle('margin-bottom');
	margin_bas_titre_cp = Number(margin_bas_titre_cp.substring(0,margin_bas_titre_cp.indexOf("px")));
	h_titre_cp = Number(h_titre_cp.substring(0,h_titre_cp.indexOf("px")))+margin_bas_titre_cp;
	
	
	var hauteur_totale_affichee = 0;
	
	//Hauteur de la boite contenant tous les articles
	var hauteur_boite_cp = String($('contenu_text_droit_Cp').getStyle('height'));
	hauteur_boite_cp = Number(hauteur_boite_cp.substring(0,hauteur_boite_cp.indexOf("px")));
	
	//Calcul du nombres d'articles affichables dans cet espace
	var nb_art_affichables = hauteur_boite_cp/h_titre_cp;
	var compteur_color = 0 ; 
	xml_articles_trier.each(function(item,index){
		//Si nous sommes entre le second et le dernier article (le premier ?tant d?j? affich?.
		//alert("compteur = "+ compteur);
		if (compteur > 0 && compteur < nb_art_affichables-1) {
			var link_ = item.childNodes[3].firstChild.nodeValue;
		 	//var elem_tbody = new Element('tbody');
			
			var elem_br = new Element('br');
			var elem_img = new Element('img',{'src':base+'/images/fleche_orange_bas.gif','alt':''});
			var elem_div = new Element('div',{'class':'content_case_press'});
			
			if(compteur_color%2 == 0)
			{
                //var elem_tr = new Element('tr');
                var elem_div = new Element('div',{'class':'content_case_press'});
			}
			else
			{
                //var elem_tr = new Element('tr',{'class':'case_gray'});
                var elem_div = new Element('div',{'class':'content_case_press case_gray'});
			}
            
            compteur_color++;


		 	var mydate = new Date();
		 	mydate.setTime(item.childNodes[2].firstChild.nodeValue);
		 	//var elem_td = new Element('td',{'class':'date_cp_box', 'valign':'top'});
		 	var elem_span = new Element('span',{'class':'couleur_orange'}).setHTML(getDateString_fr(mydate,0));
		 	//var elem_td2 = new Element('td',{'valign':'top'});
		 	
		 	//071107 Alexis : Ajout d'une div de hauteur fixe pour garder le m?me espace pour tous
		 	//Calcul de la hauteur de la div ? afficher
 			var chaine_cp = item.childNodes[1].firstChild.nodeValue;
			//Calcul de la hauteur de la div ? afficher
			var h_div = getHauteurDivForChars(chaine_cp.length);
			//
			if (chaine_cp.length > vNbCharsByLine) {
				chaine_cp = getShorterString(chaine_cp);
			}
		 	//alert("chaine_cp = "+chaine_cp);
		 	
		 	var div_lien_art = new Element('div',  {'class':'titre_cp_box', 'styles':{'height':h_div}});
		 	var elem_link = new Element('a',{'href':link_,'class':'hover_orange lien_fleche'}).setHTML(chaine_cp);
		 	div_lien_art.appendChild(elem_link);
			
			
			elem_div.appendChild(elem_span);
			elem_div.appendChild(elem_br);
			//elem_div.appendChild(elem_img);
			elem_div.appendChild(elem_link);
	
	
	
 			/*elem_td.appendChild(elem_div);
		 	elem_tr.appendChild(elem_td);
		 	elem_tbody.appendChild(elem_tr);*/
			
		 	//content_outil_cp.appendChild(elem_tbody);
		 	content_outil_cp.appendChild(elem_div);
		 			 	
		 	/*r?cup?ration de la hauteur d?finie par le style de l'article pr?c?dent, et de sa marge basse*/
			var h_titre_cp = div_lien_art.getStyle('height');
			var margin_bas_titre_cp = div_lien_art.getStyle('margin-bottom');
			margin_bas_titre_cp = Number(margin_bas_titre_cp.substring(0,margin_bas_titre_cp.indexOf("px")));
			h_titre_cp = Number(h_titre_cp.substring(0,h_titre_cp.indexOf("px")))+margin_bas_titre_cp;
		 	nb_art_affichables = (hauteur_boite_cp-hauteur_totale_affichee)/h_titre_cp;
		 	
		 	hauteur_totale_affichee += h_titre_cp;
			
		}
		++compteur;
		
	});
}

function affichage_data_xml_press_releases(responseXML)
{
	//console.log(responseXML)
	var content_outil_cp = $('press_table');
	var index=0;
	while(index < content_outil_cp .childNodes.length  )
	{
		content_outil_cp.removeChild(content_outil_cp.childNodes[index]);
	}
	var xml_themes = responseXML.getElementsByTagName("theme");
	xml_themes = $A(xml_themes)
	var laSelect = $('form_edit_short_Cp');
	
	if(Cookie.get(tools['curiculum-vitae_element'])) // si le cookie exite  on save le theme dans la cookie
	{
		var tab = [laSelect.value];
		setParamCookie(tools['curiculum-vitae_element'],tab);
	}

		var i ,j,tmp  = 0;

		var en_desordre = true;
        for(i = 0 ; (i < xml_themes.length) && en_desordre; i++)
        {
                en_desordre = false;
                for(j = 1 ; j < xml_themes.length - i ; j++)
                {
                        if(xml_themes[j].parentNode.nextSibling.nextSibling.firstChild.nodeValue < xml_themes[j-1].parentNode.nextSibling.nextSibling.firstChild.nodeValue)
                        {
                                tmp = xml_themes[j-1];
                                xml_themes[j-1] = xml_themes[j];
                                xml_themes[j] = tmp;
                                en_desordre = true;
                        }
                }
        }

	xml_themes.reverse();
	var compteur=0;
	if(laSelect.value !='' && laSelect.value !='all')
	{
		/*
		* 071107 Alexis : Adaptation du nombre d'articles ? l'espace en hauteur laiss? dans la boite (height dans le style css)
		*		Le premier article sera d?pos? dans tous les cas. Pour les suivants, on divise la hauteur de la boite par la hauteur d'un article.
		*		Et on place nb_art-1 articles dans l'espace restant.
		*		ATTENTION : 
		*		1.L'algorithme se r?f?re aux donn?es des ?l?ments de la feuille de style main_styles.css,
		*		aux classes div.lien_cp et div.contenu_text_droit_Cp. 
		*		2.Les donn?es css de hauteur doivent ?tre en PIXELS (px)
		*		3.Un changement de hauteur sur div.lien_cp implique un changement de hauteur des classes div.boite_contenu_gauche_middle2 et .s_contenu_sroll2
		*/

		/*hauteur d?finie par le style du premier article (tous ont la m?me hauteur, comme ?a pas de jaloux)*/
		var h_titre_cp;
		var hauteur_totale_affichee = 0;
		
		//Hauteur de la boite contenant tous les articles
		var hauteur_boite_cp = String($('contenu_text_droit_Cp').getStyle('height'));
		hauteur_boite_cp = Number(hauteur_boite_cp.substring(0,hauteur_boite_cp.indexOf("px")));
		
		var nb_art_affichables = 2;
		compteur_color =0;
	
		xml_themes.each(function(item,index){
								
			 if(laSelect.value == item.firstChild.nodeValue)
			 {
				
					var elem_article = item.parentNode.parentNode; // on se m? sur le noeud article 
					//Si nous pouvons encore afficher des articles dans la boite (assez de place)
					if(compteur < nb_art_affichables-1 )
					{				 		
				 		var link_ = item.parentNode.parentNode.childNodes[3].firstChild.nodeValue;
					 	/*var elem_tbody = new Element('tbody');
					 	var elem_tr = new Element('tr');*/
					 	var mydate = new Date();
					 	mydate.setTime(elem_article.childNodes[2].firstChild.nodeValue);
					 	//var elem_td = new Element('td',{'class':'date_cp_box', 'valign':'top'});
						
					
						var elem_br = new Element('br');
						var elem_img = new Element('img',{'src':base+'/images/fleche_orange_bas.gif','alt':''});
						//var elem_div = new Element('div',{'class':'content_case_press'});
								
					 	var elem_span = new Element('span',{'class':'couleur_orange'}).setHTML(getDateString_fr(mydate,0));
					 	
					 	//071107 Alexis : Ajout d'une div de hauteur fixe pour garder le m?me espace pour tous
					 	
					 	var chaine_cp = elem_article.childNodes[1].firstChild.nodeValue;
					 	//Calcul de la hauteur de la div ? afficher
 						var h_div = getHauteurDivForChars(chaine_cp.length);
						//
						if (chaine_cp.length > vNbCharsByLine) {
							chaine_cp = getShorterString(chaine_cp);
						}
						//alert("chaine_cp = "+chaine_cp);
					 	if(compteur_color%2 == 0)
						{
							//var elem_tr = new Element('tr');
							var elem_div = new Element('div',{'class':'content_case_press'});
						}
						else
						{
				 			//var elem_tr = new Element('tr',{'class':'case_gray'});
				 			var elem_div = new Element('div',{'class':'content_case_press case_gray'});
						}
						
						compteur_color++;
						
					 	var div_lien_art = new Element('div',  {'class':'titre_cp_box', 'styles':{'height':h_div}});
					 	var elem_link = new Element('a',{'href':link_,'class':'hover_orange lien_fleche'}).setHTML(chaine_cp);
					 	div_lien_art.appendChild(elem_link);
					 	
					 	elem_div.appendChild(elem_span);
						elem_div.appendChild(elem_br);
						//elem_div.appendChild(elem_img);
						elem_div.appendChild(elem_link);
 						/*elem_td.appendChild(elem_div);
					 	elem_tr.appendChild(elem_td);
					 
					 	elem_tbody.appendChild(elem_tr);*/
					 	content_outil_cp.appendChild(elem_div);

				 		
						/*r?cup?ration de la hauteur d?finie par le style de l'article pr?c?dent, et de sa marge basse*/
						var h_titre_cp = div_lien_art.getStyle('height');
						var margin_bas_titre_cp = div_lien_art.getStyle('margin-bottom');
						margin_bas_titre_cp = Number(margin_bas_titre_cp.substring(0,margin_bas_titre_cp.indexOf("px")));
						h_titre_cp = Number(h_titre_cp.substring(0,h_titre_cp.indexOf("px")))+margin_bas_titre_cp;
				 		nb_art_affichables = (hauteur_boite_cp-hauteur_totale_affichee)/h_titre_cp;
				 		
				 		nb_art_affichables = hauteur_boite_cp/h_titre_cp;
				 						 		
						++compteur;
					}
				 
			 }
		 })
	} else {
		this.sendRequest(press_releases.lien,"GET",press_releases_init);
	}
	
	if(press_releases.bool_first != 0)
	{
		var div_doc = new Fx.Styles('conteneur_global_Cp', {duration:750, wait:false});
		if (navigator.appName =="Netscape") div_doc.addEvent('onComplete', function() {if (boites_edit_ouvertes==0) initSIFR();});
		div_doc.start({'opacity':1});							
		$('edit_box_Cp').setStyle( 'display', 'none' );
		press_releases.bool_first = 1;
	}

}
var docCenter = { 
	name : 'DocCenter',
	lien : config_docs.link_xml,
	nameDiv : 'conteneur_global_doccenter',
	bool_first :0,
	config : config_docs
	}


/******************************* Les fonctions de l'outil Products and Servies*************************/

//initialisation de la select box des countries

function initSelect_products_countries(responseXML)
{
	var index=0;
	
	//Pinouf // 16/01/2008 // rajout select box dynamic des libell?s
	var tab_product_libelle = [select_pays_product,select_services_product,select_site_product];
	$('products_contenu').getElements('option').each(function(item,index){
															  	item.setHTML(tab_product_libelle[index]);
															  });
	// fin rajout
	var opac_button = new Fx.Styles('valide_go_products', {duration:750, wait:false});
	opac_button.start({'opacity':0.3});
	
	//supression de tout les noeuds
	while(index < $('select_country').childNodes.length  )
	{
		$('select_country').removeChild($('select_country').childNodes[index]);
	}
	
	var elem_option = new Element('option',{value:'0'});
	elem_option.setHTML(select_pays_product);
	$('select_country').appendChild(elem_option);
	
	var xml_countries = responseXML.getElementsByTagName("country");
	xml_countries= $A(xml_countries);
	var xml_countries_sans_doublons = [];
	
	xml_countries_sans_doublons = $A(xml_countries_sans_doublons);
	
	xml_countries.each(function(item,index){
		xml_countries_sans_doublons.include(item.firstChild.nodeValue);
	})

	xml_countries = $A(xml_countries_sans_doublons);
	
	//
	xml_countries.sort();
	//
	xml_countries.each(function(item,index){
		var elem_option = new Element('option',{'value':item});
		elem_option.setHTML(item);
		$('select_country').appendChild(elem_option);
	})
}

//initialisation de la select box des liens et des services quand on choisi un pays
function initSelect_products_services_link(responseXML)
{
	var opac_button = new Fx.Styles('valide_go_products', {duration:750, wait:false});
	opac_button.start({'opacity':0.3});
	$('select_services').empty();
	$('select_websites').empty();
	if($('select_country').value == 0)
	{
		$('select_services').disabled=true;
		var elem_option_vide = new Element('option',{'value':0});
		elem_option_vide.setHTML(select_services_product);
		$('select_services').appendChild(elem_option_vide);
		
		$('select_websites').disabled=true;
		var elem_option_vide_link = new Element('option',{'value':0});
		elem_option_vide_link.setHTML("produits");
		$('select_websites').appendChild(elem_option_vide_link);
	}
		else if($('select_country').value != 0)
		{
			var elem_option_vide = new Element('option',{'value':0});
			elem_option_vide.setHTML(select_services_product);
			$('select_services').appendChild(elem_option_vide);
			var elem_option_vide_link = new Element('option',{'value':0});
			elem_option_vide_link.setHTML(select_site_product);
			$('select_websites').appendChild(elem_option_vide_link);
			var xml_countries = responseXML.getElementsByTagName("country");
			xml_countries = $A(xml_countries);
			$('select_services').disabled=false;
			$('select_websites').disabled=false;
			var select_country = $('select_country').value;
			
			var verif = $A([]);
			xml_countries.each(function(item,index){
								if(item.firstChild.nodeValue == select_country )
								{ 
									if(item.previousSibling.firstChild != null)
									{
										var service = item.previousSibling.firstChild.nodeValue;
										if(!verif.contains(service))
										{
											verif.include(service);
											var elem_option = new Element('option',{'value':service});
											elem_option.setHTML(service);
											$('select_services').appendChild(elem_option);
										}
									}
									//si la balise du website n'est pas vide
									if(item.nextSibling.firstChild != null)
									{
										var webSite =  item.nextSibling.firstChild.nodeValue;
										var elem_option_link = new Element('option',{'value':webSite});
										elem_option_link.setHTML(webSite);
										$('select_websites').appendChild(elem_option_link);
									}
								}
							});
		}
}

// choix du services , filtre sous la select du website
// la select du website peut rester vide
function select_services(responseXML)
{
	if($('select_services').value != 0 )
	{			
		var opac_button = new Fx.Styles('valide_go_products', {duration:750, wait:false});
		opac_button.start({'opacity':1});
		$('valide_go_products').disabled=false;
		var xml_websites = responseXML.getElementsByTagName("website");
		xml_websites = $A(xml_websites);
		var select_country = $('select_country').value; 
		var select_service = $('select_services').value;
		$('select_websites').empty();
		var elem_option_vide_link = new Element('option',{'value':0});
		elem_option_vide_link.setHTML(select_site_product);
		$('select_websites').appendChild(elem_option_vide_link);
		xml_websites.each(function(item,index){
								   		if(item.previousSibling.previousSibling.firstChild != null) // service no null
								   		{		if(select_country == item.previousSibling.firstChild.nodeValue && 
											  	select_service == item.previousSibling.previousSibling.firstChild.nodeValue)
											{
												if(item.firstChild != null) // website no null
												{
													var webSite = item.firstChild.nodeValue;
													var elem_option_link = new Element('option',{'value':webSite});
													elem_option_link.setHTML(webSite);
													$('select_websites').appendChild(elem_option_link);
												}
											}
										}
								   });
		
	} else if($('select_services').value == 0) {
		$('valide_go_products').disabled=true;
		this.sendRequest(products.lien,"GET",initSelect_products_services_link);
	}
}

// choix du website , filtre sous la select du service
// la select du service peut rester vide
function select_websites(responseXML)
{
	if($('select_websites').value != 0)
	{
		var opac_button = new Fx.Styles('valide_go_products', {duration:750, wait:false});
		opac_button.start({'opacity':1});
		$('valide_go_products').disabled=false;
		
		/* Plus d'initialisation des boites de s?lection 
		var xml_services = responseXML.getElementsByTagName("service");
		xml_services = $A(xml_services);
		var select_country = $('select_country').value;
		var select_website = $('select_websites').value;
		$('select_services').empty();
		var elem_option_vide = new Element('option',{'value':0});
		elem_option_vide.setHTML(select_services_product);
		$('select_services').appendChild(elem_option_vide);
		
		xml_services.each(function(item,index){
		   			if(item.nextSibling.nextSibling.firstChild != null) // website no null
		   			{
						if(item.firstChild != null)
						{
							if(select_country == item.nextSibling.firstChild.nodeValue && 
					  		select_website == item.nextSibling.nextSibling.firstChild.nodeValue)
							{
								var service = item.firstChild.nodeValue;
								var elem_option_link = new Element('option',{'value':service});
								elem_option_link.setHTML(service);
								$('select_services').appendChild(elem_option_link);
							}
						}
					}
			   });
			   
		*/
		
		} else if($('select_websites').value == 0) {
			$('valide_go_products').disabled=true;
			this.sendRequest(products.lien,"GET",initSelect_products_services_link);
		}
}

function valide_link_product(responseXML)
{
	var select_country = $('select_country').value; 
	var select_website = $('select_websites').value;
	var select_service = $('select_services').value;
	var xml_products = responseXML.getElementsByTagName("product");
	xml_products = $A(xml_products);
	//Pinouf // 16/01/2008 // Modif pour link popup
	if(select_website == 0)
	{
		xml_products.each(function(item,index){
								   		if(select_country == item.childNodes[1].firstChild.nodeValue &&
											select_service == item.childNodes[0].firstChild.nodeValue)
								   		{
											//window.location.replace(item.attributes.getNamedItem('link').nodeValue);
											link_open = item.attributes.getNamedItem('link').nodeValue;
										}
								   });

	}
	else if(select_service == 0)
	{
		xml_products.each(function(item,index){
								   		if(select_country == item.childNodes[1].firstChild.nodeValue &&
											select_website == item.childNodes[2].firstChild.nodeValue)
								   		{
											//window.location.replace(item.attributes.getNamedItem('link').nodeValue);
											link_open = item.attributes.getNamedItem('link').nodeValue;
										}
								   });

		//window.open(link_open);
	//	window.open(link_open,'',params_popup_bubble);
		
	}
	else if(select_service !=0 && select_website !=0 )
	{
		xml_products.each(function(item,index){
								   		if(select_country == item.childNodes[1].firstChild.nodeValue &&
											select_website == item.childNodes[2].firstChild.nodeValue &&
												select_service == item.childNodes[0].firstChild.nodeValue)
								   		{
											//window.location.replace(item.attributes.getNamedItem('link').nodeValue);
											link_open = item.attributes.getNamedItem('link').nodeValue;
										}
								   });

	}
	window.open(link_open);
}

// fonction pout tout les outils
// initialisation du gabarit de l'outil
function initConfig(outil_config)
{
    
	if(outil_config.libelle != "")
	{
		var id_libelle = 'libelle_'+outil_config.id_outil;
		$(id_libelle).setHTML(outil_config.libelle);
	}
	if(outil_config.name_link != "")
	{
		var id_more = 'more_'+outil_config.id_outil;

		if($(id_more) != false)
		{
			if($(id_more) != null)
			{
				
				if(outil_config.the_link == "#")
				{
					$(id_more).setProperty('href',outil_config.the_link+outil_config.id_outil);
				}
					else
					{
						$(id_more).setProperty('href',outil_config.the_link);
					}
				$(id_more).setHTML(outil_config.name_link);
			}
		}
	}
	if(outil_config.edit != "" && outil_config.id_outil != "outil_sites")
	{
		var id_edit = 'edit_'+outil_config.id_outil;
		var link_id_edit = $(id_edit).firstChild.attributes.getNamedItem('id').nodeValue;
		$(id_edit).empty();
		//var elem_a = new Element('a',{'href':'#'+outil_config.id_outil,'id':link_id_edit});
		//var elem_a = new Element('a',{'class':'pointerhand','id':link_id_edit});
		var elem_a = new Element('a',{'href':'javascript:void(0);','id':link_id_edit});
		//elem_a.setHTML(outil_config.edit+'&nbsp;|&nbsp;');
		elem_a.setHTML(outil_config.edit);
		$(id_edit).appendChild(elem_a);
	}
}

// rajout du message sur la tool de product selon la config 
function addMessage_tools()
{
	if(typeof(products_message_tools) == 'string'
		&& boxExist('txt_product'))
	{
		$('txt_product').setHTML(products_message_tools);
	}
}


/******************************* Les fonctions de l'outil Job board*************************/

function job_init(responseXML)
{
	content_jobs = $('job_table');
	var index=0;
	while(index <content_jobs.childNodes.length  )
	{
		content_jobs.removeChild(content_jobs.childNodes[index]);
	}
	
	xml_jobs = responseXML.getElementsByTagName('job');
	xml_jobs = $A(xml_jobs);
	xml_jobs.each(function(item,index){
						   		if(index < 3 )
						   		{
						   			var titre = item.childNodes[0].firstChild.nodeValue;
						   			var desc = item.childNodes[1].firstChild.nodeValue;
						   			var link_job = item.childNodes[2].firstChild.nodeValue;
									
									var elem_tbody = new Element('tbody');
									var elem_tr = new Element('tr');
									var elem_td = new Element('td',{'valign':'top','width':'70','align':'left','class':'couleur_orange'});
									elem_td.setHTML(titre);
									var elem_td2 = new Element('td',{'valign':'top','align':'left'});
									var elem_a = new Element('a',{'href':link_job,'class':'orange_hover'});
									elem_a.setHTML(desc);
									elem_td2.appendChild(elem_a);
									
									elem_tr.appendChild(elem_td);
									elem_tr.appendChild(elem_td2);
									elem_tbody.appendChild(elem_tr);
									content_jobs.appendChild(elem_tbody); 
								}
						   });
}
/******************************* Les fonctions de l'outil Flashcard*************************/

function initTheme_flash(tab_id)
{
	var laSelect = $('select_card');
	if(tab_id.contains(flash.config.libelle_defaut)){
		laSelect.value = flash.config.libelle_defaut ;
	}
		else
		{
			laSelect.value = tab_id[0];
		}

	sendRequest(flash.lien,"GET",flashcard_affichage_xml);
}

function flash_init_form(responseXML)
{
	var select_form = $('select_card');
	var xml_themes = responseXML.getElementsByTagName('theme');
	xml_themes = $A(xml_themes);
	var tab_id = $A([]);
	select_form.empty();
	xml_themes.each(function(item,index){
								elem_option = new Element('option',{'value':item.attributes.getNamedItem('id').nodeValue});
								elem_option.setHTML(item.attributes.getNamedItem('name').nodeValue);
								select_form.appendChild(elem_option);
								tab_id.include(item.attributes.getNamedItem('id').nodeValue);
							 });
	initTheme_flash(tab_id); // envoi tableau de id
}

function flashcard_affichage_xml(responseXML)
{
	var div_content = $('text_flash_card');
	var img = $('img_flash');
	var xml_themes = responseXML.getElementsByTagName('theme');
	xml_themes = $A(xml_themes);
	var laSelect = $('select_card').value;
	
	//alert("img.getAttribute('src') = "+img.getAttribute('src'));
	
	xml_themes.each(function(item,index){
							 	if(item.attributes.getNamedItem('id').nodeValue == laSelect ){
									div_content.empty();
									var title = item.childNodes[0].firstChild.nodeValue;
									var link_img = item.childNodes[1].firstChild.nodeValue;
									var link_ = item.childNodes[2].firstChild.nodeValue;
									var popup = false;
									var width = 0;
									var height = 0;
									
									if (item.childNodes[2].attributes.getNamedItem('popup')) {
										popup = item.childNodes[2].attributes.getNamedItem('popup').nodeValue;
									}
									if (item.childNodes[2].attributes.getNamedItem('width')) {
										width = item.childNodes[2].attributes.getNamedItem('width').nodeValue;
									}
									if (item.childNodes[2].attributes.getNamedItem('height')) {
										height = item.childNodes[2].attributes.getNamedItem('height').nodeValue;
									}
									
									var elem_a;
									
									if (popup == "true") {
										if (width <= 0 && height <= 0) {
											elem_a = new Element('a', {
												'href': link_, 'target':'_blank'
											});
										}
										else {
											elem_a = new Element('a', {
												'href': link_,
												'onClick':'popup("' + link_ + '", '+width+', '+height+');return false;'
											});
										}
									} else {
										elem_a = new Element('a', {
											'href': link_
										});
									}
									
									elem_a.setHTML(title);
									div_content.appendChild(elem_a);
									img.setProperty('src',link_img);
									
									//throw StopIteration;
								}
							 });
}

/********** FONCTIONS DE LA BOITE DES SITES PREFERES ************/

//Permet de recuperer les themes selectionnes auparavant ou definis par un filtre de l'utilisateur
//Retourne une chaine de flashvars pour que l'animation flash prenne en compte ces themes.
function getSitesFromCookie()
{
	var cases_themes = $$('input.check_sites');   
	
	var chaine = "all";

	if (typeof(outil_sites_new_filtre) != 'undefined') {
		var chaine = outil_sites_new_filtre;
	} else if(typeof(home_filtre_outil_sites) != 'undefined' && home_filtre_outil_sites !='' ) {
		sites.cookie_first_time = 1;
		var	chaine = home_filtre_outil_sites;
	} else if(Cookie.get('sites_element') ) {

		var cookie_filtre = String(getValueCookie('sites_element',4));
		if(cookie_filtre != 'undefined')
		{
			sites.cookie_first_time = 1;
			var	tab_chaine_cookie = getValueCookie('sites_element',4);
			
			//alert(tab_chaine_cookie.join(','));
			
			if (tab_chaine_cookie != null && tab_chaine_cookie !='' ) {
				if (tab_chaine_cookie.length >= (cases_themes.length+1)) {
					chaine="all";
				}else{
					chaine=tab_chaine_cookie.join(",");
				}
			}
		} else if(cookie_filtre == 'undefined' && typeof(home_filtre_outil_sites) != 'undefined' && home_filtre_outil_sites =='' && sites.cookie_first_time ==1) {		
			chaine="all";
		} else {
		//Sinon, il n'y a ni forcage, ni profil, ni cookies, on recupere les themes precises dans la configuration
		//de la boite
			if(sites.config.libelle_defaut !="" && sites.cookie_first_time ==0){	
				sites.cookie_first_time = 1;
			} else {
				chaine="all";
			}
		}
	}
	
	return chaine;
	
}

function initSitesChoisis() {
	
	chaine = getSitesFromCookie();
	
	flashvars = "";
	
	//alert("chaine=" + chaine);
	
	//alert(chaine);
	//Les cases pr�cis�es dans la cha�ne sont coch�es.
	if(chaine != "all") {
		//alert(chaine);
		$('tout_sites').checked=false;
		var	tab = chaine.split(',');
		tab.each(function(item,index){
			if (item != "") {
				flashvars+=item;
				if (index < tab.length-2) {
					flashvars += ',';
				}
				$(item).checked = true;
			}
		})
	}
	
	//alert("flashvars=" + flashvars);
	
	//La cha�ne des th�mes coch�s est renvoy�e pour �tre transmise au flash pr�sentant les sites
	return flashvars;
}

function writeSitesCookie() {
    /**
     * Enregistrement des th�mes de site choisis dans la boite d'�dition,
     */
    var sitesChoisis = [];
    $$('input.check_sites').each(function(item,index){
        var bool = item.checked ? sitesChoisis.include(item.value) : false;
    });
        
    if(Cookie.get('sites_element'))
    {
        setParamCookie('sites_element',sitesChoisis)
    }
}

function affichage_contenu_sites(){
	
	
	new SitesManagementFlash($('contenu_sites_prefs'));
}

/*
function affichage_contenu_sites(responseXML) {
	var p_wait_mess = new Element('p', {'id':'sites_wait_message'});
	$('contenu_sites_prefs').appendChild(p_wait_mess);
	$('sites_wait_message').innerHTML = sites_wait_message[sLangSite];
	
	//alert(Cookie.get(tools['sites_element']));
	
	var sites_flashvars = getValueCookie("sites_element", 4);
	
	if(!sites_flashvars) {
	   sites_flashvars="";
	}
	
	var FO = { movie:sites.config.libelle_defaut, 
	           width:"296", 
	           height:"113", 
	           wmode:"transparent", 
	           majorversion:"8", 
	           build:"0", 
	           xi:"true",allowscriptaccess:"true", 
	           flashvars:"sites="+sites_flashvars+"&profilID="+profilID+"&lang="+sLangSite+""};
	
	// on passe le UFo en swfobject
	var paramsSWFOBJ = {
		quality: "high",
		scale: "noscale",
		wmode: "transparent",
		allowscriptaccess: "true"
	};
	var flashvarsSWFOBJ = {sites:sites_flashvars,profilID:profilID,lang:sLangSite,targetId:"contenu_sites_prefs"};
	var attributesSWFOBJ = {id:"contenu_sites_prefs",name: "contenu_sites_prefs"};
	
	if(sites.bool_first != 0)
	{
		var div_doc = new Fx.Styles('conteneur_global_sites', {duration:750, wait:false});
		div_doc.addEvent('onComplete', function() {
		//UFO.create(FO, "contenu_sites_prefs");
		swfobject.embedSWF(sites.config.libelle_defaut, "contenu_sites_prefs", "296px", "113px", "8", "swf/expressInstall.swf", flashvarsSWFOBJ, paramsSWFOBJ, attributesSWFOBJ);
		if (navigator.appName == "Netscape") {
			if (boites_edit_ouvertes == 0) 
				initSIFR();
		}});
		div_doc.start({'opacity':1});
		$('longedit_boite_sites').setStyle( 'display', 'none' );
		sites.bool_first = 1;
	} else {
		//UFO.create(FO, "contenu_sites_prefs");
		swfobject.embedSWF(sites.config.libelle_defaut, "contenu_sites_prefs", "296px", "113px", "8", "swf/expressInstall.swf", flashvarsSWFOBJ, paramsSWFOBJ, attributesSWFOBJ);
	}
	
}*/


/******************************* Les fonctions Divers *************************/

function clean_day(day) //tranforme 04 en 4 ( bug ff)
{
	var tab =day.split('');
	if(tab[0] == 0)
	{
		return tab[1];
	}
	else 
	{return day;}
}

function go(c)
{
	if(!c.data.replace(/\s/g,''))
		c.parentNode.removeChild(c);
}

function clean(d)
{
	var bal=d.getElementsByTagName('*');
	for(i=0;i<bal.length;i++)
	{
		a=bal[i].previousSibling;
		if(a && a.nodeType==3)
			go(a);
			b=bal[i].nextSibling;
		if(b && b.nodeType==3)
			go(b);
	}
	return d;
} 


function boxExist(UnElem)
{
	var value = $(UnElem) ? true : false;
	return value;
}


function getDateString_fr(unedate,type)
{
		var letype = type;
	var time = String(unedate.getTime()+(unedate.getTimezoneOffset()*60)+7200);
	
	if(time.length < 13) {
		time += '000';
	}
	unedate.setTime(time);
	var te = new String(unedate);
	var tab=te.split(' ');
	if(tab[3].length != 4 ) {
		tab[3] = tab[5] ;
	}
	var sMois;
	switch(letype)
	{
		case 0 :
		if (sLangSite == "fr") {
			switch (tab[1]) {
				case 'Jan' :
					sMois = 'Jan';
					break;
				case 'Feb' :
					sMois = 'F&eacute;v';
					break;
				case 'Mar' :
					sMois = 'Mars';
					break;
				case 'Apr' :
					sMois = 'Avr';
					break;
				case 'May' :
					sMois = 'Mai';
					break;
				case 'Jun' :
					sMois = 'Juin';
					break;
				case 'Jul' :
					sMois = 'Juil';
					break;
				case 'Aug' :
					sMois = 'Ao&ucirc;t';
					break;
				case 'Sep' :
					sMois = 'Sep';
					break;
				case 'Oct' :
					sMois = 'Oct';
					break;
				case 'Nov' :
					sMois = 'Nov';
					break;
				case 'Dec' :
					sMois = 'Dec';
					break;
			}
			var chaine = tab[2] +"&nbsp;" +sMois +"&nbsp;" +tab[3];
		}
		else {
		
			var chaine = tab[2] +"&nbsp;" +tab[1] +"&nbsp;" +tab[3];
		}
	
		break;
	}
	return chaine;
}

function getDateString(unedate,type)
{
	var letype = type;
	var time = String(unedate.getTime()+(unedate.getTimezoneOffset()*60)+7200);
	
	if(time.length < 13) {
		time += '000';
	}
	unedate.setTime(time);
	
	//var te2=unedate.toGMTString(); //fixe la date pour tt le monde
	var te = new String(unedate);
	
	//alert("unedate.toGMTString() = "+te);
	var tab=te.split(' ');
	// 0 day de la semaine
	// 1 mois
	// 2 jour
	// 3 annee
	
	// lann?e chez IE est la tab[5] donc on inverse pour que sa soit comme sur FF
	if(tab[3].length != 4 ) {
		tab[3] = tab[5] ;
	}
	
	var sMois;
	switch(letype)
	{
		case 0 :
		if (sLangSite == "fr") {
			switch (tab[1]) {
				case 'Jan' :
					sMois = 'Jan';
					break;
				case 'Feb' :
					sMois = 'Feb';
					break;
				case 'Mar' :
					sMois = 'Mar';
					break;
				case 'Apr' :
					sMois = 'Apr';
					break;
				case 'May' :
					sMois = 'May';
					break;
				case 'Jun' :
					sMois = 'Jun';
					break;
				case 'Jul' :
					sMois = 'Jul';
					break;
				case 'Aug' :
					sMois = 'Aug';
					break;
				case 'Sep' :
					sMois = 'Sep';
					break;
				case 'Oct' :
					sMois = 'Oct';
					break;
				case 'Nov' :
					sMois = 'Nov';
					break;
				case 'Dec' :
					sMois = 'Dec';
					break;
			}
			var chaine = tab[2] +"&nbsp;" +sMois +"&nbsp;" +tab[3];
		}
		else {
			var chaine = tab[2] +"&nbsp;" +tab[1] +"&nbsp;" +tab[3];
		}

		break;
		
		case 1:
		var chaine = tab[1]; // mois
		break;
		
		case 2 : 
		var chaine = tab[3]; // ann??e
		break;
		
		case 3 : 
		var chaine = tab[2]; // jour
		break;
		case 4 :
		var chaine = tab[2]+"-"+tab[1]+"-"+tab[3];
		break;
	
		case 5 : //JOUR, mois et ann?e en francais ou anglais
		if (sLangSite == "fr") {
			sMois = tab_mois_fr[tab[1]];	
		} else {
			sMois = tab_mois_en[tab[1]];	
		}
		
		var chaine = tab[2] +"&nbsp;" +sMois +"&nbsp;" +tab[3];	

		break;
		
		case 6 : // MOIS ET ANNEE EN FRANCAIS OU ANGLAIS
		
		if (sLangSite == "fr") {
			sMois = tab_mois_fr[tab[1]];
		} else {
			sMois = tab_mois_en[tab[1]];
		}
		
		var chaine = sMois +"&nbsp;" +tab[3];

		break;

	}

	return chaine;
}


function obtenirMois(num)
{
	var chaine ="";
		switch(num)
	{
		case 1 :
		var chaine ="Jan" 
		break;
		
		case 2:
		var chaine ="Feb" 
		break;
		
		case 3 : 
		var chaine = "Mar"
		break;
		
		case 4 :
		var chaine = "Apr"
		break;
		
		case 5 :
		var chaine ="May" 
		break;
		
		case 6 :
		var chaine = "Jun"
		break;
		
		case 7 :
		var chaine = "Jul"
		break;
		
		case 8 :
		var chaine = "Aug"
		break;
		
		case 9 :
		var chaine = "Sep"
		break;
		
		case 10 :
		var chaine = "Oct"
		break;
		
		case 11 :
		var chaine = "Nov"
		break;
		
		case 12 :
		var chaine = "Dec"
		break;
		
		
	}
	return chaine;
}


function Obenir_mois_fr(mois)
{
	var chaine = '';
	if(sLangSite == 'fr') {
		var tabmois = $A(['','janvier','f&eacute;vrier','mars','avril','mai','juin','juillet','ao&ucirc;t','septembre','octobre','novembre','d&eacute;cembre']);
	}else{
		var tabmois = $A(['','January','February','March','April','May','June','July','August','September','October','November','December']);
	}
	tabmois.each(function(item,index){
						  if(index == mois)
						  {
							chaine = new String(item);
						  }
					  })	
	return chaine;
}

function obtenirMois_int(mois)
{
	var chaine = '';
	var tabmois = $A(['','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']);
	tabmois.each(function(item,index){
						  if(item == mois)
						  {
							chaine = new String(index);
						  }
					  })
	if(chaine.length == '1'){ chaine = 0+chaine}
	return chaine;
}


	//pour trier un tableau avec des valeurs num?rics
function sortNumber(a,b)
{
	return a - b
}

//converti in attribut de profil comme 1,2,3 en tableau
function convert_profil_tab(chaine)
{
	var tab = chaine.split(',');
	return tab;
}

function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}

// modification du cookie selon profil
function setCookie_profil(elem)
{
	setIdprofilCookie(elem.value)
}

//cr?ation du cookie de sauvegarde de donn?e
// initialisation ? id@x@y@nb@
// idprofil@posX@posY@nbParam
// si nbParam > 0 => on rajoute les parametre a la suite
function savaData()
{
	
	outils_id.each(function(item,index){
								if(!Cookie.get(tools[item]))
								{
									var outil = tools[item]
									Cookie.set(tools[item],'0@x@y@nb@', {duration:365,path:"/"});
								}
							});
	outils_id.each(function(item,index){
							//alert(Cookie.get(tools[item]))
							//Cookie.remove(tools[item]);
						
							});
}


// r?cup?ration des donn?es du cookie
// prend en param un cookie et un chiffre 
// 0 = iprofil 
// 1 = posX 
// 2  = posY
// 3 = nbParam
// 4 = les parametre sous forme de tableau

//alert(getValueCookie('b_press.html',4))
function getValueCookie(myCookie,mode)
{
	if(Cookie.get(myCookie))
	{
		var cookie_data = Cookie.get(myCookie);
		var tab = cookie_data.split("@");
		var chaine ='';
		var tab_chaine = $A([]);
		switch(mode)
		{
			case 0:
				chaine = tab[0];
				return chaine;
			break;
			case 1:
				chaine = tab[1];
				return chaine;
			break;
			case 2:
				chaine = tab[2];
				return chaine;
			break;
			case 3:
				chaine = tab[3];
				return chaine;
			break;
			case 4:
				if(tab[2] > 0)
				{
				
					tab.each(function(item,index){
									  if(index > 3){tab_chaine.include(item)}
									  });
					return tab_chaine;
				}
					else
					{
						//alert('error : Ce Cookie ne possede pas de parametre');
					}
			break;
		} 
		
	}
		else
		{
			//alert("Error : Cookie n'existe pas")
		}
}

// return le cookie sous forme de tableau
function getTab_cookie(mycookie)
{
	var tab = mycookie.split('@');
	return tab;
}

// modification de idprofil de chaque outil
function setIdprofilCookie(elem)
{
	b_outils.each(function(item,index){
						   		var tab_cookie = getTab_cookie(Cookie.get(item)); // transformation en tableau
								tab_cookie[0] = elem;
								var chaine ='';
								tab_cookie.each(function(item2,index2){
														 if(item2 !='')
														 {
														 	chaine += item2+'@';
														 }
														});
						  		Cookie.remove(item);
								Cookie.set(item,chaine, {duration:365,path:"/"});
						   })
}

//modification de la posX 
//prend en parametre le nom du cookie et la nouvelle position
function setposXCookie(myCookie,newPosX)
{
	if(Cookie.get(myCookie))
	{
		var tab_cookie = getTab_cookie(Cookie.get(myCookie)); // transformation en tableau
		tab_cookie[1] = newPosX;
		var chaine ='';
		tab_cookie.each(function(item2,index2){
								 if(item2 !='')
								 {
									chaine += item2+'@';
								 }
						});
		Cookie.remove(myCookie);
		Cookie.set(myCookie,chaine, {duration:365,path:"/"});
	}
		else
		{
			//alert("error : le cookie n'existe pas")
		}
}

//setposYCookie('b_press.html',500)
//modification de la posY
//prend en parametre le nom du cookie et la nouvelle position
function setposYCookie(myCookie,newPosY)
{
	if(Cookie.get(myCookie))
	{
		var tab_cookie = getTab_cookie(Cookie.get(myCookie)); // transformation en tableau
		tab_cookie[2] = newPosY;
		var chaine ='';
		tab_cookie.each(function(item2,index2){
								 if(item2 !='')
								 {
									chaine += item2+'@';
								 }
						});
		Cookie.remove(myCookie);
		Cookie.set(myCookie,chaine, {duration:365,path:"/"});
	}
		else
		{
			//alert("error : le cookie n'existe pas")
		}
}

// fonction pour modifier le nombre de parametre et ajout? les parametres dans le cookie
// utiliser lors d'un edit d'un outil 
//tab_test = ['theme1'];
//tab_test1 = ['theme1','theme2','theme3'];
//setParamCookie('b_press.html',tab_test)
function setParamCookie(myCookie,tab_param)
{

	if(Cookie.get(myCookie))
	{
		var tab_cookie = getTab_cookie(Cookie.get(myCookie)); 
		var nbparam = tab_param.length;
		tab_cookie[3] = nbparam;
		var tab_copy =$A([]);
		tab_cookie.each(function(item,index){
								 	if(index <= 3)
								 	{
										tab_copy.include(item);	 
									}
								 });
		tab_cookie = tab_copy;
		var chaine='';
		tab_param.each(function(item,index){
									 tab_cookie.include(item)
								});
		tab_cookie.each(function(item2,index2){
								 if(item2 !='')
								 {
									chaine += item2+'@';
								 }
						});
		Cookie.remove(myCookie);
		Cookie.set(myCookie,chaine, {duration:365,path:"/"});
		
	}
		else
		{
			//alert("error : le cookie n'existe pas")
		}
}

function initParamCookie(myCookie)
{
	if(Cookie.get(myCookie)){
		var idprofil = (myCookie,0);
		var posX = getValueCookie(myCookie,1);
		var posY = getValueCookie(myCookie,2);
		var chaine = idprofil+'@'+posX+'@'+posY+'@nb@'
		Cookie.remove(myCookie);
		Cookie.set(myCookie,chaine, {duration:365,path:"/"});
	} 
}

//071107 Alexis : Fonction de r?cup?ration de la hauteur de div correspondant au nombre de caract?res ? y ins?rer LA LIMITE EST DE DEUX LIGNES
function getHauteurDivForChars(nb_chars) {
	if (nb_chars <= vNbCharsByLine) {
		return 15;
	} else if (nb_chars > vNbCharsByLine) {
		return 30;
	}
}

function getShorterString(chaine) {
	var new_length = vNbCharsByLine*2;
	if (chaine.length > new_length) {
		//alert ("chaine ? d?couper = "+chaine);
		//Si le d?coupage risque de se faire sur un mot, on se place avant lui et on ajoute des points de suspension
		while(chaine.charAt(new_length) != " ") {
			new_length--;
		}
		chaine = chaine.substr(0, new_length);
		chaine+="...";
	}
	return chaine;
}

//071107 Alexis : Fonction de r?cup?ration de la hauteur de div correspondant au nombre de caract?res ? y ins?rer
function getHauteurDivChars(nb_chars) {
	if (nb_chars <= 35) {
		return 15;
	} else if (nb_chars > 35 && nb_chars < 70) {
		return 30;
	} else if (nb_chars > 70 && nb_chars < 90) {
		return 42;
	} else {
		return 58;
	}
}

/** Page d'�dition de mes sites pr�f�r�s **/
/*var titres;
var listes;
var elm_li;
var elm_div;
var elm_input;
var elm_label;
var attr_checked;
var sitesChoisis = new Array();
var tab_param  = new Array();
*/
function show_profils(){
	new SitesManagement($('page_edit_sites'));
}

var SitesManagement = new Class({
	initialize : function(o){
		var _this = this;
		this.oDom = o;
		this.oConf = config_sites;
		this.oDomZone = $('liste_cases_sites');
	//	this.oConf.the_link = 'jhsdgfldsjhfb';
		this.oChecked = {};
		
		this.oAjax = new Ajax(this.oConf.the_link ,{
			method : 'get',
			encoding: 'utf-8',		
			onSuccess : function(response){
				var _xml = this.response.xml;
				var _o = new XML2OBJ(_xml, {arrayForcedNode:["item"]});
				_this.succeedHandler(_o);

			},
			onFailure : function(){
				//affichage erreur
				_this.setError();
			}

		}).request();
	},
	succeedHandler : function(oResp){
		var _cook = this.getCookie();
		if (_cook){
			this.setDom(oResp, false);
		}else{
			this.setDom(oResp, true);
		}
	},
	setDom : function(oResp, bDefault){
		var _this = this;
		var oUl = new Element('ul');
		
		var aChilds = oResp.rootItem.item;
		
		for (var i=0; i < aChilds.length; i++) {
			var oChild = aChilds[i];
			var oLi = new Element('li');
			var oImg = new Element('img', {'width' : oChild.width, 'height' : oChild.height, 'src' : oChild.path});
			var oLabel = new Element('label', {'for' : oChild.id}).setText(oChild.description.txt);
			var oInput = new Element('input', {'id' : oChild.id, 'type' : 'checkbox'});
			var oLink = new Element('a', {'href' : oChild.link.txt, 'target' : oChild.link.target}).setText(oChild.link.txt);
			var oDiv = new Element('div');
			var oDiv2 = oDiv.clone(oDiv).addClass('ligne');
			oUl.adopt(
				oLi.adopt(
					oDiv2.adopt(
						oDiv.adopt(
							oInput,
							oLabel
						),
						oLink
					)
				)
			)
			if (bDefault){
				this.oChecked[oChild.id] = 0;
			}else{
				if(this.oChecked[oChild.id]){
					oInput.checked = true;
				}
			}
			//ajout evenements  = input
			oInput.addEvent('click', function(e) {
				_this.inputHandler(this);
			})
			
			
		};
		oUl.injectTop(this.oDomZone);
	},
	setError : function(){
		this.oDomZone.adopt(new Element('span').setText(this.oConf.name_link));
	},
	inputHandler : function(o){
		this.oChecked[o.id] = o.checked ? 1 : 0;
		this.setCookie();
	},
	getCookie : function(){
		var _cook = Cookie.get('sites_elements');
		if (_cook){
			_cook = new Hash.Cookie('sites_elements');
			this.oChecked = _cook.obj;
			return _cook;
		}else{
			return false;
		}
		
	},
	setCookie : function(){
		var _cook = new Hash.Cookie('sites_elements');
		_cook.extend(this.oChecked);
		_cook.save();
	}
});
/*

function show_profils(){
	var _oDom = $('page_edit_sites');
	var _oConf = config_sites;
	//lecture XML
	var _ajax = new Ajax(_oConf.the_link ,{
		method : 'get',
		encoding: 'utf-8',		
		onSuccess : function(response){
			var _xml = response.xml
			console.log(response, this);
			
		},
		onFailure : function(){
			//affichage erreur
			_oDom.innerHTML  = _oConf
		}
		
	}).request();
	
	
	/*
    tab_xml_profils.each(function(item,index){
        titres = $$("#liste_cases_sites h2");
        index_profil = index;
        titres[index].setText(item[0]);
        this.sendRequest(item[1],"GET",eval("init_edit_box_sites_interne_"+index));
    });
    $ES(".btn_enregistrer","page_edit_sites").addEvent("click",function(e){
        e = new Event(e).stop();
        
        //recuperation des cases coch�s
        var tab_param  = new Array();
        $$("#page_edit_sites input").each(function(elm){
            if(elm.getProperty("checked") == true){
                tab_param.include(elm.getProperty("value"));
            }
        });
        
        setParamCookie("sites_element", tab_param);

        history.back();
    });
*
}
*/

var CreateFavorites = new Class({
	options : {
		
	},
	initialise : function(){
		
	}
})
CreateFavorites.implement(new Events, new Options);


function init_edit_box_sites_interne() {
    //Cr�ation de la case de s�lection de tous les th�mes de sites
    elm_li = new Element('li');
    elm_div = new Element('div', {'class':'ligne'});
    elm_div_2 = new Element('div');
    elm_input = new Element('input', {'type':'checkbox'});
    elm_label = new Element('label');
    elm_a = new Element('a',{'target':'_blank'});
    listes = $$("#liste_cases_sites ul");
}
function createDOM(responseXML,nb_profil){
    if((profilID == nb_profil) && (Cookie.get('sites_element') == false)) {
        attr_checked = "checked";
    }
    else if(Cookie.get('sites_element')){
        var sites_elements = true;
    }
    else{
        attr_checked = "";
    }
    var liste_sites = responseXML.getElementsByTagName('item');
    liste_sites = $A(liste_sites);
    var values = new Array();
    liste_sites.each(function(item,index){
        if(sites_elements) {
            values = Cookie.get('sites_element').split('@');
            if(values.contains(item.getAttribute("id"))) attr_checked = "checked";
            else attr_checked = "";
        }
        init_edit_box_sites_interne();
        elm_li.injectInside(listes[nb_profil]);
        elm_div.injectInside(elm_li);
        elm_div_2.injectInside(elm_div);
        elm_input.injectInside(elm_div_2).setProperty("id",item.getAttribute("id")+"").setProperty("value",item.getAttribute("id")).setProperty("checked",attr_checked).setProperty("name",item.getAttribute("id")+"");
        elm_label.injectAfter(elm_input).setProperty("for",item.getAttribute("id")+"").setText(item.childNodes[0].firstChild.nodeValue);
        elm_a.injectAfter(elm_div_2).setProperty("href",item.childNodes[2].firstChild.nodeValue).setText(item.childNodes[2].firstChild.nodeValue);
    });
}
function init_edit_box_sites_interne_0(responseXML) {
    createDOM(responseXML,0);
}
function init_edit_box_sites_interne_1(responseXML) {
    createDOM(responseXML,1);
}
function init_edit_box_sites_interne_2(responseXML) {
    createDOM(responseXML,2);
}
function init_edit_box_sites_interne_3(responseXML) {
    createDOM(responseXML,3);
}
