// JavaScript Document

function __doPostBack(eventTarget, eventArgument) {
   if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
       theForm.__EVENTTARGET.value = eventTarget;
       theForm.__EVENTARGUMENT.value = eventArgument;
       theForm.submit();
	}
}

function litnombre(aChaineNombre)
{
	// retire les espaces les points et autres caractères différents des nombres
	var li=0;
	var lChaine=""+aChaineNombre;
	while (li<eval(lChaine.length))
	{
		if (lChaine.charCodeAt(li)<48 || lChaine.charCodeAt(li)>57)
		{
			lChaine=lChaine.substring(0,li)+lChaine.substring(li+1,lChaine.length);
			li--;
		}
		li++;
	}
	return lChaine;
}


function litnombreCompte(aChaineNombre)
{
	var li=0;
	var lNb;
	var lChaine=""+aChaineNombre;

	while (li<eval(lChaine.length))
	{
		if (lChaine.charCodeAt(li)<48 || lChaine.charCodeAt(li)>57)
		{
			if (lChaine.charCodeAt(li)>=65 || lChaine.charCodeAt(li)<=90)
			{
				lNb=lChaine.charCodeAt(li)-64;
				if (lNb>9)
				{
					lNb=lNb-9;
				}

				if (lNb>9)
				{
					lNb=lNb-8;
				}

				lChar=""+lNb;
				lChaine=lChaine.substring(0,li)+lChar+lChaine.substring(li+1,lChaine.length);
			}
			else
			{
				if (lChaine.charCodeAt(li)>=97 || lChaine.charCodeAt(li)<=122)
				{
					lNb=lChaine.charCodeAt(li)-96;
					if (lNb>9)
					{
						lNb=lNb-9;
					}

					if (lNb>9)
					{
						lNb=lNb-8;
					}
	
					lChar=""+lNb;
					lChaine=lChaine.substring(0,li)+lChar+lChaine.substring(li+1,lChaine.length);
				}
				else
				{	
					// on retire le caractère indésirable
					lChaine=lChaine.substring(0,li)+lChaine.substring(li+1,lChaine.length);
					li--;
				}
			}
		}

		li++;
	}
	return lChaine;
}

function litnombreIBAN(aChaineNombre)
{
	// retire les espaces les points et autres caractères différents des nombres
	// pour les lettres A à Z, remplacement par un nombre :
	// A remplacé par 10 ... Z remplacé par 35
	var li=0;
	var lNb;
	var lChaine=""+aChaineNombre;
	var lChaineRes="";

	while (li<eval(lChaine.length))
	{
		if (lChaine.charCodeAt(li)<48 || lChaine.charCodeAt(li)>57)
		{
			if (lChaine.charCodeAt(li)>=65 || lChaine.charCodeAt(li)<=90)
			{
				lNb=lChaine.charCodeAt(li)-55;

				lChar=""+lNb;
				lChaineRes=lChaineRes+lChar;
			}
			else
			{
				if (lChaine.charCodeAt(li)>=97 || lChaine.charCodeAt(li)<=122)
				{
					lNb=lChaine.charCodeAt(li)-87;
					lChar=""+lNb;
					lChaineRes=lChaineRes+lChar;
				}
				else
				{	
					// on retire le caractère indésirable
				}
			}
		}
		else
		{
			lChaineRes=lChaineRes+lChaine.substring(li,li+1);
		}
		li++;
	}
	return lChaineRes;
}

function fCalcRib(aCodeBanque, aCodeGuichet, aNoCompte)
{
	var lCodeBanque, lCodeGuichet, lNoCompte;
	var lint ;
	var lCompteNum;
	var lCompteStr;
	var lA,	lB, lC, lD, lE, lF, lG, lH, lI, lLength, lLoop,	lAsc, lNb;

	// retire les espaces les points et autres caractères différents des nombres
	lCodeBanque=litnombre(aCodeBanque);
	lCodeGuichet=litnombre(aCodeGuichet);
	lNoCompte=litnombreCompte(aNoCompte);

	if (lCodeBanque.length!=5)
	{
		return 0;
	}

	if (lCodeGuichet.length!=5)
	{
		return 0;
	}

	if (lNoCompte.length>11)
	{
		return 0;
	}

	lA=parseFloat(lCodeBanque);
	lB=parseFloat(lCodeGuichet);
	lC=parseFloat(lNoCompte);

	lD=8*lA;

	lA=lD % 97;

	lE=15*lB;
	lB=97-(lE % 97);
	lF=3*lC;
	lC=97-(lF % 97);
	lG=lA+lB+lC;
	lI=lG % 97;

	if (lI==0)
	{
		return 97;
	}
	else
	{
		return lI;
	}
}

