
//================================================================================
//Librairie de fonctions communes
//================================================================================

var arrImg = new Array();

function funcClearStream(varTxt)
	{
	if(varTxt.length > 0)
		{
		varTxt = varTxt.replace(new RegExp('(é|è|ê|ë)', 'gi'), "e");
		varTxt = varTxt.replace(new RegExp('(à|ä|â)', 'gi'), "a");
		varTxt = varTxt.replace(new RegExp('(ü|ù|û)', 'gi'), "u");
		varTxt = varTxt.replace(new RegExp('(ö|ô)', 'gi'), "o");
		varTxt = varTxt.replace(new RegExp('(ï|î)', 'gi'), "i");		
		varTxt = varTxt.replace(new RegExp('ç', 'gi'), "c");				
		}
	return varTxt;
	}


function funcGetCookieVal(offset)
	{
	var endstr=document.cookie.indexOf (";", offset);
	if (endstr==-1) endstr=document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr)); 
	}

function funcLireCookie(nom)
	{
	var arg=nom+"=";
	var alen=arg.length;
	var clen=document.cookie.length;
	var i=0;
	while (i<clen)
		{
		var j=i+alen;
		if (document.cookie.substring(i, j)==arg) return funcGetCookieVal(j);
		i=document.cookie.indexOf(" ",i)+1;
		if (i==0) break;
		}
	return null; 
	}

function funcEcrireCookie(nom, valeur)
	{
	var arg=nom+"=";
	var alen=arg.length;
	var clen=document.cookie.length;
	var i=0;
	while (i<clen)
		{
		var j=i+alen;
		if (document.cookie.substring(i, j)==arg) return funcGetCookieVal(j);
		i=document.cookie.indexOf(" ",i)+1;
		if (i==0) break;
		}
	return null; 
	}



function funcZoomPerso(varTypId, varTheId, varContactId, varArtId)
	{
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	xmlhttp.open("POST","../_inc/funcAddZoomPerso.asp?strTypId=" + varTypId + "&strTheId=" + varTheId + "&StrContactId=" + varContactId + "&strId=" + varArtId, false);
	xmlhttp.send();
	if (xmlhttp.responseText != '')
		alert(unescape(xmlhttp.responseText));
	}


function funcCreateBlankRecord(varTable)
	{
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	xmlhttp.open("POST","../_inc/funcCreateBlankRecord.asp?strTable=" + varTable, false);
	xmlhttp.send();
//	alert(xmlhttp.responseText);
	return xmlhttp.responseText;
/*	if (xmlhttp.responseText != '')
		{
		for (i = 0; i < document.formAnnonce.length; i++)
			if ((document.formAnnonce[i].name.toLowerCase().indexOf('img') > -1) && (document.formAnnonce[i].value != ''))
				funcImgToDb(document.formAnnonce[i].value, varTable, varTable + 'Id', xmlhttp.responseText, document.formAnnonce[i].name, false, false)		
		document.formAnnonce.strFormId.value = xmlhttp.responseText;
		return xmlhttp.responseText;
		}*/
	}
	

// Mise à jour des stats
function funcStat(varTable, varField, varId, varInc)
	{
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	xmlhttp.open("POST","../_inc/funcStat.asp?strTable="+ varTable +"&strField="+ varField +"&strId="+ varId +"&strInc=" + varInc, false);
	xmlhttp.send();
	}


// Affichage des sous-menus de navigation

function funcShowCurrPag()
	{
	var strUrl = window.location.href;
	for (i = 0; i < document.links.length; i++)
		{
		if (strUrl.indexOf(document.links[i].href)>-1)
			{
			document.links[i].className="navactive";
			break;
			}
		}
	}

// Affichage de la rubrique courante
function funcShowCurrRub()
	{
	var strRep = window.location.pathname
	strRep = strRep.substring(0,strRep.lastIndexOf("/"));
	strRep = strRep.substring(strRep.lastIndexOf("/")+1);
	var ObjMenuCurr = document.getElementById("Menu_"+strRep)
	if (ObjMenuCurr)
		{
		ObjMenuCurr.className = "style_hover";
		}
	var ObjSsMenuCurr = document.getElementById("SsMenu_"+strRep);
	if (ObjSsMenuCurr)
		{
		ObjSsMenuCurr.style.visibility = "visible";
		}
	funcShowCurrPag();
	}

