// JavaScript Document
function __doPostBack(eventTarget, eventArgument) {
   if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
       theForm.__EVENTTARGET.value = eventTarget;
       theForm.__EVENTARGUMENT.value = eventArgument;
       theForm.submit();
	}
}

function convert(prixeuro){
	var prixdollar = Math.round(parseFloat(prixeuro) * parseFloat(dollar)) ;
	return (prixdollar);

}



function IsNumeric(sText){
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

   for (i = 0; i < sText.length && IsNumber == true; i++){ 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) {
         IsNumber = false;
      }
   }
   return IsNumber;  
}


//Retourne la valeur du select "selectId"
function getSelectValue(selectId){  
    var selectElmt = document.getElementById(selectId);
	if(selectElmt != null) {
    	return selectElmt.options[selectElmt.selectedIndex].value;
	}else{
		return 0;
	}
}

//Retourne la valeur du bouton radion "radiobutton"
function getSelectedRadioValue (radiobutton){
	var returnValue = "";
	if (radiobutton.length == 1){
		returnValue = radiobutton.value;
	} else {
		for (i=0;i<radiobutton.length;i++){
			if (radiobutton[i].checked==true) {
				returnValue=radiobutton[i].value;
			}
		}
	}
	return returnValue;
}


var displayingDiv = false;

function voir(article)  {
	if( document.getElementById(article).style.display == 'none' && displayingDiv==false) {
		document.getElementById(article).style.display = 'block';
		displayingDiv = true;
	}
}

function cacher(article) {
	if( document.getElementById(article).style.display == 'block' && displayingDiv==true) {
		document.getElementById(article).style.display = 'none';
		displayingDiv = false;
	}
}


function afficheCache(article){
	if(document.getElementById(article).style.display == 'none' && displayingDiv==false) {
		document.getElementById(article).style.display = 'block';
		displayingDiv = true;
	}else{
		if(document.getElementById(article).style.display == 'block' && displayingDiv==true) {
			document.getElementById(article).style.display = 'none';
			displayingDiv = false;
		}
	}	
}


///////////Menu//////////
// Browser Detect Lite  v2.1.4
// http://www.dithered.com/javascript/browser_detect/index.html
// modified by Chris Nott (chris@NOSPAMdithered.com - remove NOSPAM)