function fCalcIBAN(acodepays, aRIB)
{

	var lcodepays, lRIB, lConcat, lNb, lIBAN, lCodeNum, lCodeStr, li, lRetenue, lCle, lNbInterm, lStrInterm;

	lRIB=litnombreIBAN(aRIB);
	lcodepays=litnombreIBAN(acodepays);

	if ((acodepays.length!=2) || (lcodepays.length!=4))
	{
		return "";
	}

	lConcat=lRIB+lcodepays+"00";
	
	// découpage par bloc de 9 chiffres pour calculer le modulo (pb de précision)
	li=0;
	lRetenue="";
	while (li<eval(lConcat.length))
	{
		lStrInterm=lRetenue+lConcat.substring(li, li+9);
		lNbInterm=parseFloat(lStrInterm);
		lCle=lStrInterm % 97;
		lRetenue=""+lCle;
		
		li=li+9;
	}

	lCodeNum=98-(lCle % 97);

	if (lCodeNum<10)
	{
		lCodeStr="0"+lCodeNum;
	}
	else
	{
		lCodeStr=""+lCodeNum;
	}
	
	lIBAN=acodepays+lCodeStr+aRIB;


	return lIBAN;

}

function fCopierRib(aCodeBanque, aCodeGuichet, aNoCompte, aCleRib)
{
	var lCodeBanque, lCodeGuichet, lNoCompte, lCleRib, lCodeStr, lRib, lNbCleRib;

	lCodeBanque=litnombre(aCodeBanque);
	lCodeGuichet=litnombre(aCodeGuichet);
	lNoCompte=aNoCompte;
	lCleRib=litnombre(aCleRib);


	if (lCodeBanque.length!=5)
	{
		return 0;
	}

	if (lCodeGuichet.length!=5)
	{
		return 0;
	}

	if (lNoCompte.length!=11)
	{
		return 0;
	}
	
        if ((lCleRib.length>2)||(lCleRib.length==0))
	{
		return 0;
	}

	lNbCleRib=parseFloat(lCleRib) % 100;

        if ((lNbCleRib<1) || (lNbCleRib>97))
	{
		return 0;
	}

	if (lCleRib<10)
	{
		lCodeStr="0"+lNbCleRib;
	}
	else
	{
		lCodeStr=""+lNbCleRib;
	}

	lRib=lCodeBanque+lCodeGuichet+lNoCompte+lCodeStr;

	return lRib;
}

function cliqueaffiliation()
	{
	document.rib.clerib.value=fCalcRib(document.rib.codebanque.value, document.rib.codeguichet.value, document.rib.nocompte.value) ;
	document.rib.submit() ;
	}

function arrondir(nombre, decimales) {
	if (isNaN(nombre)) 
		return "";
	if (decimales == 0)  {
		var n = Math.round(nombre);
		return n.toString();
		}
	else if (decimales > 0)  {
		if (document.all) 
			var undefined; // Netscape 4 ne connaît pas la constante undefined
		var p10 = Math.pow(10, decimales);
		var n = Math.round(nombre * p10);
		n = n.toString();
		var point = n.length - decimales;
		if (point > 0) {
			n = n.substring(0, point) + "," + n.substring(point);
			}
		else { 
			n = "0," + n.toString() ;
			if (n.length == 3)
				n = n.toString() + '0' ;
			}
		}
	else  {
		var p10 = Math.pow(10, -decimales);
		var n = Math.round(nombre / p10) * p10;
		n = n.toString();
		}
	if (nombre.signe_decimal == undefined) 
		return n;
	else 
		return n.replace(".", nombre.signe_decimal);
	}	




function recommander(article)
	{
	window.open ('recommander.php?artid='+article+'', 'Recommander', 'Width=600, Height=450, toolbar=no, directories=no, location=no, menubar=no, resizable=no, scrollbars=no, status=no') ;
	}

function recommander2(article)
	{
	window.open ('recommander2.php?artid='+article+'', 'Recommander', 'Width=600, Height=450, toolbar=no, directories=no, location=no, menubar=no, resizable=no, scrollbars=no, status=no') ;
	}

function recommander3(diamant)
	{
	window.open ('recommander3.php?diamant='+diamant+'', 'Recommander', 'Width=600, Height=450, toolbar=no, directories=no, location=no, menubar=no, resizable=no, scrollbars=no, status=no') ;
	}

function imprimer(article)
	{
	window.open ('imprimer.php?artid='+article+'', 'Impression', 'Width=800, Height=600, toolbar=no, directories=no, location=no, menubar=no, resizable=no, scrollbars=yes, status=no') ;
	}

function imprimercommande() {
	window.open ('imprimercommande.php', 'Impression', 'Width=800, Height=600, toolbar=no, directories=no, location=no, menubar=no, resizable=no, scrollbars=yes, status=no') ;
	}