// Affichage des rubriques
	
function funcShowRub(varObjMenu,varAction,varRep)
	{
	if (varAction == "visible")
		{
		varObjMenu.className = "style_hover";
		}
	else if (varObjMenu.id != "Menu_"+varRep)
		{
		varObjMenu.className = "";
		}
	}

// Affichage des sous-menus de navigation

function funcShowMenu(varObjMenu,varObjSsMenu,varAction)
	{
	var strRep = window.location.pathname
	strRep = strRep.substring(0,strRep.lastIndexOf("/"));
	strRep = strRep.substring(strRep.lastIndexOf("/")+1);
	var ObjSsMenuEls = document.getElementById("navMenu").getElementsByTagName("DIV");
	var ObjSsMenuCurr = document.getElementById("SsMenu_"+strRep);
	for (var i=0; i<ObjSsMenuEls.length; i++)
		{
		ObjSsMenuEls[i].style.visibility = "hidden";
		}
	varObjSsMenu.style.visibility=varAction;
	if ((varAction == "hidden") && (ObjSsMenuCurr))
		{
		ObjSsMenuCurr.style.visibility = "visible";
		}
	funcShowRub(varObjMenu,varAction,strRep);
	}

function funcHideAllMenu()
	{
	var strRep = window.location.pathname
	strRep = strRep.substring(0,strRep.lastIndexOf("/"));
	strRep = strRep.substring(strRep.lastIndexOf("/")+1);
	var ObjSsMenuEls = document.getElementById("navMenu").getElementsByTagName("DIV");
	var ObjSsMenuCurr = document.getElementById("SsMenu_"+strRep);
	for (var i=0; i<ObjSsMenuEls.length; i++)
		{
		ObjSsMenuEls[i].style.visibility = "hidden";
		}
	var ObjMenuEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<ObjMenuEls.length; i++)
		{
		ObjMenuEls[i].className = "";
		}
	funcShowCurrRub();
	}

/*function funcContentOnMouseOver()
	{
	alert("funcContentOnMouseOver");
	var ObjDivEls = document.getElementsByTagName("DIV");
	for (var i=0; i<ObjDivEls.length; i++)
		{
		if (ObjDivEls[i].className == "style_contenu")
			{
			ObjContent = ObjDivEls[i];
			alert(ObjDivEls[i].innerHTML);
			}
		}
	}
function funcOnLoad()
	{
	funcShowCurrRub();
	funcContentOnMouseOver();
	}

var ObjContent;*/
window.onload = funcShowCurrRub;

/*--------------------------------------------------------------------------------*/
/* fonction permettant l'affichage du POPUP */
function funcPopupImg(varId,varFileField,varTab,varLabel)
	{
		//title='" + escape(varLabel) + "'
	var strHtmlCode =	"<html>"
						+"<body bgColor=#OOOOOO leftmargin=5 topmargin=5 marginwidth=0 marginheight=0>"
						+"<div><img src='../_inc/IMG_DbImgView.asp?strTable="+varTab+"&strSelectField="+varTab+"Id&strSelectValue="
						+ varId +"&strFileField=" + varFileField + "&blnAffiche=oui&strImgNoFile=../images/_charte/NoFileCine.gif"
						+ "' onload='window.opener.funcPopupResizeToImg();'>"
						+ "<br>"
						+ "<div align='center'><font color='#FFFFFF' style='font-family:Verdana, sans-serif;font-size:11;'>" + varLabel + '&nbsp;&nbsp;<a href="#" onClick="window.print();">[imprimer l\'image]</a></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+20, ImgH+100);
	WinPopUpImg.moveTo((ScreenW-ImgW)/2, (ScreenH-ImgH)/2);
	}


function funcAfficheList()
	{
	document.formSearch.action = '';
	document.formSearch.target = '';
//	document.formSearch.strAlertAffiche.value = '';
	document.formSearch.blnList.value = 'true'; 
	document.formSearch.submit();	
	}


function funcAlert()
	{
	var strPrompt =	window.prompt("Entrez le nom de l'alerte","");
	if (strPrompt)
		{
		document.formSearch.action = '';
		document.formSearch.target = '';
		document.formSearch.blnAlert.value = strPrompt;
		document.formSearch.submit();
		}
	}
		
