var Navigateur = navigator.appName;

if(Navigateur == "Microsoft Internet Explorer")
	var ie = true;
else
	var ie = false;


function menu(obj, idsub)
{
	
	//SelectFix.repairFloatingElement(document.getElementById('langue_produit_id'));
	if(!$(obj).hasClass('active')) {
		$(obj).addClass('hover').addClass('jshover');
		var posLeft = getLeftImg(obj);
		$(obj).addClass('submenu_hover');
	}
	
		
	
	
	if($(idsub)) {
		$(idsub).addClass('submenu_hoverjs');
		$(idsub).style.position = "absolute";
		$(idsub).style.marginTop = "-1px";
		$(idsub).style.left = posLeft;


		
			
		
	}
	
	
}


var Hactu = 0;
var maxH = 0;
var saveH = 0;
function effetderoule(idsub) {
		if(maxH==0) {
			$(idsub).style.display = "block";
			maxH = $(idsub).offsetHeight;
		}
		
		if(saveH==0) {
			saveH = Hactu;
		}		
		
		$(idsub).style.overflow = "hidden";
		if(Hactu <= maxH) {
			Hactu+=5;
			$(idsub).style.height=Hactu+"px";
			setTimeout(function(){effetderoule(idsub)}, 10);	
		}else{
			Hactu = 0;
			maxH = 0;	
		}

}

var Hactu2 = 0;
var maxH2 = 0;
var saveH2 = 0;
function effetenroule(idsub) {
	

		if(maxH2==0) {
			Hactu2 = $(idsub).offsetHeight;
		}
		
		if(saveH2==0) {
			saveH2 = Hactu2;
		}
		
	
		
		
		$(idsub).style.overflow = "hidden";
		
		if(maxH2 < Hactu2) {
			Hactu2-=5;
			$(idsub).style.height=Hactu2+"px";
			setTimeout(function(){effetenroule(idsub)}, 10);	
		}else{
				Hactu2 = 0;
				maxH2 = 0;
				$(idsub).style.display = "none";
				$(idsub).style.height = saveH2+"px";
				saveH2 = 0;
			}
	
}


//hidemenu('menu', 'sub_{$c.categorie_id}');inactive('colortest_{$c.categorie_id}');    -    menu($('supermenu_{$c.categorie_id}'), 'sub_{$c.categorie_id}');active('colortest_{$c.categorie_id}');
function active(obj)
{
		$(obj).style.color = "#DE2887";
}

function inactive(obj)
{
		$(obj).style.color = "#592F46";
}

function hidemenu(item, idsub)
{
	
	$$('#'+item+' li.jshover').removeClass('hover').removeClass('jshover');
	$$('#'+item+' li.submenu_hover').removeClass('submenu_hover');
	if($(idsub)) $(idsub).removeClass('submenu_hoverjs');
}

function popupimage(chemin)
{	
	var html;
	html = '<HTML>\n'
	+ '<HEAD>\n'
	+ '<TITLE>D&eacute;tail de la photo</TITLE>\n'
	+ '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">\n'
	+ '<link rel="stylesheet" href="/charte/style.css" type="text/css">\n'
	+ '</HEAD>\n'
	+ '<BODY onLoad="window.focus();window.resizeTo(document.imageTest.width+35,document.imageTest.height+90);" bgcolor="#FFFFFF" leftmargin="10" topmargin="10" marginwidth="10" marginheight="10">\n'
	+ '<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">\n'
	+ '<tr><td align="center" valign="middle">'
	+ '<img src="'+chemin+'" border="0" name="imageTest"></td></tr>\n'
	+ '</table>\n'
	+ '</BODY>\n'
	+ '</HTML>'
	
	var popup;
	popup = window.open('','popupgo','left=200,top=100,width=10,height=10,toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=0');
	popup.document.write(html);
	popup.document.close();
}


function SecureConfirm(obj)
{
	if(confirm('Voulez-vous supprimer votre adresse du carnet ?')) {
		return true;
	}else{
		return false;
	}
}

var fondDiv = false;
var dataDiv = false;
// Ajout au panier
function addPanier(idForm)
{
	if(!fondDiv){
		fondDiv = document.createElement('div');
		fondDiv.style.position = 'absolute';
		document.body.appendChild(fondDiv);
	}
	fondDiv.innerHTML = '';
	//alert(getHeight());

	$(fondDiv).setStyles({
	   backgroundColor: '#000000',
	   width: '100%',
	   height: getScrollHeight(),
	   position: 'absolute',
	   opacity: '0.5',
	   overflow: 'hidden',
	   top: '0px',
	   left: '0px',
	   zIndex: '999999',
	   visibility: 'hidden'
	});

	if(!dataDiv){
		dataDiv = document.createElement('div');
		dataDiv.style.position = 'absolute';
		document.body.appendChild(dataDiv);
	}

	$(dataDiv).setStyles({
	   backgroundColor: '#000000',
	   width: '359px',
	   height: '300px',
	   position: 'absolute',
	   border: '1px solid #000',
	   top: '50%',
	   left: '50%',	   
	   marginLeft: '-150px',	   
	   marginTop: (getScrollTop()-150) + 'px',	   	   	   
	   zIndex: '9999991',
	   visibility: 'hidden'
	});

	new Ajax(
		'/js/ajax/panier-change.php',
		{
			update: dataDiv,
			data:$(idForm).toQueryString(),
			onSuccess: function(req) {

					$$(fondDiv).setStyles({visibility: 'visible' });
					$$('select').setStyles({visibility: 'hidden' });
					$$(dataDiv).setStyles({visibility: 'visible' });
	
					new Ajax(
						'/js/ajax/updatePanier.php',
						{
							update: $('header_panier')
						}
					).request();
			},
			evalScripts: true
		}
	).request();
}

// Ajout au panier
function addNewsletter(idForm) {
	
	new Ajax(
		'/js/ajax/newsletter.php',
		{
			method: 'post',
			data:$(idForm).toQueryString(),
			onSuccess: function(req) {
				$(idForm).newsletter_email.value='';
				if(req!="nomail") alert(req);
				
			},
			evalScripts: true
		}
	).request();
}

function removeDivPanier()
{
	if(fondDiv){
		$(fondDiv).remove();
		fondDiv = false;
	}	
	if(dataDiv){
		$(dataDiv).remove();
		dataDiv = false;
	}
	$$('select').setStyles({visibility: 'visible' });		
}

function getTop(deKoi)
{
	var obj = deKoi;
	var curleft = 0;

	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetTop;
			obj = obj.offsetParent;
		}
	}
	else
	{
		if (obj.y)
			curleft += obj.y;
	}

	return (curleft);
}

function getLeftImg(deKoi)
{
	var obj = deKoi;
	var curleft = 0;

	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft;
			obj = obj.offsetParent;
		}
	}
	else
	{
		if (obj.x)
			curleft += obj.x;
	}

	return (curleft);
}

function showPreviewBig_home(idProd,imglist)
{

	div = 'prod'+idProd;
	
	vartop=getTop(imglist)-getTop($('contenu'));
	varleft=getLeftImg(imglist)-getLeftImg($('header_gauche'));
		
	$(div).style.top=vartop-135+105 + 'px';
	$(div).style.left=varleft-135+110 + 'px';

	$(div).style.display='block';	
}



function showPreviewBig(idProd,imglist)
{
	$$('.previsu').setStyle('display', 'none');

	div = 'prod'+idProd;
	conteneur = 'conteneur_lst_img'+idProd;
	
	vartop=getTop(imglist)-getTop(conteneur);
	varleft=getLeftImg(imglist)-getLeftImg(conteneur);
		
	$(div).style.top=-350 + 'px';
	$(div).style.left=-50 + 'px';
	$(div).style.zIndex=1000;
	$(div).style.display='block';	
}



function cachePrevisu(idProd)
{
	div = 'prod' + idProd;
	$(div).style.display='none';	
}

function affichePromocode() {
	var div = document.getElementById('promocode');
	
	if(div.style.display=='block') {
		div.style.display='none'
	}else{
		div.style.display='block'
	}
}
function afficheCheque() {
	var div = document.getElementById('bonachatcadeau');
	
	if(div.style.display=='block') {
		div.style.display='none'
	}else{
		div.style.display='block'
	}
}
if(!edz_zooms) var edz_zooms = false;

function show_ss_menu(id) {
	if(edz_zooms)
	{
		if(edz_zooms._zoomCur) edz_zooms._zoomCur._divLoupe.style.display='none';
	}
	
	var d = document.getElementById(id);
		for (var i = 1; i<=17; i++) {
			if(document.getElementById('smenu'+i)) document.getElementById('smenu'+i).style.display='none';
		}
		
		if (d && id) {d.style.display='block';}
		
}

var Interval;
//window.onload = wl;
var iScroll=0;
function defileBas(param_scroll) {
	if(param_scroll==1)	iScroll=param_scroll;
	if(iScroll)
	{
		$('listeMarque').scrollTop+=1;
		setTimeout(defileBas, 10);
	}
}

function defileHaut(param_scroll) {
	if(param_scroll==1)	iScroll=param_scroll;
	if(iScroll)
	{
		$('listeMarque').scrollTop-=1;
		setTimeout(defileHaut, 10);
	}	
}
function defileBas2(param_scroll) {
	if(param_scroll==1)	iScroll=param_scroll;
	if(iScroll)
	{
		$('listeCouleur').scrollTop+=1;
		setTimeout(defileBas2, 10);
	}
}