function agrandir(article, largeur, hauteur, photoid)
	{
	/*var newlargeur = largeur * 4 ;
	var newhauteur = hauteur * 2 ;*/
	var newlargeur = 750 ;
	var newhauteur = 700 ;
	if (photoid != '0')
		{
		window.open ('photos.php?artid='+article+'&articlephotoid='+photoid+'', 'Photos', 'Width='+newlargeur+', Height='+newhauteur+', toolbar=no, directories=no, location=no, menubar=no, resizable=no, scrollbars=no, status=no') ;
		}
	else
		{
		window.open ('photos.php?artid='+article+'', 'Photos', 'Width='+newlargeur+', Height='+newhauteur+', toolbar=no, directories=no, location=no, menubar=no, resizable=no, scrollbars=no, status=no') ;
		}
	}


function agrandir2(article, largeur, hauteur, photoid)
	{
	/*var newlargeur = largeur * 4 ;
	var newhauteur = hauteur * 2 ;*/
	var newlargeur = 750 ;
	var newhauteur = 700 ;
	if (photoid != '0')
		{
		window.open ('photos2.php?artid='+article+'&articlephotoid='+photoid+'', 'Photos', 'Width='+newlargeur+', Height='+newhauteur+', toolbar=no, directories=no, location=no, menubar=no, resizable=no, scrollbars=no, status=no') ;
		}
	else
		{
		window.open ('photos2.php?artid='+article+'', 'Photos', 'Width='+newlargeur+', Height='+newhauteur+', toolbar=no, directories=no, location=no, menubar=no, resizable=no, scrollbars=no, status=no') ;
		}
	}


function zoom(diamant) {
	window.open ('photos3.php?diamant='+diamant+'', 'Photos', 'Width=400, Height=400, toolbar=no, directories=no, location=no, menubar=no, resizable=no, scrollbars=no, status=no') ;
	}
function mesures1(diamant) {
	window.open ('photos3.php?mesures=1&diamant='+diamant+'', 'Photos', 'Width=300, Height=300, toolbar=no, directories=no, location=no, menubar=no, resizable=no, scrollbars=no, status=no') ;
	}
function mesures2(diamant) {
	window.open ('photos3.php?mesures=2&diamant='+diamant+'', 'Photos', 'Width=300, Height=300, toolbar=no, directories=no, location=no, menubar=no, resizable=no, scrollbars=no, status=no') ;
	}

function agrandirannonce(annonce, photoid)
	{
	var newlargeur = 700 ;
	var newhauteur = 650 ;
	window.open ('photos.php?annonce='+annonce+'&photosup='+photoid, 'Photos', 'Width='+newlargeur+', Height='+newhauteur+', toolbar=no, directories=no, location=no, menubar=no, resizable=no, scrollbars=no, status=no') ;
	}


function recalculer() 
	{
	document.formu.submit();
	}

function etape2() 
	{
	document.formu.action='cde2.php';
	document.formu.submit();
	}

function enregistrer() 
	{
	document.formu.action2.value = '';
	document.formu.taction.value = 'carte';
	document.formu.submit();
	}




function ferme(menu) 
	 {
	 document.getElementById(menu).style.display='none';
	 }

function ouvre(afermer, menu) 
	 {
	 if (afermer != '')
		{
		ferme(afermer) ;
		}
	 document.getElementById(menu).style.display='block';
	 }


function voir(article) 
	 {
	 document.getElementById(article).style.display = 'block';
	 }

function cacher(article) 
	 {
	 document.getElementById(article).style.display = 'none';
	 }



function MM_preloadImages() 
		{
		var d=document ;
		if (d.images)
			{
			if (!d.MM_p)
				d.MM_p=new Array();
			var i, j = d.MM_p.length, a = MM_preloadImages.arguments ;
			for (i = 0 ; i < a.length ; i++)
			if (a[i].indexOf("#") != 0)
				{
				d.MM_p[j] = new Image ; 
				d.MM_p[j++].src = a[i] ;
				}
			}	
		}

function changeImgAnnonce(srcImg)
	{
	document.getElementById('diapo').innerHTML = '<img src='+srcImg+' id=big style=\'border:solid 1px black;\'>';
	}	

function changeImgAnnonce2(srcImg)
	{
	document.getElementById('big').src = srcImg ;
	}	

function toggle(id,p)
	{
	var myChild = document.getElementById(id);
	if(myChild.style.display!='block')
		{
		myChild.style.display='block';
		document.getElementById(p).className='folderOpen';
		}
	else
		{
		myChild.style.display='none';
		document.getElementById(p).className='folder';
		}
	}
function vider(objet)
	{
	if (objet.value == "recherche" || objet.value == "Adresse mail" || objet.value == "passe" || objet.value == "Votre e-mail" || objet.value == "Mot de passe")
		{
		objet.value = "" ;
		}
	}

function clignotement()
	{
    if (document.getElementById("MonElement").style.display=="block")
       document.getElementById("MonElement").style.display="none";
    else
       document.getElementById("MonElement").style.display="block";
	}


