/** ---------------------------------------------------------------------------------
 * XMLHttp Lib
 */
var boutikhttp = false

function initBoutikHTTP() {
	boutikhttp = false	
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	// JScript gives us Conditional compilation, we can cope with old IE versions.
	// and security blocked creation of the objects.
		try {
	 		boutikhttp	= new ActiveXObject("Msxml2.XMLHTTP");
	 	} catch (e) {
	 		try {
	 			boutikhttp = new ActiveXObject("Microsoft.XMLHTTP");
	 		} catch (E) {
	 			boutikhttp 		= false;
	 		}
	 	}
	@end @*/

	if (!boutikhttp && typeof XMLHttpRequest != 'undefined') {
	  boutikhttp = new XMLHttpRequest();
	}

	boutikhttp.onreadystatechange = function () { oPile.set_cState(boutikhttp.readyState) }
}

// trigge de changement d'état pour le connecteur''
var e = ''


/** ---------------------------------------------------------------------------------
 * Objet de gestion de pile de connection
 */
function oPileObject(){

	// tableau des fonctions contenues dans la pile
	this.aPile = new Array();

	// élément courant
	this.cItem = null
	
	// élément dépilé
	this.lItem = null

	// état courant du connecteur
	this.cState = 0;
	
	// retourne le nombre d'éléments de la pile
	this.nbItems = function() {
		return this.aPile.length;
	}
	
	// ajoute un élément dans la pile
	this.addItem = function(el) {
		this.aPile.push(el)
		//e+='oPile.addItem = '+this.aPile.length+"\n"
		this.execItem()
	}

	// dépile le premier élément
	this.getItem = function() {
		//e+='oPile.getItem'+"\n"
		//this.cItem = this.aPile.shift()
		this.cItem = this.aPile[0]
	}

	// dépile le premier élément
	this.delItem = function() {
		this.lItem = this.cItem
		this.aPile.shift()
	}

	// redéfini l'état du connecteur
	this.set_cState = function(v) {
		//e+='oPile.set_cState('+v+')'+"\n"
		this.cState = v
		this.execItem()
	}

	// exécute l'élément courant
	this.execItem = function() {

		if(this.cState == 0){
			this.getItem()


			if(this.cItem!=null&&typeof(this.cItem)=='object'){

				if (this.cItem.rMethod == 'GET') {
					this.cItem.rUrl=(''!=this.cItem.rData)?this.cItem.rUrl+'?'+this.cItem.rData:this.cItem.rUrl
					boutikhttp.open("GET", this.cItem.rUrl, true)
					boutikhttp.send(this.cItem.rData)

				} else if (this.cItem.rMethod == 'POST') {
					boutikhttp.open("POST", this.cItem.rUrl, true)
					boutikhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
					boutikhttp.send(this.cItem.rData)
				}
			}
		} else if(this.cState == 4){
			this.cItem.responseText		= boutikhttp.responseText
			this.cItem.responseXML		= boutikhttp.responseXML
			this.cItem.responseHeaders	= boutikhttp.getAllResponseHeaders()
			initBoutikHTTP()
			this.delItem()
			this.set_cState(0)
			eval(this.lItem.fnToExec)
			
		}
	}
}


function oPileElement(rMethod, rUrl, rData, fnToExec) {
	this.responseXML	= ''
	this.responseText	= ''
	this.responseHeaders= ''
	this.rMethod 		= rMethod
	this.rUrl 			= rUrl
	this.rData 			= rData
	this.fnToExec 		= fnToExec
}

function display_liste(txt,id_chg) {

	if (id_chg == "") {
		id_chg	= 'article_listing'
	}
	
    if (txt == null || txt == '')	return false
    if (!document.all && document.getElementById) {
		document.getElementById(id_chg).innerHTML 	= txt
	} else if (document.all) {
    	eval('document.all.'+id_chg).innerHTML		= txt
    }
}

oPile = new oPileObject()
initBoutikHTTP()
// instance du gestionnaire de pile