function defileHaut2(param_scroll) {
	if(param_scroll==1)	iScroll=param_scroll;
	if(iScroll)
	{
		$('listeCouleur').scrollTop-=1;
		setTimeout(defileHaut2, 10);
	}	
}

function defileBas3(param_scroll) {
	if(param_scroll==1)	iScroll=param_scroll;
	if(iScroll)
	{
		$('listeChou').scrollTop+=1;
		setTimeout(defileBas3, 10);
	}
}

function defileHaut3(param_scroll) {
	if(param_scroll==1)	iScroll=param_scroll;
	if(iScroll)
	{
		$('listeChou').scrollTop-=1;
		setTimeout(defileHaut3, 10);
	}	
}

function defilePause() {
	iScroll=0;
}

function expand(obj, div, fleche, color) {

	if($(div).style.display == "block") {
		$(div).style.display = "none";
		if(obj != "") {
			$(obj).style.background = "#f7f1e1 url('/styles/images/sep_gauche.png') no-repeat top left";
			$(obj).style.color = "#000000";
			//$(obj).style.borderBottom = "#ffffff 3px solid";
			$(obj).className = "critere_recherche";
		}

		if(fleche!="") $(fleche).src = '/styles/images/header/flecheblanc.png';
		if(color!="") $(color).style.color = '#FFFFFF';
	}
	else{
		$(div).style.display = "block";
		if(obj != "") {
			//$(obj).style.background = "#000000 url('/styles/images/header/bg_recherche.png') repeat-x";
			$(obj).style.background = "#f7f1e1 url('/styles/images/sep_gauche.png') top left";
			$(obj).style.color = "#FFFFFF";
			$(obj).style.borderBottom = "none";
			$(obj).className = "crlnk";
		}
		if(fleche!="") $(fleche).src = '/styles/images/flecherose.png';
		if(color!="") $(color).style.color = '#E42F8B';
	}
}

function expandall() {
	
	if($('menu_type').style.display == "block") {
		$('menu_type').style.display = "none";
		$('menu_type_titre').style.background = "#F7F1E1 url(/styles/images/sep_gauche.png) repeat-x scroll left bottom";
		$('menu_type_titre').style.color = "#000000";
		//$('menu_type_titre').style.borderBottom = "#ffffff 3px solid";
		$('menu_type_titre').className = "critere_recherche";
	}
	
	/*
	if($('menu_marque').style.display == "block") {
		$('menu_marque').style.display = "none";
		$('menu_marque_titre').style.background = "#f7f1e1 url('/styles/images/sep_gauche.png') repeat-x bottom left";
		$('menu_marque_titre').style.color = "#000000";
		//$('menu_marque_titre').style.borderBottom = "#ffffff 3px solid";
		$('menu_marque_titre').className = "critere_recherche";
	}	
*/
	if($('menu_couleursmat').style.display == "block") {
		$('menu_couleursmat').style.display = "none";
		$('menu_couleursmat_titre').style.background = "#f7f1e1 url('/styles/images/sep_gauche.png') repeat-x bottom left";
		$('menu_couleursmat_titre').style.color = "#000000";
		//$('menu_couleursmat_titre').style.borderBottom = "#ffffff 3px solid";
		$('menu_couleursmat_titre').className = "critere_recherche";
	}		
/*
	if($('menu_style').style.display == "block") {
		$('menu_style').style.display = "none";
		$('menu_style_titre').style.background = "#f7f1e1 url('/styles/images/sep_gauche.png') repeat-x bottom left";
		$('menu_style_titre').style.color = "#000000";
		//$('menu_style_titre').style.borderBottom = "#ffffff 3px solid";
		$('menu_style_titre').className = "critere_recherche";
	}		
*/
	if($('menu_budget').style.display == "block") {
		$('menu_budget').style.display = "none";
		$('menu_budget_titre').style.background = "#f7f1e1 url('/styles/images/sep_gauche.png') repeat-x bottom left";
		$('menu_budget_titre').style.color = "#000000";
		//$('menu_budget_titre').style.borderBottom = "#ffffff 3px solid";
		$('menu_budget_titre').className = "critere_recherche";
	}	
	
}

function expandclose(obj, div) {
	$(div).style.display = "none";
	if(obj != "") {
		$(obj).style.background = "#f7f1e1 url('/styles/images/sep_gauche.png') repeat-x bottom left";
		$(obj).style.color = "#000000";
		$(obj).className = "critere_recherche";
		//$(obj).style.borderBottom = "#ffffff 3px solid";
	}
}

function inactive_color(obj,fleche) {
	$(obj).style.color = '#ffffff';
	$(fleche).src = '/styles/images/header/flecheblanc.png';
}

function hideSelectPay(inputValue) {
	document.getElementById('blocMX').style.display='none';
	document.getElementById('blocCH').style.display='none';
	if(inputValue=='MX')
		document.getElementById('blocMX').style.display='inline';
	if(inputValue=='CH')
		document.getElementById('blocCH').style.display='inline';
}

function montre(id) {
var d = document.getElementById(id);
	for (var i = 1; i<=10; i++) {
		if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';}
	}
if (d) {d.style.display='block';}
}


function sendAmis(id,type) {
	window.open('/wish_amis.php', 'conseils', 'width=450,height=320,resizable=no,scrollbars=no,toolbar=0,directories=0,status=0,menubar=0');
}

function check_add_panier(toto)
{

	nVarNom = toto;	

	if(nVarNom != null) //check_add_panier('toto')

	{

		if(!nVarNom)

			check_add_panier('toto');

		else

		{

			document.forms['savepanier'].elements['panier_nom'].value = nVarNom;	

			document.forms['savepanier'].submit();	

		}
	}
}


function check_add_panier_ajax() {
	
	if(!fondDiv){
		fondDiv = document.createElement('div');
		fondDiv.style.position = 'absolute';
		document.body.appendChild(fondDiv);
	}
	fondDiv.innerHTML = '';
	//alert(getHeight());

	$(fondDiv).setStyles({
	   backgroundColor: '#000000',
	   width: '100%',
	   height: getScrollHeight(),
	   position: 'absolute',
	   opacity: '0.5',
	   overflow: 'hidden',
	   top: '0px',
	   left: '0px',
	   zIndex: '1500',
	   visibility: 'hidden'
	});

	if(!dataDiv){
		dataDiv = document.createElement('div');
		dataDiv.style.position = 'absolute';
		document.body.appendChild(dataDiv);
	}

	$(dataDiv).setStyles({
	   backgroundColor: '#000000',
	   width: '243px',
	   height: '243px',
	   position: 'absolute',
	   border: '1px solid #000',
	   top: '50%',
	   left: '50%',	   
	   marginLeft: '-150px',	   
	   marginTop: (getScrollTop()-150) + 'px',	   	   	   
	   zIndex: '1600',
	   visibility: 'hidden'
	});	

	new Ajax(
		'/js/ajax/panier-save.php',
		{
			update: dataDiv,
			onSuccess: function(req) {

					$$(fondDiv).setStyles({visibility: 'visible' });
					$$('select').setStyles({visibility: 'hidden' });
					$$(dataDiv).setStyles({visibility: 'visible' });
	
			},
			evalScripts: true
		}
	).request();	
}

function check_add_panier_ajax2(id) {
	check_add_panier(id);
}


function LoadZoomList(img, desc, img_gauche, img_droite, dispo) {
	
	
	$('img_list_big').style.backgroundImage = 'url('+img+')';
	$('produit_desc').innerHTML = desc;
	$('produit_isdispo').style.display='block';
	$('produit_isdispo').innerHTML = dispo;

	
	if(img_gauche == "") {
		if( $('etiquette_gauche')) { $('etiquette_gauche').style.display = "none"; }
		if( $('detiquette_gauche')) { $('detiquette_gauche').style.display = "none"; }
	}else{
		//alert(img_gauche);
		$('detiquette_gauche').style.display = "block";
		$('etiquette_gauche').style.display = "block";
		$('etiquette_gauche').src = img_gauche;
	}

	if(img_droite  == "") {
		if( $('etiquette_droite') ) { $('etiquette_droite').style.display = "none"; }
		if( $('detiquette_droite') ) { $('detiquette_droite').style.display = "none"; }
	}else{
		$('detiquette_droite').style.display = "block";
		$('etiquette_droite').style.display = "block";
		$('etiquette_droite').src = img_droite;
	}
	
	//alert(img_gauche + " " + img_droite);
}

function showPreviewBigDef (img, desc) {
	//$('img_list_big').src = img;
	$('img_list_big').style.backgroundImage = 'url('+img+')';
	$('produit_isdispo').style.display='none';
	$('produit_desc').innerHTML = desc;	
	
	$('etiquette_droite').style.display = "none";
	$('etiquette_gauche').style.display = "none";
	$('detiquette_droite').style.display = "none";
	$('detiquette_gauche').style.display = "none";	
}


function changefleche(id) {
	
	
}


function openFournisseur(id) {
	$(id).style.display="block";
}
function closeFournisseur(id) {
	$(id).style.display="none";
}


function sendAmisProduit(id) {
	window.open('/produit_amis.php?produit_id='+id, 'Produit', 'width=500,height=500,resizable=no,scrollbars=no,toolbar=0,directories=0,status=0,menubar=0');
}