function affiche(id) 
	{
	var d = document.getElementById(id);
	if (d) 
		{
		d.style.display='block';
		}
	SelectVisible("hidden",document.getElementsByTagName('select'));
	}
	
function cache(id) 
	{
	var d = document.getElementById(id);
	if (d) 
		{
		d.style.display='none';
		}
	SelectVisible("visible",document.getElementsByTagName('select'));
	}

function SelectVisible(v,elem) 
	{
	if (navigator.appName=="Microsoft Internet Explorer" && typeof document.body.style.maxHeight == "undefined")
		{
		for (var i=0;i<elem.length;i++) 
			elem[i].style.visibility=v;
		}
	}


function poplink(id)
	{
	 document.getElementById(id).style.display = 'block';
	}

function killlink(id)
	{
	 document.getElementById(id).style.display = 'none';
	}

function explication()
	{
	window.open ('explication.php', 'Paiement', 'Width='+'350'+', Height='+'150'+', toolbar=no, directories=no, location=no, menubar=no, resizable=no, scrollbars=no, status=no') ;
	}

function reserver(article)
	{
	window.open ('reserver.php?artid='+article, 'Réserver', 'Width='+'540'+', Height='+'500'+', toolbar=no, directories=no, location=no, menubar=no, resizable=no, scrollbars=no, status=no') ;
	}

function orange(id)
	{
//    alert('couleur de fond : '+document.getElementById(id).style.background) ;
    document.getElementById(id).style.background = "#F9DEC6" ;
	}

function blanc(id)
	{
    document.getElementById(id).style.background = "#FFFFFF" ;
	}

function afficheobject(nom_piece)
	{
	document.write('<object id="objMP" width="353" height="291" ');
	document.write('classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95" ');
	document.write('codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6.4.7.1112"');
	document.write('standby="Chargement en cours" type="application/x-oleobject">');
	document.write('<param name="Filename" value="http://www.leclerc-pierry.com/configurations/www.leclerc-pierry.com/images/player/pieces_jointes/'+nom_piece+'" />');
	document.write('<param name="AnimationAtStart" value="false" />');
	document.write('<param name="AutoSize" value="false" />');
	document.write('<param name="AutoStart" value="true" />');
	document.write('<param name="Balance" value="0" />');
	document.write('<param name="CanSeekToMarkers" value="true" />   ');
	document.write('<param name="EnableContextMenu" value="false" />');
	document.write('<param name="EnableTracker" value="true" />   ');
	document.write('<param name="Loop" value="false" />');
	document.write('<param name="ShowAudioControls" value="true" />');
	document.write('<param name="ShowControls" value="true" />');
	document.write('<param name="ShowDisplay" value="false" />');
	document.write('<param name="ShowGotoBar" value="false" />');
	document.write('<param name="ShowPositionControls" value="false" />');
	document.write('<param name="ShowStatusBar" value="true" />');
	document.write('<param name="ShowTracker" value="true" />');
	document.write('<param name="TransparentAtStart" value="true" />');
	document.write('<param name="Volume" value="-500" />');
	document.write('<param name="wmode" value="transparent">');
	document.write('<param name="quality" value="high">');
	document.write('<param name="bgcolor" value="#FFFFFF">');
	document.write('<embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" ');
	document.write('src="http://www.leclerc-pierry.com/configurations/www.leclerc-pierry.com/images/player/pieces_jointes/'+nom_piece+'" id="objMP" width="353" height="291" ');
	document.write('animationatstart="false" autosize="false"');
	document.write('autostart="false" balance="false" canseektomarkers="true" enablecontextmenu="false" enabletracker="true" loop="false"'); 
	document.write('showaudiocontrols="true" showcontrols="true" showdisplay="false" showgotobar="false" showpositioncontrols="false" ');
	document.write('showstatusBar="true"');
	document.write('showtracker="true" transparentatstart="true" volume="-500" quality="high" wmode="transparent" bgcolor="#FFFFFF"></embed>');
	document.write('</object>');
	}

function SetCookieM(c_name,value,expiredays) {
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+ ( (expiredays==null) ? "" : ";expires="+exdate);
}


function GetCookie(c_name) {
	if (document.cookie.length>0){
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1) { 
			c_start=c_start + c_name.length+1 ;
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) {
				c_end=document.cookie.length;
			}
			return unescape(document.cookie.substring(c_start,c_end))
		} 
	}
	return null
} 


var TSpider = new Array("googlebot", "architextspider", "scooter", "infoseek", "ultraseek", "lycos_spider", "gulliver", "fast-webcrawler", "slurp");
function Spiders() {
	var Retour, i, Signature;
	Signature = navigator.userAgent.toLowerCase();
	for(i=0;(i<TSpider.length && !Retour);i++)
		Retour = (Signature.indexOf(TSpider[i]) > 0);
	return(Retour);
}
function CookieOn()
{
	SetCookieM("TestCookie", 123, 1);
	return (GetCookie("TestCookie")==123);
}


