// JavaScript Document

function underline(){
	
		  var li=document.getElementById('sousmenu').childNodes;
				 for(i=0 ; i<li.length ; i++){	
						li[i].lastChild.style.color='#ffec00';
						li[i].lastChild.style.textDecoration="underline";						
				}
				
				li[0].lastChild.style.color='#FFF';
				li[0].lastChild.style.textDecoration="none";						
	
}

function replaceImg()
{
	/*var contenu=document.getElementById('contenu').childNodes;
	for(i=0 ; i<contenu.length ; i++)
	{
			if(contenu[i].nodeName=='P')
				for(j=0 ; j<contenu[i].childNodes.length ; j++)
					if(contenu[i].childNodes[j].nodeName=="IMG")
					{
						var fond=document.createElement("IMG");
						//fond.setAttribute("SRC","../images/topdrive/back_img.jpg");
						fond.src="../images/topdrive/back_img.gif";
						contenu[i].childNodes[j].style.marginLeft='40px';
							contenu[i].childNodes[j].style.marginTop='40px';
							fond.style.position='relative';	
							
							contenu[i].childNodes[j].style.zIndex='1000';
							contenu[i].childNodes[j].style.position='relative';	
							contenu[i].childNodes[j].style.cssFloat='left';	
							contenu[i].childNodes[j].style.styleFloat='left';	
							fond.style.cssFloat='left';	
							fond.style.styleFloat='left';	
							contenu[i].childNodes[j].style.marginRight='40px';
						

							contenu[i].childNodes[j].style.marginBottom='40px';
						fond.width=contenu[i].childNodes[j].width + 80;
						fond.height=contenu[i].childNodes[j].height + 80;		
						
					 if (navigator.appName=="Microsoft Internet Explorer")
					 {
					 
						contenu[i].insertBefore(fond,contenu[i].childNodes[j]);							
								contenu[i].childNodes[j].style.position='absolute'
								fond.style.left=0;
								fond.style.marginTop='10px';
												
					 }
					 else
					 {
						contenu[i].insertBefore(fond,contenu[i].childNodes[j+1]);
							fond.style.marginLeft=-(contenu[i].childNodes[j].width + 80)+'px';
						}
				
					
						break;
				}		
	}*/
	
	// placement du menu
	if(document.getElementById('sousmenu'))
	{
		var left=0;
		var childs=document.getElementById('contenu').childNodes;
		for(i=0 ; i<childs.length ; i++)
			if(childs[i].nodeName=='IMG'){
				left=childs[i].width;break;}
				left+=20;
		//document.getElementById('sousmenu').style.marginLeft=left+'px';
		underline();
	}

}
function stripslashes( str ) {

    return (str+'').replace(/\0/g, '0').replace(/\\([\\'"])/g, '$1');
}


// affichage du contenu des sous menus.
function afficheContent(nompage)
{


		  var xhr; 
	
		  
		
    try {  xhr = new ActiveXObject('Msxml2.XMLHTTP');   }
    catch (e) 
    {
        try {   xhr = new ActiveXObject('Microsoft.XMLHTTP');    }
        catch (e2) 
        {
          try {  xhr = new XMLHttpRequest();     }
          catch (e3) {  xhr = false;   }
        }
     }
   xhr.open( 'GET', '../admin/pages_ajax/affichemenu.php?nompage='+nompage,  false); 
   xhr.send(null);
    var span=nompage.split('_');
	 var title=stripslashes(span[1]);

	 //xhr.onreadystatechange  = function() 
         if(xhr.readyState  == 4)         
              if(xhr.status  == 200)       {                     
                 textretourne = xhr.responseText;
					document.getElementById('complete_false').innerHTML=textretourne;
						//goBack();
						
					  var li=document.getElementById('sousmenu').childNodes;
					  for(i=0 ; i<li.length ; i++){	
					 		
							
								if(li[i].lastChild.nodeName == 'SPAN' && li[i].lastChild.innerHTML ==title)
								{
									li[i].lastChild.style.color='#FFF'; 
									li[i].lastChild.style.textDecoration ="none";						 	
								}
								else {
								li[i].lastChild.style.color='#ffec00';//ffec00
									li[i].lastChild.style.textDecoration="underline";
								}
							
					  }
					  
				  }	  
}

function grandImage(id)
{
	
	var bigdiv=document.createElement("div");
	bigdiv.setAttribute("id","grand_image");

	
	var txt=document.createElement("img");
	txt.setAttribute("id","image_grand");
	txt.setAttribute("src",document.getElementById(id).getAttribute("src"));
	var closeTab=document.createElement("img");
	closeTab.setAttribute("src","../images/topdrive/close.png");
	closeTab.setAttribute("id","close_grand_image");

	var cadre=document.createElement("img");
	cadre.setAttribute("src","../images/topdrive/grd_cadre.png");
	cadre.setAttribute("id","cadre_image_grand");

	if (navigator.appName=="Microsoft Internet Explorer")
	{
			var taille=document.getElementById('bigcontent').style.width;
			taille=parseInt(taille);
			taille+=50;
	
			bigdiv.style.width=taille+'px';
		
			var marge=document.body.clientWidth / 2 ;
			marge-=510;
			bigdiv.style.marginLeft=marge+'px';
			closeTab.attachEvent("onclick", littleImage);
			bigdiv.attachEvent("onclick", littleImage);
	}
	else
	{
		bigdiv.style.width='1024px';
			closeTab.setAttribute("onclick","littleImage()");
				bigdiv.setAttribute("onclick","littleImage()");
	}

	document.getElementById('bigcontent').appendChild(bigdiv);
		document.getElementById('bigcontent').appendChild(cadre);
			document.getElementById('bigcontent').appendChild(txt);
				document.getElementById('bigcontent').appendChild(closeTab);
}

function littleImage()
{
		var img=document.getElementById('image_grand');
			img.parentNode.removeChild(img);
		var div=document.getElementById('grand_image');
			div.parentNode.removeChild(div);
		var cl=document.getElementById('close_grand_image');
				cl.parentNode.removeChild(cl);
		var cadre=document.getElementById('cadre_image_grand');
			cadre.parentNode.removeChild(cadre);
}