function BrowserDetectLite() {
   var ua = navigator.userAgent.toLowerCase(); 

   // browser name
   this.isGecko     = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1);
   this.isMozilla   = (this.isGecko && ua.indexOf('gecko/') + 14 == ua.length);
   this.isNS        = ( (this.isGecko) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('opera') == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) ) );
   this.isIE        = ( (ua.indexOf('msie') != -1) && (ua.indexOf('opera') == -1) && (ua.indexOf('webtv') == -1) ); 
   this.isSafari    = (ua.indexOf('safari') != - 1);
   this.isOpera     = (ua.indexOf('opera') != -1); 
   this.isKonqueror = (ua.indexOf('konqueror') != -1 && !this.isSafari); 
   this.isIcab      = (ua.indexOf('icab') != -1); 
   this.isAol       = (ua.indexOf('aol') != -1); 
   
   // spoofing and compatible browsers
   this.isIECompatible = ( (ua.indexOf('msie') != -1) && !this.isIE);
   this.isNSCompatible = ( (ua.indexOf('mozilla') != -1) && !this.isNS && !this.isMozilla);
   
   // browser version
   this.versionMinor = parseFloat(navigator.appVersion); 
   
   // correct version number
   if (this.isNS && this.isGecko) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('/') + 1 ) );
   }
   else if (this.isIE && this.versionMinor >= 4) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
   }
   else if (this.isMozilla) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) );
   }
   else if (this.isSafari) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('/') + 1 ) );
   }
   else if (this.isOpera) {
      if (ua.indexOf('opera/') != -1) {
         this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera/') + 6 ) );
      }
      else {
         this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera ') + 6 ) );
      }
   }
   else if (this.isKonqueror) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('konqueror/') + 10 ) );
   }
   else if (this.isIcab) {
      if (ua.indexOf('icab/') != -1) {
         this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab/') + 6 ) );
      }
      else {
         this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab ') + 6 ) );
      }
   }
   
   this.versionMajor = parseInt(this.versionMinor); 
   this.geckoVersion = ( (this.isGecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 );
   
   // dom support
   this.isDOM1 = (document.getElementById);
   this.isDOM2Event = (document.addEventListener && document.removeEventListener);
   
   // css compatibility mode
   this.mode = document.compatMode ? document.compatMode : 'BackCompat';

   // platform
   this.isWin   = (ua.indexOf('win') != -1);
   this.isWin32 = (this.isWin && ( ua.indexOf('95') != -1 || ua.indexOf('98') != -1 || ua.indexOf('nt') != -1 || ua.indexOf('win32') != -1 || ua.indexOf('32bit') != -1 || ua.indexOf('xp') != -1) );
   this.isMac   = (ua.indexOf('mac') != -1);
   this.isUnix  = (ua.indexOf('unix') != -1 || ua.indexOf('sunos') != -1 || ua.indexOf('bsd') != -1 || ua.indexOf('x11') != -1)
   this.isLinux = (ua.indexOf('linux') != -1);
   
   // specific browser shortcuts
   this.isNS4x = (this.isNS && this.versionMajor == 4);
   this.isNS40x = (this.isNS4x && this.versionMinor < 4.5);
   this.isNS47x = (this.isNS4x && this.versionMinor >= 4.7);
   this.isNS4up = (this.isNS && this.versionMinor >= 4);
   this.isNS6x = (this.isNS && this.versionMajor == 6);
   this.isNS6up = (this.isNS && this.versionMajor >= 6);
   this.isNS7x = (this.isNS && this.versionMajor == 7);
   this.isNS7up = (this.isNS && this.versionMajor >= 7);
   
   this.isIE4x = (this.isIE && this.versionMajor == 4);
   this.isIE4up = (this.isIE && this.versionMajor >= 4);
   this.isIE5x = (this.isIE && this.versionMajor == 5);
   this.isIE55 = (this.isIE && this.versionMinor == 5.5);
   this.isIE5up = (this.isIE && this.versionMajor >= 5);
   this.isIE6x = (this.isIE && this.versionMajor == 6);
   this.isIE6up = (this.isIE && this.versionMajor >= 6);
   
   this.isIE4xMac = (this.isIE4x && this.isMac);
}
var browser = new BrowserDetectLite();