function entrer()
	{
	Rang = 1;
	SetCookieM("majorite", Rang, 1);
	Rang = GetCookie("majorite");
	var prov = document.formu.prov.value ;
	var id = document.formu.id.value ;
	var lib = document.formu.lib.value ;
	location.href = prov+','+id+','+lib+'.htm' ;
	}
	
function sortir()
	{
	location.href = 'index.htm' ;
	}

function ajoute1()
	{
	var qte = parseFloat(document.getElementById('qte').value) ;
	qte = qte + 1 ;
	document.getElementById('qte').value = qte ; 
	}

function enleve1()
	{
	var qte = parseFloat(document.getElementById('qte').value) ;
	if (qte > 1)
		{
		qte = qte - 1 ;
		document.getElementById('qte').value = qte ; 
		}
	}
	
function reserver(article)
	{
	window.open ('reserver.php?artid='+article, 'Réserver', 'Width='+'540'+', Height='+'400'+', toolbar=no, directories=no, location=no, menubar=no, resizable=no, scrollbars=no, status=no') ;
	}

function initialise_tree()
	{
	
	var liste = document.getElementById('liste_catids').value;
	var montableau = liste.split(',');
	var x;
	for (x=1; x<montableau.length; x++) 
		{
		var id = 'C'+montableau[x];
		document.getElementById(id).style.display = 'none';
		}
	}

function GetId(id)
	{
		//alert('ok'+id);
	return document.getElementById(id);
	}
var i=false; // La variable i nous dit si la bulle est visible ou non

function move(e) 
	{
	if(i) 
		{  // Si la bulle est visible, on calcul en temps reel sa position ideale
		if (navigator.appName!="Microsoft Internet Explorer") 
			{ // Si on est pas sous IE
			GetId("curseur").style.left=e.pageX + 10+"px";
			GetId("curseur").style.top=e.pageY - 50+"px";
			}
		else 
			{
			if(document.documentElement.clientWidth>0) 
				{
					//alert('ok'+);
				GetId("curseur").style.left=-100+event.x+document.documentElement.scrollLeft+"px";
				GetId("curseur").style.top=10+event.y+document.documentElement.scrollTop+"px";
				}
			else 
				{
			GetId("curseur").style.left=-100+event.x+document.body.scrollLeft+"px";
			GetId("curseur").style.top=10+event.y+document.body.scrollTop+"px";
			}
			}
		}
	}

function montre(text) 
	{
	if(i==false) 
		{
		GetId("curseur").style.visibility="visible";
		GetId("curseur").innerHTML = '<div class=poplink_h></div><div class=poplink_m><div class=poplink_mh>'+text+'</div><div class=poplink_mb></div></div><div class=poplink_b></div>'; // Cette fonction est a améliorer, il parait qu'elle n'est pas valide (mais elle marche)
		i=true;
		}
	}

function cachej() 
	{
	if(i==true) 
		{
		GetId("curseur").style.visibility="hidden";
		i=false;
		}
	}

function bonachat(id,mtt)
	{
	var checkid = 'chk['+id+']' ;
	var inputid = 'input['+id+']' ;
	var totaln = document.getElementById('totaln').value ;
	var reg1=new RegExp("[.]","g");
	if (document.getElementById(checkid).checked == true)
		{
		mtt2 = mtt ;
		if (mtt2.match(reg1))
			mtt2 = mtt2.replace('.', ',');
		else
			mtt2 = mtt2+',00';
		document.getElementById(inputid).value = mtt2 ;
		var nouveautotal = parseFloat(totaln)-parseFloat(mtt) ;
		if (document.getElementById('cadeau'))
			nouveautotal = parseFloat(nouveautotal) - parseFloat(document.getElementById('cadeau').value) ;
		if (nouveautotal < 0)
			nouveautotal = 0 ;
		document.getElementById('totaln').value = nouveautotal ;
		nouveautotal = String(nouveautotal);
		if (nouveautotal.match(reg1))
			nouveautotal = nouveautotal.replace('.', ',');
		else
			nouveautotal = nouveautotal+',00';
		document.getElementById('total').value = nouveautotal ;
		}
	else
		{
		document.getElementById(inputid).value = '0,00' ;
		var totalarts = 0 ;
		var tabarticles = document.getElementsByName('prixarticle') ;
		for (i = 0 ; i < tabarticles.length ; i++) {
			totalarts += parseFloat(tabarticles[i].value);
			}
		var totalbons = 0 ;
		var identifiant = new RegExp('input', "g");
		mesInput = document.getElementsByTagName("input");
		for (var i=0; i<mesInput.length; i++) {
			var libelle = mesInput[i].id;
			if (libelle.match(identifiant))
				totalbons += parseFloat(mesInput[i].value);
			}
		var nouveautotal = parseFloat(totalarts) - parseFloat(totalbons);
		if (document.getElementById('cadeau'))
			nouveautotal = parseFloat(nouveautotal) - parseFloat(document.getElementById('cadeau').value) ;
		if (nouveautotal < 0)
			nouveautotal = 0 ;
		document.getElementById('totaln').value = nouveautotal ;
		nouveautotal = String(nouveautotal);
		if (nouveautotal.match(reg1))
			nouveautotal = nouveautotal.replace('.', ',');
		else
			nouveautotal = nouveautotal+',00';
		document.getElementById('total').value = nouveautotal ;
		}
	}