/* --------------------------------------------------------------------------------*/
/* Calcul et affichage du nombre d'annonces*/
function funcAfficheNb(blnHideResult)
	{
//	alert('strMode : ' + strMode);
	document.formSearch.action = '../_inc/countAnnonces.asp?strMode=' + strMode;
	document.formSearch.target = 'frameSearch';
	for (k=0; k < document.formSearch.length ; k++)
		if (document.formSearch[k].name.indexOf('$') > -1)
			document.formSearch[k].value = '';
//	document.formSearch.blnList.value = 'false';
//	document.formSearch.RmContactId.value = '0';
	if (blnHideResult == true)
		if (document.getElementById('divResult'))
			document.getElementById('divResult').style.display = 'none';
	document.formSearch.submit();
//	document.formSearch.RmContactId.value = '0';
//	document.formSearch.ZoPaAutoPremium.value = '0';
	document.formSearch.action = '';
	document.formSearch.target = '';
//	document.getElementById('divPub').style.display = 'inline';			
	}
								


/* --------------------------------------------------------------------------------*/
/* Dans les petites annonces, affichage du DIV Recherche rapide, avancée ou en Liste */

function funcAfficheSearchPlus(varTable)
	{
	if (strMode == 0)
		funcAfficheSearch(1, varTable)
	else
		funcAfficheSearch(0, varTable);
	}
	
