var NS4 = (navigator.appName.indexOf("Netscape")>=0 && !document.getElementById)? true : false;
var IE4 = (document.all && !document.getElementById)? true : false;
var IE5 = (document.getElementById && document.all)? true : false;
var NS6 = (document.getElementById && navigator.appName.indexOf("Netscape")>=0 )? true: false;
var W3C = (document.getElementById)? true : false;

top.focus();

// Ouvre fenetre pour l'image agrandit
function fenetre(theURL,Targ) {
        fen = window.open(theURL, Targ, 'titlebar=no,status=no,location=no,scrollbars=no,toolbar=no,menubar=no,resizable=yes,width=250,height=200');
        if (!fen.opener) fen.opener = self;
}

function fen(theURL,Targ,Param) {
        window.open(theURL, Targ, Param);
}

// Execute une fonction javascript ou renvoi vers une url
function urlexec(adr) {
        if(adr.substr(0,10) == "javascript") {
                eval(adr);
        } else {
                document.location = adr;
        }
}

// Ouvre fenetre pour affichage image avec redimensionnement automatique
function pimage(img, alt, title) { 
	// Compatible IE5+ / NN6+ / Mozilla
	pfen = window.open('','Image','width=10,height=10,toolbar=no,scrollbars=no,resizable=no');
	pfen.document.write("<html><head><title>"+title+"</title>"); 
	pfen.document.write("<script type=\"text/javascript\">function presize() { if (document.images[0].complete) { window.resizeTo(document.images[0].width+10,document.images[0].height+40); window.focus();} else { setTimeout('presize()',1000) } }</"+"script></head>");
	pfen.document.write("<body onload='presize()' onblur='window.close()' onclick='window.close()' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0>"); 
	pfen.document.write("<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" height=\"100%\"><tr><td valign=\"middle\" align=\"center\">");
	pfen.document.write("<img src=\""+img+"\" border=\"0\" alt=\""+alt+"\" title=\""+title+"\">");
	pfen.document.write("</th><tr></table></body></html>"); 
	pfen.document.close(); 
} 

// Ouvre fenetre popup
function popup(theURL, Targ, Opt, Top, Left, Width, Height) {
	var param="resizable=";
	if (Opt&1){param+="yes"} else {param+="no";}
	param+=",scrollbars=";
	if (Opt&2){param+="yes"} else {param+="no";}
	param+=",directories=";
	if (Opt&4){param+="yes"} else {param+="no";}
	param+=",locations=";
	if (Opt&8){param+="yes"} else {param+="no";}
	param+=",status=";
	if (Opt&16){param+="yes"} else {param+="no";}
	param+=",toolbar=";
	if (Opt&32){param+="yes"} else {param+="no";}
	param+=",menubar=";
	if (Opt&64){param+="yes"} else {param+="no";}
	if (Top>0) param+=",top="+Top;
	if (Left>0) param+=",left="+Left;
	if (Width>0) param+=",width="+Width;
	if (Height>0) param+=",height="+Height;
        fen = window.open(theURL, Targ, param);
        if (!fen.opener) fen.opener = self;
}

// Interdit la selection de texte
function disableselect(e){ return false; }
function reEnable(){ return true; }
function noselect() {
	document.onselectstart=new Function ("return false");	//if IE4+
	if (NS6){ document.onmousedown=disableselect; document.onclick=reEnable; }	//if NS6
}

