	function getSelectTag()
	{
		return document.getElementsByTagName("select").length;
	}
	
	
	glisse.Registry = [];
	// safari sniffer
	var agt = navigator.userAgent.toLowerCase();
	var is_safari = ((agt.indexOf('safari')!=-1)&&(agt.indexOf('mac')!=-1))?1:0;
	
	function glisse(identifier,numLines)
	{	
		glisse.Registry[identifier] = [];
		glisse.Registry[identifier]['height']       = 1;
		glisse.Registry[identifier]['containerObj'] = document.getElementById(identifier+"Container");

		glisse.Registry[identifier]['haslines'] = (numLines != 0)?1:0;

		if(glisse.Registry[identifier]['haslines'] != 0)
		{
			glisse.Registry[identifier]['contentObj']   = document.getElementById(identifier+"Content");
			glisse.Registry[identifier]['maxHeight']    = new Number((numLines * glisse.lineHeight) + 1);
			glisse.Registry[identifier]['interval']     = null;
			glisse.Registry[identifier]['timeout']      = null;
			glisse.Registry[identifier]['contentObj'].style.height  = '1px';
		}
		
		// le menu se déplie
		glisse.Registry[identifier]['containerObj'].onmouseover = function(){glisse.showMenu(identifier)}
		glisse.Registry[identifier]['containerObj'].onfocus     = function(){glisse.showMenu(identifier)}
		
		
		// Le menu se replie
		if(glisse.Registry[identifier]['haslines'] != 0)
		{
			glisse.Registry[identifier]['containerObj'].onmouseout  = function(){glisse.hideMenu(identifier)}
			glisse.Registry[identifier]['containerObj'].onblur      = function(){glisse.hideMenu(identifier)}
		}
		else
		{
			glisse.Registry[identifier]['containerObj'].onmouseout  = function(){glisse.switchOff(identifier)}
		}
		
	}
	
	glisse.showMenu = function(identifier)
	{	
		/*
		p = id.indexOf("Container")
		if(is_safari && p != -1) id = id.substr(0,p);
		alert(id)
		*/
		if(glisse.Registry[identifier]['haslines'])
		{
			for(i=0;i<getSelectTag();i++)
			{
				document.getElementsByTagName("select")[i].style.visibility = "hidden";
			}
			clearInterval(glisse.Registry[identifier]['interval']);
			glisse.Registry[identifier]['contentObj'].style.display = 'block';
			glisse.Registry[identifier]['contentObj'].style.zIndex += 100;
			glisse.Registry[identifier]['interval'] = window.setInterval("glisse.slideDown('"+identifier+"')",1);
		}
		
		// Rollover
		y = identifier.substr(4,1);
		eval("MM_swapImage('ong" + y + "','','/img/onglet_" + y + "_on.gif',1);");
		
	}
	
	glisse.hideMenu = function(identifier)
	{	
		for(i=0;i<getSelectTag();i++)
	  	{
		  document.getElementsByTagName("select")[i].style.visibility = "visible";
	  	}
		clearInterval(glisse.Registry[identifier]['interval']);
		
		glisse.Registry[identifier]['contentObj'].style.zIndex = 100;
		glisse.Registry[identifier]['interval'] = window.setInterval("glisse.slideUp('"+identifier+"')",1);
		
	}
	
	glisse.switchOff = function(identifier)
	{	
		y = identifier.substr(4,1);
		if(currentRub != y)
		{
			eval("MM_swapImage('ong" + y + "','','/img/onglet_" + y + "_off.gif',1);");
		}
	}
	
	glisse.slideDown = function(identifier)
	{
		
		for(var i=0;i<20;i++)
		{
			if(glisse.Registry[identifier]['height'] >= glisse.Registry[identifier]['maxHeight']) clearInterval(glisse.Registry[identifier]['interval']);
			else
			{
				glisse.Registry[identifier]['contentObj'].style.height = glisse.Registry[identifier]['height']+'px';
				glisse.Registry[identifier]['height'] ++;
			}
			
		}
	}
	
	glisse.slideUp = function(identifier)
	{
	//	for(var i=0;i<15;i++)
	//  {
		//alert(id);
		y = identifier.substr(4,1);
		//alert(y);
		//eval("MM_swapImageRestore('onglet_" + y + "','','onglet_" + y + "_on.gif',1);");
		i=0;
		
		while(i<20)
		{
			if(glisse.Registry[identifier]['height'] <= 1)
			{
				clearInterval(glisse.Registry[identifier]['interval']);
				glisse.Registry[identifier]['contentObj'].style.display = 'none';
				i++;
				
				y = identifier.substr(4,1);
				// Rollout
				if(i == 20 && currentRub != y)
				{
					eval("MM_swapImage('ong" + y + "','','/img/onglet_" + y + "_off.gif',1);");
				}

				
			}
		   else
		   {
				glisse.Registry[identifier]['contentObj'].style.height = glisse.Registry[identifier]['height'] + 'px';
				glisse.Registry[identifier]['height']--;
				i++;
			}
		}
			
	}
	
	/*---------------- Fonction macromedia pour rollover ---------------------*/
	function MM_swapImgRestore() { //v3.0
	  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}
	
	function MM_findObj(n, d) { //v4.01
	  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	  if(!x && d.getElementById) x=d.getElementById(n); return x;
	}
	
	function MM_swapImage() { //v3.0
	  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}
	/*---------------- Fonction macromedia pour rollover ---------------------*/
	
	
	
	/*---------------- Fonction pour le pied de page ---------------------*/
	
	function flevDivPositionValue(sDiv, sProperty) { // v2.1, Marja Ribbers-de Vroed, FlevOOware
		this.opera = (window.opera); // Opera 5+
		this.ns4 = (document.layers); // Netscape 4.x
		this.ns6 = (document.getElementById && !document.all && !this.opera); // Netscape 6+
		this.ie = (document.all);  // Internet Explorer 4+
		var sValue = ""; docObj = eval("MM_findObj('" + sDiv + "')"); if (docObj == null) {return 0;}
		if ((sProperty == "left") || (sProperty == "top")) {
			if (!this.ns4) {docObj = docObj.style;} 
			sValue = eval("docObj." + sProperty);
			if ((this.ie) && (sValue == "")) { // IE (on PC) bug with nested layers
				if (sProperty == "top") { sValue = eval(sDiv + ".offsetTop"); } 
				else { sValue = eval(sDiv + ".offsetLeft"); } 
			};
		}
		else {
			if (this.opera) {
				docObj = docObj.style;
				if (sProperty == "height") { sValue = docObj.pixelHeight; } 
				else if (sProperty == "width") { sValue = docObj.pixelWidth; } 
			}
			else if (this.ns4) {sValue = eval("docObj.clip." + sProperty);} 
			else if (this.ns6) {sValue = document.defaultView.getComputedStyle(docObj, "").getPropertyValue(sProperty); } 
			else if (this.ie) { 
				if (sProperty == "width") { sValue = eval(sDiv + ".offsetWidth"); } 
				else if (sProperty == "height") { sValue = eval(sDiv + ".offsetHeight"); } 
			}
		}
		sValue = (sValue == "") ? 0 : sValue; 
		if (isNaN(sValue)) { if (sValue.indexOf('px') > 0) { sValue = sValue.substring(0,sValue.indexOf('px')); } } 
		return parseInt(sValue); 
	}
	
	function flevPersistentLayer(){
		if (flevPersistentLayer.arguments.length < 7) {return;}
		// gather arguments
		var sDivID = arguments[0]; if (sDivID == "") {return;}
		var	docObj = eval("MM_findObj('" + sDivID + "')"); if (docObj == null) {return;}
		if (!document.layers) {docObj = docObj.style;} // not NS4.x 
		if (docObj.tmpTimeout != null) {clearTimeout(docObj.tmpTimeout);}
		var sXLeft = arguments[1], sXCenter = arguments[2], sXRight = arguments[3];
		var sYTop = arguments[4], sYCenter = arguments[5], sYBottom = arguments[6];
		var iSpeed = (arguments.length > 7) ? parseInt(arguments[7]) : 0;
		var iPx = (arguments.length > 8) ? parseInt(arguments[8]) : 0;
		var iTimeout = 10, sSuffix = "";
		// determine current document window size and scroll position
		var iWinWidth, iWinHeight, iScrollX, iScrollY;
		if (window.innerWidth) { // NS4, NS6 and Opera
			iWinWidth = window.innerWidth;
			iWinHeight = window.innerHeight;
			iScrollX = window.pageXOffset;
			iScrollY = window.pageYOffset;
			}
		else if (document.documentElement && document.documentElement.clientWidth) { // IE6 in standards compliant mode
			iWinWidth = document.documentElement.clientWidth; 
			iWinHeight = document.documentElement.clientHeight; 
			iScrollX = document.documentElement.scrollLeft;
			iScrollY = document.documentElement.scrollTop;
			}
		else if (document.body) { // IE4+
			iWinWidth = document.body.clientWidth; 
			iWinHeight = document.body.clientHeight; 
			iScrollX = document.body.scrollLeft;
			iScrollY = document.body.scrollTop;
			}
		else {return;}
		// determine current layer position
		var iCurX = iNewX = parseInt(docObj.left), iCurY = iNewY = parseInt(docObj.top);
		// calculate new X coordinate
		if (sXLeft != "") {iNewX = iScrollX + parseInt(sXLeft);}
		else if (sXCenter != "") {iNewX = Math.round(iScrollX + (iWinWidth/2) - (flevDivPositionValue(sDivID, 'width')/2));}
		else if (sXRight != "") {iNewX = iScrollX + iWinWidth - (flevDivPositionValue(sDivID, 'width') + parseInt(sXRight));}
		// calculate new Y coordinate
		if (sYTop != "") {iNewY = iScrollY + parseInt(sYTop);}
		else if (sYCenter != "") {iNewY = Math.round(iScrollY + (iWinHeight/2) - (flevDivPositionValue(sDivID, 'height')/2));}
		else if (sYBottom != "") {iNewY = iScrollY + (iWinHeight - flevDivPositionValue(sDivID, 'height') - parseInt(sYBottom));}
		// force persistency?
		if ((iCurX != iNewX) || (iCurY != iNewY)) {  // layer position needs to be adjusted
			if (iSpeed > 0) { // animated move
				if (iPx > 0) { // constant speed
					iTimeout = iSpeed;
					var iPxX = iPx, iPxY = iPx, iMoveX = Math.abs(iCurX - iNewX), iMoveY = Math.abs(iCurY - iNewY);
					// take care of diagonal movement
					if (iMoveX < iMoveY) {iPxY = (iMoveX != 0) ? ((iMoveY/iMoveX)*iPx) : iPx;}
					else {iPxX = (iMoveY != 0) ? ((iMoveX/iMoveY)*iPx) : iPx;}
					if (iPxX >= iMoveX) {iPxX = Math.min(Math.ceil(iPxX), iPx);}
					if (iPxY >= iMoveY) {iPxY = Math.min(Math.ceil(iPxY), iPx);}
					// calculate temporary X/Y coordinates
					if ((iCurX < iNewX) && (iCurX + iPxX < iNewX)) {iNewX = iCurX + iPxX;}
					if ((iCurX > iNewX) && (iCurX - iPxX > iNewX)) {iNewX = iCurX - iPxX;}
					if ((iCurY < iNewY) && (iCurY + iPxY < iNewY)) {iNewY = iCurY + iPxY;}
					if ((iCurY > iNewY) && (iCurY - iPxY > iNewY)) {iNewY = iCurY - iPxY;}
				}
				else { // gradually decreasing speed
					var iMoveX = ((iNewX - iCurX) / iSpeed); 
					iMoveX = (iMoveX > 0) ? Math.ceil(iMoveX) : Math.floor(iMoveX);
					iNewX = iCurX + iMoveX; 
					var iMoveY = ((iNewY - iCurY) / iSpeed); 
					iMoveY = (iMoveY > 0) ? Math.ceil(iMoveY) : Math.floor(iMoveY);
					iNewY = iCurY + iMoveY;
				}
			}
			// now actually move layer
			if ((parseInt(navigator.appVersion)>4 || navigator.userAgent.indexOf("MSIE")>-1) && (!window.opera)) {sSuffix="px";}
			if (iMoveX != 0) {eval("docObj.left = '" + iNewX + sSuffix + "'");}
			if (iMoveY != 0) {eval("docObj.top = '" + iNewY + sSuffix + "'");}
		}
		var sFunction = "flevPersistentLayer('" + sDivID + "','" + sXLeft + "','" + sXCenter + "','" + sXRight + "','" + sYTop + "','" + sYCenter + "','" + sYBottom + "'," + iSpeed + "," + iPx + ")";
		docObj.tmpTimeout = setTimeout(sFunction,1);
	}
	
	//							0		 1  2  3  4  5  6  7  8
	//flevInitPersistentLayer('fonction',0,'','','','','','0',3);
	
	function flevInitPersistentLayer() { // v3.0, Marja Ribbers-de Vroed, FlevOOware
		if (arguments.length < 8) {return;}
		// gather arguments
		var sDivID = arguments[0];
		if (sDivID == "") {return;}
		var	docObj = eval("MM_findObj('" + sDivID + "')");
		if (docObj == null) {return;}
		var iCSS = parseInt(arguments[1]);
		var sXLeft = arguments[2], sXCenter = arguments[3], sXRight = arguments[4];
		var sYTop = arguments[5], sYCenter = arguments[6], sYBottom = arguments[7];
		var iSpeed = (arguments.length > 8) ?parseInt(arguments[8]) : 0;
		var iPx = (arguments.length > 9) ? parseInt(arguments[9]) : 0;
		
		// Position according to CSS style?
		if (iCSS != 0)
		{ 	// maintain top/left position specified by CSS style
			if (!document.layers) {docObj = docObj.style;} // not NS4.x 
			sXLeft = parseInt(docObj.left)
			sYTop = parseInt(docObj.top);
		}
		var sFunction = "flevPersistentLayer('" + sDivID + "','" + sXLeft + "','" + sXCenter + "','" + sXRight + "','" + sYTop + "','" + sYCenter + "','" + sYBottom + "'," + iSpeed + "," + iPx + ")";
		
		if(!is_safari) eval(sFunction);
		else return
	}
	
	
	//validation du formulaire de contact
	
	function validateForm(form) {
	if (isNotEmpty(form.nom)) {
		if (isNotEmpty(form.prenom)) {
			if (isNotEmpty(form.adresse)) {
				if (isNotEmpty(form.ville)) {
					if (isNotEmpty(form.cp)) {
						if (isNotEmpty(form.message)) {
								if (isNotEmpty(form.eMail)) {
               	 					if (isEMailAddr(form.eMail)) {

							return true;
								}
							}
						}
					}
				}
			}
		}
	}
	return false;
}

