function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}




var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) < 5);

function allSelected(s, r){
	for(i=0; i<s.length; i++){
		s[i].selected = r;
	}
}

function addOption(theSel, theText, theValue)
{
  var newOpt = new Option(theText, theValue);
  var selLength = theSel.length;
  theSel.options[selLength] = newOpt;
}

function deleteOption(theSel, theIndex)
{ 
  var selLength = theSel.length;
  if(selLength>0)
  {
    theSel.options[theIndex] = null;
  }
}

function moveOptions(theSelFrom, theSelTo)
{

var selLength = theSelFrom.length;
  var selectedText = new Array();
  var selectedValues = new Array();
  var selectedCount = 0;
  
  var i;
  
  // Find the selected Options in reverse order
  // and delete them from the 'from' Select.
  for(i=selLength-1; i>=0; i--)
  {
    if(theSelFrom.options[i].selected)
    {
      selectedText[selectedCount] = theSelFrom.options[i].text;
      selectedValues[selectedCount] = theSelFrom.options[i].value;
      deleteOption(theSelFrom, i);
      selectedCount++;
    }
  }
  
  // Add the selected text/values in reverse order.
  // This will add the Options to the 'to' Select
  // in the same order as they were in the 'from' Select.
  for(i=selectedCount-1; i>=0; i--)
  {
    addOption(theSelTo, selectedText[i], selectedValues[i]);
  }
  
  if(NS4) history.go(0);
}

function extractData(div, page, method, fct){

	vars = 'noHead';
	divH = document.getElementById(div);
	menu = divH.getElementsByTagName('select');
	chps = divH.getElementsByTagName('input');
	area = divH.getElementsByTagName('textarea');
	
	if(chps.length > 0){
		for(i=0; i<chps.length; i++){
			if(chps[i].type == 'checkbox'){
				if(chps[i].checked) vars = vars + '&' + chps[i].name + '=' + chps[i].value;
			}else{
				vars = vars + '&' + chps[i].name + '=' + chps[i].value;
			}
		}
	}

	if(menu.length > 0){
		for(i=0; i<menu.length; i++){
			el = menu[i];
			if(!el.multiple){
				vars = vars + '&' + el.name + '=' + el[menu[i].selectedIndex].value;
			}else{
				for(j=0; j<el.length; j++){
					if(el[j].selected) vars = vars + '&' + el.name + '[]=' + el[j].value;
				}
			}
		}
	}

	if(area.length > 0){
		for(i=0; i<area.length; i++){
			vars = vars + '&' + area[i].name + '=' + area[i].value;
		}
	}

	loadData(div, vars, page, method, fct);
}

function digData(div, href, vars, value){

	divH = document.getElementById(div);
	chps = divH.getElementsByTagName('input');

	if(chps.length > 0){
		for(i=0; i<chps.length; i++){
			if(chps[i].name == vars && chps[i].value == value){
				loadData('data', 'noHead', href, 'GET');
			}
		}
	}
}

function reloadData(href){
	loadData('data', 'noHead', href, 'GET');
}

function loadData(div, data, page, method, callBackFonction){

	var str = document.getElementById('loadingAJX');
	var src = document.getElementById(div);
	src.innerHTML = str.innerHTML;

	sendData(div, data, page, method, callBackFonction);

	return false;
}

function sendData(div, data, page, method, callBackFonction) { 

	
	if(document.all){ 
		var XhrObj = new ActiveXObject("Microsoft.XMLHTTP") ; 
	}else{
		var XhrObj = new XMLHttpRequest(); 
	} 

	// Définition de l'endroit d'affichage:
	if(document.getElementById(div)){
		var content = document.getElementById(div);
	}else{
		var content = div;
	}

	// Si on envoie par la méthode GET: 
	if(method == "GET"){ 
		if(data == 'null'){ 
			XhrObj.open("GET", page); 
		}else{ 
			XhrObj.open("GET", page+"?"+data); 
		}
	}else
	if(method == "POST"){ 
		XhrObj.open("POST", page); 
	}

	if(method == "GET") { 
		XhrObj.send(null); 
	}else
	if(method == "POST"){ 
		XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); 
		XhrObj.send(data); 
	}

	//Ok pour la page cible 
	XhrObj.onreadystatechange = function() {	
		if (XhrObj.readyState == 4 && XhrObj.status == 200){
			if(callBackFonction != null){
				content.innerHTML = XhrObj.responseText;
				eval(callBackFonction);
			}else{
				content.innerHTML = XhrObj.responseText;
			}
			
		}
	}

}