var fondDiv = false;
var dataDiv = false;
// Ajout WishList
function addWishlist(produit_id, client_id) {
	if(!fondDiv){
		fondDiv = document.createElement('div');
		fondDiv.style.position = 'absolute';
		document.body.appendChild(fondDiv);
	}
	fondDiv.innerHTML = '';
	//alert(getHeight());

	$(fondDiv).setStyles({
	   backgroundColor: '#000000',
	   width: '100%',
	   height: getScrollHeight(),
	   position: 'absolute',
	   opacity: '0.5',
	   overflow: 'hidden',
	   top: '0px',
	   zIndex: '1500',
	   visibility: 'hidden'
	});

	if(!dataDiv){
		dataDiv = document.createElement('div');
		dataDiv.style.position = 'absolute';
		document.body.appendChild(dataDiv);
	}

	$(dataDiv).setStyles({
	   backgroundColor: '#FFFFFF',
	   width: '700px',
	   height: '490px',
	   position: 'absolute',
	   border: '1px solid #000',
	   top: '50%',
	   left: '50%',	   
	   marginLeft: '-350px',	   
	   marginTop: (getScrollTop()-180) + 'px',	   	   	   
	   zIndex: '16000',
	   visibility: 'hidden'
	});
	new Ajax(
		'/js/ajax/addwishlist.php',
		{
			update: dataDiv,
			data:"produit_id="+produit_id+"&client_id="+client_id,
			onSuccess: function(req) {
					//alert(req);	
					$$(fondDiv).setStyles({visibility: 'visible' });
					$$('select').setStyles({visibility: 'hidden' });
					$$(dataDiv).setStyles({visibility: 'visible' });
			},
			evalScripts: true
		}
	).request();
}


function popup_alerte() {
	if(!fondDiv){
		fondDiv = document.createElement('div');
		fondDiv.style.position = 'absolute';
		document.body.appendChild(fondDiv);
	}
	fondDiv.innerHTML = '';
	//alert(getHeight());

	$(fondDiv).setStyles({
	   backgroundColor: '#000000',
	   width: '100%',
	   height: getScrollHeight(),
	   position: 'absolute',
	   opacity: '0.5',
	   overflow: 'hidden',
	   top: '0px',
	   zIndex: '1500',
	   visibility: 'hidden'
	});

	if(!dataDiv){
		dataDiv = document.createElement('div');
		dataDiv.style.position = 'absolute';
		document.body.appendChild(dataDiv);
	}

	$(dataDiv).setStyles({
	   /*backgroundColor: '#FFFFFF',*/
	   width: '400px',
	   height: '184px',
	   position: 'absolute',
	   /*border: '1px solid #000',*/
	   top: '50%',
	   left: '50%',	   
	   marginLeft: '-200px',	   
	   marginTop: (getScrollTop()-80) + 'px',	   	   	   
	   zIndex: '16000',
	   visibility: 'hidden'
	});
	new Ajax(
		'/js/ajax/popup_alerte.php',
		{
			update: dataDiv,
			// data:"produit_id="+produit_id+"&client_id="+client_id,
			onSuccess: function(req) {
					//alert(req);	
					$$(fondDiv).setStyles({visibility: 'visible' });
					$$('select').setStyles({visibility: 'hidden' });
					$$(dataDiv).setStyles({visibility: 'visible' });
			},
			evalScripts: true
		}
	).request();
}

function check_all(){
	$$(".input-marque").each(function(item){
		item.checked = true;
	});
}

function uncheck_all(){
	$$(".input-marque").each(function(item){
		item.checked = false;
	});
}


function updateInfoStock(id) {
	
	
	new Ajax(
		'/js/ajax/updateInfoStock.php',
		{
			method: 'post',
			data:"produit_attribut_id="+id,
			onSuccess: function(req) {
					$('maj_stock_attr').innerHTML = req;
			},
			evalScripts: true
		}
	).request();		
}


function showMenuW(id, obj)
{
	//console.log('on = ' + id);
	var height_fx = new Fx.Style('submenuw_' + id,'height')

	
	var Pos = $(obj).getPosition();
	var nb = $('sub_' + id).getChildren().length
	
	$('submenuw_' + id).style.display = 'block';	
	
	$('submenuw_' + id).style.left = Pos.x - 2 + 'px';
	//console.log('left'+ $(id).style.left)

	height_fx.stop();
	height_fx.start(nb*31);	
}

function hideMenuW(id, obj)
{
	//console.log('off = ' + id);
	
	var height_fx = new Fx.Style('submenuw_' + id,'height')	
	$('submenuw_' + id).style.display = 'none';	
	height_fx.stop();
	height_fx.start('0');	
}

function init_menu(selected_section){
	
	var main_menu_items = $$('.sousmenu');
	//console.log(main_menu_items.length);
	
	main_menu_items.each(function(item){
			
			//console.log(item.id);		
			data = item.id.split('_');	
			//console.log('categorie_id = ' + data[1]);		

			if($('sub_' + data[1]))
			{
				submenu = $('sub_' + data[1]);
				
				var height_fx = new Fx.Style($('sub_' + data[1]),'height')
				
				var nb = $('sub_' + data[1]).getChildren().length
				
				//var Pos = $('supermenu_' + data[1]).getPosition();
				//$('submenuw_' + data[1]).style.left = Pos.x - 2 + 'px';
				
				//console.log('nb = ' + nb);		

			

				//--deb
				item.addEvent('mouseenter',function(e){
					//$$('input').setStyles({visibility: 'hidden' });
					item.addClass('active');


					e = new Event(e)
					
					// calculate the submenu new item
					height_fx.stop()
					height_fx.start(nb*29)
					//console.log('sdsd'+submenu.id);
					submenu.getChildren().each(function(submenu_item){
						//console.log('pwet');
						submenu_item.addEvent('mouseover',function(e){
							// change color
							//submenu_item.addClass('active');
							// end of submenu_item.addEvent('mouseover')
						})
						submenu_item.addEvent('mouseout',function(e){
							// change color
							//submenu_item.removeClass('active');
							// end of submenu_item.addEvent('mouseout')
						})
					})

					e.stop()
					// end of item.addEvent('mouseenter')
				})
				//--deb

				
				//--deb
				item.addEvent('mouseleave',function(e){
					item.removeClass('active');

					
					e = new Event(e)
					height_fx.stop()
					height_fx.start(0)
					// change color
					e.stop()

					//$$('input').setStyles({visibility: 'visible' });
					
					// end of item.addEvent('mouseleave')
				})
				//--deb


			} //ifsubmenu


			
		


	// end of each
	})
	
// end of function
}





function addTemoignage(idForm) {
	if(!fondDiv){
		fondDiv = document.createElement('div');
		fondDiv.style.position = 'absolute';
		document.body.appendChild(fondDiv);
	}
	fondDiv.innerHTML = '';
	//alert(getHeight());

	$(fondDiv).setStyles({
	   backgroundColor: '#000000',
	   width: '100%',
	   height: getScrollHeight(),
	   position: 'absolute',
	   opacity: '0.5',
	   overflow: 'hidden',
	   top: '0px',
	   left: '0px',
	   zIndex: '1500',
	   visibility: 'hidden'
	});

	if(!dataDiv){
		dataDiv = document.createElement('div');
		dataDiv.style.position = 'absolute';
		document.body.appendChild(dataDiv);
	}

	$(dataDiv).setStyles({
	   backgroundColor: '#000000',
	   width: '395px',
	   height: '330px',
	   position: 'absolute',
	   border: '1px solid #000',
	   top: '50%',
	   left: '50%',	   
	   marginLeft: '-150px',	   
	   marginTop: (getScrollTop()-150) + 'px',	   	   	   
	   zIndex: '1600',
	   visibility: 'hidden'
	});

	new Ajax(
		'/js/ajax/addTemoignage.php',
		{
			update: dataDiv,
			data:$(idForm).toQueryString(),
			onSuccess: function(req) {

					$$(fondDiv).setStyles({visibility: 'visible' });
					$$('select').setStyles({visibility: 'hidden' });
					$$(dataDiv).setStyles({visibility: 'visible' });
	
			},
			evalScripts: true
		}
	).request();	
}

function ShowDesc(nom)
{
	$('produit_desc').innerHTML=nom;
}


function loadNewImage(produit_image_loupe, produit_image_zoom, produit_image_detail, produit_image_mini, produit_image_nom) {
	new Ajax(
		'/js/ajax/photoprod.php',
		{
			method: 'post',
			data:"produit_image_loupe="+produit_image_loupe+"&produit_image_zoom="+produit_image_zoom+"&produit_image_detail="+produit_image_detail+"&produit_image_mini="+produit_image_mini+"&produit_image_nom="+produit_image_nom,			
			update: $('conteneur_photoprod'),
			onSuccess: function(req) {
				edz_smallLoaded(document.getElementById('photoprod'));
				edz_bigLoaded(document.getElementById('photobig'));
			}
		}
	).request();	
}


// onclick="document.getElementById('zoomsrc2').src='{$img.produit_image}';document.getElementById('photobig').src='{$img.produit_image}';document.getElementById('photoprod').src='{$img.produit_image_detail}';document.getElementById('photoprod').title='{$img.produit_image_nom}'"

