function update_nom_produit()
{
    if (typeof XMLHttpRequest != "undefined") {
        this.http = new XMLHttpRequest();
    } else if (typeof ActiveXObject != "undefined") {
        this.http = new ActiveXObject("MSXML2.XmlHttp");
    } else {
        alert("No XMLHttpRequest object available. This functionality will not work.");
    }
    
    var oHttp = this.http;
    var aSuggestions = [];
    
    //if there is already a live request, cancel it
    if (oHttp.readyState != 0) {
        oHttp.abort();
    }                 
    
    var sous_categorie = document.getElementById('sous_categorie').value;
	var lang = document.getElementById('lang').value;
    //build the URL
    var sURL = "../include/update_nom_produit.php?sous_categorie_id=" + sous_categorie + "&_lang=" + lang;
    
    //open connection to states.txt file
    oHttp.open("post", sURL , true);
    oHttp.onreadystatechange = function () 
    {
        if (oHttp.readyState == 4) 
        {
            //evaluate the returned text JavaScript (an array)
            var parent = document.getElementById('nom_produit');
            while(parent.childNodes.length > 0)
                parent.removeChild(parent.childNodes[0]);
            
            var tabResult = oHttp.responseXML.getElementsByTagName('resultat');
            option = document.createElement("option");
            option.appendChild(document.createTextNode(document.getElementById('nom_produit_texte').value));
            parent.appendChild(option);
            for (var i = 0; i < tabResult.length; i++) 
            {
                resultat = tabResult.item(i); 
                
                option = document.createElement("option");
                option.setAttribute("value",resultat.getAttribute('valeur'));
				var titre = resultat.getAttribute('titre');
				titre = titre.replace("&#38;trade;",entity('&trade;'));
				titre = titre.replace("&trade;",entity('&trade;'));
                option.appendChild(document.createTextNode(titre));
                parent.appendChild(option);
            }
        }    
    };
    oHttp.send(null);
}

function entity(str, mode) {
	str = (str) ? str : "";
	mode = (mode) ? mode : "string";

	var e = document.createElement("div");
	e.innerHTML = str;

	if (mode == "numeric") {
		return "&#" + e.innerHTML.charCodeAt(0) + ";";
	}
	else if (mode == "utf16") {
		var un = e.innerHTML.charCodeAt(0).toString(16);
		while (un.length < 4) un = "0" + un;
		return "\\u" + un;
	}
	else return e.innerHTML;
}

function pop_up80x80(url)
{
	window.open(url,'jav','width=350,height=350,left=0,top=0,scrollbars=yes');
}

function pop_up160x80(url)
{
	window.open(url,'jav','width=575,height=350,left=0,top=0,scrollbars=yes');
}

function pop_up80x160(url)
{
	window.open(url,'jav','width=350,height=575,left=0,top=0,scrollbars=yes');
}