function funcAfficheSearch(varMode, varTable)
	{
	if ((strMode > 1) && (document.getElementById('lnkCriterePlus').innerText == 'Moins de critères'))
		strMode = 1;	
	else
		strMode = varMode;

	document.getElementById('lnkCritereSearch').style.textDecoration = 'none';
	document.getElementById('lnkCritereSearch').style.padding = '0 5px 3px';
	document.getElementById('lnkCritereSearch').style.border = 'solid 1px #A000AB';
	document.getElementById('lnkCategMarqSearch').style.textDecoration = 'none';
	document.getElementById('lnkCategMarqSearch').style.padding = '0 5px 3px';
	document.getElementById('lnkCategMarqSearch').style.border = 'solid 1px #A000AB';
	document.getElementById('lnkProCategSearch').style.textDecoration = 'none';
	document.getElementById('lnkProCategSearch').style.padding = '0 5px 3px';
	document.getElementById('lnkProCategSearch').style.border = 'solid 1px #A000AB';

	switch (strMode)
		{
		case 0 :
			{
			document.getElementById('divCritereSearch').style.display = 'inline';
			document.getElementById('divCriterePlus').style.display = 'none';
			document.getElementById('lnkCritereSearch').style.color = '#FFFFFF';
			document.getElementById('lnkCritereSearch').style.fontWeight = 'bold';
			document.getElementById('lnkCritereSearch').style.backgroundColor = '#A000AB';
//			document.getElementById('lnkSubmit'].style.display = 'inline';
			document.getElementById('lnkCriterePlus').innerText = 'Plus de critères';
			document.getElementById('divCategMarqSearch').style.display = 'none';
			document.getElementById('lnkCategMarqSearch').style.color = '#CC99CC';
			document.getElementById('lnkCategMarqSearch').style.fontWeight = 'normal';
			document.getElementById('lnkCategMarqSearch').style.backgroundColor = '#FFFFFF';
			
			document.getElementById('divProCategSearch').style.display = 'none';
			document.getElementById('lnkProCategSearch').style.color = '#CC99CC';
			document.getElementById('lnkProCategSearch').style.fontWeight = 'normal';
			document.getElementById('lnkProCategSearch').style.backgroundColor = '#FFFFFF';						
			
			if (document.formSearch.ContactId.value == '1')
				document.getElementById('lnkAlert').style.display = 'inline';			
			document.formSearch.strMode.value = 0;
			formRecherche = 'formSearch';
			document.formSearch.RmContactId.value = '';
			document.getElementById(varTable + 'Premium').value = '';
			document.formSearch.posNavBar.value = '0';
			break;
			}
		case 1 :
			{
			document.getElementById('divCritereSearch').style.display = 'inline';
			document.getElementById('divCriterePlus').style.display = 'inline';

			document.getElementById('lnkCritereSearch').style.color = '#FFFFFF';
			document.getElementById('lnkCritereSearch').style.fontWeight = 'bold';
			document.getElementById('lnkCritereSearch').style.backgroundColor = '#A000AB';

//			document.getElementById('lnkSubmit'].style.display = 'inline';
			document.getElementById('lnkCriterePlus').innerText = 'Moins de critères';
			document.getElementById('divCategMarqSearch').style.display = 'none';

			document.getElementById('lnkCategMarqSearch').style.color = '#CC99CC';
			document.getElementById('lnkCategMarqSearch').style.fontWeight = 'normal';
			document.getElementById('lnkCategMarqSearch').style.backgroundColor = '#FFFFFF';

			document.getElementById('divProCategSearch').style.display = 'none';

			document.getElementById('lnkProCategSearch').style.color = '#CC99CC';
			document.getElementById('lnkProCategSearch').style.fontWeight = 'normal';
			document.getElementById('lnkProCategSearch').style.backgroundColor = '#FFFFFF';						

			document.formSearch.strMode.value = 1;
			formRecherche = 'formSearch';
			if (document.formSearch.ContactId.value == '1')
				document.getElementById('lnkAlert').style.display = 'inline';
			document.formSearch.RmContactId.value = '';
			document.getElementById(varTable + 'Premium').value = '';
			document.formSearch.posNavBar.value = '0';
			break;
			}
		case 2 :
			{
			document.getElementById('divCritereSearch').style.display = 'none';

			document.getElementById('lnkCritereSearch').style.color = '#CC99CC';
			document.getElementById('lnkCritereSearch').style.fontWeight = 'normal';
			document.getElementById('lnkCritereSearch').style.backgroundColor = '#FFFFFF';

			document.getElementById('divProCategSearch').style.display = 'none';			

			document.getElementById('lnkCategMarqSearch').style.color = '#FFFFFF';
			document.getElementById('lnkCategMarqSearch').style.fontWeight = 'bold';
			document.getElementById('lnkCategMarqSearch').style.backgroundColor = '#A000AB';

			document.getElementById('divCategMarqSearch').style.display = 'inline';

			document.getElementById('lnkProCategSearch').style.color = '#CC99CC';
			document.getElementById('lnkProCategSearch').style.fontWeight = 'normal';
			document.getElementById('lnkProCategSearch').style.backgroundColor = '#FFFFFF';

			document.getElementById('lnkAlert').style.display = 'none';
			document.getElementById('lnkSubmit').style.display = 'none';
			document.formSearch.strMode.value = 2;
			formRecherche = 'formSearch';
			document.formSearch.RmContactId.value = '';
			document.getElementById(varTable + 'Premium').value = '';
			document.formSearch.posNavBar.value = '0';
			document.getElementById('typAnnonceur').value = '1';			
			break;
			}
		case 3 :
			{
			document.getElementById('divCritereSearch').style.display = 'none';

			document.getElementById('lnkCritereSearch').style.color = '#CC99CC';
			document.getElementById('lnkCritereSearch').style.fontWeight = 'normal';
			document.getElementById('lnkCritereSearch').style.backgroundColor = '#FFFFFF';

			document.getElementById('divCategMarqSearch').style.display = 'none';

			document.getElementById('lnkCategMarqSearch').style.color = '#CC99CC';
			document.getElementById('lnkCategMarqSearch').style.fontWeight = 'normal';
			document.getElementById('lnkCategMarqSearch').style.backgroundColor = '#FFFFFF';

			document.getElementById('divProCategSearch').style.display = 'inline';			

			document.getElementById('lnkProCategSearch').style.color = '#FFFFFF';
			document.getElementById('lnkProCategSearch').style.fontWeight = 'bold';
			document.getElementById('lnkProCategSearch').style.backgroundColor = '#A000AB';

			document.getElementById('lnkAlert').style.display = 'none';
			document.getElementById('lnkSubmit').style.display = 'none';
			document.formSearch.strMode.value = 3;
			formRecherche = 'formSearch';
			document.formSearch.RmContactId.value = '';
			document.getElementById(varTable + 'Premium').value = '';
			document.getElementById('typAnnonceur').value = '1';		
			break;
			}
		}
	}
	
