
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 affichecounties(index)
{var seltag='';var idtag='';index=index-1;var nom="Id_Region"+index;seltag=document.getElementById(nom);idtag=seltag.options[seltag.selectedIndex].value;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){counties(xhr,index);}};var envoi="idregion="+idtag;xhr.open("POST",urlitdistri+"inc/affcounties.php",true);xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");xhr.send(envoi);}
function counties(xhr,index)
{var docXML=xhr.responseXML;response=cleanXML(docXML.documentElement);var items=response.getElementsByTagName("county");document.getElementById('county'+index).innerHTML='';count=items.length;var vhtmlpays='';var taille=count+1;for(i=0;i<count;i++)
{vhtmlpays+='<option value="'+items[i].getElementsByTagName("id_county")[0].firstChild.nodeValue+'">';vhtmlpays+=''+items[i].getElementsByTagName("lib_county")[0].firstChild.nodeValue+'</option>';}
document.getElementById('county'+index).innerHTML+=vhtmlpays;}