function selectAttributPerso(nom_span, nom_select){
	//nom_span = choix_att_taille
	//nom_select = select_taille 
	
	if($(nom_span)){
		$(nom_span).innerHTML=($(nom_select).options[$(nom_select).selectedIndex].text);
		$(nom_span).getParent('div').setStyle('display','block');					
	}
	
	if(nom_span == 'choix_att_couleur'){
		if($('the_couleur_att')){
			$('the_couleur_att').value = 1;
		}
	}else{
		if($('the_taille_att')){
			$('the_taille_att').value = 1;
		}
	}
}

function selectCouleur(obj,load)
{
	//alert(obj.options[obj.selectedIndex].value);
	if(obj.options[obj.selectedIndex].value != '-1')
	{
		$('select_taille').disabled = false;
		$('select_taille').removeClass('disable');

		compat = obj.options[obj.selectedIndex].className;
		arrCompat = compat.split(' ');
		
		arrArt2 = $$('#select_taille option.tocheck').setStyle('display', 'none');
		arrArt = $$('#select_taille .'+obj.options[obj.selectedIndex].value).setStyle('display', 'block');
		console.log(arrArt2.length);
		finalz = 0;
		for(z=0; z < arrArt2.length; z++)
		{
			if(arrArt2[z].style.display == 'block')
			{
				finalz = z;
				console.log(finalz);
				
				break;
			}
		}
		$('select_taille').selectedIndex = finalz;
		/*
		document.forms['produit'].produit_option_valeur_id.value = obj.options[obj.selectedIndex].value;
		document.forms['produit'].produit_option_valeur_id_bis.value="";
		*/
		
		//if(load=="undefined") updateTarif();
		
		if($('choix_att_couleur')){
			$('choix_att_couleur').innerHTML=($('select_couleur').options[$('select_couleur').selectedIndex].text);
			$('choix_att_couleur').getParent('div').setStyle('display','block');					
		}
		
		if($('choix_att_taille')){
			$('choix_att_taille').innerHTML=($('select_taille').options[$('select_taille').selectedIndex].text);
			$('choix_att_taille').getParent('div').setStyle('display','block');					
		}
		
	}
	else
	{
		$('select_taille').disabled = true;
		$('select_taille').selectedIndex = 0;
		//document.forms['produit'].produit_option_valeur_id_bis.value="";
		//stepOne = false;
	}

	//if(load=="undefined") $('select_matiere').selectedIndex = 0;
	
	updateInfoStock($('select_taille').value)
	
}


function showDiv(obj,li,color,etat)
{
	$(obj).style.display = 'block';		
	$(li).style.backgroundColor = color;
	if(etat == '0') {
		$('amarqueorange').style.color = "#ffffff";
	}else{
		$('colortest_'+etat).style.color = "#ffffff";
	}	
}

function hideDiv(obj,li,color,etat)
{
	$(obj).style.display = 'none';	
	$(li).style.backgroundColor = color;
	if(etat == '0') {
		$('amarqueorange').style.color = "#F29400";
	}else{
		$('colortest_'+etat).style.color = "#ffffff";
	}	
}

function showDiv2(obj,li,color,etat)
{
	$(obj).style.display = 'block';		
	$(li).style.backgroundColor = color;
	if(etat == '0') {
		$('amarqueorange').style.color = "#cf4f0a";
	}else{
		$('colortest_'+etat).style.color = "#cf4f0a";
	}	
}

function hideDiv2(obj,li,color,etat)
{
	$(obj).style.display = 'none';	
	$(li).style.backgroundColor = color;
	if(etat == '0') {
		$('amarqueorange').style.color = "#cf4f0a";
	}else{
		$('colortest_'+etat).style.color = "#cf4f0a";
	}	
}

function prodGarantieIn(obj) {
	$(obj).style.color = '#000000';	
	$(obj).style.backgroundColor = '#e7e5e5';	
	$(obj).style.borderLeft = '1px solid #000000';
	$(obj).style.borderRight = '1px solid #000000';
	$(obj).style.borderTop = '1px solid #000000';
}

function prodGarantieOut(obj) {
	$(obj).style.color = '#999999';	
	$(obj).style.backgroundColor = '#e7e5e5';	
	$(obj).style.borderLeft = '1px solid #e8e7e2';
	$(obj).style.borderRight = '1px solid #e8e7e2';
	$(obj).style.borderTop = '1px solid #e8e7e2';
}

// Formulaire inscription
function file(fichier)
{
	if(window.XMLHttpRequest) // FIREFOX
	  xhr_object = new XMLHttpRequest(); 
	else if(window.ActiveXObject) // IE
	  xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 
	else 
	  return(false); 
	xhr_object.open("GET", fichier, false); 
	xhr_object.send(null); 
	if(xhr_object.readyState == 4) return(xhr_object.responseText);
	else return(false);
}

var Error_form = 0;
function check(champ,NbCarac,idChamp,BlocChamp)
{

	if(idChamp == 1)
		valeur = "Nom";
	else if(idChamp == 2)
		valeur = "Prénom";
	
	if(idChamp == 2) {
		if(champ.value.length < NbCarac) {
			texte = file('/js/ajax/MessageError.php?champ=' + idChamp);
			document.getElementById("valid" + idChamp).innerHTML="<img src='/styles/images/login/info_ajax_error.png' class='png' widht='20' height='18' alt='Non valide' style='float:left;' /><strong class='insc_error_ajax'>" + texte + "</strong>";
			document.getElementById(BlocChamp).style.backgroundColor="#eaa697";
			Error_form++;			
		}else{
			if(champ.value!=document.forms["register"].elements["client_password"].value) {
				texte = file('/js/ajax/MessageError.php?champ=' + idChamp);
				document.getElementById("valid" + idChamp).innerHTML="<img src='/styles/images/login/info_ajax_error.png' class='png' widht='20' height='18' alt='Non valide' style='float:left;' /><strong class='insc_error_ajax'>" + texte + "</strong>";	
				document.getElementById(BlocChamp).style.backgroundColor="#eaa697";
				Error_form++;	
			}else{
				document.getElementById("valid" + idChamp).innerHTML="<img src='/styles/images/login/info_ajax_valid.png' class='png' widht='20' height='18' alt='' />";
				document.getElementById(BlocChamp).style.backgroundColor="#e3dec9";
			}
		}
	}
	else if(idChamp == 12 || idChamp == 21) {
		
		if(champ.value.length < NbCarac)
		{				
			//if(idChamp == 21) { alert(champ.value); }
				texte = file('/js/ajax/MessageError.php?champ=' + idChamp);
				document.getElementById("valid" + idChamp).innerHTML="<img src='/styles/images/login/info_ajax_error.png' class='png' widht='20' height='18' alt='Non valide' style='float:left;' /><strong class='insc_error_ajax'>" + texte + "</strong>";
				document.getElementById(BlocChamp).style.backgroundColor="#eaa697";
				Error_form++;	
		}
		else{
			if(isNumeric(champ.value)) {
				document.getElementById("valid" + idChamp).innerHTML="<img src='/styles/images/login/info_ajax_valid.png' class='png' widht='20' height='18' alt='valide' />";
				document.getElementById(BlocChamp).style.backgroundColor="#e3dec9";
			}else{
				texte = file('/js/ajax/MessageError.php?champ=' + idChamp);
				document.getElementById("valid" + idChamp).innerHTML="<img src='/styles/images/login/info_ajax_error.png' class='png' widht='20' height='18' alt='Non valide' style='float:left;' /><strong class='insc_error_ajax'>" + texte + "</strong>";
				document.getElementById(BlocChamp).style.backgroundColor="#eaa697";
				Error_form++;	
			}
		}
		
	}
	else
	{

		//if(idChamp == 1){ alert(champ.value.length); }

		if(champ.value.length < NbCarac)
		{			
				if(idChamp != 1)	{
					texte = file('/js/ajax/MessageError.php?champ=' + idChamp);
					document.getElementById("valid" + idChamp).innerHTML="<img src='/styles/images/login/info_ajax_error.png' class='png' widht='20' height='18' alt='Non valide' style='float:left;' /><strong class='insc_error_ajax'>" + texte + "</strong>";
				}
				else {
					document.getElementById("valid" + idChamp).innerHTML="<img src='/styles/images/login/info_ajax_error.png' class='png' widht='20' height='18' alt='Non valide' />";		
				}
				document.getElementById(BlocChamp).style.backgroundColor="#eaa697";
				Error_form++;	
		}
		else{
				document.getElementById("valid" + idChamp).innerHTML="<img src='/styles/images/login/info_ajax_valid.png' class='png' widht='20' height='18' alt='valide' />";
				document.getElementById(BlocChamp).style.backgroundColor="#e3dec9";
		}
	}

	
}

function checkEmail(champ,BlocChamp)
{
	//alert(champ.value);
	texte = file('/js/ajax/verifMail.php?mail=' + champ.value);
	if (texte == "true")
	{
		document.getElementById("validEmail").innerHTML="<img src='/styles/images/login/info_ajax_valid.png' class='png' widht='20' height='18' alt='valide' />";
		document.getElementById(BlocChamp).style.backgroundColor="#e3dec9";
	}
	else {
		if(texte == "false"){
			document.getElementById("validEmail").innerHTML="<img src='/styles/images/login/info_ajax_error.png' class='png' widht='20' height='18' alt='Non valide' />";
			document.getElementById(BlocChamp).style.backgroundColor="#eaa697";
			Error_form++;	
		}
		else{
			document.getElementById("validEmail").innerHTML="<img src='/styles/images/login/info_ajax_error.png' class='png' widht='20' height='18' alt='Non valide' style='float:left;' /><strong class='insc_error_ajax'>" + texte + "</strong>";
			document.getElementById(BlocChamp).style.backgroundColor="#eaa697";
			Error_form++;	
		}
	}
}