/* --------------------------------------------------------------------------------*/
/* Petites annonces : Afichage des valeurs*/
function funcAfficheValue(varInput, varValue, varType)
	{
//									if ('<%=strMode%>' != 'recherche')
		switch (varType)
			{
			//-- Liste choix unique
			case 1 :
				{
				if (varValue != '')
					for (i = 0; i < varInput.length; i++)
						if (varValue == varInput[i].value)
							varInput[i].selected = true;
				break;
				}
			//-- Liste choix multiple
			case 2 :
				{
//				alert(varInput.name);
				varValue = ', ' + varValue + ',';
				if (varValue != ', ,')
					for (i = 0; i < varInput.length; i++)
						if (varValue.indexOf(', ' + varInput[i].value + ',') >= 0)
							varInput[i].selected = true;
				break;
				}
				
			//-- Case à cocher
			case 3 :
				{
				varInput.checked = varValue;
				break;
				}
				
			//-- input Text
			case 4 :
				{
				if (varValue != '')
					varInput.value = varValue;
				}
			}
	}

/* --------------------------------------------------------------------------------*/
/* Popup envoi de message  */
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 de suppression d'une image en base
//-------------------------------------------------------------------------------
function funcImgDelToDb(varTable, varSelectField, varSelectValue, varFileField, varBlnMsg, varReload)
	{
//	alert('ok');
	var	strMessage = "<h4><center><font color=#FF0000>La suppression de l'image est en cours</font></center></h4>"
					+'<div align="center"><img src="../images/progression.gif"></div><br><br>';
	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>";
	WinPopupImgDel = window.open ("../_inc/funcImgUpload.asp?strAction=delete&strTable=" + varTable + "&strSelectField=" + varSelectField + "&strSelectValue=" + varSelectValue + "&strFileField=" + varFileField, "popupImgDel", "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));


					
//	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
//	xmlhttp.open("POST","../_inc/funcImgUpload.asp?strAction=delete&strTable="+ varTable +"&strSelectField="+ varSelectField +"&strSelectValue="+ varSelectValue +"&strFileField="+ varFileField, false);
//	xmlhttp.send();
	}

	
//-------------------------------------------------------------------------------
//	Fonction de lancement d'un upload d'image en base
//-------------------------------------------------------------------------------
function funcImgToDb(varPath, varTable, varSelectField, varSelectValue, varFileField, varBlnMsg, varReload)
	{
   // create ADO-stream Object
   var ado_stream = new ActiveXObject("ADODB.Stream");

   // create XML document with default header and primary node
   var xml_dom = new ActiveXObject("MSXML2.DOMDocument");
   xml_dom.loadXML('<?xml version="1.0" ?> <root/>');
   // specify namespaces datatypes
   xml_dom.documentElement.setAttribute("xmlns:dt", "urn:schemas-microsoft-com:datatypes");

   // create a new node and set binary content
   var l_node1 = xml_dom.createElement("file1");
   l_node1.dataType = "bin.base64";
	if (varPath != "")
	   	{
		// open stream object and read source file
		ado_stream.Type = 1;  // 1=adTypeBinary 
		ado_stream.Open(); 
		ado_stream.LoadFromFile(varPath);
	
	   // store file content into XML node
	   l_node1.nodeTypedValue = ado_stream.Read(-1); // -1=adReadAll
	   ado_stream.Close();
	   xml_dom.documentElement.appendChild(l_node1);
		// send XML document to SysWeb server
		var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		xmlhttp.open("POST","../_inc/funcImgUpload.asp?strAction=upload&strTable="+ varTable +"&strSelectField="+ varSelectField +"&strSelectValue="+ varSelectValue +"&strFileField=" + varFileField + "&strPath=" + varPath, false);
		xmlhttp.send(xml_dom);
		}
	else
		{
		// send XML document to SysWeb server
		var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		xmlhttp.open("POST","../_inc/funcImgUpload.asp?strAction=delete&strTable="+ varTable +"&strSelectField="+ varSelectField +"&strSelectValue="+ varSelectValue +"&strFileField="+ varFileField, false);
		xmlhttp.send(xml_dom);
		}
	
   // show server message in message-area
	if (varBlnMsg)
		alert(xmlhttp.responseText);

	if (varReload == 1)
		window.location.href = window.location.href;
}

//-------------------------------------------------------------------------------
// Fonction de suppression d'une image
//-------------------------------------------------------------------------------
function funcImgDelete(varImg)
	{
	varImg.outerHTML = '<img alt="' + varImg.alt + '" id="' + varImg.id + '" title="Photo" src="../images/_charte/NoFileCine.gif" onLoad="funcRedimImg(this,200,200);">';
//	alert(varImg.outerHTML);
	}

function funcImgChange(varImg, varSrc)
	{
	varImg.outerHTML = '<img alt="' + varImg.alt + '" id="' + varImg.id + '" title="Photo" src="' + rewriteLocalURL(varSrc) + '" onLoad="funcRedimImg(this,200,200);">';
	varImg.src = varSrc;
//	alert('ImgChange : ' +varImg.outerHTML);
	}

function rewriteLocalURL(url) { 
                var uri = url; 
				var spaceMatch = / /gi; 
		        var slashMatch = /\\/gi;
                /* identify Windows-Scheme */ 
                if ((uri.charAt(1) == ':') && (uri.charAt(2) == '\\'))
					{ 
                    uri = 'file:///' + uri.replace(slashMatch, "/");
					uri = uri.replace(spaceMatch, "%20"); 

//replace(/\\+/, '/'); 
	                } 
                /* identify Linux-Scheme */ 
                else if (uri.charAt(0) == '/') { 
                        uri = 'file:///' + uri; 
                } 
                return uri; 
        } 


//-------------------------------------------------------------------------------
//	Fonction de redimensionnement des images
//-------------------------------------------------------------------------------
function funcRedimImg(varImg, varWidth, varHeight)
	{
	var oldWidth = varImg.width;
	var oldHeight = varImg.height;
	arrImg[varImg.alt] = varImg.width + 'X' + varImg.height;
//	alert(varImg.alt + ' - ' + arrImg[varImg.alt]);
//	alert(varImg.width + ' X ' + varImg.height);
	var newWidth = oldWidth;
	var newHeight = oldHeight;
	if (varImg.width > varWidth)
		{
		newWidth = varWidth;
		newHeight = Math.round((varWidth/oldWidth) * oldHeight);
		varImg.width = newWidth;
		varImg.height = newHeight;
		oldWidth = newWidth;
		oldHeight = newHeight;
		}
	if (newHeight > varHeight)
		{
		newHeight = varHeight;
		newWidth = Math.round((varHeight/oldHeight) * newWidth);
		varImg.width = newWidth;
		varImg.height = newHeight;
		}
	}

//-------------------------------------------------------------------------------
//	Fonction d'ajout à Mon Zoom Perso
//-------------------------------------------------------------------------------
function funcAddBookmark()
	{
	if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4))
		{
		var url="http://www.zoom42.fr";
		var title="zoom42.fr 100% local, 200% utile";
		external.AddFavorite(url,title);
		}
	}

