
function nodeCleaner(n){if(!n.data.replace(/\s/g,''))n.parentNode.removeChild(n);}
function cleanXML(docElement){var node=docElement.getElementsByTagName('*');for(i=0;i<node.length;i++){a=node[i].previousSibling;if(a&&a.nodeType==3)nodeCleaner(a);b=node[i].nextSibling;if(b&&b.nodeType==3)nodeCleaner(b);}
return docElement;}
function afficheajax(lang,selection,liste)
{var seltag='';var idtag='';seltag=document.getElementById(selection);idtag=seltag.options[seltag.selectedIndex].value;if(selection=='selectregion'){idregion=idtag;var seltagpays='';var idtagpays='';if(document.getElementById('selectpays')){seltagpays=document.getElementById('selectpays');idtagpays=seltagpays.options[seltagpays.selectedIndex].value;idtag=idtagpays;}else{var location=document.location.href.split("/");idtag=location[6];}}else{idregion=0;}
var xhr=null;if(window.XMLHttpRequest){xhr=new XMLHttpRequest();}
else if(window.ActiveXObject)
{try{xhr=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){xhr=new ActiveXObject("Microsoft.XMLHTTP");}}
xhr.onreadystatechange=function()
{if(xhr.readyState==4&&xhr.status==200){switch(liste)
{case'zone':zone(xhr,lang);break;case'pays':pays(xhr,lang,idtag);break;case'region':region(xhr,lang,idtag);break;case'famille':famille(xhr,lang);break;}}};var envoi="lang="+lang+"&id="+idtag+"&idregion="+idregion+"&liste="+liste;xhr.open("POST",urlitdistri+"inc/affreponse.php",true);xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");xhr.send(envoi);}
function pays(xhr,lang,idtag)
{document.getElementById('counties').style.visibility='hidden';document.getElementById('region').style.visibility='visible';MontreLigne();var docXML=xhr.responseXML;response=cleanXML(docXML.documentElement);var items=response.getElementsByTagName("country");document.getElementById('region').innerHTML='';count=items.length;var vhtmlpays='';var taille=count+1;vhtmlpays+='<select id="selectregion" name="selectregion" size="10" onclick="javascript:afficheajax(\''+lang+'\',\'selectregion\',\'region\');">';for(i=0;i<count;i++)
{vhtmlpays+='<option value="'+items[i].getElementsByTagName("id_country")[0].firstChild.nodeValue+'">';vhtmlpays+=''+items[i].getElementsByTagName("lib_country")[0].firstChild.nodeValue+'</option>';}
vhtmlpays+='</select>';var docXML=xhr.responseXML;response=docXML.documentElement;var items=response.getElementsByTagName("region");count=items.length;var lib_region="";var lblregion="";for(j=0;j<count;j++)
{lib_region=items[j].getElementsByTagName("lib_region")[0].firstChild;if(lib_region){lblregion=items[j].getElementsByTagName("lib_region")[0].firstChild.nodeValue;}}
document.getElementById('region').innerHTML+='<p><h5 style="line-height: 2em; margin-left: 0px;" id="titreregion">'+lblregion+'</h5>'+vhtmlpays+'</p>';}
function region(xhr,lang,idtag)
{var docXML=xhr.responseXML;var itemscounty=0;response=cleanXML(docXML.documentElement);itemscounty=response.getElementsByTagName("county");count=itemscounty.length;document.getElementById('counties').innerHTML='';if(count>=1){var libelle_dpt=response.getElementsByTagName("lib_county")[0].firstChild.nodeValue;document.getElementById('counties').style.visibility='visible';var vhtmlcounties='';var taille=count+1;vhtmlcounties+='<select id="selectcounties" name="selectcounties" size="10" onclick="javascript:afficheajax(\''+lang+'\',\'selectcounties\',\'county\');">';for(i=0;i<count;i++)
{vhtmlcounties+='<option value="'+itemscounty[i].getElementsByTagName("id_county")[0].firstChild.nodeValue+'">';vhtmlcounties+=''+itemscounty[i].getElementsByTagName("lib_county")[0].firstChild.nodeValue+'</option>';}
vhtmlcounties+='</select>';document.getElementById('counties').innerHTML+='<p><h5 style="line-height: 2em; margin-left: 0px;">'+libelle_dpt+'</h5>'+vhtmlcounties+'</p>';}}
function zone(xhr,lang)
{document.getElementById('region').style.visibility='hidden';var docXML=xhr.responseXML;var itemszone=0;response=cleanXML(docXML.documentElement);itemszone=response.getElementsByTagName("un_pays");count=itemszone.length;var titre=document.getElementById('titrepays').innerHTML;document.getElementById('pays').innerHTML='';var vhtmlzone='';vhtmlzone+='<select id="selectpays" name="selectpays" size="10" onclick="javascript:afficheajax(\''+lang+'\',\'selectpays\',\'pays\');">';for(i=0;i<count;i++)
{vhtmlzone+='<option value="'+itemszone[i].getElementsByTagName("id_pays")[0].firstChild.nodeValue+'">';vhtmlzone+=''+itemszone[i].getElementsByTagName("lib_pays")[0].firstChild.nodeValue+'</option>';}
vhtmlzone+='</select>';document.getElementById('pays').innerHTML+='<p><h5 style="line-height: 2em; margin-left: 0px;" id="titrepays">'+titre+'</h5>'+vhtmlzone+'</p>';}
function categorie(xhr)
{}
function famille(xhr,lang)
{document.getElementById('type').style.visibility='visible';var docXML=xhr.responseXML;var itemscounty=0;response=cleanXML(docXML.documentElement);itemsfamilly=response.getElementsByTagName("un_type");count=itemsfamilly.length;var titre=document.getElementById('titretype').innerHTML;document.getElementById('type').innerHTML='';var vhtmlfamille='';var taille=count+1;vhtmlfamille+='<select id="selecttype" name="selecttype" size="10" onclick="javascript:afficheajax(\''+lang+'\',\'selecttype\',\'type\');">';vhtmlfamille+='<option value="0">---</option>';for(i=0;i<count;i++)
{vhtmlfamille+='<option value="'+itemsfamilly[i].getElementsByTagName("id_type")[0].firstChild.nodeValue+'">';vhtmlfamille+=''+itemsfamilly[i].getElementsByTagName("lib_type")[0].firstChild.nodeValue+'</option>';}
vhtmlfamille+='</select>';document.getElementById('type').innerHTML+='<p><h5 style="line-height: 2em; margin-left: 0px;" id="titretype">'+titre+'</h5>'+vhtmlfamille+'</p>';}