/*
Author   : bieler batiste
Company  : doSimple : http://www.dosimple.ch
send me a mail for more informations : faden@PASDEPOURRIELaltern.org - remove ( PASDEPOURRIEL )

Short javascript function to create and handle a CSS navigation menu

Copyright (C) 2004  Bieler Batiste

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

// the timeout for the menu
var timeout = 500;

// not very clean but simple
// the function can be run in the HTML for faster display
// window.onload=initMenu;

// creat timeout variables for list item
// it's for avoid some warning with IE
for( var i = 0; i < 100; i++ )
{
    eval("var timeoutli" + i + " = false;");
}

// this fonction apply the CSS style and the event
function initMenu()
{
    // a test to avoid some browser like IE4, Opera 6, and IE Mac
    if ( browser.isDOM1 
    && !( browser.isMac && browser.isIE ) 
    && !( browser.isOpera && browser.versionMajor < 7 )
    && !( browser.isIE && browser.versionMajor < 5 ) )
    {
        // get some element
        var menu = document.getElementById('menu'); // the root element
        var lis = menu.getElementsByTagName('li'); // all the li
        
        // change the class name of the menu, 
        // it's usefull for compatibility with old browser
        menu.className='menu';
        
        // i am searching for ul element in li element
        for ( var i=0; i<lis.length; i++ )
        {
            // is there a ul element ?
            if ( lis.item(i).getElementsByTagName('ul').length > 0 )
            {        
                // improve IE key navigation
                if ( browser.isIE )
                {
                    addAnEvent(lis.item(i),'keyup',show);
                }
                // link events to list item
                addAnEvent(lis.item(i),'mouseover',show);
                addAnEvent(lis.item(i),'mouseout',timeoutHide);
                addAnEvent(lis.item(i),'blur',timeoutHide);
                addAnEvent(lis.item(i),'focus',show);
                
                // add an id to list item
                lis.item(i).setAttribute( 'id', "li"+i );
            }
        }
    }
}

function addAnEvent( target, eventName, functionName )
{
    // apply the method to IE
    if ( browser.isIE )
    {
        //attachEvent dont work properly with this
        eval('target.on'+eventName+'=functionName');
    }
    // apply the method to DOM compliant browsers
    else
    {
        target.addEventListener( eventName , functionName , true ); // true is important for Opera7
    }
}
    
// hide the first ul element of the current element
function timeoutHide()
{
    // start the timeout
    eval( "timeout" + this.id + " = window.setTimeout('hideUlUnder( \"" + this.id + "\" )', " + timeout + " );");
}

// hide the ul elements under the element identified by id

function hideUlUnder( id )
{   
    document.getElementById(id).getElementsByTagName('ul')[0].style['visibility'] = 'hidden';
}

// show the first ul element found under this element
function show()
{
    // show the sub menu
    this.getElementsByTagName('ul')[0].style['visibility'] = 'visible';
    var currentNode=this;
    while(currentNode)
    {
            if( currentNode.nodeName=='LI')
            {
                currentNode.getElementsByTagName('a')[0].className = 'linkOver';
            }
            currentNode=currentNode.parentNode;
    }
    // clear the timeout
    eval ( "clearTimeout( timeout"+ this.id +");" );
    hideAllOthersUls( this );
}

// hide all ul on the same level of  this list item
function hideAllOthersUls( currentLi )
{
    var lis = currentLi.parentNode;
    for ( var i=0; i<lis.childNodes.length; i++ )
    {
        if ( lis.childNodes[i].nodeName=='LI' && lis.childNodes[i].id != currentLi.id )
        {
            hideUlUnderLi( lis.childNodes[i] );
        }
    }
}

// hide all the ul wich are in the li element
function hideUlUnderLi( li )
{
    var as = li.getElementsByTagName('a');
    for ( var i=0; i<as.length; i++ )
    {
        as.item(i).className="";
    }
    var uls = li.getElementsByTagName('ul');
    for ( var i=0; i<uls.length; i++ )
    {
        uls.item(i).style['visibility'] = 'hidden';
    }
} 

///////////////////////////


/*
// Début script pour le menu horizontal déroulant 
window.onload=montre;
function montre(id) {
	var d = document.getElementById(id);
	var tabdd = document.getElementsByTagName('dd');
	for (var i=0;i<tabdd.length;i++) {
		document.getElementById(tabdd[i].id).style.display='none';
		}

	if (d) {
		d.style.display='block';
	}
}

function affiche(id) {
	for(i=0;i<4;i++){
		valeur = "calque" + i;
		document.getElementById(valeur).style.display="none";
	}
	valeur = "calque" + id;
	document.getElementById(valeur).style.display="block";
}
*/


	
function poplink(msg)	{
		//alert(document.body.scrollLeft);
	var content = '<img src="'+msg+'">';
	if (domok){
	  	document.getElementById("topdecklink").innerHTML = content;
	  	skn.visibility = "visible";
  	}
}

function get_mouse(e){
	var x = (navigator.appName.substring(0,3) == "Net") ? e.pageX : event.x+document.documentElement.scrollLeft;
	var y = (navigator.appName.substring(0,3) == "Net") ? e.pageY : event.y+document.documentElement.scrollTop;
	skn.left = x + 15 +"px";
	skn.top = y - 255 +"px";
	
}
function killlink(){
	if (domok)
  		skn.visibility = "hidden";
}


///////////////////////////


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(artid){
	window.open ('recommander.php?artid='+artid+'', 'Recommander', 'Width=600, Height=450, toolbar=no, directories=no, location=no, menubar=no, resizable=no, scrollbars=no, status=no') ;
}

