/*
A propos de ce fichier :
 > nom : ajax.js
 > Description : Librairie de fonctions ajax
 > Date de création : 19 juillet 2006
 > Dernière modification : 4 aout 2006
 > Par : Martius
*/

/** @doc
 * == Fonctions AJAX ==
 */
 
/**
 * @param obj Ajax  Objet XMLHttpRequest
 */
var Ajax = false;

/**
 * @function getAjaxRequest
 *
 * Retourne l'objet XMLHttpRequest en fonction du navigateur utilisé.
 *
 * @return obj XMLHttpRequest
 */
function getAjaxRequest()
	{
		if(window.XMLHttpRequest) // Firefox et autres
			Ajax = new XMLHttpRequest(); 
		else if(window.ActiveXObject)
			{ // Internet Explorer 
				try
					{
						Ajax = new ActiveXObject('Msxml2.XMLHTTP');
					}
				catch (e)
					{
						Ajax = new ActiveXObject("Microsoft.XMLHTTP");
					}
			}
	}

function currentState()
	{
		if(!Ajax)
			return false;

		document.getElementById('ajax_popup_state').style.display = 'block';
		
		state = document.getElementById('ajax_state');

		if(Ajax.readyState == 4)
			{
				state.innerHTML = ajax4;
				if(Ajax.status != 200)
					state.innerHTML = ajaxerror;
				else
					document.getElementById('ajax_popup_state').style.display = 'none';
			}
		else if(Ajax.readyState == 3)
			state.innerHTML = ajax3;
		else if(Ajax.readyState == 2)
			state.innerHTML = ajax2;
		else if(Ajax.readyState == 1)
			state.innerHTML = ajax1;
		else
			state.innerHTML = ajax0;
	}

/** @doc
 * Fonctions de nettoyage XML
 */
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 ajaxtest()
	{
		if(!Ajax)
			getAjaxRequest();
			
		Ajax.onreadystatechange = currentState;
		
		Ajax.open('GET', 'http://magnet.martiusweb.net/ajax/test.php', true);
		Ajax.send(null);
	}
//*/
