window.addEvent('domready', function() {
									 
	//if($("menuCataCol")) menuCascade ("menuCataCol");
	if($chk($('menuEcom'))) {
		$('menuEcom').innerHTML = '<img src="'+racine+'/theme/img/imgform/loading.gif" /> Chargement...';
		$('menuEcom').load(racine+'/modules/ecommerce/aj_info_user.php');
	}
	
	
});

function menuCascade (idMenu) {
	
	if(!$(idMenu).hasClass('modAdmin')) {
		var l=document.getElementById(idMenu).getElementsByTagName('LI');
		for ( var n=0; n<l.length; n++ ){
		var fait = true;
		
		if($(l[n]).hasClass('rubEnCours')) {
			if(idMenu == 'menuCataGen') {fait = true;}else{fait = false;}
		}
		  if(fait) {
			l[n].unselectable="on";	// pour faire plus propre : "non sélectionnable", ne fonctionne pas avec FF ?
			if ( l[n].getElementsByTagName('UL') && l[n].getElementsByTagName('UL').length>0 ){
			  l[n].onmouseover = function(){	
				 this.getElementsByTagName('UL')[0].style.visibility="visible";
			  }
			  l[n].onmouseout = function(){	
				this.getElementsByTagName('UL')[0].style.visibility="hidden";	
			  }
			  l[n].getElementsByTagName('A')[0].innerHTML = "<img src='"+racine+"/theme/img/imgstand/cataPlus.gif' />"+l[n].getElementsByTagName('A')[0].innerHTML;
			}else{
			  l[n].getElementsByTagName('A')[0].innerHTML += "<img src='"+racine+"/theme/img/imgstand/cataPlus.gif' style='width:0;height:0;'/>";
			}
		  }
		}
	}
}
function superMenu () {
	
	
	$('fond_menu_b').setStyles({'backgroundColor' : '#000000', 'opacity' : 0.5});
	
	var mySlide = new Fx.Slide('fond_menu_b', {mode: 'vertical', duration:'short'});
	mySlide.hide();
	
	var btnFerme = new Element('img', {'id' : 'supMenuFerm', 'src' : racine+'/theme/img/admin/delete.png'});
	var infoRubrique = new Element('div', {'id' : 'infoRubrique'});
	

	var ln = $$("#menuCataGen .niveau_0");
	
	ln.each(function(elem,index){
			
		var sousMenu = elem.getElementsByTagName('UL')[0];
		
		var balisA = elem.getFirst();
					 
		balisA.addEvent('click', function(e){
			
			e = new Event(e);
			mySlide.slideIn();
			
			$$("#menuCataGen li ul").each(function(elemMenu,index){
				elemMenu.setStyle('display','none');									   
			});
			
			sousMenu.fade('hide');
			sousMenu.setStyles({'display' : 'block'});
			sousMenu.fade('in');
			
			if($chk($('supMenuFerm'))) $('supMenuFerm').destroy();
			if($chk($('infoRubrique'))) $('infoRubrique').destroy();
			
			infoRubrique.fade('hide');
			infoRubrique.inject(sousMenu, 'before');
			btnFerme.inject($('fond_menu'), 'top');
			
			$('infoRubrique').load(racine+'/modules/catalogue/aj_aff_rubrique.php?idRub='+balisA.get('id'));
			
			infoRubrique.fade('in');
			
			e.stop();
			
				
		});
			
		btnFerme.addEvent('click', function(e){
	
			$$("#menuCataGen li ul").each(function(elemMenu,index){
				elemMenu.setStyle('display','none');									   
			});
			
			e = new Event(e);
			mySlide.slideOut();
			btnFerme.destroy();
			infoRubrique.destroy();
			e.stop();
		
		});
					 
	});		 
	
}
function proAffPhoto (id) {
	
	$$('.proPhoto').each(function(elem,index){
		elem.setStyle('display', 'none');
	});
	
	$('gVignette-'+id).setStyle('display', 'block');
	
	
}
function selTaille (id, disp) {
	
	
	if(disp == 'non') {
		
		$('btnPanier').set('href','javascript:void(0);');
		$('btnPanier').innerHTML = 'Produit plus disponnible';
		
	}else{
	
		$$("#liste_taille a").each(function(elem,index){elem.erase('class');});
		
		var myRequest=new Request({
			method:'post',
			url:racine+'/modules/catalogue/aj_sel_taille.php',
			onComplete:function(response){
				
				param=response.split('%%%');
				
				if($('proTailleSel')) $('proTailleSel').innerHTML = param[1];
				if($('proPrixFin')) $('proPrixFin').innerHTML = param[0];
				if($('proCardePromo') && param[3]) $('proCardePromo').innerHTML = param[3];
				
				$$('#proListTaille .sel').set('class', '');
				
				$('taille'+id).set('class', 'sel');
				$('tailleSel').value = id;
				
				
				
			}
		});
		myRequest.send('id='+id);
	
	}
	
}