function checkEmailConfirm(champ,BlocChamp)
{
	//alert(champ.value);
	texte = file('/js/ajax/verifMail.php?mail=' + champ.value);
	if (texte == "true")
	{
		if(champ.value == document.getElementById("client_email").value) {
			document.getElementById("validEmailConfirm").innerHTML="<img src='/styles/images/login/info_ajax_valid.png' class='png' widht='20' height='18' alt='valide' />";
			document.getElementById(BlocChamp).style.backgroundColor="#e3dec9";
		}
		else {
			document.getElementById("validEmailConfirm").innerHTML="<img src='/styles/images/login/info_ajax_error.png' class='png' widht='20' height='18' alt='Non valide' />";
			document.getElementById(BlocChamp).style.backgroundColor="#eaa697";
			Error_form++;	
		}
	}
	else{
		document.getElementById("validEmailConfirm").innerHTML="<img src='/styles/images/login/info_ajax_error.png' class='png' widht='20' height='18' alt='Non valide' />";
		document.getElementById(BlocChamp).style.backgroundColor="#eaa697";
		Error_form++;	
	}
}

function checkEmailParain(champ,BlocChamp)
{

	texte = file('/js/ajax/verifMail.php?mail=' + champ.value + "&parrain=1");
	
	//alert(texte);

	if(texte == "false" && champ.value!="") {
		document.getElementById("validEmail2").innerHTML="<img src='/styles/images/login/info_ajax_error.png' class='png' widht='20' height='18' alt='Non valide' />";
		document.getElementById(BlocChamp).style.backgroundColor="#eaa697";
		Error_form++;	
	}
	
	if (texte == "true" && champ.value!="")
	{
		document.getElementById("validEmail2").innerHTML="<img src='/styles/images/login/info_ajax_valid.png' class='png' widht='20' height='18' alt='valide' />";
		document.getElementById(BlocChamp).style.backgroundColor="#e3dec9";
	}
	

	
	if(champ.value=="") {
		document.getElementById("validEmail2").innerHTML="";
	}
	
}

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; 
} 

function remove_loupe()
{
	if(edz_zooms)
	{
		if(edz_zooms._zoomCur) edz_zooms._zoomCur._divLoupe.style.display='none';
	}
}

function showDiv5(obj,li,color,etat)
{
	$(obj).style.display = 'block';		
}

function hideDiv5(obj,li,color,etat)
{
	$(obj).style.display = 'none';	
}

/***********************************************************************/
/* PERSONNALISATION PRODUIT */
/***********************************************************************/

function suppPhotoPerso(){
	$('images1').innerHTML="";
	$('transfert_image_ok').setStyle('display','none');
	$('result_upload_photo').setStyle('display','none');
	$('choix_photo').setStyle('visibility','hidden');
	$('choix_photo').getParent('div').setStyle('display','none');
	$('perso_photo_perso').value="";
}

function selectAttPerso(obj, champ){
	
	produit_id = $('produit_id').value;
	
	if(champ=='produit_option_valeur_id_bis'){ 
		if(obj==-1 || obj==-2){
				$('comp_couleur_ttc').value = 0;
						
				tout_complement_ttc=0;
				
				// on calcule tous les input comp_
				$$("input[id^=comp_]").each(function(item){
					the_comp_ttc = parseFloat(item.value);
					tout_complement_ttc+=the_comp_ttc;
				});
					
				new_px_total = parseFloat($('px_ttc').value) + tout_complement_ttc;
				$('px_total_bijoux').innerHTML = new_px_total.toFixed(2);
				$('px_total_bijoux_up').innerHTML = new_px_total.toFixed(2);
				
				//on met a jour le span du choix
				//if(obj!=-2) $('choix_couleur').innerHTML = "";
				//else $('choix_couleur').innerHTML = $('txt_epuise').value;
				$('choix_couleur').innerHTML = "";
				$('choix_couleur').getParent('div').setStyle('display','none');
		}else{
			//couleur
			new Ajax(
				'/js/ajax/select_att_perso.php',
				{
					data:"produit_id="+produit_id+"&produit_option_valeur_id_bis="+obj,
					onSuccess: function(req) {
						var arr = req.split("|");
						choix_txt_px="";
						
						//on recupere le prix actuel
						//on ajoute le complement si il y a
						$('comp_couleur_ttc').value = parseFloat(arr[0]);
						
						tout_complement_ttc=0;
						
						// on calcule tous les input comp_
						$$("input[id^=comp_]").each(function(item){
							the_comp_ttc = parseFloat(item.value);
							tout_complement_ttc+=the_comp_ttc;
						});
							
						new_px_total = parseFloat($('px_ttc').value) + tout_complement_ttc;
						$('px_total_bijoux').innerHTML = new_px_total.toFixed(2);
						$('px_total_bijoux_up').innerHTML = new_px_total.toFixed(2);
						if(arr[0]!=0) choix_txt_px = " (+ "+arr[0]+" &euro;)";
						
						//on met a jour le span du choix
						choix_txt = arr[1];
						if(choix_txt_px!="") choix_txt+=choix_txt_px;
						$('choix_couleur').innerHTML = choix_txt;
						$('choix_couleur').getParent('div').setStyle('display','block');
					},
					evalScripts: true
				}
			).request();
		}
	}else{ 
		if(obj==-1 || obj==-2){
				$('comp_taille_ttc').value = 0;
						
				tout_complement_ttc=0;
				
				// on calcule tous les input comp_
				$$("input[id^=comp_]").each(function(item){
					the_comp_ttc = parseFloat(item.value);
					tout_complement_ttc+=the_comp_ttc;
				});
					
				new_px_total = parseFloat($('px_ttc').value) + tout_complement_ttc;
				$('px_total_bijoux').innerHTML = new_px_total.toFixed(2);
				$('px_total_bijoux_up').innerHTML = new_px_total.toFixed(2);
				
				//on met a jour le span du choix
				//if(obj!=-2) $('choix_taille').innerHTML = "";
				//else $('choix_taille').innerHTML = $('txt_epuise').value;
				$('choix_taille').innerHTML = "";
				$('choix_taille').getParent('div').setStyle('display','none');
		}else{
		 	//epaisseur /taille
			new Ajax(
			'/js/ajax/select_att_perso.php',
			{
				data:"produit_id="+produit_id+"&produit_option_valeur_id="+obj,
				onSuccess: function(req) {
					var arr = req.split("|");
					choix_txt_px="";
					
					//on recupere le prix actuel
					//on ajoute le complement si il y a
					$('comp_taille_ttc').value = parseFloat(arr[0]);
					
					tout_complement_ttc=0;
					
					// on calcule tous les input comp_
					$$("input[id^=comp_]").each(function(item){
						the_comp_ttc = parseFloat(item.value);
						tout_complement_ttc+=the_comp_ttc;
					});
						
					new_px_total = parseFloat($('px_ttc').value) + tout_complement_ttc;
					$('px_total_bijoux').innerHTML = new_px_total.toFixed(2);
					$('px_total_bijoux_up').innerHTML = new_px_total.toFixed(2);
					if(arr[0]!=0) choix_txt_px = " (+ "+arr[0]+" &euro;)";
					
					//on met a jour le span du choix
					choix_txt = arr[1];
					if(choix_txt_px!="") choix_txt+=choix_txt_px;
					$('choix_taille').innerHTML = choix_txt;
					$('choix_taille').getParent('div').setStyle('display','block');
				},
				evalScripts: true
			}
			).request();
		}
	}
}