//-------------------------------------------------------------------------------
// Fonction permettant d'ouvrir le popup de perte des identifiants
//-------------------------------------------------------------------------------
function funcPertId()
	{
	WinPopUp = window.open ("../_inc/PerteId.asp", "PopUpFavoris", "toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no, width=427, height=175");
	}

//-------------------------------------------------------------------------------
// 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=no, 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 de contrôle du navigateur
function FuncNavigatorCtrl()
	{
//	alert(window.navigator.userAgent + '\n' + screen.width);	
	//--- Déclaration des variables
	var strMsg = "";
	var ValidNavigator = true;
	var IeVersMini = 5.5;
	var FfVersMini = 1;
	var CurrNavigator = window.navigator.userAgent;
	if ((window.navigator.appName == "Microsoft Internet Explorer") && (CurrNavigator.indexOf("Opera") == -1))
		{
		var varNavigatorVers = parseFloat(navigator.appVersion.substring(navigator.appVersion.indexOf("MSIE ")+5, navigator.appVersion.indexOf("MSIE ")+10));
		if (varNavigatorVers < IeVersMini)
			{
			strMsg += "Votre navigateur Internet Explorer est une version "+ varNavigatorVers +"\n";
			strMsg += "et ce site Web est optimisée pour les versions "+ IeVersMini +" et supérieures.\n\n";
			strMsg += "Certaines informations ou fonctionnalités ne vous seront peut-être pas accessibles.\n\n";
			strMsg += "Vous pouvez télécharger gratuitement une version plus récente sur www.microsoft.fr\n";
			strMsg += "ou contactez votre administrateur réseau.\n\n";
			ValidNavigator = false;
			}
		}

if (((window.navigator.appName != "Microsoft Internet Explorer") && (CurrNavigator.indexOf("firefox") != -1)) || (CurrNavigator.indexOf("Opera") > -1) || (CurrNavigator.indexOf("AppleWebKit") > -1) || (CurrNavigator.indexOf("Safari") > -1))
		if (CurrNavigator.indexOf("Safari") > -1)
			{
			strMsg += "Zoom42 n'est pas optimisé pour Safari.\n";
			strMsg += "Certaines informations ou fonctionnalités ne vous seront peut-être pas accessibles\n\n\n";
			strMsg += "Installez, soit Internet Explorer, soit Firefox.\n";
			strMsg += "Vous pouvez télécharger gratuitement une version de ces navigateurs sur\n";
			strMsg += "www.microsoft.fr et www.mozilla-europe.org\/fr,\n";
			strMsg += "ou contactez votre administrateur réseau.\n\n";
			ValidNavigator = false;
			}
		else
			{
			strMsg += "Ce site Web est optimisée pour les versions "+ IeVersMini +" et supérieures d\'Internet Explorer ";
			strMsg += "et les versions "+ FfVersMini +" et supérieures de Firefox\n\n\n";
			strMsg += "Certaines informations ou fonctionnalités ne vous seront peut-être pas accessibles.\n\n\n";
			strMsg += "Vous pouvez télécharger gratuitement une version de ces navigateurs sur\n";
			strMsg += "www.microsoft.fr et www.mozilla-europe.org\/fr,\n";
			strMsg += "ou contactez votre administrateur réseau.\n\n";
			ValidNavigator = false;
			}
			
	//--- Vérification de la provenance de la connexion
	if (document.referrer.indexOf("http://"+ window.location.hostname) != 0)
		{
		//--- Contrôle du type de navigateur
		if (screen.width < 1024)
			{
			strMsg += "----------------------------------------------------------------------\n";
			strMsg += "Ce site est optimisé pour une résolution d'écran de 1024x768 pixels.\n";
			strMsg += "Votre écran affiche une résolution de "+ screen.width +"x"+ screen.height;
			strMsg += ", la consultation du site risque d'en être affectée.\n\n\n";
			strMsg += "Si vous le pouvez, nous vous invitons à modifier vos paramètres \n";
			strMsg += "dans les propriétés d'affichage de votre ordinateur\n";
			strMsg += "(sur PC : clic droit sur le bureau > Propriétés > Onglet paramètres).\n";
			ValidNavigator = false;
			}
		}
		//--- Information de l'utilisateur
	if (ValidNavigator == false)
		{
		// Affaire N°490	
		//alert(strMsg);
		}
	}

