//****************************************************************
// Librairie de scripts 
//****************************************************************


//****************************************************************
// Affichage des sous-menus 
//****************************************************************
function funcTitle(varTitle)
	{
//		alert('ok - ' + varTitle);
	document.title = varTitle;
	}


sfHover = function() {
	var sfEls = document.getElementById("navigation").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);


//****************************************************************
// Gestion des couleurs de fonds des lignes survolées du catalogue
//****************************************************************

sfHover = function() {
	if (document.getElementById("list_cat") != null)
		{
		var sfEls = document.getElementById("list_cat").getElementsByTagName("TH");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=" sfhover";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			}
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

sfHover = function() {
	if (document.getElementById("list_cat") != null)
		{
		var sfEls = document.getElementById("list_cat").getElementsByTagName("TR");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=" sfhover";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			}
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

sfHover = function() {
	if (document.getElementById("list_cat2") != null)
		{
		var sfEls = document.getElementById("list_cat2").getElementsByTagName("TH");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=" sfhover";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			}
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

sfHover = function() {
	if (document.getElementById("list_cat2") != null)
		{
		var sfEls = document.getElementById("list_cat2").getElementsByTagName("TR");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=" sfhover";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			}
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);


//****************************************************************
// Fonction d'import des animations Flash 
//****************************************************************

function RunFlash(swf, hauteur, largeur, nom) {
	document.write("<object width=\""+hauteur+"\" height=\""+largeur+"\" id=\""+nom+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\">\n");
	document.write("<param name=\"quality\" value=\"high\">\n");
	document.write("<param name=\"wmode\" value=\"transparent\">\n");
	document.write("<param name=\"movie\" value=\""+swf+"\">\n");
	document.write("<embed src=\""+swf+"\" quality=\"high\" wmode=\"transparent\" width=\""+hauteur+"\" height=\""+largeur+"\" name=\""+nom+"\" align=\"middle\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\">\n");
	document.write("</object>\n");
}


//****************************************************************
// Fonction permettant d'ouvrir un popup
//****************************************************************
function funcPopup(varUrl, varWidth, varHeight, varModal, varResize)
	{
	var ScreenW = screen.availWidth;
	var ScreenH = screen.availHeight;
	var WinPopUp = window.open(varUrl, 'popup', "toolbar=no, menubar=no, scrollbars=yes, resizable=" + varResize + ", location=no, directories=no, status=no, width=" + varWidth + ", height=" + varHeight);
//	alert(ScreenW + " x " + ScreenH + " " + Math.round((ScreenW-varWidth)/2) + " X " + Math.round((ScreenH-varHeight)/2));
	WinPopUp.moveTo(Math.round((ScreenW-varWidth)/2), Math.round((ScreenH-varHeight)/2));	
	}


//****************************************************************
// Fonction permettant d'ouvrir le popup "Envoyer à un ami"
//****************************************************************
function funcPopupMail(varUrl, varWidth, varHeight)
	{
		WinPopUpMail = window.open (varUrl, 'PopUpMail','height=' + varHeight + ',width=' + varWidth + ',toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,modal=1');
	}



//****************************************************************
// fonction permettant l'affichage du POPUP "DETAIL IMAGE"
//****************************************************************
function funcPopupImg(varId,varFileField,varTab,varLabel)
	{
	var strHtmlCode =	"<html>"
						+"<body style='margin:10px 9px 0 9px;text-align:center;' onBlur='focus();'>"
						+"<div><img title='" + varLabel + "' src='../_inc/IMG_DbImgView.asp?strTable="+varTab+"&strSelectField="+varTab+"Id&strSelectValue="
						+ varId +"&strFileField=" + varFileField + "&blnAffiche=oui&strImgNoFile=../images/_charte/NoFile2.gif"
						+ "' onload='window.opener.funcPopupResizeToImg();'>"
						+ "<br>"
						+ "<div align='center'><font color='#666666' style='font-family:Verdana, sans-serif;font-size:11;'>" + varLabel + "&nbsp;&nbsp;</font></div>"
						+ "</div>"
						+"</body></html>";
	
	WinPopUpImg = window.open ("", "PopUpImg", "toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no");
	WinPopUpImg.document.write(strHtmlCode);
	WinPopUpImg.document.close();
	WinPopUpImg.document.title= "Zoom image";
	WinPopUpImg.focus();
	}
	
	/* --------------------------------------------------------------------------------*/
/*fonction permettant de redimensionner le POPUP en fonction de la taille de l'image*/
function funcPopupResizeToImg()
	{
	var ScreenW = screen.availWidth;
	var ScreenH = screen.availHeight;
	var ImgW = WinPopUpImg.document.images[0].width;
	var ImgH = WinPopUpImg.document.images[0].height;
	WinPopUpImg.resizeTo(ImgW+30, ImgH+100);
	WinPopUpImg.moveTo((ScreenW-ImgW)/2, (ScreenH-ImgH)/2);
	}


function funcKeyPress(evenement)
{
       var touche = window.event ? evenement.keyCode : evenement.which;
       alert(touche);
   }


function funcChgElt(varElt)
	{
	var oElt;
//	alert(varElt.id);
	if (varElt.id != 'RmContactPwd3')
		{
		varElt.id = 'RmContactPwd3'
		try
			{
			
			oElt = document.createElement('<input type="password" name="RmContactPwd3" id="RmContactPwd3" value="">');
			varElt.insertAdjacentElement("BeforeBegin",oElt);
			varElt.outerHTML = '';
			oElt.focus();
			oElt.select();
			}
		catch(e) {}
		
		if (!oElt || !oElt.name)
			{
			varElt.type = 'password';				
			varElt.value = '';
			}
		}
	else
		{
		document.getElementById('RmContactPwd').value = varElt.value;
		document.getElementById('formAuthent').sumit();
		}
	}