function recommander2(artid){
	window.open ('recommander2.php?artid='+artid+'', '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 recommander4(artid,diamant){
	window.open ('recommander4.php?artid='+artid+'&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 imprimer2(article){
	window.open ('imprimer2.php?artid='+article+'', 'Impression', 'Width=800, Height=600, toolbar=no, directories=no, location=no, menubar=no, resizable=no, scrollbars=yes, status=no') ;
}

function imprimer3(diamant){
	window.open ('imprimer3.php?diamant='+diamant+'', 'Impression', 'Width=800, Height=600, toolbar=no, directories=no, location=no, menubar=no, resizable=no, scrollbars=yes, status=no') ;
}

function imprimer4(artid,diamant){
	window.open ('imprimer4.php?artid='+artid+'&diamant='+diamant+'', 'Impression', 'Width=800, Height=600, toolbar=no, directories=no, location=no, menubar=no, resizable=no, scrollbars=yes, status=no') ;
}

function imprimercommande() {
	if (document.formcde.cadeauid.value != "")
		var cadeauid = document.formcde.cadeauid.value ;
	else
		var cadeauid = 0 ;
	window.open ('imprimercommande.php?cadeauid='+cadeauid, 'Impression', 'Width=800, Height=600, toolbar=no, directories=no, location=no, menubar=no, resizable=no, scrollbars=yes, status=no') ;
}

function imprimerfacture(facture) {
	if (document.formcde.cadeauid.value != "")
		var cadeauid = document.formcde.cadeauid.value ;
	else
		var cadeauid = 0 ;
	window.open ('imprimercommandeRecap.php?style=2&factureid='+facture+'&cadeauid='+cadeauid, 'Impression', 'Width=800, Height=600, toolbar=no, directories=no, location=no, menubar=no, resizable=no, scrollbars=yes, status=no') ;
}

function help(id){
	window.open ('popuphelp.php?id='+id+'', 'HELP', 'Width=900, Height=600, toolbar=no, directories=no, location=no, menubar=no, resizable=no, scrollbars=yes, status=no') ;
}

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 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 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 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 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 = "" ;
	}
}


fDomOffset = function(oObj, sProp) {
	var iVal = 0;
	while (oObj && oObj.tagName != 'BODY') {
		eval('iVal += oObj.' + sProp + ';');
		oObj = oObj.offsetParent;
	}
	return iVal;
}
	
fSwapSelect = function(oDiv) {
	var i = 0, oSlt = null, iST = 0, iSL = 0, iSW = 0, iSH = 0, isLeft = false, isTop = false, sVis = '';
	var oObj = document.getElementById(oDiv);
	var iOT  = fDomOffset(oObj, 'offsetTop')-315;
	var iOL  = fDomOffset(oObj, 'offsetLeft')-125;
	/*var iOT  = oObj.offsetTop;
	var iOL  = oObj.offsetLeft;*/
	var iOW  = oObj.offsetWidth;
	var iOH  = oObj.offsetHeight;
	var oSelects = document.getElementsByTagName('SELECT');
	if (oSelects.length > 0) {
		for (i = 0; i < oSelects.length; i++) {
			isLeft = false; 
			isTop = false; 
			oSlt = oSelects[i];
			iST = fDomOffset(oSlt, 'offsetTop'); 
			iSL = fDomOffset(oSlt, 'offsetLeft');
			iSW = oSlt.offsetWidth; 
			iSH = oSlt.offsetHeight;
			//document.getElementById("truc").innerHTML += "iOT : "+iOT+", iOL : "+iOL+", iOW : "+iOW+", iOH : "+iOH+", iST : "+iST+", iSL : "+iSL+", iSW : "+iSW+", iSH : "+iSH+" (oSlt : )"+oSlt.name+"<br>" ;
			// On verifie le Magical Square
			if ((iOL > (iSL - iOW)) && (iOL < (iSL + iSW))) 
				{isLeft = true;}
			if ((iOT > (iST - iOH)) && (iOT < (iST + iSH))) 
				{isTop = true;}
			if (isLeft && isTop) {
				sVis = (oObj.style.visibility == 'hidden') ? 'visible' : 'hidden';
				if (oSlt.style.visibility != sVis) {
					oSlt.style.visibility = sVis;
					}
				} 
			else {
				if (oSlt.style.visibility != 'visible') {oSlt.style.visibility = 'visible';}
				}
			}
		}
	}

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 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 choixreglement(moyenid){
	document.paiement.moyenid.value = moyenid ;
	document.paiement.submit() ;
}



