var as = 1;
var fontt;

function querySt(ji) {
hu = window.location.search.substring(1);
gy = hu.split("&");
for (i=0;i<gy.length;i++) {
ft = gy[i].split("=");
if (ft[0] == ji) {
return ft[1];
}
}
}


function openMenu()
{
var rubName = querySt("r");
addChilds(rubName);	
}



function addChilds(das)
{
	var nam =das;
	if(das == "municipalite")
	{
	var tdr = document.getElementById("municipalite");
	removeChilds(fontt);
	fontt = tdr.getElementsByTagName('font').item(0);
	removeChilds(fontt);

		addChil(fontt,ajss+ "bienvenue.php?r=municipalite&id=1","&raquo; Bienvenue&nbsp;&agrave;&nbsp;Mont-Carmel",1);
		addChil(fontt,ajss+"conseil-municipal.php?r=municipalite&id=2","&raquo; Conseil&nbsp;municipal",2);
		addChil(fontt,ajss+"calendrier-des-seances.php?r=municipalite&id=3","&raquo; Calendrier&nbsp;des&nbsp;s&eacute;ances",3);
		addChil(fontt,ajss+"mosaique-des-maires.php?r=municipalite&id=4","&raquo; Mosa&iuml;que&nbsp;des&nbsp;maires<br/>&nbsp;&nbsp;&nbsp;de&nbsp;Mont-Carmel",4);
		addChil(fontt,ajss+"blason-et-logo.php?r=municipalite&id=5","&raquo; Blason&nbsp;et&nbsp;logo",5);
		addChil(fontt,ajss+"charte-des-valeurs.php?r=municipalite&id=6","&raquo; Charte&nbsp;des&nbsp;valeurs",6);

}
        else if(das=="servmuni")
        {
            var tdr = document.getElementById("servmuni");
            removeChilds(fontt);
            fontt = tdr.getElementsByTagName('font').item(0);
            removeChilds(fontt);


      addChil(fontt,ajss+"edifice-municipal.php?r=servmuni&id=7","&raquo; &Eacute;difice&nbsp;municipal",7);
      addChil(fontt,ajss+"equipe-de-travail.php?r=servmuni&id=8","&raquo; &Eacute;quipe&nbsp;de&nbsp;travail",8);
      addChil(fontt,ajss+"proces-verbaux.php?r=servmuni&id=9","&raquo; Proc&egrave;s-verbaux",9);
      addChil(fontt,ajss+"reglementation.php?r=servmuni&id=10","&raquo; R&egrave;glementation",10);
      addChil(fontt,ajss+"services-aux-citoyens.php?r=servmuni&id=11","&raquo; Services&nbsp;aux&nbsp;citoyens",11);
      addChil(fontt,ajss+"service-de-securite-incendie.php?r=servmuni&id=12","&raquo; Service&nbsp;de&nbsp;s&eacute;curit&eacute;&nbsp;incendie",12);
      addChil(fontt,ajss+"bibliotheque-odile-boucher.php?r=servmuni&id=13","&raquo; Biblioth&egrave;que&nbsp;Odile-Boucher",13);
      addChil(fontt,ajss+"collection-oeuvre-art.php?r=servmuni&id=14","&raquo; Collection&nbsp;d&rsquo;oeuvres&nbsp;d&rsquo;art",14);
      addChil(fontt,ajss+"politique-familiale.php?r=servmuni&id=15","&raquo; Politique&nbsp;familiale",15);


        }	
	else if(das == "recreo")
	{
	var tdr = document.getElementById("recreo");
	removeChilds(fontt);
	fontt = tdr.getElementsByTagName('font').item(0);
	removeChilds(fontt);

	addChil(fontt,ajss+"calendrier-des-activites-et-organismes.php?r=recreo&id=16","&raquo; Calendrier&nbsp;des<br/>&nbsp;&nbsp;&nbsp;activit&eacute;s&nbsp;et&nbsp;organismes",16);
	addChil(fontt,ajss+"hebergement-et-restauration.php?r=recreo&id=17","&raquo; H&eacute;bergement&nbsp;et&nbsp;restauration",17);
	addChil(fontt,ajss+"parc-municipal-et-piscine.php?r=recreo&id=18","&raquo; Parc&nbsp;municipal",18);
	addChil(fontt,ajss+"camping-et-plage.php?r=recreo&id=19","&raquo; Camping&nbsp;et&nbsp;<br/>&nbsp;&nbsp;&nbsp;plage&nbsp;du&nbsp;lac&nbsp;de&nbsp;l\'Est",19);
    addChil(fontt,ajss+"sentier-pedestre-culturel.php?r=recreo&id=20","&raquo; Sentier&nbsp;p&eacute;destre&nbsp;culturel",20);
    addChil(fontt,ajss+"halte-la-bretagne.php?r=recreo&id=21","&raquo; Halte&nbsp;La&nbsp;Bretagne",21);
    addChil(fontt,ajss+"circuit-patrimonial.php?r=recreo&id=22","&raquo; Circuit&nbsp;patrimonial",22);
    addChil(fontt,ajss+"parc-lineaire-monk.php?r=recreo&id=23","&raquo; Parc&nbsp;lin&eacute;aire&nbsp;Monk",23);
    addChil(fontt,ajss+"patinoire-municipale.php?r=recreo&id=24","&raquo; Patinoire&nbsp;municipale",24);
    addChil(fontt,ajss+"chasse-et-peche.php?r=recreo&id=25","&raquo; Chasse&nbsp;et&nbsp;p&ecirc;che",25);
        
        }
	



	else if(das == "activeco")
	{
	var tdr = document.getElementById("activeco");
	removeChilds(fontt);
	fontt = tdr.getElementsByTagName('font').item(0);
	removeChilds(fontt);

	addChil(fontt,ajss+"plan-de-dev.php?r=activeco&id=26","&raquo; Plan&nbsp;de&nbsp;d&eacute;veloppement",26);
	addChil(fontt,ajss+"liste-des-comm-et-serv.php?r=activeco&id=27","&raquo; Liste&nbsp;des&nbsp;commerces<br/>&nbsp;&nbsp;&nbsp;et&nbsp;services",27);	
	}
	
	
	else if(das == "corpodev")
	{
	var tdr = document.getElementById("corpodev");
	removeChilds(fontt);
	fontt = tdr.getElementsByTagName('font').item(0);
	removeChilds(fontt);

	fontt.innerHTML="Laboratoire rural";

	addChil(fontt,ajss+"mission.php?r=corpodev&id=28","&raquo; Mission",28);
	addChil(fontt,ajss+"salle-de-presse.php?r=corpodev&id=29","&raquo; Salle&nbsp;de&nbsp;presse",29);
	addChil(fontt,ajss+"rapport-activites.php?r=corpodev&id=30","&raquo; Rapport&nbsp;d&rsquo;&eacute;tape",30);
	addChil(fontt,ajss+"contrat-amenagement.php?r=corpodev&id=31","&raquo; Contrat&nbsp;d&rsquo;am&eacute;nagement",31);
	addChil(fontt,ajss+"projet-biomasse.php?r=corpodev&id=32","&raquo; Projet&nbsp;Biomasse",32);
	addChil(fontt,ajss+"transfert-de-connaissances.php?r=corpodev&id=33","&raquo; Transfert&nbsp;de&nbsp;connaissances",33);
	addChil(fontt,ajss+"partenaire.php?r=corpodev&id=34","&raquo; Partenaires",34);




	}
	
	


}