/*--------------------------------------------------------------------------------*/
/* fonction permettant l'affichage du POPUP */
function funcPopupImgLnk(varImgUrl, varLabel)
	{
	var strHtmlCode =	"<html>"
						+"<body bgColor=#OOOOOO leftmargin=5 topmargin=5 rightmargin=5 bottommargin=100 marginwidth=0 marginheight=0>"
						+"<div><img title='" + varLabel + "' src='" + varImgUrl + "' "
						+"onload='window.opener.funcPopupResizeToImg();'>"
						+ "<br>"
						+ "<div align='center'><font color='#FFFFFF' style='font-family:Verdana, sans-serif;font-size:11;'>" + varLabel + '&nbsp;&nbsp;<a href="#" onClick="window.print();">[imprimer l\'image]</a></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 d'affichage standard des animations Flash
//*************************************************************************

function RunFlash(swf, largeur, hauteur, nom) {
	document.write("<object width=\""+largeur+"\" height=\""+hauteur+"\" id=\""+nom+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,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=\""+largeur+"\" height=\""+hauteur+"\" name=\""+nom+"\" align=\"middle\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\">\n");
	document.write("</object>\n");
}


//*************************************************************************
// Fonction d'affichage standard des animations Flash
//*************************************************************************

function RunBanFlash(swf, largeur, hauteur, nom) {
	document.write("<object width=\""+largeur+"\" height=\""+hauteur+"\" id=\""+nom+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\">\n");
	document.write("<param name=\"quality\" value=\"high\">\n");
	document.write("<param name=\"movie\" value=\""+swf+"\">\n");
	document.write("<embed src=\""+swf+"\" quality=\"high\" width=\""+largeur+"\" height=\""+hauteur+"\" name=\""+nom+"\" align=\"middle\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\">\n");
	document.write("</object>\n");
}


//*************************************************************************
// Fonction d'import de la carte météo en Flash 
//*************************************************************************

function RunMeteo(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,29,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");
}


//****************************************************************
// Affichage des sous-menus 
//****************************************************************

sfHover = function() {
	if (document.getElementById('navigation'))
		{
		var sfEls = document.getElementById('navigation').getElementsByTagName("LI");
		for (var i=0; i<sfEls.length; i++)
			{
			sfEls[i].onmouseover=function()
				{
				this.className+=" sfhover";
				if (window.navigator.userAgent.indexOf("SV1") != -1)
					{
					for (k=0; k<document.getElementsByTagName('select').length; k++)
						document.getElementsByTagName('select')[k].style.display='none';
					for (k=0; k<document.getElementsByTagName('object').length; k++)
						if(document.getElementsByTagName('object')[k].WMode)
							{
//						alert(document.getElementsByTagName('object')[k].WMode);
							document.getElementsByTagName('object')[k].WMode='transparent';
//							alert(document.getElementsByTagName('object')[k].BackgroundColor);
//							document.getElementsByTagName('object')[k].BackgroundColor=new number('0x' + document.getElementsByTagName('object')[k].BackgroundColor);	
							}
					}
				}
			sfEls[i].onmouseout=function()
				{
				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
				if (window.navigator.userAgent.indexOf("SV1") != -1)
					for (k=0; k<document.getElementsByTagName('select').length; k++)
						document.getElementsByTagName('select')[k].style.display='block';
				}
			}

		}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);




//----------------------------------------------------------------------------------
// Limitation du nombre de caractère d'un textarea
// Affaire 450
//----------------------------------------------------------------------------------

// args : string varIdTextarea, int varNbCar, string varIdControleCompte
// return : aucun
// Affecte à certains évènements d'un textarea, le contrôle de la longueur de son contenu
function funcTextareaLimiter (varIdTextarea, varNbCar, varIdControleCompte) {
	
	var objTextarea 		= document.getElementById(varIdTextarea);
	var objControleCompte 	= document.getElementById(varIdControleCompte);

	if (objTextarea && objControleCompte) {

		objTextarea.onclick 	= function(){funcTextareaEstRempli(objTextarea, varNbCar, objControleCompte)};
		objTextarea.onblur 		= function(){funcTextareaEstRempli(objTextarea, varNbCar, objControleCompte)};
		objTextarea.onkeyup 	= function(){funcTextareaEstRempli(objTextarea, varNbCar, objControleCompte)};
		objTextarea.onkeypress 	= function(){funcTextareaEstRempli(objTextarea, varNbCar, objControleCompte)};

		// Affichage nb caractères restant
		if (objControleCompte.type)
			objControleCompte.value 	= funcTextareaNbCarRestant(objTextarea, varNbCar); // Pour un input de formulaire
		else
			objControleCompte.innerHTML = funcTextareaNbCarRestant(objTextarea, varNbCar); // Pour un élément HTML
	}
}

// args : textarea objTextarea, int varNbCar, element_HTML objControleCompte
// return : bool
// Renvoie vrai si le nombre de caractères maximum du textarea n'est pas atteint
function funcTextareaEstRempli (objTextarea, varNbCar, objControleCompte) {

	if (objTextarea) {
		
		if (objTextarea.value.length <= varNbCar) {
			
			// Affichage nb caractères restant
			if (objControleCompte.type)
				objControleCompte.value 	= funcTextareaNbCarRestant(objTextarea, varNbCar);
			else
				objControleCompte.innerHTML = funcTextareaNbCarRestant(objTextarea, varNbCar);
			
			return true;
			
		} else {
		
			// Affichage du nombre de caractères restant
			objTextarea.value = objTextarea.value.substr(0, varNbCar);
		
			// Affichage nb caractères restant
			if (objControleCompte.type)
				objControleCompte.value 	= funcTextareaNbCarRestant(objTextarea, varNbCar);
			else
				objControleCompte.innerHTML = funcTextareaNbCarRestant(objTextarea, varNbCar);
		
			return false;
		}
	}
}

// args : textarea objTextarea, int varNbCar
// return : int
// Renvoie le nombre de caractère à saisir
function funcTextareaNbCarRestant (objTextarea, varNbCar) {
	if (objTextarea.value.length)
		return new Number(varNbCar - objTextarea.value.length);
	else
		return new Number(varNbCar);
}