// Interdit le click droit
function noclick() {
	var mssg="";
	function clickIE() {if (document.all) {(mssg);return false;}}
	function clickNS(e) {if (document.layers||(document.getElementById&&!document.all)) {if (e.which==2||e.which==3) {(mssg);return false;}}}
	if (document.layers) {document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
	else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
	document.oncontextmenu=new Function("return false")
}

function checkcgv(theurl,msg) {
	if (document.cgv) {
		if (document.cgv.cgv) {
			if (document.cgv.cgv.checked) {
				document.location = theurl;
			} else {
				if (msg.length>0) alert(msg);
			}
		}
	}
}

// Ajouter une adresse dans le bookmark (IE)
function addbookmark(TheUrl,Titre){ if (document.all) window.external.AddFavorite(TheUrl,Titre); }

// Menu Dynamique specifique
var dmcpt,dmelm;
function dmenu(obj) {
        dhmenu();
        if (dmelm = document.getElementById(obj)) {
                dmelm.style.display = "block";
                dmelm.style.zIndex = "10";
                dmelm.onmouseover = dimenu;
                dmelm.onmouseout = domenu;
                dmcpt = setTimeout("dhmenu()",1000);
 
/*
                if (elm = document.getElementById("mifrm")) {
                        elm.style.display = "block";
                        //elm.style.pixelTop = dmelm.style.pixelTop;
                        //elm.style.pixelLeft = dmelm.style.pixelLeft;
                        elm.style.top = dmelm.style.top;
                        elm.style.left = dmelm.style.left;
                        elm.style.width = dmelm.style.width;
                        elm.style.height = dmelm.style.height;
                        elm.style.margin = dmelm.style.margin;
                }
*/
        }
}
function dimenu(e) {
        if (window.Event) var obj = e.target;
        else var obj = window.event.srcElement;
 
        if (obj!=dmelm) obj = obj.parentNode;
        if (obj!=dmelm) obj = obj.parentNode;
        if (obj!=dmelm) obj = obj.parentNode;
        if (obj==dmelm) {
                clearTimeout(dmcpt);
                //dmcpt = setTimeout("dhmenu()",500);
        }
}
function domenu(e) {
        if (window.Event) var obj = e.target;
        else var obj = window.event.srcElement;
 
        //if (type) clearTimeout(dmcpt);
        dmcpt = setTimeout("dhmenu()",500);
}
function dhmenu() {
        if (dmelm) {
                dmelm.style.display = "none";
        //        if (elm = document.getElementById("mifrm")) {
         //               elm.style.display = "none";
          //      }
        }
}
// ------------ Fin de menu dynamique specifique --------------

// ROLLOVER pour les Menus

var cpt,niv1, niv2, niv3, niv4, niv5;

function rollhide(obj,niv) {
	if (niv<6 && niv5) { if (obj.id.search(niv5.id.substr(0,niv5.id.length-1))) { niv5.style.display = "none";niv5 = null; } }
	if (niv<5 && niv4) { if (obj.id.search(niv4.id.substr(0,niv4.id.length-1))) { niv4.style.display = "none";niv4 = null; } }
	if (niv<4 && niv3) { if (obj.id.search(niv3.id.substr(0,niv3.id.length-1))) { niv3.style.display = "none";niv3 = null; } }
	if (niv<3 && niv2) { if (obj.id.search(niv2.id.substr(0,niv2.id.length-1))) { niv2.style.display = "none";niv2 = null; } }
	if (niv<2 && niv1) { if (obj.id.search(niv1.id.substr(0,niv1.id.length-1))) { niv1.style.display = "none";niv1 = null; } }
}
function rollhide1() {
	if (niv5) { niv5.style.display = "none";niv5 = null; }
	if (niv4) { niv4.style.display = "none";niv4 = null; }
	if (niv3) { niv3.style.display = "none";niv3 = null; }
	if (niv2) { niv2.style.display = "none";niv2 = null; }
	if (niv1) { niv1.style.display = "none";niv1 = null; }
}
function rollmenu(obj,type,dyn) {
	var niv;

	if (!obj.className) obj = obj.parentNode;
	if (obj.className == "mbout")
	{
		if (obj.className != "mnoroll" && obj.className != "mroll" && obj.className != "mclick") obj = obj.parentNode;
		if (obj.className != "mnoroll" && obj.className != "mroll" && obj.className != "mclick") obj = obj.parentNode;
		if (obj.className != "mnoroll" && obj.className != "mroll" && obj.className != "mclick") obj = obj.parentNode;
		if (obj.className != "mnoroll" && obj.className != "mroll" && obj.className != "mclick") obj = obj.parentNode;

		if (obj.className == "mnoroll" || obj.className == "mroll" || obj.className == "mclick") {
			if (type) clearTimeout(cpt);
			else cpt = setTimeout("rollhide1()",500);

			if (type == 1) obj.className = "mroll";
			else if (type == 2) obj.className = "mclick";
			else obj.className = "mnoroll";

			if (dyn) {
				if (niv = document.getElementById(obj.id+"n")) {
					if (niv.className == "niv1") { if (niv1) rollhide(obj,1);niv1 = niv; }
					else if (niv.className == "niv2") { if (niv2) rollhide(obj,2);niv2 = niv; }
					else if (niv.className == "niv3") { if (niv3) rollhide(obj,3);niv3 = niv; }
					else if (niv.className == "niv4") { if (niv4) rollhide(obj,4);niv4 = niv; }
					else if (niv.className == "niv5") { if (niv5) rollhide(obj,5);niv5 = niv; }

					if (type) niv.style.display = "block";
				}
				else rollhide(obj,1);
			}
		}
	}
}
function roverd(e) {
	if (window.Event) var obj = e.target;
	else var obj = window.event.srcElement;
	rollmenu(obj,1,1);
}
function routd(e) {
	if (window.Event) var obj = e.target;
	else var obj = window.event.srcElement;
	rollmenu(obj,0,1);
}
function rover(e) {
	if (window.Event) var obj = e.target;
	else var obj = window.event.srcElement;
	rollmenu(obj,1,0);
}
function rout(e) {
	if (window.Event) var obj = e.target;
	else var obj = window.event.srcElement;
	rollmenu(obj,0,0);
}
function rdown(e) {
	if (window.Event) var obj = e.target;
	else var obj = window.event.srcElement;
	rollmenu(obj,2,0);
}
function rup(e) { 
	if (window.Event) var obj = e.target;
	else var obj = window.event.srcElement;
	rollmenu(obj,2,0);
}
function rmenu(obj,dyn) {
	var melm = document.getElementById(obj);
	if (dyn) {
		melm.onmouseover = roverd;
		melm.onmouseout = routd;
	}
	else {
		melm.onmouseover = rover;
		melm.onmouseout = rout;
	}
	melm.onmouseup = rup;
	melm.onmousedown = rdown;
}

// Affichage dynamique de la date et de l'heure
function dateheure(obj,type) {
	var Digital=new Date();
	var hours=Digital.getHours();
	var minutes=Digital.getMinutes();
	var seconds=Digital.getSeconds();
	var day=Digital.getDate();
	var month=(Digital.getMonth())+1;
	var year=Digital.getFullYear();
	var myElem = document.getElementById(obj);
	var lheure = "";

	if (hours==0) hours=12;
	if (minutes<=9) minutes="0"+minutes;
	if (seconds<=9) seconds="0"+seconds;
	if (type&1) lheure=day+ "/" +month+ "/" +year;
	if (type&1 && type&2) lheure=lheure+ " - ";
	if (type&2) lheure=lheure +hours+ ":" +minutes+ ":" +seconds;
	myElem.innerHTML = lheure;
	cpt=(setTimeout("dateheure(\""+obj+"\","+type+")",1000));
}

