function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages(path) {
	if (document.images) {
		menu1 = newImage(path+"images/on.gif");
		preloadFlag = true;
	}
}

function ConfirmMessage(url,msg) {
	if (msg=="") var msg="Voulez-vous vraiment supprimer cet élément ?";
	if (url!='' && confirm(msg)) window.open(url, '_self');
}

function affMaskBlock(index, affmask) {
	var ISchaine=index.indexOf(",",0);
	if (ISchaine>0) var tableau=index.split(',');
	else var tableau=new Array([index]);

	for (var i=0; i<tableau.length; i++) {
		var index=tableau[i];
		if (affmask=="auto") {
			keep1 = document.getElementById(index).style.display;
			keep2 = document.getElementById(index).style.visibility;	
			currentD = (keep1 == 'block') ? 'none' : 'block';
			currentV = (keep2 == 'visible') ? 'hidden' : 'visible';		
			document.getElementById(index).style.display = currentD;
			document.getElementById(index).style.visibility = currentV;
		}
		else {
			if (affmask=="1") {
				document.getElementById(index).style.visibility='visible';	
				document.getElementById(index).style.display='block';
			}
			else {
				document.getElementById(index).style.visibility='hidden';
				document.getElementById(index).style.display='none';
			}
		}
	}
}

function topover(path, onoff, onglet) { 
	var ong="ong"+onglet;
	if (onoff=="on") document.getElementById(ong).background=path+"images/on.gif";
	if (onoff=="off") document.getElementById(ong).background=path+"images/off.gif";
}

function openCloseRubs(path,rub) {
	var img="imgR"+rub;
	var bloc="blocR"+rub;
	keep1 = document.getElementById(bloc).style.display;
	keep2 = document.getElementById(bloc).style.visibility;	
	currentD = (keep1 == 'none') ? 'block' : 'none';
	currentV = (keep2 == 'hidden') ? 'visible' : 'hidden';		
	document.getElementById(bloc).style.display = currentD;
	document.getElementById(bloc).style.visibility = currentV;
	if (currentD=="block") document.getElementById(img).src=path+"ressources/pictos/mm.gif";
	else document.getElementById(img).src=path+"ressources/pictos/pp.gif";
}

function check_ongB(path, onglet, les_onglets) {
	reg=new RegExp(",", "g");
	var tableau=les_onglets.split(reg);
	for (var i=0; i<tableau.length; i++) {
		var ong=0+Math.round(tableau[i]);
		if (ong>0) {
			var B1="ongB"+ong;
			var B2="blocB"+ong;
			var B3="flecheB"+ong;

			document.getElementById(B2).style.display='none';
			document.getElementById(B2).style.visibility='hidden';
			document.getElementById(B3).src=path+"images/fleche1.gif";
			document.getElementById(B1).background=path+"ressources/pictos/trsp.gif";
		}
	}
	if (onglet>0) {
		var B1="ongB"+onglet;
		var B2="blocB"+onglet;
		var B3="flecheB"+onglet;
		document.getElementById(B2).style.display='block';
		document.getElementById(B2).style.visibility='visible';
		document.getElementById(B3).src=path+"images/fleche2.gif";
		document.getElementById(B1).background=path+"images/ongB.gif";
	}
	/*
	blocB1.style.display="none";
	blocB1.style.visibility="hidden";
	flecheB1.src=path+"images/fleche1.gif";
	document.getElementById("ongB1").background=path+"ressources/pictos/trsp.gif";

	blocB2.style.display="none";
	blocB2.style.visibility="hidden";
	flecheB2.src=path+"images/fleche1.gif";
	document.getElementById("ongB2").background=path+"ressources/pictos/trsp.gif";

	blocB3.style.display="none";
	blocB3.style.visibility="hidden";
	flecheB3.src=path+"images/fleche1.gif";
	document.getElementById("ongB3").background=path+"ressources/pictos/trsp.gif";

	blocB4.style.display="none";
	blocB4.style.visibility="hidden";
	flecheB4.src=path+"images/fleche1.gif";
	document.getElementById("ongB4").background=path+"ressources/pictos/trsp.gif";

	blocB5.style.display="none";
	blocB5.style.visibility="hidden";
	flecheB5.src=path+"images/fleche1.gif";
	document.getElementById("ongB5").background=path+"ressources/pictos/trsp.gif";

	if (onglet=="1") {
		blocB1.style.display="block";
		blocB1.style.visibility="visible";
		flecheB1.src=path+"images/fleche2.gif";
		document.getElementById("ongB1").background=path+"images/ongB.gif";
	}
	if (onglet=="2") {
		blocB2.style.display="block";
		blocB2.style.visibility="visible";
		flecheB2.src=path+"images/fleche2.gif";
		document.getElementById("ongB2").background=path+"images/ongB.gif";
	}
	if (onglet=="3") {
		blocB3.style.display="block";
		blocB3.style.visibility="visible";
		flecheB3.src=path+"images/fleche2.gif";
		document.getElementById("ongB3").background=path+"images/ongB.gif";
	}
	if (onglet=="4") {
		blocB4.style.display="block";
		blocB4.style.visibility="visible";
		flecheB4.src=path+"images/fleche2.gif";
		document.getElementById("ongB4").background=path+"images/ongB.gif";
	}
	if (onglet=="5") {
		blocB5.style.display="block";
		blocB5.style.visibility="visible";
		flecheB5.src=path+"images/fleche2.gif";
		document.getElementById("ongB5").background=path+"images/ongB.gif";
	}
	*/
}



// correctly handle PNG transparency in Win IE 5.5 & 6.
function correctPNG() {
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if (version <7 && version >= 5.5 &&document.body.filters) {
      for(var i=0; i<document.images.length; i++) {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG") {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText 
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }    
}
window.attachEvent("onload", correctPNG);