function codereduc(id,mtt)
	{
	var checkid = 'chk2['+id+']' ;
	var inputid = 'input2['+id+']' ;
	var totaln = document.getElementById('totaln').value ;
	var reg1=new RegExp("[.]","g");
	if (document.getElementById(checkid).checked == true)
		{
		mtt2 = mtt ;
		if (mtt2.match(reg1))
			mtt2 = mtt2.replace('.', ',');
		else
			mtt2 = mtt2+',00';
		document.getElementById(inputid).value = mtt2 ;
		var nouveautotal = parseFloat(totaln)-parseFloat(mtt) ;
		/*if (document.getElementById('cadeau'))
			nouveautotal = parseFloat(nouveautotal) - parseFloat(document.getElementById('cadeau').value) ;*/
		if (nouveautotal < 0)
			nouveautotal = 0 ;
		document.getElementById('totaln').value = nouveautotal ;
		nouveautotal = String(nouveautotal);
		if (nouveautotal.match(reg1))
			nouveautotal = nouveautotal.replace('.', ',');
		else
			nouveautotal = nouveautotal+',00';
		document.getElementById('total').value = nouveautotal ;
		}
	else
		{
		document.getElementById(inputid).value = '0,00' ;
		var totalarts = 0 ;
		var tabarticles = document.getElementsByName('prixarticle') ;
		for (i = 0 ; i < tabarticles.length ; i++) {
			totalarts += parseFloat(tabarticles[i].value);
			}
		var totalbons = 0 ;
		var identifiant = new RegExp('input', "g");
		mesInput = document.getElementsByTagName("input");
		for (var i=0; i<mesInput.length; i++) {
			var libelle = mesInput[i].id;
			if (libelle.match(identifiant))
				totalbons += parseFloat(mesInput[i].value);
			}
		var nouveautotal = parseFloat(totalarts) - parseFloat(totalbons);
		if (document.getElementById('cadeau'))
			nouveautotal = parseFloat(nouveautotal) - parseFloat(document.getElementById('cadeau').value) ;
		if (nouveautotal < 0)
			nouveautotal = 0 ;
		document.getElementById('totaln').value = nouveautotal ;
		nouveautotal = String(nouveautotal);
		if (nouveautotal.match(reg1))
			nouveautotal = nouveautotal.replace('.', ',');
		else
			nouveautotal = nouveautotal+',00';
		document.getElementById('total').value = nouveautotal ;
		}
	}

function choixreglement(moyenid)
	{
	document.paiement.moyenid.value = moyenid ;
	document.paiement.submit() ;
	}

function comparer(nb) {
	var cochee = 0 ;
	for (var i=1; i <= nb; i++) 
		{ 
		if (document.getElementById(i).checked == true)
			cochee++ ;
		}
	if (cochee > 1) 
		document.formucompare.submit();
	else
		alert('Vous devez sélectionner au moins deux diamants à comparer.');
	}


function new_position_prix(mini, maxi) {
//	doRequest('prixaccueil', 'mini', 'maxi');
	onchange_prix(mini, maxi);
}


function onchange_prix(mini, maxi) {
	document.getElementById("prix_min").value = mini ;
	document.getElementById("prix_max").value = maxi ;
	
	var prixmini = mini ;
	var prixmaxi = maxi ;
	var valeurprixaccueilmini = document.getElementById("valeurprixaccueilmini").value ;
	var valeurprixaccueilmaxi = document.getElementById("valeurprixaccueilmaxi").value ;
	maxlogaccueil(prixmini, prixmaxi, valeurprixaccueilmini, valeurprixaccueilmaxi);
}


function separeMilliers (sNombre) {
		separateurMilliers=" ";
		var sRetour = "";
		while (sNombre.length % 3 != 0) {
			sNombre = "0"+sNombre;
		}
		for (i = 0; i < sNombre.length; i += 3) {
			if (i ==  sNombre.length-1) separateurMilliers = '';
			sRetour += sNombre.substr(i, 3)+separateurMilliers;
		}
		while (sRetour.substr(0, 1) == "0") {
			sRetour = sRetour.substr(1);
		}
		return sRetour.substr(0, sRetour.lastIndexOf(separateurMilliers));
	}