function removeChilds(fontt)
{
	if(fontt != null)
	{
		while(fontt.hasChildNodes() && fontt.childNodes.length> 1)
		{	
		if(as > 1)
		{
		fontt.removeChild(fontt.lastChild);
		}
		as = as+1;
		}
	}
}

var love = "yes";
function addChil(parent,linkname,textname,id)
{

var breaka = document.createElement("br");
var divs= document.createElement("div");



var link = document.createElement("a");

var tLink = document.createElement("p");
tLink.innerHTML=textname;
tLink.className= "lienAct";

link.setAttribute("href",linkname);
link.className = "menuniv1";

divs.style.marginLeft="10px";
divs.style.marginRight="4px";
divs.style.paddingLeft="8px";
divs.style.paddingTop="10px";
divs.style.fontSize="15px";
//divs.style.lineHeight="12px";
divs.style.border="0px green solid";


if(love == "yes")
{
//divs.style.backgroundColor="none";
love = "no";
}
else
{
//divs.style.backgroundColor="none";
love = "yes";
}
link.style.textDecoration="none";




var name = document.createTextNode(textname);
parent.appendChild(divs);


if (querySt("id") == id )
{
divs.appendChild(tLink);
}
else
{
divs.appendChild(link);
}


link.appendChild(name);
link.innerHTML=textname;


}

/*** Function for select the code ***/
function fnSelect(objId)
{
   fnDeSelect();
   if (document.selection) 
   {
      var range = document.body.createTextRange();
      range.moveToElementText(document.getElementById(objId));
      range.select();
   }
   else if (window.getSelection) 
   {
      var range = document.createRange();
      range.selectNode(document.getElementById(objId));
      window.getSelection().addRange(range);
   }
}
function fnDeSelect() 
{
   if (document.selection)
             document.selection.empty();
   else if (window.getSelection)
              window.getSelection().removeAllRanges();
} 
/*** Function for select the code ***/