function comparer(nb) {
	var cochee = 0 ;
	var langue = GetCookie("langue");
	for (var i=1; i <= nb; i++) 
		{ 
		if (document.getElementById(i).checked == true)
			cochee++ ;
		}
	if (cochee > 1) {
		document.formucompare.submit();
	}else{
		if (langue=="EN") {
			alert('You have to select at least 2 diamond.');
		}else{
			alert('Vous devez sélectionner au moins deux diamants à comparer.');
		}
	}
}


	
function GetId(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) {
				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 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 paiement(id){
	document.getElementById('paiement0').style.display = 'none' ;
	document.getElementById('paiement1').style.display = 'none' ;
	document.getElementById('paiement2').style.display = 'none' ;
	document.getElementById('paiement3').style.display = 'none' ;
	if (id == '0'){
		document.getElementById('cde3moyensh').style.display = 'block';
		document.getElementById('cde3moyens').style.display = 'block';
	}else{
		document.getElementById('cde3moyensh').style.display = 'none';
		document.getElementById('cde3moyens').style.display = 'none';
	}
	var paiement = 'paiement'+id ;
	document.getElementById(paiement).style.display = 'block' ;
}





function new_position_prix(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) {
	
	var langue = GetCookie("langue");
	
	longueur = 147 ;
	
	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));
	

	//if (langue=="EN") {
	//	prix1 = convert(prix1) ;
	//	prix2 = convert(prix2) ;
	//}
	prix1=separeMilliers(prix1);
	prix2=separeMilliers(prix2);

	
	if (langue=="EN") {
		document.getElementById("resultats").value = "from " + prix1 + " to " + prix2 + " €" ;
	}else{
		document.getElementById("resultats").value = "de " + prix1 + " à " + prix2 + " €" ;
	}
}




function onchange_carat(mini, maxi) {
	document.getElementById("carat_min").value = mini ;
	document.getElementById("carat_max").value = maxi ;
	document.getElementById("zpSlider2FirstSliderGris").style.width = mini+"px" ;
	var largeurd = 286 - maxi ;
	document.getElementById("zpSlider2SecondSliderGris").style.width = largeurd+"px" ;
	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 ;  
	document.getElementById("zpSlider1FirstSliderGris").style.width = mini+"px" ;
	var largeurd = 286 - maxi ;
	document.getElementById("zpSlider1SecondSliderGris").style.width = largeurd+"px" ;
	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) {
	var langue = GetCookie("langue");
	longueur = 286 ;
	
	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));
	//if (langue=="EN") {
	//	prix1 = convert(prix1) ;
	//	prix2 = convert(prix2) ;
	//}
	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 ; 
	document.getElementById("zpSlider5FirstSliderGris").style.width = mini+"px" ;
	var largeurd = 498 - maxi ;
	document.getElementById("zpSlider5SecondSliderGris").style.width = largeurd+"px" ;
	}

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 ; 
	document.getElementById("zpSlider3FirstSliderGris").style.width = mini+"px" ;
	var largeurd = 498 - maxi ;
	document.getElementById("zpSlider3SecondSliderGris").style.width = largeurd+"px" ;
	}

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 ;
	document.getElementById("zpSlider4FirstSliderGris").style.width = mini+"px" ;
	var largeurd = 498 - maxi ;
	document.getElementById("zpSlider4SecondSliderGris").style.width = largeurd+"px" ;
	}



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 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 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='+'400'+', toolbar=no, directories=no, location=no, menubar=no, resizable=no, scrollbars=no, status=no') ;
}
*/