function videAutreFinition(support_id){
	
	//si on change la valeur du support
	//on doit recharger les autres listes de finition (fermoir, etc)
	// et les listes d'elements finition (pendentif, etc) + vider les gravures + virer les images visu
	// et on recalcule le prix
	//pas de finition choisie
	
	//autres finitions
	var autre_finition = 	$$('select[id^=finition_id]');		
	autre_finition.each(function(item){
		var theId = item.id;
		var num_id = theId.slice(12,theId.length);
			
		if(num_id!=support_id){
			$(theId).selectedIndex  = 0;
			if($('finition_id_'+support_id).value==-1 || $('finition_id_'+support_id).value==-2) $(theId).disabled = true;

			$('comp_finition_ttc_'+num_id).value=0;
			$('choix_finition_'+num_id).innerHTML = "";
			$('choix_finition_'+num_id).getParent('div').setStyle('display','none');
		}
	});
		
	//element de finitions
	var element_finition = 	$$('select[id^=element_finition_id_]');			
	element_finition.each(function(item){
		
		var theId = item.id;							
	  var num_cpt = theId.slice(22,theId.length);			
	  $(theId).selectedIndex  = 0;
		if($('finition_id_'+support_id).value==-1 || $('finition_id_'+support_id).value==-2) $(theId).disabled = true;

		$('comp_element_ttc_'+num_cpt).value=0;
		$('choix_element_finition_'+num_cpt).innerHTML = "";
	  $('choix_element_finition_'+num_cpt).getParent('div').setStyle('display','none');	
	  
	  $('valeur_parent_element_finition_id_'+num_cpt).value="";				
	  $('valeur_element_finition_id_'+num_cpt).value="";				
	});
		
	//div d'affichage des inputs de gravure	
	$$("div[id^=affiche_gravure_]").each(function(item){
		item.innerHTML="";
		item.setStyle('height','0');
	});
			
	//div d'affichage du recap des gravures
	$$("div[id^=choix_gravure_]").each(function(item){
		var mynode = document.getElementById(item.id);
		var parent_el = mynode.parentNode;
		parent_el.removeChild(mynode);
	});
	
	//div d'affichage du recap des produit option
	$$("span[id^=choix_produit_option]").each(function(item){
		item.innerHTML = "";
	  item.getParent('div').setStyle('display','none');	
	});
	
	//div d'affichage du recap des produit option
	$$("input[id^=comp_option_finition_ttc]").each(function(item){
		item.value = 0;
	});
	
	$('img_support').innerHTML="";
					
	//image perso
	$$("div[id^=img_element]").each(function(item){
		item.setStyle('width', '0px');
		item.innerHTML='';
	});
				
	//on recalcule le prix total
	tout_complement_ttc=0;

	// on calcule tous les input comp_
	$$("input[id^=comp_]").each(function(item){
		the_comp_ttc = parseFloat(item.value);
		tout_complement_ttc+=the_comp_ttc;
	});

	new_px_total = parseFloat($('px_ttc').value) + tout_complement_ttc;
	$('px_total_bijoux').innerHTML = new_px_total.toFixed(2);
	$('px_total_bijoux_up').innerHTML = new_px_total.toFixed(2);
}



// Si aucun element de finition (pendentif, charms) est choisi
// ou si il ne rentre pas dans le prévisu, on vide tout
function videSelectElementFinition(obj, input, id, id_element){
	//on met le complement ttc à 0
		$(input).value = 0;
		
		if(obj==-1 || obj==-2){
		}else{
			obj="";
		}
		
		$('valeur_parent_element_finition_id_'+id).value=obj;
		$('valeur_element_finition_id_'+id).value=obj;
			
		//on met a jour le span du récap
		$('choix_element_finition_'+id).innerHTML = "";
		$('choix_element_finition_'+id).getParent('div').setStyle('display','none');	
		
		
		// si il y avait une garvure associée à cet element, on cache le tout
		var helgrav = ($('affiche_gravure_'+id).getStyle('height').toInt());
						
		if(helgrav>0){
			var hel1 = ($('element_'+id).getStyle('height').toInt())-60;
			$('element_'+id).setStyle('height',hel1+'px');
		}
				
		$('affiche_gravure_'+id).innerHTML = "";
		$('affiche_gravure_'+id).setStyle('height','0');
		
		$$("input[id^=comp_gravure_ttc_"+id+"]").each(function(item){
			$(item.id).value = 0;
		});
		
		//on cache le div d'affichage du recap des gravures
		$$("div[id^=choix_gravure_"+id+"_]").each(function(item){
			var mynode = document.getElementById(item.id);
			var parent_el = mynode.parentNode;
			parent_el.removeChild(mynode);
		});
	
		tout_complement_ttc=0;
						
		// on calcule tous les input comp_ pour le prix total
		$$("input[id^=comp_]").each(function(item){
			the_comp_ttc = parseFloat(item.value);
			tout_complement_ttc+=the_comp_ttc;
		});

		new_px_total = parseFloat($('px_ttc').value) + tout_complement_ttc;
		$('px_total_bijoux').innerHTML = new_px_total.toFixed(2);
		$('px_total_bijoux_up').innerHTML = new_px_total.toFixed(2);
		
		
		//on cache l'image de la prévisu
		if($('img_element'+id)){
			$('img_element'+id).setStyle('width', '0px');
			$('img_element'+id).innerHTML='';
		}
		
		var the_width=0;
		
		//image perso
		$$("div[id^=img_element]").each(function(item){
			var the_width_el = (item.getStyle('width').toInt());
			item.setStyle('width', the_width_el+'px');
			the_width+=the_width_el;
		});
		
		if($('conteneur_img_element')){
			$('conteneur_img_element').setStyle('width', the_width+'px');
			var new_left = (380-the_width)/2;
			$('conteneur_img_element').setStyle('left', new_left+'px');
		}
		
		//on vide le select associe si existe (pendentif ou charms)
		var the_element_id = "element_finition_id_"+id+"_"+id_element;
		
		$$("select[id^=element_finition_id_"+id+"]").each(function(item){
			if(item.id!=the_element_id) $(item.id).value = -1;
		});
}

function selectOptionFinitionPerso(obj, input, id){
	//obj => valeur du select produit_option_id
	//inout => completement pour le prix
	//id = prosuit_option_id
	
	//ELEMENTS DE FINITION (Pendentif, charms ...) EN FONCTION DU SUPPORT
	var element_finition = 	$$('select[id^=element_finition_id_]');
	
	element_finition.each(function(item){	
		var theId = item.id;							
	  $(theId).disabled = false;
	});

	if(obj==-1 || obj==-2){
		$('img_support').innerHTML='';
		$(input).value = 0;
		
		$('choix_produit_option_'+id).innerHTML = "";
		$('choix_produit_option_'+id).getParent('div').setStyle('display','none');	
		
		tout_complement_ttc=0;
						
		// on calcule tous les input comp_ pour le prix total
		$$("input[id^=comp_]").each(function(item){
			the_comp_ttc = parseFloat(item.value);
			tout_complement_ttc+=the_comp_ttc;
		});

		new_px_total = parseFloat($('px_ttc').value) + tout_complement_ttc;
		$('px_total_bijoux').innerHTML = new_px_total.toFixed(2);
		$('px_total_bijoux_up').innerHTML = new_px_total.toFixed(2);
		//si il prend une truc vide ---

		if(id==1) {
			$$('div[id^=fpp_error_couleur_support_]').each(function(item){	
				var theId = item.id;
			  $(theId).setStyle('display','block');
			});
		}
		
	}else{

		if(id==1) {
			$$('div[id^=fpp_error_couleur_support_]').each(function(item){	
				var theId = item.id;
			  $(theId).setStyle('display','none');
			});
		}
		
		var support_id = $('finition_support_id').value;
		var finition_valeur_id = $('finition_id_'+support_id).value;
		
		
		new Ajax(
				'/js/ajax/select_option_finition_perso.php',
				{
					data:"finition_valeur_id="+finition_valeur_id+"&produit_option_valeur_id="+obj,
					onSuccess: function(req) {
						var arr = req.split("|");
						choix_txt_px="";
						
						//on recupere le prix actuel
						//on ajoute le complement si il y a
						$(input).value = parseFloat(arr[0]);
						
						tout_complement_ttc=0;
						
						// on calcule tous les input comp_
						$$("input[id^=comp_]").each(function(item){
							the_comp_ttc = parseFloat(item.value);
							tout_complement_ttc+=the_comp_ttc;
						});
	
						new_px_total = parseFloat($('px_ttc').value) + tout_complement_ttc;
						$('px_total_bijoux').innerHTML = new_px_total.toFixed(2);
						$('px_total_bijoux_up').innerHTML = new_px_total.toFixed(2);
						if(arr[0]!=0) choix_txt_px = " (+ "+arr[0]+" &euro;)";
						
						//on met a jour le span du choix
						choix_txt = arr[1];
						if(choix_txt_px!="") choix_txt+=choix_txt_px;
						$('choix_produit_option_'+id).innerHTML = choix_txt;
						$('choix_produit_option_'+id).getParent('div').setStyle('display','block');
						
						//on y met l'image
						$('img_de_base').setStyle('display', 'none');
						if(arr[2] != "") $('img_support').innerHTML='<img src="'+arr[2]+'" alt="'+arr[1]+'" class="png" style="width:'+arr[3]+'px;height:'+arr[4]+'px;" />';
					},
					evalScripts: true
				}
			).request();	
	}
}



