// JavaScript Document

//************************************************
// Affichage des sous-menus 
//************************************************

sfHover = function() {
	var sfEls = document.getElementById("nav").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=8,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");
}


//****************************************************************
// Popup envoi de message
//****************************************************************
function funcSendFriend(varUrl)
	{
	WinPopUpSendFriend = window.open (varUrl, 'PopUpSendFriend','height=450,width=673,toolbar=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,modal=1');
	}

//****************************************************************
// Popup envoi de message  
//****************************************************************
function funcPerteId(varUrl)
	{
//	WinPopUpPerteId = window.open (varUrl, 'PopUpPerteId','height=500,width=800,toolbar=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,modal=1');
	window.location.href = varUrl;
	}

//****************************************************************
// 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; background-color:#000000;' 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='#FFFFFF' 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);
	}


//************************************************
// Gestion des INPUT d'authentification
//************************************************

function funcChgElt(varElt)
	{
	var oElt;
	try
		{
		oElt = document.createElement('<input type="password" name="RmContactPwd" id="RmContactPwd" value="">');
		varElt.insertAdjacentElement("BeforeBegin",oElt);
		varElt.outerHTML = '';
		oElt.focus();
		oElt.select();
		}
	catch(e) {}
	if (!oElt || !oElt.name)
		{
		varElt.type = 'password';				
		varElt.value = '';
		}
	}


//************************************************
// 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=8,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");
}

//************************************************
//	Fonctions relative à l'annuaire
//************************************************
function funcCtlSect(varNb, varCheckBox)
	{
	var nbCheck = 0;
	for (var i=0 ; i < document.formMemberAccount.RmCat1Id.length ; i++)
		{
		if (document.formMemberAccount.RmCat1Id[i].checked)
			nbCheck++;
		if (nbCheck > varNb)
			{
			varCheckBox.checked = false;
			alert('Vous ne pouvez choisir que '+ varNb + ' catégorie(s).');
			return;
			}
		}
	}

function funcCtlTailleImg(varForm)
		{
		var fso, fichier, k, strMessage, cptImg, imgWidth, imgHeight, strImg;
		blnImg = false;
		blnBigImg = false;
		cptImg = 0;
		strImg = '';
		strMessage = "<h4><center><font color=#FF0000>L'enregistrement de votre profil est en cours</font></center></h4>"
					+'<div align="center"><img src="../images/_charte/progression.gif"></div><br><br>';


		for (k=0;k<document.getElementById(varForm).length;k++)
			if (document.getElementById(varForm)[k].getAttribute('type') == 'file')
				if (document.getElementById(varForm)[k].value != '')
					{
					cptImg = cptImg + 1;
					strImg = strImg + "&nbsp;&nbsp;Photo n° " + cptImg + " : " + arrImg[cptImg].substring(0, arrImg[cptImg].indexOf('X')) + " x " + arrImg[cptImg].substring(arrImg[cptImg].indexOf('X')+1,arrImg[cptImg].length) + " pixels<br>";
					}

		if (cptImg > 0)
			strMessage = strMessage + "Vos photos vont être automatiquement redimensionnées à la taille 640 x 480 pixels.<br><br>"
									+ "<b><font color=#FF0000>Le transfert des photos peut durer quelques minutes, merci de patienter.</font></b><br><br>"
									+ "Analyse des fichiers images envoyés :<br>"
									+ "<b>" + strImg + "</b><br><br>";

		strMessage = strMessage + "<p align=center><font style=font-size:9;>En cas de problème d'enregistrement, veuillez nous contacter.</font></p>";
		
		var strHtmlCode = 	 "<html>"
							+"<body leftmargin=3 topmargin=3 marginwidth=3 marginheight=3 onBlur='focus();'>"
							+"<div align='left'><font color='#000000' style='font-family:Verdana, sans-serif;font-size:11;'>" + strMessage + "&nbsp;&nbsp;</font></div>"
							+ "</div>"
							+"</body></html>";
		WinPopupEnreg = window.open ("", "PopUpEnreg", "height=300, width=450, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, center=yes, directories=no, status=no, modal=1");
		WinPopupEnreg.document.write(strHtmlCode);
		WinPopupEnreg.document.close();

		WinPopupEnreg.moveTo(Math.round((screen.width-450)/2), Math.round((screen.height-300)/2));
		document.getElementById(varForm).submit();
		}

