/**
 * @author Didier
 */
 //affichage du pre¯ier echos ouverture de page
//Event.observe(window,"load",PrepareAffichage);

/*
var oEditor = FCKeditorAPI.GetInstance('mytextbox') ;    // Get the editor instance that we want to interact with
contents =  oEditor.GetXHTML( true ) ;   
 autre solus
 The editor's content is empty when submitting the editor's surrounding form by ajax. What is wrong?

This problem is caused by a missing call of the function FCK.UpdateLinkedField(). By submitting the editor's surrounding form with an ajax function the values of all form elements are collected in a javascript object (some kind of an array). At this time the value of the hidden field that usually contains the editor's html output is empty, because the editor's surrounding form wasn't submitted for real, you can call it a simulated submit. The workaround is to call the FCK.UpdateLinkedField() function before submitting the form. Either you call it directly before the ajax collect function or in the onClick attribute of the submit button. For general use, even if you have more than one FCKeditor instance, I wrote the following hack to solve the problem.


// Some Class
function MyClass()
{
        this.UpdateEditorFormValue = function()
        {
                for ( i = 0; i < parent.frames.length; ++i )
                        if ( parent.frames[i].FCK )
                                parent.frames[i].FCK.UpdateLinkedField();
        }
}
// instantiate the class
var MyObject = new MyClass();
Now can call this method in the onSubmit attribute of the editor's surrounding form before calling the ajax collecting function:

<form ... onSubmit="MyObject.UpdateEditorFormValue(); Ajax.Collect(); return false;">
Note: the previous syntax won't work if using VisualStudio 2005 and Atlas and IE. It will be ok to use :


<form ... onSubmit="MyObject.UpdateEditorFormValue(); return true;">
Or you'll do it in the onClick attribute of the submit button, which is also called before the onSubmit event:


<input type="submit" ... onClick="MyObject.UpdateEditorFormValue();" />
 
 */
// fonction loading
function displayLoading(element) {
	while(element.hasChildNodes()) {
		element.removeChild(element.lastChild);
	}
	var image = document.createElement("img");
	image.setAttribute("src","images/loading.gif");
	image.setAttribute("alt","loading...");
	element.appendChild(image);
}
///choix echos****************************************
function afficheChoix(requete) {
	$('loading').hide();
	$('insertionChoix').innerHTML="";//on vide
	new Insertion.Bottom('insertionChoix', requete.responseText);// on insere
	
}
function requeteAffichage(idAffiche) {
	//alert(this);
	var pars = "choix="+this;
	new Ajax.Request('WEchosChoix.php',
		{
			
			method: 'get',
			parameters: pars,
			onLoading: function() {
				$('loading').show();
			},
			onSuccess: function(requete) {
				afficheChoix(requete);
				}
		});
} // projet
function PrepareAffichage(e) {
	//alert("prepare ok");
	
	var ligneChoix = $('echos').getElementsByClassName('echosChoix');
	//alert(ligneChoix);
	for(i=0; i<ligneChoix.length; ++i) 
	{
		
		var idAffiche = ligneChoix[i].id;
		//alert(id);
		Event.observe(idAffiche, 'click', requeteAffichage.bindAsEventListener(idAffiche));
	}
	
	
	
}
//********************************************
////chargement echos premier********************************************************************
function afficheEchosPremier(transport) {
	$('loading').hide();
	new Insertion.Bottom('insertionChoix', transport.responseText);
	
}
//
function echosPremier(e) {
	
	new Ajax.Request('WEchosPremier.php',
		{
			method: 'get',
			onSuccess: function(transport) {
				afficheEchosPremier(transport);
				}
		});
} // projet

//chargement desnews********************************************************************
function afficheNews(transport) {
	
	new Insertion.Bottom('insertion', transport.responseText);
	PrepareAffichage();
	
}
//
function news(e) {
	
	new Ajax.Request('Wechos.php',
		{
			onSuccess: function(transport) {
				afficheNews(transport);
				}
		});
} // projet


Event.observe(window, "load", news);
Event.observe(window,"load", echosPremier);
//affichage du pre¯ier echos ouverture de page
//Event.observe(window,"load",PrepareAffichage);

/*
var oEditor = FCKeditorAPI.GetInstance('mytextbox') ;    // Get the editor instance that we want to interact with
contents =  oEditor.GetXHTML( true ) ;   
 autre solus
 The editor's content is empty when submitting the editor's surrounding form by ajax. What is wrong?

This problem is caused by a missing call of the function FCK.UpdateLinkedField(). By submitting the editor's surrounding form with an ajax function the values of all form elements are collected in a javascript object (some kind of an array). At this time the value of the hidden field that usually contains the editor's html output is empty, because the editor's surrounding form wasn't submitted for real, you can call it a simulated submit. The workaround is to call the FCK.UpdateLinkedField() function before submitting the form. Either you call it directly before the ajax collect function or in the onClick attribute of the submit button. For general use, even if you have more than one FCKeditor instance, I wrote the following hack to solve the problem.


// Some Class
function MyClass()
{
        this.UpdateEditorFormValue = function()
        {
                for ( i = 0; i < parent.frames.length; ++i )
                        if ( parent.frames[i].FCK )
                                parent.frames[i].FCK.UpdateLinkedField();
        }
}
// instantiate the class
var MyObject = new MyClass();
Now can call this method in the onSubmit attribute of the editor's surrounding form before calling the ajax collecting function:

<form ... onSubmit="MyObject.UpdateEditorFormValue(); Ajax.Collect(); return false;">
Note: the previous syntax won't work if using VisualStudio 2005 and Atlas and IE. It will be ok to use :


<form ... onSubmit="MyObject.UpdateEditorFormValue(); return true;">
Or you'll do it in the onClick attribute of the submit button, which is also called before the onSubmit event:


<input type="submit" ... onClick="MyObject.UpdateEditorFormValue();" />
 
 */