function selectFinitionPerso(obj, input, id){
	
	if(id==3) {
		$$('div[id^=fpp_error_couleur_support_]').each(function(item){	
			var theId = item.id;							
		  $(theId).style.display = "block";
		});
	}

	produit_id = $('produit_id').value;
	var have_opt = 0;

	if(obj==-1 || obj==-2){
		
		//pas de finition choisie
		$(input).value = 0;
		
		tout_complement_ttc=0;
						
		// on calcule tous les input comp_
		$$("input[id^=comp_]").each(function(item){
			the_comp_ttc = parseFloat(item.value);
			tout_complement_ttc+=the_comp_ttc;
		});

		new_px_total = parseFloat($('px_ttc').value) + tout_complement_ttc;
		$('px_total_bijoux').innerHTML = new_px_total.toFixed(2);
		$('px_total_bijoux_up').innerHTML = new_px_total.toFixed(2);
						
		//on met a jour le span du choix
		$('choix_finition_'+id).innerHTML = "";
		$('choix_finition_'+id).getParent('div').setStyle('display','none');					
		
		var support_finition_id = $('finition_support_id').value;
						
		if(id==support_finition_id){	
			videAutreFinition(support_finition_id);
		}

		
	}else{
		new Ajax(
				'/js/ajax/select_finition_perso.php',
				{
					data:"produit_id="+produit_id+"&finition_valeur_id="+obj,
					onSuccess: function(req) {
						var arr = req.split("|");
						choix_txt_px="";
						
						//on recupere le prix actuel
						//on ajoute le complement si il y a
						$(input).value = parseFloat(arr[0]);
						
						tout_complement_ttc=0;
						
						// on calcule tous les input comp_
						$$("input[id^=comp_]").each(function(item){
							the_comp_ttc = parseFloat(item.value);
							tout_complement_ttc+=the_comp_ttc;
						});
	
						new_px_total = parseFloat($('px_ttc').value) + tout_complement_ttc;
						$('px_total_bijoux').innerHTML = new_px_total.toFixed(2);
						$('px_total_bijoux_up').innerHTML = new_px_total.toFixed(2);
						if(arr[0]!=0) choix_txt_px = " (+ "+arr[0]+" &euro;)";
						
						//on met a jour le span du choix
						choix_txt = arr[1];
						if(choix_txt_px!="") choix_txt+=choix_txt_px;
						$('choix_finition_'+id).innerHTML = choix_txt;
						$('choix_finition_'+id).getParent('div').setStyle('display','block');					
						
						var support_finition_id = $('finition_support_id').value;
						
						if(id==support_finition_id){	
							
							videAutreFinition(support_finition_id);
							
							//AUTRE FINITION QUE SUPPORT => fermoir, etc
							var autre_finition = 	$$('select[id^=finition_id]');
							
							autre_finition.each(function(item){
								
								var theId = item.id;
								var num_id = theId.slice(12,theId.length);
											
								if(num_id!=id){
									
									var id_sel = $(theId).value;		
															
									//on recharge la liste des finitions (fermoir) en fonction du choix
									new Ajax(
										'/js/ajax/charge_finition_assoc.php',
										{
											data:"produit_id="+produit_id+"&finition_valeur_id="+obj+"&finition_id="+num_id+"&id_sel="+id_sel,
											update:$('div_int_fin_'+num_id),
											onSuccess: function(req) {
												$(theId).disabled = false;
											},
											evalScripts: true
										}
									).request();
								}
								
							});

							//OPTION DE FINITION DU SUPPORT => Couleur, taille, etc
							var option_finition = $$('div[id^=div_opt_fin_]');
							
							option_finition.each(function(item){
								
								var theId = item.id;
								var num_id = theId.slice(12,theId.length);
														
								//on recharge la liste des options de finitions (couleur, taille) en fonction du choix
								new Ajax(
									'/js/ajax/charge_option_finition_assoc.php',
									{
										data:"&finition_valeur_id="+obj+"&produit_option_id="+num_id,
										update:$('div_opt_fin_'+num_id),
										onSuccess: function(req) {
											if($('produit_option_id_'+num_id)) $('produit_option_id_'+num_id).disabled = false;
											if($('produit_option_id_'+num_id)) have_opt = 1;
										},
										evalScripts: true
									}
								).request();
								
							});
						
						
							//ELEMENTS DE FINITION (Pendentif, charms ...) EN FONCTION DU SUPPORT
							var element_finition = 	$$('select[id^=element_finition_id_]');
							
							element_finition.each(function(item){
								
								var theId = item.id;							
							  var num_cpt_id = theId.slice(20,theId.length);			//element_finition_id_+etape+_+idelement
							  
							  var arr_id = num_cpt_id.split("_");
							  var etape = arr_id[0];
							  var el_id = arr_id[1];
							  							  
								//on recharge la liste des finitions en fonction du choix
								new Ajax(
									'/js/ajax/charge_element_finition_assoc.php',
									{
										data:"finition_valeur_id="+obj+"&element_finition_id="+el_id+"&etape="+etape,
										update:$('div_int_elfin_'+etape+'_'+el_id),
										onSuccess: function(req) {
											if(have_opt == 0) $(theId).disabled = false;
											if(have_opt == 1) $(theId).disabled = true;
										},
										evalScripts: true
									}
								).request();					
							});
							
							
							
							var valeur_element_finition_id = 	$$('input[id^=valeur_element_finition_id_]');
							
							valeur_element_finition_id.each(function(item){
								
								var theId = item.id;							
							  $(theId).value='';
			
							});
							
							var valeur_parent_element_finition_id = 	$$('input[id^=valeur_parent_element_finition_id_]');
							
							valeur_parent_element_finition_id.each(function(item){
								
								var theId = item.id;							
							  $(theId).value='';
			
							});
							
							var choix_element_finition = 	$$('span[id^=choix_element_finition_]');
							
							choix_element_finition.each(function(item){
								
								var theId = item.id;							
							  $(theId).innerHTML='';
								$(theId).getParent('div').setStyle('display','none');
			
							});

						}
						
					},
					evalScripts: true
				}
			).request();
	}
}


function selectElementFinition(obj, input, id, id_element){
	// obj => value retourné du select
	// input => input du complement ttc de l'element
	// id => id de l'etape de l'élement de finition
	// id_element => id de l'élement de finition
	
	produit_id = $('produit_id').value;
	
	if(obj==-1 || obj==-2){
		//pas d'element de finition choisi ou element epuisé (-2)
		videSelectElementFinition(obj, input, id, id_element);
		
	}else{
		//on vide le select associe si existe (pendentif ou charms)
		var the_element_id = "element_finition_id_"+id+"_"+id_element;
		
		$$("select[id^=element_finition_id_"+id+"]").each(function(item){
			if(item.id!=the_element_id) $(item.id).value = -1;
		});
		
		$$("input[id^=comp_gravure_ttc_"+id+"]").each(function(item){
			$(item.id).value = 0;
		});
		
		$('valeur_parent_element_finition_id_'+id).value=id_element;
		$('valeur_element_finition_id_'+id).value=obj;
		
		 new Ajax(
				'/js/ajax/select_element_finition_perso.php',
				{
					data:"element_finition_valeur_id="+obj,
					onSuccess: function(req) {
						var arr = req.split("|");
						
						var the_width_total = 0;
						var the_width_element = arr[3];
						var the_width_max = 380;
						
						//on va regarder si l'élement selectionné rentre dans le visuel

						$$("div[id^=img_element]").each(function(item){							
							var the_width_el = (item.getStyle('width').toInt());							
							the_width_total+=the_width_el;
						});
						
						//si l'élement existe deja, on enleve son width
						if($('img_element'+id)){
							the_width_total = the_width_total - ($('img_element'+id).getStyle('width').toInt());	
						}

						var the_width_total_element = the_width_total.toInt()+the_width_element.toInt();
						
						if(the_width_total_element<=the_width_max){
							
							$('nb_max_element').setStyle('display', 'none');
							$('nb_max_element_'+id).setStyle('display', 'none');
							
							choix_txt_px="";
							
							//on recupere le prix actuel, on le met ds le input du complement associe
							$(input).value = parseFloat(arr[0]);
							
							tout_complement_ttc=0;
							
							// on calcule tous les input comp_ (pour avoir le prix des complements a ajouter au prix produit)
							$$("input[id^=comp_]").each(function(item){

								the_comp_ttc = parseFloat(item.value);
								tout_complement_ttc+=the_comp_ttc;
							});
		
							new_px_total = parseFloat($('px_ttc').value) + tout_complement_ttc; //prix produit + complement des options
							$('px_total_bijoux').innerHTML = new_px_total.toFixed(2); // affichage du prix total
							$('px_total_bijoux_up').innerHTML = new_px_total.toFixed(2); // affichage du prix total
							if(arr[0]!=0) choix_txt_px = " (+ "+arr[0]+" &euro;)"; // prix de l'option
							
							//on met a jour le span du choix de l'option
							choix_txt = arr[1];
							if(choix_txt_px!="") choix_txt+=choix_txt_px;
							$('choix_element_finition_'+id).innerHTML = choix_txt;
							$('choix_element_finition_'+id).getParent('div').setStyle('display','block');	
							
							// image de personnalisation
							if(arr[2]!=""){
								//div conteneur des div images, on le cree qu'une seule fois							
								if(!$('conteneur_img_element')){
										var position_top = $('position_top').value.toInt();
										var conteneur_photoprod = $('conteneur_photoprod');
									
										var perso_image = new Element('div', {
											id: 'conteneur_img_element',
									    'styles': {'top': 224+'px', 'position' : 'absolute', 'z-index' : 50}
										});
										
										perso_image.inject(conteneur_photoprod, 'top');
								}
								
								
								if($('img_element'+id)){
									//le div existe deja, on change l'image
									$('img_element'+id).innerHTML='<img id="img_img_element'+id+'" src="'+arr[2]+'" alt="'+arr[1]+'" class="png" style="width:'+arr[3]+'px;height:'+arr[4]+'px;" />';					
									$('img_element'+id).setStyle('width', arr[3]+'px');
								}else{
									// on cree un div dans le conteneur_img_element
									var conteneur_img_element = $('conteneur_img_element');
									
									var perso_image_element = new Element('div', {
										id: 'img_element'+id,
								    'styles': {'float' : 'left'}
									});
		
									//on y met l'image
									perso_image_element.innerHTML='<img id="img_img_element'+id+'" src="'+arr[2]+'" alt="'+arr[1]+'" class="png" style="width:'+arr[3]+'px;height:'+arr[4]+'px;" />';
									
									//on insere
									perso_image_element.inject(conteneur_img_element, 'bottom');
		
									$('img_element'+id).setStyle('width', arr[3]+'px');
									
									perso_image_element.inject(conteneur_img_element);
									
									var places = new Array();
									
									$$("div[id^=img_element]").each(function(item){
										//si ya avant
										var theId = item.id;
										var num_id = theId.slice(11,theId.length);
										
										if(num_id < id) places.push(num_id);
									});
									
									if(places.length!=0){
										var der_id = places[places.length-1];
										var the_indice = $('img_element'+der_id);
										
										//on le place apres l'indice trouve
										perso_image_element.inject(the_indice, 'after');
									}else{
										$$("div[id^=img_element]").each(function(item){
											//si ya apres
											var theId = item.id;
											var num_id = theId.slice(11,theId.length);
											
											if(num_id > id) places.push(num_id);
										});
										
										if(places.length!=0){
												var der_id = places[0];
												var the_indice = $('img_element'+der_id);
												
												//on le place apres l'indice trouve
												perso_image_element.inject(the_indice, 'before');
										}
									}
								}
								
								//on recalcule les width pour centrer le tout
								var the_width = 0;
								
								$$("div[id^=img_element]").each(function(item){
									var the_width_el = (item.getStyle('width').toInt());							
									the_width+=the_width_el;
								});
								
								$('conteneur_img_element').setStyle('width', the_width+'px');
								var new_left = (380-the_width)/2;
								$('conteneur_img_element').setStyle('left', new_left+'px');	
							}
							
							
							var helgrav = ($('affiche_gravure_'+id).getStyle('height').toInt());
							
							//ya a til de la gravure associe a cet element de finition ?
							new Ajax(
							'/js/ajax/select_gravure_produit.php',
							{
								update:$('affiche_gravure_'+id),
								data:"element_finition_valeur_id="+obj+"&iteration="+id,
								onSuccess: function(req) {
			
									//faut vider les gravures lors du changement d'element
									$$("div[id^=choix_gravure_"+id+"_]").each(function(item){
										var mynode = document.getElementById(item.id);
										var parent_el = mynode.parentNode;
										parent_el.removeChild(mynode);
									});
									
									
									if(req!=""){
										if(helgrav==0){
											var hel1 = ($('element_'+id).getStyle('height').toInt())+60;
											$('element_'+id).setStyle('height',hel1+'px');
										}
										
										$('affiche_gravure_'+id).setStyle('height','70px');
									}else{
										if(helgrav>0){
											var hel1 = ($('element_'+id).getStyle('height').toInt())-60;
											$('element_'+id).setStyle('height',hel1+'px');
										}
										
										$('affiche_gravure_'+id).setStyle('height','0');
									}
								},
								evalScripts: true
							}
						).request();
						}else{
							//plus de place pour l'élement selectionne
							$("element_finition_id_"+id+"_"+id_element).value="-1";
							$('nb_max_element').setStyle('display', 'block');
							$('nb_max_element_'+id).setStyle('display', 'block');
							
							var hel1 = ($('element_'+id).getStyle('height').toInt())+20;
							$('element_'+id).setStyle('height',hel1+'px');
							
							videSelectElementFinition(obj, input, id, id_element);
							
							
						}
					},
					evalScripts: true
				}
			).request();
	}
}




