var ie = /MSIE/.test(navigator.userAgent);

function hover(obj) {
  if (ie) {
    UL = obj.getElementsByTagName('ul');
    if (UL.length > 0) {
      sousMenu = UL[0].style;
      sousMenu.display = 'block';
			obj.style.marginBottom = '0px';
    }
  }
}

function out(obj) {
  if (ie) {
    UL = obj.getElementsByTagName('ul');
    if(UL.length > 0) {
      sousMenu = UL[0].style;
      sousMenu.display = 'none';
			obj.style.marginBottom = '0px';
    }
  }
}

function setHover() {
  if (ie) {
		LI = document.getElementById('menu').getElementsByTagName('li');
		for(i=0; i < LI.length; i++) {
			LI[i].onmouseover = function() { hover(this) };
			LI[i].onmouseout = function() { out(this) };
    }
  }
}

//window.onload = function() { setHover() };



/*
SLF
*/
function afficheListLayer(fichier) {
	if(fichier && fichier != "") {
		new Ajax('ajax.inc.php?listCouche='+fichier,{
		 	method:'get',
			postBody:'',
			evalScripts : true,
			onRequest : function () {
				$("divListeCouche").innerHTML = "";
				$("divListeChamp").innerHTML = "";
			},
			onComplete : function (str) {
				$("divListeCouche").innerHTML = str;
			}
		}).request();
	}
}

function afficheListeChamp(couche,map) {
		new Ajax('ajax.inc.php?listChamp='+couche+'&mapChamp='+map,{
		 	method:'get',
			postBody:'',
			evalScripts : true,
			onRequest : function () {
				$("divListeChamp").innerHTML = "";
			},
			onComplete : function (str) {
				$("divListeChamp").innerHTML = str;
			}
		}).request();
}

function modifDoc() {
	var alistdoc = new Array();
	for(var ill=0; ill < $('selListLien').options.length; ill++) {
		if($('selListLien').options[ill].selected) {
			alistdoc.push($('selListLien').options[ill].value);
		}
	}
	if(alistdoc.length == 0) {
		// si aucun selection
		alert("Séléctionner une élément dans la liste");
	}else if(alistdoc.length == 1){
		openCadreAdm('Modification','ajax.inc.php','ajoutDoc='+alistdoc,{id: 'divDocPop', divCenter: 'pnradmcontent',width:500,height:420});
	}else {
		// si plusieurs selection
		alert("Séléctionner un seul élément dans la liste");
	}
}

function supprDoc() {
	var alistdoc = new Array();
	for(var ill=0; ill < $('selListLien').options.length; ill++) {
		if($('selListLien').options[ill].selected) {
			alistdoc.push($('selListLien').options[ill].value.split("_")[0]);
		}
	}
	if(alistdoc.length > 0) {
		if(confirm("Voulez vous supprimer les éléments séléctionnés")) {
			new Ajax('ajax.inc.php?supprChamp='+alistdoc,{
			 	method:'get',
				postBody:'',
				evalScripts : true,
				onRequest : function () {
					
				},
				onComplete : function (str) {
					
				}
			}).request();			
		}
	}
}
function reloadSelectDoc(opt) {
	$("selListLien").length = 0;
	for(var it in opt) {
		$("selListLien").options[$("selListLien").options.length] = new Option(opt[it][1],opt[it][0]);
	}
}