function ajax_engine(){
	var xhr = null;
	if(window.XMLHttpRequest){ // Firefox et autres
	   xhr = new XMLHttpRequest();
	}else if(window.ActiveXObject){ // Internet Explorer
	   try {
            xhr = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            xhr = new ActiveXObject("Microsoft.XMLHTTP");
        }
	} else { // XMLHttpRequest non supporté par le navigateur
	   alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
	   xhr = false;
	}
	return xhr;
}
/*
function $(id){
	return document.getElementById(id);
}
*/
function setdisplay(id,value){
	if($(id)){
		$(id).style.display=value;
	}
}

function supprimer_option_by_value(select,val){
	for(var i = 0; i < select.options.length;i++){
		var v = select.options[i].value;
		if(v==val){
			select.remove(i);
		}
	}
}

function selectionner_multiple_select_by_id(id){
	selectionner_multiple_select_by_object($(id));
}
function selectionner_multiple_select_by_object(select){
	if(select){
		for(var i = 0; i < select.options.length;i++){
			select.options[i].selected=true;
		}
	}
}

function get_selected_value_by_select_id(id){
	return get_selected_value_by_select_object($(id));
}

function get_selected_value_by_select_object(sel){
	if(sel){
		return sel.options[sel.selectedIndex].value;
	}
}
function get_selected_option_by_obj(sel){
	if(sel){
		return sel.options[sel.selectedIndex];
	}
}
function insert_into_select_if_not_exists_by_id(id,value,text){
	return insert_into_select_if_not_exists_by_object($(id),value,text);
}

function insert_into_select_if_not_exists_by_object(sel,val,text){
	if(sel){
		if(! is_value_in_select_by_object(sel,val)){
			var new_option = new Option();
			new_option.innerText=text;
			new_option.text=text;
			new_option.value=val;
			sel.appendChild(new_option);
			new_option.style.width="100%";
			return new_option;
		}
	}
	return false;
}

function is_value_in_select_by_id(id,value){
	return is_value_in_select_by_object($(id),value);
}

function is_value_in_select_by_object(sel,val){
	if(sel){
		for(var i = 0;i<sel.options.length;i++){
			if(sel.options[i].value==val){
				return true;
			}
		}
	}
	return false;
}

function selected_id(id){
	return selected_object($(id));
}
function selected_object(sel){
	if(sel){
		return sel.options[sel.selectedIndex].value;
	}
}
function select_selected_id(id,val){
	select_selected_object($(id),val);
}

function select_selected_object(sel,val){
	if(sel){
		for(var i=0; i<sel.options.length;i++){
			if(sel.options[i].value==val){
				sel.options[i].selected=true;
			}
		}
	}
}

function is_color_without_diese(val){
	return is_color("#"+val);
}

function is_color(val){
	var color = /^#([a-f0-9]{6})$/i;
	return color.test(val);
}

function vider_select_id(id){
	vider_select_object($(id));
}
function vider_select_object(sel){
	if(sel){
		while(sel.options.length>0){
			sel.remove(0);
		}
	}
}

function isNumeric(x) {
	var RegExp = /^(-)?(\d*)(\.?)(\d*)$/; // Note: this WILL allow a number that ends in a decimal: -452.
	var result = x.match(RegExp);
	return result;
}