// Vérifie si un champ a bien été renseigné
function isNotEmpty(elem) {
	var str = elem.value;
    var re = /.+/;
    if(!str.match(re)) {
        alert("Veuillez renseigner les champs obligatoires.");
        setTimeout("focusElement('" + elem.form.name + "', '" + elem.name + "')", 0);
        return false;
    } else {
        return true;
    }
}

// Vérifie si l'adresse e-mail est valide
function isEMailAddr(elem) {
	var str = elem.value;
    var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
    if (!str.match(re)) {
        alert("Veuillez vérifier le format de votre adresse e-mail.");
        setTimeout("focusElement('" + elem.form.name + "', '" + elem.name + "')", 0);
        return false;
    } else {
        return true;
    }
}

// Positionne le curseur dans un champ donné
function focusElement(formName, elemName) {
    var elem = document.forms[formName].elements[elemName];
    elem.focus();
    elem.select();
}
//Vérifie si un champ ne contient que des chiffres
function isNumber(elem) {
	var str = elem.value;
    var re = /^[-]?\d*\.?\d*$/;
    str = str.toString();
    if (!str.match(re)) {
        alert("Votre code postal ne doit contenir que des chiffres");
        setTimeout("focusElement('" + elem.form.name + "', '" + elem.name + "')", 0);
        return false;
    }
    return true;
}
	
	//validation du formulaire de contact
	
	
	
	/*---------------- Fonction pour le forum ---------------------*/
	
	function verif() {
	
	if (document.form.Proposition_de_forum.value=="" ) {
		alert("Saisissez votre proposition de forum");
		 }
	else { verif2(); }
}
function verif2() {
	if (document.form.Adresse_email.value=="" ) {
		alert("Saisissez votre adresse e-mail !"); 
		}
	else { verifmail(); }
}
function verifmail() {
	if (document.form.Adresse_email.value!="") {
		test_email(document.form.Adresse_email);
		return false; }
	else {document.form.submit();	}
}