function popPub (lien, H, L) {
	
	//Centrer la popup
	if (parseInt(navigator.appVersion)>3) {
	 if (navigator.appName=="Netscape") {
	  winW = window.innerWidth;
	  winH = window.innerHeight;
	 }
	 if (navigator.appName.indexOf("Microsoft")!=-1) {
	  winW = document.body.offsetWidth;
	  winH = screen.height - 300;
	  
	 }
	}



	//Création d'une popup
	if($chk($('popPanier'))) $('popPanier').destroy();
	if($chk($('contPop'))) $('contPop').destroy();
	var popPanier = new Element('div', {'id' : 'popPanier'});
	
	//Style conteneur
	nouvH = H+30;
	nouvL = L+30;
	posTop = (winH - nouvH) /2;
	posLeft = (winW - nouvL) /2;
	
	popPanier.setStyles({'width' : nouvL, 'height' : nouvH, 'position' : 'fixed', 'top' : posTop, 'left' : posLeft, 'zIndex' : 100, 'background-color': '#000', opacity: 0, 'id' : 'popTPanier'});
	popPanier.get('tween', {property: 'opacity', duration: 200}).start(0.7);
	
	
	//Feneêtre de la popup
	var contPopup = new Element('div', {'id' : 'contPop'});
	posTop = (winH - H) /2 -1;
	posLeft = (winW - L) /2 -1;
	contPopup.setStyles({
		'width' : L, 
		'height' : H, 
		'position' : 'fixed', 
		'top' : posTop, 
		'left' : posLeft, 
		'zIndex' : 200, 
		'border' : 'solid 1px #000',
		'overflow' : 'auto', 
		opacity: 0
	});
	contPopup.get('tween', {property: 'opacity', duration: 200}).start(1);
	

	
	posCharge = (H / 2) - 16;
	contPopup.innerHTML = '<div style="margin-top:'+posCharge+'px;text-align:center;" id="resultPop"><img src="'+racine+'/theme/img/imgstand/ajax-loader.gif" /><span> <b>Chargement...</span></b></div>';
	
	
	 
	popPanier.inject($('main'), 'top');
	 	
	contPopup.inject($('main'), 'top');
	
	var myRequest=new Request({
	method:'post',
	url:lien,
	onFailure :function () { 
		$('resultPop').innerHTML ='Une erreur est survenue. Merci d\'essayer plus tard';
	}, 
	onComplete:function(reponse){
		
		$('contPop').innerHTML = reponse;
		
		var ferme = new Element('a',{
			'id' : 'ferm_resultPop', 
			'href' : 'javascript:popPubClose();', 
			'style' : 'position:absolute;text-decoration:none;right:5px;display:block;text-align:center;width:16px;height:16px;'
		});
		
		ferme.innerHTML = 'x';
		
		ferme.inject($('contPop'), 'top');
		
		
	}		
	
	}).send();
	
	
	
	
}

function popPubClose() {
	$('contPop').get('tween', {property: 'opacity', duration: 200}).start(0);
	$('popPanier').get('tween', {property: 'opacity', duration: 200}).start(0);
}


function ajoutPanier(idProd, idRub, idQte) {
	
	popPub (racine+'/modules/mon-panier/aj_ajout_panier.php?idPro='+idProd+'&idRub='+idRub+'&idQte='+idQte, 250, 410);
	
}
function qte_article (qte, id) {

	
	$('panier').innerHTML = '<p>chargement des données de votre panier, merci de bien vouloir patienter...</p><p><img src="'+racine+'/theme/img/imgstand/ajax-loader.gif" /></p>';

	var myRequest=new Request({
	method:'post',
	url:racine+'/modules/mon-panier/aj_qte_panier.php',
	onFailure :function () { 
		
		$('panier').innerHTML = "Une erreur est surnvenue. ";
		
	}, 
	onComplete:function(reponse){
		
		$('panier').load(racine+'/modules/mon-panier/aj_contenu_panier.php');
		
	}		
	
	}).send('id='+id+'&qte='+qte);

}

function aff_autre_res () {

	if(!$chk(liste_id_res[cle])) cle = 0;
	
	id = liste_id_res[cle];
	
	if(id == '') {cle++;aff_autre_res ();}
	
	$('res_autres_resultats').innerHTML = '<p style="padding:10px;text-align:center"><img src="'+racine+'/theme/img/imgstand/ajax-loader.gif" /><br/>Veuillez patienter...</p>';
	
	var myRequest=new Request({
		method:'post',
		url:racine+'/modules/catalogue/aj_autre_res.php',
		onComplete:function(reponse){
		
			$('res_autres_resultats').innerHTML = reponse;
			cle++;
			
		}		
	}).send('id='+id);

}





