function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}

function montre(id) {
	var d = document.getElementById(id);
	
		for (var i = 1; i<=10; i++) {
			if (document.getElementById('smenu'+i)) 
			{
				document.getElementById('smenu'+i).style.display='none';
			//	first_child(first_child(document.getElementById('smenu'+i).parentNode)).className='menucache';
			}
		}
	
	if (d) 
	{
		d.style.display='block'; 
	//	first_child(first_child(d.parentNode)).className='menuderoule';
	}
}

function getXhr()
{	
	var xhr_object = null;		
	if (window.XMLHttpRequest)	// FIREFOX
	{
		xhr_object = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)	// IE
	{
		try
		{
			xhr_object = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	else
	{
		xhr_object = false;
	}	
	return xhr_object;
}

function file(fichier)
{
	var xhr_object = getXhr();
	xhr_object.open("GET", fichier, false);
	xhr_object.send(null);
	if (xhr_object.readyState == 4)
	{
		//alert(xhr_object.responseText);
		return (xhr_object.responseText);
	}
   	else
   	{
		return (false);
	}
}

function supprimer(fichier, dossier, table, champ, id)
{
	if (confirm('Etes vous sur de vouloir supprimer ce fichier ?')) {
		resultat = file('supprimerFichier.php?fichier=' + fichier + '&dossier=' + dossier);
		if (table != "" && champ != "" && id != "") {
			resultat = file('modifBDD.php?table=' + table + '&champ=' + champ + '&id=' + id);
			window.location.href = this.window.location.href;		
		}
	}
}

function is_ignorable( nod )
{
  return ( nod.nodeType == 8) || // A comment node
         ( (nod.nodeType == 3) && is_all_ws(nod) ); // a text node, all ws
}

function first_child( par )
{
  var res=par.firstChild;
  while (res) {
    if (!is_ignorable(res)) return res;
    res = res.nextSibling;
  }
  return null;
}

function is_all_ws( nod )
{
  // Use ECMA-262 Edition 3 String and RegExp features
  return !(/[^\t\n\r ]/.test(nod.data));
}

function getVar (nomVariable)
{
	var infos = location.href.substring(location.href.indexOf("?")+1, location.href.length)+"&"
	if (infos.indexOf("#")!=-1)
		infos = infos.substring(0,infos.indexOf("#"))+"&"
	var variable=0
	{
		nomVariable = nomVariable + "="
		var taille = nomVariable.length
		if (infos.indexOf(nomVariable)!=-1)
		variable = infos.substring(infos.indexOf(nomVariable)+taille,infos.length).substring(0,infos.substring(infos.indexOf(nomVariable)+taille,infos.length).indexOf("&"))
	}
	return variable;
} 

function montreDiv(id) {
	var d = document.getElementById('div_'+id);
	var img = document.getElementById('imgPM_'+id);
	
	if (d && img) {
		if (d.style.display == 'none') {
			d.style.display = 'block';
			img.src = 'images/minus.gif';
		}
		else {
			d.style.display = 'none';
			img.src = 'images/plus.gif';
		}
	}	
}

window.onload = function() {
	externalLinks();
	montre();
}