function test_email(objet) {
	if (objet.value!="") {
 	 with (objet) {
    	apos=value.indexOf("@");
    	dotpos=value.lastIndexOf(".");
    	lastpos=value.length-1;
    	if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) {
		  document.form.Adresse_email.focus();
		  document.form.Adresse_email.select();
	   	  alert("L'e-mail indiqué est sans doute invalide.");
		   }
    	else {
    	  document.form.submit(); }
	  }
   }
}
/*---------------- Fonction pour le forum ---------------------*/

/*---------------- Fonction pour commander le catalogue ---------------------*/

function Formulaire(Url) {
        Javas = window.open (Url, "bergeredefrance","scrollbars=yes,tolbar=no,menubar=no,location=no,status=no,resizable=no,directories=no,width=690,height=600");
        Javas.focus();
}

/*---------------- Fonction pour commander le catalogue ---------------------*/
	
	
/*---------------- Fonction pour les pages commandes ---------------------*/

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);



function phare(option){
var visibilite;
//alert("option : "option);
if (option==0){
				visibilite="hidden";
				document.form.calque.value="0";
			  }
		  else{
				if(document.layers){
									visibilite="show";
									document.form.calque.value="1";
									}
								else{visibilite="visible";
									document.form.calque.value="1";
									}
			  }
//alert("visibilite : "visibilite);
if(document.all){
       			document.all.divWin0.style.visibility = visibilite;
       			}
			else{
				if(document.layers){
           							document.divWin0.visibility = visibilite;
           							}
    							else{
        							if(document.getElementById){
               													document.getElementById('divWin0').style.visibility = visibilite;
               													}
        							}
				}

}

function openWindow(file,tx,ty)
{
	myWindow= open(file, 'newWindow', 'width='+tx+',height='+ty+',menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no');
}


function ouvrir_fenetre(j)
{   
	param = "visuel.phtml?nom="+j;
	tempo='toolbar=no,location=no,directories=no,menubar=no,';
	tempo +='resizable=yes,status=no,titlebar=no,toolbar=no,';	
	tempo+='scrollbars=yes, width=360,height=390';	
	if (navigator.appName.indexOf("Microsoft")>=0) 
	{
		tempo+=',left=300,top=100';
	}
	else
	{
		tempo+=',screenX=300,screenY=100';
	}	
	flottant=open(param,"name",tempo);   
}
function verif()
{

	if (document.form.cb_bain.checked == true && document.form.quantite.value > 3)
	{
		// Test javascript pour la quantité max des pelotes en réassortiment
		//alert('La quantité maximum autorisée pour les réassortiments est de 3 pelotes.');
		//return false;
	}
	return true;
}
/*---------------- Fonction pour les pages commandes ---------------------*/