function maxlogaccueil(prixmini, prixmaxi, valeurprixmini, valeurprixmaxi) {
	longueur = 109 ;
	
	largeurlog = custLog(valeurprixmaxi,10) - custLog(valeurprixmini,10) ;
	tmpprix1 = ((prixmini * largeurlog) / longueur) + custLog(valeurprixmini,10) ;
	prix1 = Math.floor(Math.pow(10,tmpprix1));
	tmpprix2 = ((prixmaxi * largeurlog) / longueur) + custLog(valeurprixmini,10) ;
	prix2 = Math.ceil(Math.pow(10,tmpprix2));
	prix1=separeMilliers(prix1);
	prix2=separeMilliers(prix2);
	document.getElementById("resultats").value = "de " + prix1 + " à " + prix2 + " €" ;
}




function onchange_carat(mini, maxi) {
	document.getElementById("carat_min").value = mini ;
	document.getElementById("carat_max").value = maxi ;
	var caratmini = mini ;
	var caratmaxi = maxi ;
	var prixmini = document.getElementById("prix_min2").value ;
	var prixmaxi = document.getElementById("prix_max2").value ;
	var valeurcaratmini = document.getElementById("valeurcaratmini").value ;
	var valeurcaratmaxi = document.getElementById("valeurcaratmaxi").value ;
	var valeurprixmini = document.getElementById("valeurprixmini").value ;
	var valeurprixmaxi = document.getElementById("valeurprixmaxi").value ;
	maxlog(caratmini, caratmaxi, prixmini, prixmaxi, valeurcaratmini, valeurcaratmaxi, valeurprixmini, valeurprixmaxi);
}
function onchange_prix2(mini, maxi) {
	document.getElementById("prix_min2").value = mini ; 
	document.getElementById("prix_max2").value = maxi ;  
	var caratmini = document.getElementById("carat_min").value ;
	var caratmaxi = document.getElementById("carat_max").value ;
	var prixmini = mini ;
	var prixmaxi = maxi ;
	var valeurcaratmini = document.getElementById("valeurcaratmini").value ;
	var valeurcaratmaxi = document.getElementById("valeurcaratmaxi").value ;
	var valeurprixmini = document.getElementById("valeurprixmini").value ;
	var valeurprixmaxi = document.getElementById("valeurprixmaxi").value ;
	maxlog(caratmini, caratmaxi, prixmini, prixmaxi, valeurcaratmini, valeurcaratmaxi, valeurprixmini, valeurprixmaxi);
}

function custLog(x,base) {
	return (Math.log(x))/(Math.log(base));
}



function maxlog(caratmini, caratmaxi, prixmini, prixmaxi, valeurcaratmini, valeurcaratmaxi, valeurprixmini, valeurprixmaxi) {
	longueur = 50 ;
	
	largeurlog = custLog(valeurcaratmaxi,10) - custLog(valeurcaratmini,10) ;
	tmpcarat1 = ((caratmini * largeurlog) / longueur) + custLog(valeurcaratmini,10) ;
	carat1 = Math.pow(10,tmpcarat1);
	tmpcarat2 = ((caratmaxi * largeurlog) / longueur) + custLog(valeurcaratmini,10) ;
	carat2 = Math.pow(10,tmpcarat2);
	document.getElementById("valcaratmin").value = arrondir(carat1,2);
	document.getElementById("valcaratmax").value = arrondir(carat2,2);
	
	largeurlog = custLog(valeurprixmaxi,10) - custLog(valeurprixmini,10) ;
	tmpprix1 = ((prixmini * largeurlog) / longueur) + custLog(valeurprixmini,10) ;
	prix1 = Math.floor(Math.pow(10,tmpprix1));
	tmpprix2 = ((prixmaxi * largeurlog) / longueur) + custLog(valeurprixmini,10) ;
	prix2 = Math.ceil(Math.pow(10,tmpprix2));
	document.getElementById("valprixmin").value = separeMilliers(prix1);
	document.getElementById("valprixmax").value = separeMilliers(prix2);
}




function new_position_carat(mini, maxi) {doRequest('carat', 'mini', 'maxi');}

function new_position_prix2(mini, maxi) {doRequest('prix2', 'mini', 'maxi');}

function new_position_taille(mini, maxi) {doRequest('taille', 'mini', 'maxi'); }
function onchange_taille(mini, maxi) {document.getElementById("taille_min").value = mini ; document.getElementById("taille_max").value = maxi ; }

function new_position_couleur(mini, maxi) {doRequest('couleur', 'mini', 'maxi');}
function onchange_couleur(mini, maxi) {document.getElementById("couleur_min").value = mini ; document.getElementById("couleur_max").value = maxi ; }

