// JavaScript Document
xmlTypesSet="";
nb=0;


function createXHR() 
{
    var request = false;
        try {
            request = new ActiveXObject('Msxml2.XMLHTTP');
        }
        catch (err2) {
            try {
                request = new ActiveXObject('Microsoft.XMLHTTP');
            }
            catch (err3) {
		try {
			request = new XMLHttpRequest();
		}
		catch (err1) 
		{
			request = false;
		}
            }
        }
    return request;
}
function affich_fiche(id_fiche) {
	//alert(id_fiche);
	if (id_fiche!=0){
		xhr_fiche=createXHR();
		xhr_fiche.onreadystatechange = function()
			{
				if (xhr_fiche.readyState == 4 && xhr_fiche.status == 200)
				 {			 
						
					xmlTypesSet=xhr_fiche.responseXML;
					 
					

					var catid=xmlTypesSet.getElementsByTagName("catid")[0].firstChild.nodeValue;
					var catalias=xmlTypesSet.getElementsByTagName("catalias")[0].firstChild.nodeValue;
					var contid=xmlTypesSet.getElementsByTagName("contid")[0].firstChild.nodeValue;
					var contalias=xmlTypesSet.getElementsByTagName("contalias")[0].firstChild.nodeValue;

					lien="index.php?option=com_content&view=article&id=" + contid + ":" + contalias + "&catid=" + catid + ":" + catalias;
					//alert(lien);
					document.location.href=lien;
					

	
						
						
				 }
			}
		
		xhr_fiche.open("POST","/scripts/load_fiche.php",true);
		xhr_fiche.setRequestHeader("Content-Type","application/x-www-form-urlencoded");	
		data="id=" + id_fiche;
		xhr_fiche.send(data);
	}

}


function affich_boutiques(idcat) {

		xhr_boutiques=createXHR();
		xhr_boutiques.onreadystatechange = function()
			{
				if (xhr_boutiques.readyState == 4 && xhr_boutiques.status == 200)
				 {			 
					
					while (document.getElementById("lst_boutiques").options.length>0)
						{
							document.getElementById("lst_boutiques").options[0] = null;
						}
						
					 xmlTypesSet=xhr_boutiques.responseXML;
					 
					 boutiques = xmlTypesSet.getElementsByTagName('root'); 
					 nb = boutiques[0].childNodes.length; 	
					
						for (i=0; i<nb; i++)
						{
							var id_bout=xmlTypesSet.getElementsByTagName("id_boutique")[i].firstChild.nodeValue;
							var title_bout=xmlTypesSet.getElementsByTagName("title_boutique")[i].firstChild.nodeValue;
							document.getElementById("lst_boutiques").options[document.getElementById("lst_boutiques").options.length] = new Option(title_bout,id_bout);
	
						} 
	
						
						
				 }
			}
		
		xhr_boutiques.open("POST","/scripts/load_boutiques.php",true);
		xhr_boutiques.setRequestHeader("Content-Type","application/x-www-form-urlencoded");	
		data="id=" + idcat;
		xhr_boutiques.send(data);
	

}
function affich_boutiques_centre(idcat) {

		xhr_boutiques=createXHR();
		xhr_boutiques.onreadystatechange = function()
			{
				if (xhr_boutiques.readyState == 4 && xhr_boutiques.status == 200)
				 {			 
					
					while (document.getElementById("lst_boutiques_centre").options.length>0)
						{
							document.getElementById("lst_boutiques_centre").options[0] = null;
						}
						
					 xmlTypesSet=xhr_boutiques.responseXML;
					 
					 boutiques = xmlTypesSet.getElementsByTagName('root'); 
					 nb = boutiques[0].childNodes.length; 	
					
						for (i=0; i<nb; i++)
						{
							var id_bout=xmlTypesSet.getElementsByTagName("id_boutique")[i].firstChild.nodeValue;
							var title_bout=xmlTypesSet.getElementsByTagName("title_boutique")[i].firstChild.nodeValue;
							document.getElementById("lst_boutiques_centre").options[document.getElementById("lst_boutiques_centre").options.length] = new Option(title_bout,id_bout);
	
						} 
	
						
						
				 }
			}
		
		xhr_boutiques.open("POST","/scripts/load_boutiques.php",true);
		xhr_boutiques.setRequestHeader("Content-Type","application/x-www-form-urlencoded");	
		data="id=" + idcat;
		xhr_boutiques.send(data);
	

}