function enterGravure(obj, input, ite, id, cible){
	
	produit_id = $('produit_id').value;
	
	if(cible=='produit'){
		new Ajax(
				'/js/ajax/select_gravure_produit.php',
				{
					data:"produit_id="+produit_id+"&gravure_id="+id,
					onSuccess: function(req) {
						var arr = req.split("|");
						choix_txt_px="";
						
						//on recupere le prix actuel
						//on ajoute le complement si il y a
						if(obj!=""){
							$(input).value = parseFloat(arr[0]);
							$('gravure_produit_id'+id).value = id;
						}else{
							$(input).value = 0;
							$('gravure_produit_id'+id).value = "";
						}
						
						tout_complement_ttc=0;
						
						// on calcule tous les input comp_
						$$("input[id^=comp_]").each(function(item){
							the_comp_ttc = parseFloat(item.value);
							tout_complement_ttc+=the_comp_ttc;
						});
	
						new_px_total = parseFloat($('px_ttc').value) + tout_complement_ttc;
						$('px_total_bijoux').innerHTML = new_px_total.toFixed(2);
						$('px_total_bijoux_up').innerHTML = new_px_total.toFixed(2);
						if(arr[0]!=0) choix_txt_px = " (+ "+arr[0]+" &euro;)";
					
						if(obj!=""){
							 $('choix_gravure_'+id).innerHTML = obj;
							 $('choix_gravure_'+id).getParent('div').setStyle('display','block');	
						}else{
							$('choix_gravure_'+id).innerHTML = "";
							$('choix_gravure_'+id).getParent('div').setStyle('display','none');	
						}
							
						
					},
					evalScripts: true
				}
			).request();
	}else{
		//element finition : pendentif
		var id_efv = $('valeur_element_finition_id_'+ite).value;
		
		new Ajax(
				'/js/ajax/select_gravure_produit.php',
				{
					data:"element_finition_valeur_id="+id_efv+"&gravure_id="+id,
					onSuccess: function(req) {
						var arr = req.split("|");
						choix_txt_px="";
						
						//on recupere le prix actuel
						//on ajoute le complement si il y a
						if(obj!=""){
							$(input).value = parseFloat(arr[0]);
							$('gravure_id_'+ite+'_'+id).value = id;
						}else{
							$(input).value = 0;
							$('gravure_id_'+ite+'_'+id).value = "";
						}
						
						tout_complement_ttc=0;
						
						// on calcule tous les input comp_
						$$("input[id^=comp_]").each(function(item){
							the_comp_ttc = parseFloat(item.value);
							tout_complement_ttc+=the_comp_ttc;
						});
	
						new_px_total = parseFloat($('px_ttc').value) + tout_complement_ttc;
						$('px_total_bijoux').innerHTML = new_px_total.toFixed(2);
						$('px_total_bijoux_up').innerHTML = new_px_total.toFixed(2);
						if(arr[0]!=0) choix_txt_px = " (+ "+arr[0]+" &euro;)";
					
						if(obj!=""){
							if(!$('the_choix_gravure_'+ite+'_'+id)){
								var the_div_recap = $('choix_element_finition_'+ite).getParent();
								var the_gravure_recap = new Element('div', {id: 'choix_gravure_'+ite+'_'+id});
								
								the_gravure_recap.inject(the_div_recap, 'bottom');
								var lib_gravure = $('lib_gravure_'+ite+'_'+id).innerHTML;
								var inhtml = '<div style="margin:5px 0 5px 10px;font-size:11px;">- '+lib_gravure+' <span id="the_choix_gravure_'+ite+'_'+id+'" class="span_recap_choix">'+obj+'</span></div> ';
								
								the_gravure_recap.innerHTML = inhtml;
							}else{
								$('the_choix_gravure_'+ite+'_'+id).innerHTML=obj;
							}
						}else{
							if($('the_choix_gravure_'+ite+'_'+id)){
								$('the_choix_gravure_'+ite+'_'+id).innerHTML=obj;
								$('choix_gravure_'+ite+'_'+id).setStyle('display','none');	
							}
						}
						
					},
					evalScripts: true
				}
			).request();
		
	}
}

function scrollPersoTo(el){
	var scrollfx = new Fx.Scroll(window).toElement(el);
}


function slideElement(el){
	
	var main_menu_items = $$('div[id^=element_]');	
	
	main_menu_items.each(function(item){
			
			var fx = new Fx.Styles($(item.id), {duration:300, wait:false});
				
			if($(item.id).getStyle('height').toInt()>0){
				fx.start({
						'height' : 0
				});
			}
		});
		
		
		var fx = new Fx.Styles($(el), {duration:400, wait:false});
	
		var content1 = $('int_'+el);
		var c1Height = content1.getSize().scrollSize.y;
		c1Height += 10;
		
		if($(el).getStyle('height').toInt()==0){
			fx.start({
					'height' : c1Height
			});		
		}else{
			fx.start({
					'height' : 0
			});
		}
}


function boutonSlide(){
	
	var bouton_slide = $$('div[id^=btn_slide_]');	
	
	bouton_slide.each(function(item){
		item.addEvent('click',function(e){
			var theId = item.id;
			var num_id = theId.slice(10,theId.length);
			slideElement('element_'+num_id);
		});
	});
}

function memoBook(){
	/*var lien_memo = $$('a[id^=memo_]');	
	
	lien_memo.each(function(item){
		item.addEvent('click',function(e){
			var theId = item.id;
			var produit_id = theId.slice(5,theId.length);
			Memokado.bookmark(e, produit_id);
			return false;
		});
	});*/
	
	$$('a[id^=memo_]').addEvent('click',function(e){
		var theId = this.id;
		var produit_id = theId.slice(5,theId.length);
		Memokado.bookmark(e, produit_id);
		return false;
	});
	
	$$('a[id^=autre_memo_]').addEvent('click',function(e){
		var theId = this.id;
		var produit_id = theId.slice(11,theId.length);
		Memokado.bookmark(e, produit_id);
		return false;
	});
}