function new_position_purete(mini, maxi) {doRequest('purete', 'mini', 'maxi');}
function onchange_purete(mini, maxi) {document.getElementById("purete_min").value = mini ; document.getElementById("purete_max").value = maxi ;}



function enlevediamant(id) {
	document.getElementById('input_'+id).name = '';
	document.formcompare.submit();
	}

function doRequest_check(id, valeur) {
	if (document.getElementById(id).value == 'on')
		document.getElementById(id).value = 'off' ;
	else
		document.getElementById(id).value = 'on' ;
	var mini = document.getElementById("couleur_min").value ;
	var maxi = document.getElementById("couleur_max").value ;

	doRequest('couleur', mini, maxi);
	}

function choisiforme(id) {
	var macheckbox = document.getElementById('listeforme['+id+']') ;
	if (macheckbox.checked)
		document.getElementById('checked['+id+']').value = '1' ;
	else
		document.getElementById('checked['+id+']').value = '0' ;
	doRequest('couleur', document.getElementById("couleur_min").value, document.getElementById("couleur_max").value)
	}
	
	
function afficherimageforme(option) {
	document.getElementById('diamantformeimg').style.display='block'
	/*affiche('imgforme'+option);*/
	}
		
function cacherimageforme(option) {
	document.getElementById('diamantformeimg').style.display='none'
	/*cache('imgforme'+option);*/
	}


function affichecache(id) {
    if (document.getElementById(id).style.display == "block")
       document.getElementById(id).style.display = "none" ;
    else
       document.getElementById(id).style.display = "block" ;
	}

function valide_soumet(form, id, message) {
    if (document.getElementById(id).checked)
       document.forms[form].submit() ;
	else
		alert(message);
	}

function verif(limite, id) {
	var length = document.getElementById(id).value.length;
	document.getElementById("cpt"+id).value = limite - length ;
	if (length > limite)
		document.getElementById(id).value = document.getElementById(id).value.substring(0, limite);
	else
		return true;
	} 


function clignotement(id) {
    if (document.getElementById(id).style.display == "block")
       document.getElementById(id).style.display = "none" ;
    else
       document.getElementById(id).style.display = "block" ;
	}

function popupcalc(montant){
var win2 = window.open("http://www.receiveandpay.com/wallet/customer/calculette.php?MerchantID=9198&Amount="+montant ,'popup','height=503,width=600,status=yes,scrollbars=yes,menubar=no,resizable=yes');
	}

	
function init_accordion()
{
	//create Accordion instance
//	var stretchers = document.getElementsByClassName('acc_ssmenu');
//	var toggles = document.getElementsByClassName('acc_menu');
//	var myAccordion = new Fx.Accordion(toggles, stretchers, {trigger:'mouseOver', opacity: true, duration: 400});

$(".rubriqueinfo").accordion({ header: ".acc_menu", event: "mouseover", navigation:true, autoHeight:true });

}

function launch_prehome()
{
	if (swfobject.hasFlashPlayerVersion("6")) 
	{
		//
//		document.getElementById("presentation_catalogue").style.display='none';
		if (document.getElementById("presentation_catalogue"))
			swfobject.removeSWF("anim_catalogue");


		// check if SWF hasn't been removed, if this is the case, create a new alternative content container
		var c = document.getElementById("precarr");
		if (!c) {
			var d = document.createElement("div");
			d.setAttribute("id", "precarr");
			document.getElementById("carroussel").appendChild(d);
		}
		// create SWF
		var att = { data:"/configurations/"+host+"/images/templates/carroussel/pre_carr.swf", width:"980", height:"470", wmode:"transparent"};
		var par = { menu:"false", wmode:"transparent" };
		var id = "precarr";
		swfobject.createSWF(att, par, id);

	
	}
}

function stop_prehome()
{

		swfobject.removeSWF("precarr");

		if (document.getElementById("presentation_catalogue"))
		{
			// check if SWF hasn't been removed, if this is the case, create a new alternative content container
			var c = document.getElementById("anim_catalogue");
			if (!c) {
				var d = document.createElement("div");
				d.setAttribute("id", "anim_catalogue");
				document.getElementById("presentation_catalogue").appendChild(d);
			}
			// create SWF
			var att = { data:"/configurations/"+host+"/images/templates/catalogue.swf", width:"582", height:"185", wmode:"transparent"};
			var par = { menu:"false", wmode:"transparent" };
			var id = "anim_catalogue";
			swfobject.createSWF(att, par, id);
		}



		// create SWF
		var att = { data:"/configurations/"+host+"/images/templates/carroussel/launcher.swf", width:"980", height:"130", wmode:"transparent"};
		var par = { menu:"false", wmode:"transparent" };
		var id = "launcher";
		swfobject.createSWF(att, par, id);

}



function submitCadeau() {
	document.formcde.action='cde2.php';
	document.formcde.action3.value='cadeau';
	document.formcde.submit();
	}