// /* Faux Console by Chris Heilmann http://wait-till-i.com */ if(!window.console){var console={init:function(){console.d=document.createElement('div');document.body.appendChild(console.d);var a=document.createElement('a');a.href='javascript:console.hide()';a.innerHTML='close';console.d.appendChild(a);var a=document.createElement('a');a.href='javascript:console.clear();';a.innerHTML='clear';console.d.appendChild(a);var id='fauxconsole';if(!document.getElementById(id)){console.d.id=id;}console.hide();},hide:function(){console.d.style.display='none';},show:function(){console.d.style.display='block';},log:function(o){console.d.innerHTML+='<br/>'+o;console.show();},clear:function(){console.d.parentNode.removeChild(console.d);console.init();console.show();},/*Simon Willison rules*/addLoadEvent:function(func){var oldonload=window.onload;if(typeof window.onload!='function'){window.onload=func;}else{window.onload=function(){if(oldonload){oldonload();}func();}};}};console.addLoadEvent(console.init);}
if (typeof console == "undefined" || typeof console.log == "undefined") var console = { log: function() {} }; 
var fondDiv = false;
var dataDiv = false;
var console_ie=false;
//var href_compatibility_regexp	=	/^([a-z0-9]+:\/\/)?([^\/:]+)?(:[\d]+)?(\/)?(.*$)?/g ;// Permet de retraiter les hrf et autres pathname quelque soit le navigateur
var href_compatibility_regexp	=	/^(?:\w+:\/\/[^\s\/]+)?\/?(.*)/;// Permet de retraiter les hrf et autres pathname quelque soit le navigateur

function menu(obj)
{
	if(!$(obj).hasClass('active'))
		$(obj).addClass('hover').addClass('jshover');
}

function hidemenu(item)
{
	$$('#'+item+' li.jshover').removeClass('hover').removeClass('jshover');
}

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);

}





function popup(href, id, w, h, r, s) {

	if(id == 'taille')
	{
		if(!fondDiv){
			fondDiv = document.createElement('div');
			fondDiv.style.position = 'absolute';
			initPopUp();
			
			document.body.appendChild(fondDiv);
		}
		fondDiv.innerHTML = '';
	
		$(fondDiv).setStyles({
		   backgroundColor: '#000000',
		   width: '100%',
		   height: getScrollHeight(),
		   position: 'absolute',
		   opacity: '0.75',
		   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: '#dcdcdc',
		   width: '640px',
		   height: '450px',
		   position: 'absolute',
		   top: '50%',
		   left: '50%',	   
		   marginLeft: '-320px',	   
		   marginTop: (getScrollTop()-225) + 'px',	   	   	   
		   zIndex: '1600',
		   visibility: 'hidden'
		});
	
		new Ajax(
			href,
			{
				update: dataDiv,
				onSuccess: function(req) {
	
						$$(fondDiv).setStyles({visibility: 'visible' });
						//$$('select').setStyles({visibility: 'hidden' });
						$$(dataDiv).setStyles({visibility: 'visible' });
						
				},
				evalScripts: true,
				method:'get'
			}
		).request();
	}
	else if(id == 'amis')
	{
	if(!fondDiv){
			fondDiv = document.createElement('div');
			fondDiv.style.position = 'absolute';
			initPopUp();
			
			document.body.appendChild(fondDiv);
		}
		fondDiv.innerHTML = '';
		//alert(getHeight());
	
		$(fondDiv).setStyles({
		   backgroundColor: '#000000',
		   width: '100%',
		   height: getScrollHeight(),
		   position: 'absolute',
		   opacity: '0.75',
		   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: '#dcdcdc',
		   width: '640px',
		   height: '350px',
		   position: 'absolute',
		   top: '50%',
		   left: '50%',	   
		   marginLeft: '-320px',	   
		   marginTop: (getScrollTop()-175) + 'px',	   	   	   
		   zIndex: '1600',
		   visibility: 'hidden'
		});
	
		new Ajax(
			href,
			{
				update: dataDiv,
				onSuccess: function(req) {
	
						$$(fondDiv).setStyles({visibility: 'visible' });
						//$$('select').setStyles({visibility: 'hidden' });
						$$(dataDiv).setStyles({visibility: 'visible' });
						
				},
				evalScripts: true,
				method:'get'
			}
		).request();
	}
	else if(id == 'image')
	{
	if(!fondDiv){
			fondDiv = document.createElement('div');
			fondDiv.style.position = 'absolute';
			initPopUp();
	
			document.body.appendChild(fondDiv);
		}
		fondDiv.innerHTML = '';
		//alert(getHeight());
	
		$(fondDiv).setStyles({
		   backgroundColor: '#000000',
		   width: '100%',
		   height: getScrollHeight(),
		   position: 'absolute',
		   opacity: '0.75',
		   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: '#FFF',*/
		   width: '452px',
		   height: '514px',
		   position: 'absolute',
		   top: '50%',
		   left: '50%',	   
		   marginLeft: '-226px',	   
		   marginTop: (getScrollTop()-257) + 'px',	   	   	   
		   zIndex: '1600',
		   visibility: 'hidden'
		});

		new Ajax(
			'/image.php',
			{
				update: dataDiv,
				data:'url='+href+'&produit_id='+r,
				
				onSuccess: function(req) {
	
						$$(fondDiv).setStyles({visibility: 'visible' });
						//$$('select').setStyles({visibility: 'hidden' });
						$$(dataDiv).setStyles({visibility: 'visible' });
						
				},
				evalScripts: true
			}
		).request();
	}
	else
		window.open(href, id, 'width='+w+',height='+h+',resizable='+r+',scrollbars='+s+',toolbar=0,directories=0,status=0,menubar=0');

}



function affectPrix(bon_achat_id,valeur,panier,ports)

{

	if(document.getElementById(bon_achat_id).checked)

	{

		texte = file('/ajax/ajax_ba.php?bon_achat_id='+ bon_achat_id);

		if(texte=="ok")

		{

			document.getElementById(bon_achat_id).checked=true;

			$('total').innerHTML=Math.round((parseFloat(panier) - parseFloat(valeur))*100)/100;

		}

		else if(texte=="ok2")

		{

			//document.getElementById(bon_achat_id).disabled=true;

			//$('total').innerHTML=Math.round((parseFloat(panier) - parseFloat(valeur))*100)/100;

			$('total').innerHTML=ports;

			

			erreur_ba = file('/ajax/ajax_txt.php?erreur_ba=1');

			alert(erreur_ba);

		}

		else

		{

			document.getElementById(bon_achat_id).checked=false;

			alert(texte);

		}

	}

	else

	{

		texte = file('/ajax/ajax_ba.php?del=1&bon_achat_id='+ bon_achat_id);

		$('total').innerHTML=panier;

	}

}



function SecureConfirm(obj)

{

	if(confirm('Voulez-vous supprimer votre adresse du carnet ?')) {

		obj.submit();

	}else{

		return false;

	}

}



function SecureConfirm2(obj)

{

	if(confirm('Voulez-vous supprimer ce flux?')) {

		obj.submit();

	}else{

		return false;

	}

}



function ActionSelect(Objet){  

	var val = Objet.value.toLowerCase();       

	var dest;        

	switch(val){            

		case "nouvelle_adresse" :                

			dest="/account_address_book.html?cmd=add&origin=panier";                

			break;            

		default:                

			return false;            

	}        

	location.href=dest;

}

function gotourl(obj)
{
	if($(obj).value) location.href=$(obj).value;
}



function filter_art(Obj)

{



	if(Obj == 'all')

	{

		

		arrArt = $$('#listing_art option').setStyle('display', 'block');

		arrArt2 = $$('#listing_art2 option').setStyle('display', 'none');

		

		numArt = arrArt.length;

		numArt2 = arrArt2.length;

		

		$('num_arti').setHTML(numArt2);

		

		if(document.all)

		{



			document.getElementById('listing_art').options.length = 0;

			var obj = document.getElementById('listing_art');



			for(i=0;i<numArt2;i++)

			{

				obj.options[obj.options.length] = new Option(arrArt2[i].text,arrArt2[i].value)

			}

			

		}				

				

		

	}

	else

	{

		$$('#listing_art option').setStyle('display', 'none');

		arrArt = $$('#listing_art option.'+Obj).setStyle('display', 'block');

		arrArt2 = $$('#listing_art2 option.'+Obj).setStyle('display', 'block');

		

		

		numArt = arrArt.length;

		numArt2 = arrArt2.length;

		

		

		$('num_arti').setHTML(numArt2);				

		

		

		if(numArt>1) $('is_two').setStyle('display', 'inline');

		else $('is_two').setStyle('display', 'none');

		

		

		if(document.all)

		{



			document.getElementById('listing_art').options.length = 0;

			var obj = document.getElementById('listing_art');



			for(i=0;i<numArt2;i++)

			{

				obj.options[obj.options.length] = new Option(arrArt2[i].text,arrArt2[i].value)

			}



			for(i=0;i<numArt;i++)

			{

				obj.options[obj.options.length] = new Option(arrArt[i].text,arrArt[i].value)

			}		

			

		}

	}

}



function showHide(id) {

	

	var obj = document.getElementById(id);



	if (obj.style.display == 'inline')

	{

		obj.style.display = 'none'

	}else{

		obj.style.display = 'inline'

	}	

	

}



var curForm = false;



function addNewsletter(obj)

{

	

	curForm = obj;

	new Ajax(

		obj.action,

		{

			data:$(obj).toQueryString(),

			onComplete: displayError

		}

	).request();

}



function displayError(txt)

{

	alert(txt);	

	if(txt.indexOf('notre') != -1)

		curForm.reset();

}



var xtoAdd = 475;

/*

function leftClick() {

	leftx = document.getElementById('innercontent');

	x = leftx.style.left.toInt();

	if(x == "" || isNaN(x)){

		x = 0;

	}

	

	//alert(x);

	if(x>-10 || x>=0) x=x-xtoAdd;



	//alert(x);



	if(x<=-xtoAdd)

		$('innercontent').effect('left',{ duration: 800, transition: Fx.Transitions.Quad.easeOut, wait:true }).start(x, x + xtoAdd );

}



function rightClick() {

	rightx = document.getElementById('innercontent');

	x = rightx.style.left.toInt();

	if(x == "" || isNaN(x)) {

		x = 0;

	}

	

	alert(rightx.style.width.toInt() + xtoAdd+' = '+ (-x));

	if(-x < rightx.style.width.toInt() + xtoAdd)

		$('innercontent').effect('left',{ duration: 800, transition: Fx.Transitions.Quad.easeIn, wait:true }).start(x, x - xtoAdd )

}

*/

/*

	window.addEvent("domready", function() {  

	    new iCarousel("example_3_content", {  

	        idPrevious: "example_3_previous",  

	        idNext: "example_3_next",  

	        idToggle: "undefined",  

	        item: {  

	            klass: "example_3_item",  

	            size: 93  

	        },  

	        animation: {  

	            duration: 500,  

	            amount: 5  

	        }  

	    });  

	});

	*/

/*

window.addEvent("domready", function() {  

 



	if($('innercontent')) {

    new iCarousel("innercontent", {  

        idPrevious: "slide_artiste_left",  

        idNext: "slide_artiste_right",  

        idToggle: "undefined",  

        item: {  

            klass: "slide_artiste_image",  

            size: 85  

        },  

        animation: {  

            duration: 1000,  

            amount: 4,  

            type: "scroll"

        }  

    });  

   }

});

*/



function displayArtisteRSS(obj,p,artiste_rss_nom_id,artiste)

{

	

	$$('#info_bio a').removeClass('active');

	$(obj).addClass('active');



	texte = file('/ajax/artiste_rss.php?artiste_rss_nom_id='+ artiste_rss_nom_id +'&artiste_id='+artiste);

	document.getElementById(p).innerHTML=texte;

	return false;





		

}





function check_add_panier(toto)

{

	if(!toto)

		nVarNom = prompt("Entrez un nom pour votre panier :");

	else

		nVarNom = prompt("Vous devez entrer un nom pour votre panier :");

		

	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 addPanier(idForm)

{

	if(!fondDiv){

		fondDiv = document.createElement('div');
		fondDiv.style.position = 'absolute';
		initPopUp();

		document.body.appendChild(fondDiv);

	}

	fondDiv.innerHTML = '';

	//alert(getHeight());



	$(fondDiv).setStyles({

	   backgroundColor: '#000000',

	   width: '100%',

	   height: getScrollHeight(),

	   position: 'absolute',

	   opacity: '0.75',

	   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: '#000000',

	   width: '455px',

	   height: '175px',

	   position: 'absolute',

	   border: '1px solid #000',

	   top: '50%',

	   left: '50%',	   

	   marginLeft: '-227px',	   

	   marginTop: (getScrollTop()-87) + 'px',	   	   	   

	   zIndex: '1600',

	   visibility: 'hidden'

	});



	new Ajax(

		'/panier-change-ajax.php',

		{

			method: 'get',

			update: dataDiv,

			data:$(idForm).toQueryString(),

			onSuccess: function(req) {

				$$(fondDiv).setStyles({visibility: 'visible' });

				//$$('select').setStyles({visibility: 'hidden' });

				$$(dataDiv).setStyles({visibility: 'visible' });



				new Ajax(

					'/ajax/updatePanier.php',

					{

						update: $('account')

					}

				).request();

				

			},

			evalScripts: true

		}

	).request();

	

}

function addPanierPerso(idForm)
{
	
	if($(idForm).produit_attribut_id.value=="") {
		alert('Veuillez choisir une taille');
		return false;
	}
	
	if($(idForm).perso_id.checked==true) {
		var i=1;
		while($('texte'+i) && i<=10) {
			if($('texte'+i).value == "") {
				alert('Veuillez renseigner toutes les lignes de la personnalisation');
				return false;
			}
			i++;
		}
	}
	
	if(!fondDiv){

		fondDiv = document.createElement('div');
		fondDiv.style.position = 'absolute';
		initPopUp();
		document.body.appendChild(fondDiv);
	}
	fondDiv.innerHTML = '';

	//alert(getHeight());

	$(fondDiv).setStyles({
	   backgroundColor: '#000000',
	   width: '100%',
	   height: getScrollHeight(),
	   position: 'absolute',
	   opacity: '0.75',
	   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: '#000000',
	   width: '455px',
	   height: '175px',
	   position: 'absolute',
	   border: '1px solid #000',
	   top: '50%',
	   left: '50%',	   
	   marginLeft: '-227px',	   
	   marginTop: (getScrollTop()-87) + 'px',	   	   	   
	   zIndex: '1600',
	   visibility: 'hidden'

	});

	new Ajax(
		'/panier-change-ajax.php',
		{
			method: 'get',
			update: dataDiv,
			data:$(idForm).toQueryString(),
			onSuccess: function(req) {
				$$(fondDiv).setStyles({visibility: 'visible' });
				//$$('select').setStyles({visibility: 'hidden' });
				$$(dataDiv).setStyles({visibility: 'visible' });

				new Ajax(
					'/ajax/updatePanier.php',
					{
						update: $('account')
					}
				).request();
			},
			evalScripts: true
		}
	).request();

}



function addCadeau(nom,nb)

{

	

	if(!fondDiv){

		fondDiv = document.createElement('div');
		fondDiv.style.position = 'absolute';
		initPopUp();


		document.body.appendChild(fondDiv);

	}

	fondDiv.innerHTML = '';

	//alert(getHeight());



	$(fondDiv).setStyles({

	   backgroundColor: '#000000',

	   width: '100%',

	   height: getScrollHeight(),

	   position: 'absolute',

	   opacity: '0.75',

	   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: '#000000',

	   width: '455px',

	   height: '175px',

	   position: 'absolute',

	   border: '1px solid #000',

	   top: '50%',

	   left: '50%',	   

	   marginLeft: '-227px',	   

	   marginTop: (getScrollTop()-87) + 'px',	   	   	   

	   zIndex: '1600',

	   visibility: 'hidden'

	});

	

		

	for (var j = 0; j < nb; j++) {

		frm = 'cadeau_' + nom + '_' + j;

		new Ajax(

			'/panier-change-ajax.php',

			{

				method: 'get',

				data:$(frm).toQueryString(),

				EvalScripts: true

			}

		).request();

	}

		

	frm = 'cadeau_' + nom;

	

	new Ajax(

		'/panier-change-ajax.php',

		{

			method: 'get',

			update: dataDiv,

			data:$(frm).toQueryString(),

			onSuccess: function(req) {

				$$(fondDiv).setStyles({visibility: 'visible' });

				//$$('select').setStyles({visibility: 'hidden' });

				$$(dataDiv).setStyles({visibility: 'visible' });



				new Ajax(

					'/ajax/updatePanier.php',

					{

						update: $('account')

					}

				).request();

				

			},

			evalScripts: true

		}

	).request();

	

}

function initPopUp()
{
	$(fondDiv).onclick = function() {removeDivPanier();};
	$(fondDiv).style.cursor = 'pointer';
}

function removeDivPanier()

{

	if(fondDiv){

		$(fondDiv).remove();

		fondDiv = false;

	}	



	if(dataDiv){

		$(dataDiv).remove();

		dataDiv = false;

	}	

	

	//$$('select').setStyles({visibility: 'visible' });

}









function addNoel(page)

{

	if(!fondDiv){

		fondDiv = document.createElement('div');
		fondDiv.style.position = 'absolute';
		initPopUp();

		document.body.appendChild(fondDiv);

	}
	
	fondDiv.innerHTML = '';

	//alert(getHeight());



	$(fondDiv).setStyles({

	   backgroundColor: '#000000',

	   width: '100%',

	   height: getScrollHeight(),

	   position: 'absolute',

	   opacity: '0.75',

	   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: '#000000',

	   width: '800px',

	   height: '200px',

	   position: 'absolute',

	   border: '1px solid #000',

	   top: '50%',

	   left: '50%',	   

	   marginLeft: '-400px',	   

	   marginTop: (getScrollTop()-50) + 'px',	   	   	   

	   zIndex: '1600',

	   visibility: 'hidden'

	});



	new Ajax(

		'/livraison-noel.php',

		{

			method: 'get',

			update: dataDiv,

			data: 'page='+page,

			onSuccess: function(req) {

				$$(fondDiv).setStyles({visibility: 'visible' });

				//$$('select').setStyles({visibility: 'hidden' });

				$$(dataDiv).setStyles({visibility: 'visible' });

				

			},

			evalScripts: true

		}

	).request();

	

}



function updateRestant(id_avoir,statut)

{

	new Ajax(

		'/ajax/ajax_av.php',

		{

			method: 'get',

			update: $('tr_paiement'),

			data: 'avoir_id='+id_avoir+'&statut='+statut,

			onComplete: function(req) {

				var myTips = new Tips($$('.infobulle'),

					{

						maxTitleChars: 50

					}

				);

			}

		}

	).request();	

	

}





function ticketnet(div,artiste)

{

	$(div).innerHTML='<iframe src="http://www.ticketnet.fr/shop/fr/resultat.asp?recherche=mots&mots='+artiste+'&idtier=5214971" width="640" height="950" />';

	

}



var supatimer = false;

var blogDiv = false;

var CURblogDiv = false;



function showPopup(pwaaaaa,datafsfs)

{

	toto = $(pwaaaaa).getPosition();

	if($(datafsfs))

	{

	if(CURblogDiv != datafsfs)

	{

		CURblogDiv = datafsfs;

		killPopup2();

			blogDiv = document.createElement('div');

			blogDiv.style.position = 'absolute';

			document.body.appendChild(blogDiv);

			blogDiv.innerHTML = $(datafsfs).innerHTML;

		

	

			blabla = $(blogDiv).getSize();

			blabla = blabla.size.y;

		

			$(blogDiv).setStyles({

			   width: '260px',

			   position: 'absolute',

			   top: toto.y-blabla+20+'px',

			   left: toto.x+72+'px',

			   zIndex: '1600'

			});

			

			blabla = $(blogDiv).getSize();

			blabla = blabla.size.y;	

			

			$(blogDiv).setStyles({

			   width: '260px',

			   position: 'absolute',

			   top: toto.y-blabla+20+'px',

			   left: toto.x+72+'px',

			   zIndex: '1600'

			});		

			

	}

	}	

	else

	{

		killPopup2();

		CURblogDiv = false;

	}

		 

}



function killPopup()

{

 setTimeout("killPopup2()",500);

}



function killPopup2()

{



	if(blogDiv){

		$(blogDiv).remove();

		blogDiv = false;

	}	

}


function addAlerteStock(idForm)
{
			
	if(!fondDiv){
		fondDiv = document.createElement('div');
		fondDiv.style.position = 'absolute';
		initPopUp();
		
		document.body.appendChild(fondDiv);
	}
	fondDiv.innerHTML = '';
	//alert(getHeight());

	$(fondDiv).setStyles({
	   backgroundColor: '#000000',
	   width: '100%',
	   height: getScrollHeight(),
	   position: 'absolute',
	   opacity: '0.75',
	   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: '#000000',
	   width: '300px',
	   height: '200px',
	   position: 'absolute',
	   top: '50%',
	   left: '50%',	   
	   marginLeft: '-150px',	   
	   marginTop: (getScrollTop()-100) + 'px',	   	   	   
	   zIndex: '1600',
	   visibility: 'hidden'
	});

	new Ajax(
		'/ajax/addAlerteStock.php',
		{
			update: dataDiv,
			data:$(idForm).toQueryString(),
			onSuccess: function(req) {

					$$(fondDiv).setStyles({visibility: 'visible' });
					//$$('select').setStyles({visibility: 'hidden' });
					$$(dataDiv).setStyles({visibility: 'visible' });
					
			},
			evalScripts: true
		}
	).request();
}





/* ILOVE */

function loadTextile(idCategorie) {
	
	//$('ilove_spinner').style.display = 'block';
	
	
	new Ajax(
		'/ajax/ilove_init.php',
		{
			update: $('ilove_editor'),
			data:"ilove_categorie_id="+idCategorie+"&itype_id="+$('ilove_type_id').value+"&ilove_picto_nom="+$('ilove_picto_nom').value,
			onSuccess: function(req) {
				selectSexe($('produit_sexe_id').value);
			},
			evalScripts: true
		}
	).request();	
}

function selectSexe(id)
{
	
	loadLoveCouleur(id);
	/*
	loadLoveImg(id);
	loadLoveTaille(id);--ok
	setProduit(id);--ok
	*/
}

function loadLoveCouleur(id) {
	
	new Ajax(
		'/ajax/ilove_couleur.php',
		{
			update: $('ilove_couleur'),
			data:"produit_sexe_id="+id+"&ilove_categorie_id="+$('ilove_categorie_id').value+"&itype_id="+$('ilove_type_id').value,
			onSuccess: function(req) {
				loadLoveTaille(id);
				loadLovePicto2(id);
			},
			evalScripts: true
		}
	).request();	
}

function loadLovePicto2(id) {
	new Ajax(
		'/ajax/ilove_pictos.php',
		{
			update: $('bloc_pictos_form_love'),
			data:"produit_sexe_id="+$('produit_sexe_id').value+"&ilove_categorie_id="+$('ilove_categorie_id').value+"&ilove_couleur_id="+$('ilove_couleur_id').value+"&itype_id="+$('ilove_type_id').value+"&ilove_picto_id="+$('ilove_picto_id').value+"&ilove_picto_nom="+$('ilove_picto_nom').value,
			/*
			onSuccess: function(req) {
					loadEcriture($('ilove_ecriture_id').value);	
			},
			*/
			evalScripts: true
		}
	).request();	
}

function selectLoveCouleur(idColor) {
	
	loadLoveTaille($('produit_sexe_id').value);
	loadLovePicto2();
}

function loadLoveTaille(id) {
	
	new Ajax(
		'/ajax/ilove_taille.php',
		{
			update: $('ilove_taille'),
			data:"produit_sexe_id="+id+"&ilove_categorie_id="+$('ilove_categorie_id').value+"&ilove_couleur_id="+$('ilove_couleur_id').value,
			onSuccess: function(req) {
				loadLoveAttribut($('produit_attribut_id').value);
				setProduit(id);
			},
			evalScripts: true
		}
	).request();	
}

function setProduit(id) {
	new Ajax(
		'/ajax/ilove_produit.php',
		{
			data:"produit_sexe_id="+id+"&ilove_categorie_id="+$('ilove_categorie_id').value+"&ilove_couleur_id="+$('ilove_couleur_id').value,
			onSuccess: function(req) {
				$('produit_id').value=req;
				
				calculPrixLove(req,$('ilove_picto_id').value);
				
				loadLoveImg(req);
			},
			evalScripts: true
		}
	).request();
	
}


function calculPrixLove(id,ilove_picto_id) {
		if (typeof(id)!='undefined'&&id!=''&&!isNaN(id))
		{
			if (typeof(ilove_picto_id)=='undefined')	var ilove_picto_id	=	0;
			new Ajax
			(
				'/ajax/ilove_prix.php',
				{
					update: $('ilove_prix_vo'),
					data:"produit_id="+id+"&ilove_picto_id="+ilove_picto_id,
					onSuccess: function(req) {
					},
					evalScripts: true
				}
			)
			.request()
			;
	}
}

function calculPrixPerso(idForm,id,check) {
	
		if($(idForm).perso_id.checked==true) {
			var i=1;
			while($('texte'+i) && i<=10) {
				$('texte'+i).disabled = false;
				i++;
			}
		}
		else {
			var i=1;
			while($('texte'+i) && i<=10) {
				$('texte'+i).disabled = true;
				i++;
			}
		}
	
		new Ajax(
		'/ajax/perso_prix.php',
		{
			update: $('perso_prix_vo'),
			data:"produit_id="+id+"&check="+check,
			onSuccess: function(req) {

			},
			evalScripts: true
		}
	).request();	
}


function loadLoveImg(id) {
	new Ajax(
		'/ajax/ilove_img.php',
		{
			update: $('image_ilove'),
			data:"produit_id="+id,
			onSuccess: function(req)
			{			
			}			
		}
	).request();	
}




function loadLoveAttribut(id) {
				
	
	new Ajax(
		'/ajax/ilove_attribut.php',
		{
			update: $('ilove_stock'),
			data:"produit_attribut_id="+id,
			onSuccess: function(req) {

			},
			evalScripts: true
		}
	).request();	
}


function getElementsByClassName(className, tag, elm){
	var testClass = new RegExp("(^|s)" + className + "(s|$)");
	var tag = tag || "*";
	var elm = elm || document;
	var elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag);
	var returnElements = [];
	var current;
	var length = elements.length;
	for(var i=0; i<length; i++){
		current = elements[i];
		if(testClass.test(current.className)){
			returnElements.push(current);
		}
	}
	return returnElements;
}

function loadLovePicto(id, src, type_id)
{
	if (typeof type_id=='undefined')	var type_id	=	false;
	var picto = $('ilove_picto_tshirt');

	var arr=getElementsByClassName('ligne2_cadre');
	for( i=0; i < arr.length; i++){
		arr[i].className = "ligne2_cadre";
	}	
	var arr=getElementsByClassName('ligne2_cadre_hover');
	for( i=0; i < arr.length; i++){
		arr[i].className = "ligne2_cadre";
	}	

	if($('ilove_categorie_picto_rotate')) rotate = $('ilove_categorie_picto_rotate').value;
	else rotate = 0;

	if($('ilove_categorie_picto_reduce')) reduce = $('ilove_categorie_picto_reduce').value;
	else reduce = 0;

	$('ilove_picto_id').value = id;
	if (type_id)
		$('ilove_type_id').value = type_id;

	img_mini = $('ilove_picto_id_'+id);
	img_mini.className="ligne2_cadre_hover";

	picto.style.display = "block";
	picto.src = src+'?rotate='+rotate+'&reduce='+reduce;
	
	if ($('ilove_ecriture_id')===null)
	{
	}
	else
		loadEcriture($('ilove_ecriture_id').value);

	// Selon le type du picto on cache ou on montre les zones d'écriture
	if ($('bloc_text_form_love')!=null)
	{
		var visibility;
		if (type_id==3||type_id==5)
		{
			visibility		=	'hidden';
		}
		else if(type_id==6)
		{
			visibility		=	'ligne1';
		}
		else
		{
			visibility		=	'visible';
		}
		
		if (visibility=='ligne1')
		{
			$('bloc_text_form_love').setStyle('visibility','visible');
			if ($('bloc_text2_form_love'))
				$('bloc_text2_form_love').setStyle('visibility','hidden');
			$('bloc_ecriture_form_love').setStyle('visibility','visible');
			$('btn_apercu_ilove').setStyle('visibility','visible');
			$('bloc_txt_aperc').setStyle('visibility','visible');
			if ($('apercu_texte2'))
				$('apercu_texte2').setStyle('visibility','hidden');
		}
		else
		{
			$('bloc_text_form_love').setStyle('visibility',visibility);
			if ($('bloc_text2_form_love'))
				$('bloc_text2_form_love').setStyle('visibility',visibility);
			$('bloc_ecriture_form_love').setStyle('visibility',visibility);
			$('btn_apercu_ilove').setStyle('visibility',visibility);
			$('bloc_txt_aperc').setStyle('visibility',visibility);
			if ($('apercu_texte2'))
				$('apercu_texte2').setStyle('visibility',visibility);
		}
	}
	(function($)
		{
			var $picto_element	=	$('#ilove_picto_tshirt');
			if ($picto_element.length==1)
			{
				$picto_element
					.css
					(
						{
							top:	(parseFloat($('#ilove_categorie_picto_top').val())+parseFloat(($('.onglet_zone:visible .ilove_type_picto_top').val())?$('.onglet_zone:visible .ilove_type_picto_top').val():$('#tabs'+$('#ilove_type_id').val()+' .ilove_type_picto_top').val()))+'px',
							left:	(parseFloat($('#ilove_categorie_picto_left').val())+parseFloat(($('.onglet_zone:visible .ilove_type_picto_left').val())?$('.onglet_zone:visible .ilove_type_picto_left').val():$('#tabs'+$('#ilove_type_id').val()+' .ilove_type_picto_left').val()))+'px'
						}
					)
				;
			}
		}
	)(jQuery)

	calculPrixLove(jQuery('#produit_id').val(),$('ilove_picto_id').value);
}

function changeDesc(id, def) {
	
	var texte1 = $('texte1').value;
	if($('texte2')) var texte2 = $('texte2').value;
	else var texte2 = '';

	new Ajax(
		'/ajax/ilove_ecriture.php',
		{
			update: $('bloc_text_form_love'),
			data:"ilove_ecriture_id="+id+"&texte1="+texte1+"&texte2="+texte2+"&ilove_categorie_id="+$('ilove_categorie_id').value+"&type_id="+$('ilove_type_id').value,
			onSuccess: function(req) {
			},
			evalScripts: true
		}
	).request();
	
	loadEcriture(id, def);
			
}


function loadEcriture(id, def) {
	
	if($('ilove_picto_id').value!="") {
		if($('ilove_ecriture_id').value!="") {
			if(def!="1") {
				if($('texte1').value!="") {
		
					new Ajax(
						'/ajax/ilove_ecriture.php',
						{
							update: $('bloc_txt_aperc'),
							data:"ilove_ecriture_id="+id+"&traitement=1&ilove_couleur_font="+$('ilove_couleur_font').value+"&ilove_categorie_id="+$('ilove_categorie_id').value+"&type_id="+$('ilove_type_id').value,
							onSuccess: function(req) {
								if ($('ilove_type_id').value==6)// Remplacement typo image
								{
									/*
									(function($)
										{
										}
									)(jQuery);
									*/
									var img_src	=	'/perso_typo_image.php?configuration_prefix=ilb_&ecriture_id='+id+'&ecriture_couleur='+$('ilove_couleur_font').value+'&fond_couleur='+$('ilove_couleur_fond').value+'&texte='+$('texte1').value;
									$('apercu_texte1').innerHTML = '<img src="'+img_src+'" border="0"/>';
								}
								else
									$('apercu_texte1').innerHTML = $('texte1').value;
								$('apercu_texte1').style.display = "block";
								if($('texte2')) 
								{
									$('apercu_texte2').innerHTML = $('texte2').value;
									$('apercu_texte2').style.display = "block";						
								}
								else
								{
									$('apercu_texte2').innerHTML = '';
									$('apercu_texte2').style.display = "none";
								}
								
								document.getElementById('etatgallerie').value='1';
							
							},
							evalScripts: true
						}
					).request();			
					
				}else{
					//alert("Vous devez saisir un texte sur la ligne 1");
				}
			}			
		}else{
			alert("Vous devez selectionner une taille de texte");
		}
	}else{
		alert("Vous devez selectionner une image I love");
	}
}


function loadEcriturePerso(fontSize1,fontSize2,type_image,couleur_typo,couleur_fond,couleur_typo2) {

			new Ajax(
				'/ajax/perso_ecriture.php',
				{
					update: $('bloc_txt_aperc'),
					data:$('produit').toQueryString(),
					onSuccess: function(req)
					{
						if (!isNaN(fontSize1))
						{
							(function($)
								{
									$('#perso_apercu_texte1').css('font-size',fontSize1+'px');
									if (!isNaN(fontSize2))
									{
										$('#perso_apercu_texte2').css('font-size',fontSize2+'px');
									}
								}
							)(jQuery);
						}
						var i=1;
						while($('texte'+i) && i<=10) {
							if (typeof(type_image)=='object')// Alors toutes les variables de personnalisation doivent être de type object (array) et de même taille
							{
								var img_src	=	'/perso_typo_image.php?configuration_prefix='+type_image[i]+'&ecriture_id=0&texte='+$('texte'+i).value+'&ecriture_couleur='+couleur_typo[i]+'&fond_couleur='+couleur_fond[i];
								$('perso_apercu_texte'+i).innerHTML = '<img src="'+img_src+'" border="0"/>';
							}
							else if (type_image)
							{
								var img_src	=	'/perso_typo_image.php?configuration_prefix='+type_image+'&ecriture_id=0&texte='+$('texte'+i).value+'&ecriture_couleur='+couleur_typo+'&fond_couleur='+couleur_fond;
								$('perso_apercu_texte'+i).innerHTML = '<img src="'+img_src+'" border="0"/>';
							}
							else
							{
								$('perso_apercu_texte'+i).innerHTML = $('texte'+i).value;
								$('perso_apercu_texte'+i).style.display = "block";
							}
							i++;
						}
					
					},
					evalScripts: true
				}
			).request();			
			
}

var regExpBeginning = /^\s+/;
var regExpEnd = /\s+$/;  

// Supprime les espaces inutiles en d�but et fin de la cha�ne pass�e en param�tre.
function trim(aString) {
    return aString.replace(regExpBeginning, "").replace(regExpEnd, "");
}

function panierValideLove() {
	if
	(
			$('produit_id').value==""
		||	$('produit_attribut_id').value==""
		||	$('ilove_picto_id').value==""
		||
		(
			//$('itype_id').value==3
			//||
			(
				$('ilove_type_id').value!=3
				&&
				$('ilove_type_id').value!=5
				&&
				(
						$('ilove_ecriture_id').value==""
					||	trim($('texte1').value) == ""
				)
			)
		)
	)
	{
		alert('Erreur : veuillez selectionner tous les criteres !');
	}
	else
	{
		if ($('ilove_type_id').value==3||$('ilove_type_id').value==5||$('ilove_type_id').value==6)
		{
			if ($('ilove_type_id').value!=6)
				$('texte1').value='';
			if ($('texte2'))
				$('texte2').value='';
		}
		addPanier('produit');
	}
}



function addGallerie(client_id, produit_id) {
	if($('etatgallerie').value!="") {
		if($('produit_id').value == "" ||  $('ilove_picto_id').value == "" || $('ilove_ecriture_id').value == "" || $('texte1').value == "") {
			alert('error');
		}
		else
		{
			var ilove_ecriture_id = $('ilove_ecriture_id').value;
			var ilove_picto_id = $('ilove_picto_id').value;
			var texte1 = $('texte1').value;
			var texte2 = $('texte2').value;
			
			new Ajax(
			'/ajax/ilove_addgallerie.php',
			{
				data:$('produit').toQueryString(),
				onSuccess: function(req) {
					alert(req);
				},
				evalScripts: true
			}
		).request();			
			
			//alert(produit_id + " - " + client_id + " - " +ilove_ecriture_id + " - " + ilove_picto_id + " - " + texte1 + " - " + texte2 );
			
			//addPanier('produit');
		}	
	}
	else
	{
		alert('Veuillez faire un apercu de votre creation !');
	}
}


/* ILOVE */


function selectatt(obj, id_att)
{
	$('produit_attribut_id').value = id_att;
	$$('#list_att li.active').removeClass('active');
	$(obj).addClass('active');
	
	$$('.div_status').removeClass('dsactive');
	$('div_status_' + id_att).addClass('dsactive');
	
	
}

function selectatt_change(id_att)
{
	var param = id_att.split('_');
	$('produit_attribut_id').value = param[0];
	$('bouton_add_panier').value=param[1];
	
	$$('.div_status').removeClass('dsactive');
	$('div_status_' + param[0]).addClass('dsactive');
}


function AlerteStock(idprod, idatt)
{
			
	if(!fondDiv){
		fondDiv = document.createElement('div');
		fondDiv.style.position = 'absolute';
		initPopUp();

		document.body.appendChild(fondDiv);
	}
	fondDiv.innerHTML = '';
	//alert(getHeight());

	$(fondDiv).setStyles({
	   backgroundColor: '#000000',
	   width: '100%',
	   height: getScrollHeight(),
	   position: 'absolute',
	   opacity: '0.75',
	   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: '#dcdcdc',
	   width: '640px',
	   height: '325px',
	   position: 'absolute',
	   top: '50%',
	   left: '50%',	   
	   marginLeft: '-320px',	   
	   marginTop: (getScrollTop()-163) + 'px',	   	   	   
	   zIndex: '1600',
	   visibility: 'hidden'
	});

	var type_id_value	=	($('ilove_type_id'))?$('ilove_type_id').value:'';
	new Ajax(
		'/ajax/addAlerteStock.php',
		{
			update: dataDiv,
			data:'produit_id='+ idprod +'&produit_attribut_id='+ idatt +'&itype_id='+type_id_value,
			onSuccess: function(req) {

					$$(fondDiv).setStyles({visibility: 'visible' });
					//$$('select').setStyles({visibility: 'hidden' });
					$$(dataDiv).setStyles({visibility: 'visible' });
					
			},
			evalScripts: true,
			method:'get'
		}
	).request();
}

function AlerteStock2()
{

	new Ajax(
		'/ajax/addAlerteStock.php',
		{
			update: dataDiv,
			data: $('form_rupture').toQueryString(),
			onSuccess: function(req) {

					$$(fondDiv).setStyles({visibility: 'visible' });
					//$$('select').setStyles({visibility: 'hidden' });
					$$(dataDiv).setStyles({visibility: 'visible' });
					
			},
			evalScripts: true
		}
	).request();
}


function envoyeramis()
{
	new Ajax(
		'/envoyer_amis.php',
		{
			update: dataDiv,
			data: $('envoyeramis_form').toQueryString(),
			onSuccess: function(req) {
	
					$$(fondDiv).setStyles({visibility: 'visible' });
					//$$('select').setStyles({visibility: 'hidden' });
					$$(dataDiv).setStyles({visibility: 'visible' });
					
			},
			evalScripts: true
		}
	).request();
}		

function envoyerblogamis()
{
	new Ajax(
		'/blog_envoyer_amis.php',
		{
			update: dataDiv,
			data: $('envoyeramis_form').toQueryString(),
			onSuccess: function(req) {
	
					$$(fondDiv).setStyles({visibility: 'visible' });
					//$$('select').setStyles({visibility: 'hidden' });
					$$(dataDiv).setStyles({visibility: 'visible' });
					
			},
			evalScripts: true
		}
	).request();
}	

function verifrss1() {
	
	var zoom_id = $('produit_zoom_id').value;
	var lecteur_id = $('lecteur_rss_id').value;
	
	if(zoom_id=="" || lecteur_id =="") {
		alert("Merci de remplir tous les champs.");
		return false;
	}else{
		return true;
	}
}

function verifrss2() {
	
	var zoom_id = $('produit_zoom_id2').value;
	var lecteur_id = $('lecteur_rss_id2').value;
	var genre_id = $('genre_id').value;
	
	if(zoom_id=="" || lecteur_id=="" || genre_id=="") {
		alert("Merci de remplir tous les champs.");
		return false;
	}else{
		return true;
	}
}

function verifrss3() {
	
	var zoom_id = $('produit_zoom_id3').value;
	var lecteur_id = $('lecteur_rss_id3').value;
	var artist_id = $('artiste_id').value;
	
	if(zoom_id=="" || lecteur_id=="" || artist_id=="") {
		alert("Merci de remplir tous les champs.");
		return false;
	}else{
		return true;
	}
}

function verifrss4() {
	
	var zoom_id = $('produit_zoom_id4').value;
	var lecteur_id = $('lecteur_rss_id4').value;
	var artist_id = $('artiste_id2').value;
	
	if(zoom_id=="" || lecteur_id=="" || artist_id=="") {
		alert("Merci de remplir tous les champs.");
		return false;
	}else{
		return true;
	}
}

divRollover = false;

function rollover_over(obj, img)
{
	var Pos = $(obj).getPosition();

	if(!divRollover){
		divRollover = document.createElement('img');
		divRollover.style.position = 'absolute';
		document.body.appendChild(divRollover);
	}	
	
	divRollover.src = img;
	divRollover.style.top = (Pos.y - 115) + 'px';
	divRollover.style.left = (Pos.x - 115) + 'px';			
	divRollover.style.border = '1px solid #CECECE';
	divRollover.style.cursor = 'pointer';
	
	divRollover.onmouseout = function ()
	{
		if(divRollover)
		{
			$(divRollover).remove();
			divRollover = false;
		}
	}
	
}


function showRelaisColis(cp)
{
	if($('liv_rco').style.display="none")
	{
		new Ajax(
			'/ajax/relaiscolis.php',
			{
				update: $('liv_rco'),
				data:'cp='+cp,
				onSuccess: function(req) {
						$('liv_rco').style.display="block";
				},
				evalScripts: true,
				method:'get'
			}
		).request();
		
		
		/*
		$('liv_rco').setHTML('test');
		$('liv_rco').style.display="block"
		*/
	}
}

function hideRelaisColis()
{
	if($('liv_rco').style.display="block")
	{
		$('liv_rco').setHTML('');
		$('liv_rco').style.display="none"
	}
}


function showPreviewBig(idProd)
{

	div = 'prod'+idProd;
	$(div).style.display='block';	
}


function cachePrevisu(idProd)
{
	div = 'prod' + idProd;
	$(div).style.display='none';	
}


function popup_galerie(href, id, w, h, r, s) {

	if(id == 'taille')
	{
		if(!fondDiv){
			fondDiv = document.createElement('div');
			fondDiv.style.position = 'absolute';
			initPopUp();
			
			document.body.appendChild(fondDiv);
		}
		fondDiv.innerHTML = '';
	
		$(fondDiv).setStyles({
		   backgroundColor: '#000000',
		   width: '100%',
		   height: getScrollHeight(),
		   position: 'absolute',
		   opacity: '0.75',
		   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: '#dcdcdc',
		   width: '640px',
		   height: '450px',
		   position: 'absolute',
		   top: '50%',
		   left: '50%',	   
		   marginLeft: '-320px',	   
		   marginTop: (getScrollTop()-225) + 'px',	   	   	   
		   zIndex: '1600',
		   visibility: 'hidden'
		});
	
		new Ajax(
			href,
			{
				update: dataDiv,
				onSuccess: function(req) {
	
						$$(fondDiv).setStyles({visibility: 'visible' });
						//$$('select').setStyles({visibility: 'hidden' });
						$$(dataDiv).setStyles({visibility: 'visible' });
						
				},
				evalScripts: true,
				method:'get'
			}
		).request();
	}
	else if(id == 'amis')
	{
	if(!fondDiv){
			fondDiv = document.createElement('div');
			fondDiv.style.position = 'absolute';
			initPopUp();
			
			document.body.appendChild(fondDiv);
		}
		fondDiv.innerHTML = '';
		//alert(getHeight());
	
		$(fondDiv).setStyles({
		   backgroundColor: '#000000',
		   width: '100%',
		   height: getScrollHeight(),
		   position: 'absolute',
		   opacity: '0.75',
		   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: '#dcdcdc',
		   width: '640px',
		   height: '350px',
		   position: 'absolute',
		   top: '50%',
		   left: '50%',	   
		   marginLeft: '-320px',	   
		   marginTop: (getScrollTop()-175) + 'px',	   	   	   
		   zIndex: '1600',
		   visibility: 'hidden'
		});
	
		new Ajax(
			href,
			{
				update: dataDiv,
				onSuccess: function(req) {
	
						$$(fondDiv).setStyles({visibility: 'visible' });
						//$$('select').setStyles({visibility: 'hidden' });
						$$(dataDiv).setStyles({visibility: 'visible' });
						
				},
				evalScripts: true,
				method:'get'
			}
		).request();
	}
	else if(id == 'image')
	{
	if(!fondDiv){
			fondDiv = document.createElement('div');
			fondDiv.style.position = 'absolute';
			initPopUp();
	
			document.body.appendChild(fondDiv);
		}
		fondDiv.innerHTML = '';
		//alert(getHeight());
	
		$(fondDiv).setStyles({
		   backgroundColor: '#000000',
		   width: '100%',
		   height: getScrollHeight(),
		   position: 'absolute',
		   opacity: '0.75',
		   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: '#FFF',*/

		   height: '514px',
		   position: 'absolute',
		   top: '50%',
		   left: '50%',	   
		   marginLeft: '-226px',	   
		   marginTop: (getScrollTop()-257) + 'px',	   	   	   
		   zIndex: '1600',
		   visibility: 'hidden'
		});

		new Ajax(
			'/image_galerie.php',
			{
				update: dataDiv,
				data:'url='+href+'&produit_id='+r,
				
				onSuccess: function(req) {
	
						$$(fondDiv).setStyles({visibility: 'visible' });
						//$$('select').setStyles({visibility: 'hidden' });
						$$(dataDiv).setStyles({visibility: 'visible' });
						
				},
				evalScripts: true
			}
		).request();
	}
	else
		window.open(href, id, 'width='+w+',height='+h+',resizable='+r+',scrollbars='+s+',toolbar=0,directories=0,status=0,menubar=0');

}

function PageGalerie(id,page,type_id)
{
	if ((typeof type_id == 'undefined')||(type_id!='artiste'))	type_id	=	'produit';
	new Ajax(
		'/ajax/pageGalerie.php',
		{
			update: $('liste_galerie_perso'),
			data:type_id+'_id='+id+'&page='+page,
			onSuccess: function(req) {
			},
			evalScripts: true
		}
	).request();

}

// Execution au chargement
jQuery
(
	function($)
	{
  	
		// Gestion des recherches sur mots clefs
		var $motclef_elements	=	$('input[type=text][name=motclef]');
		if ($motclef_elements.length)
		{
			$motclef_elements
				.filter('.recherche_gauche,.recherche_bas')
					.each
					(
						function()
						{
							var $motclef_element	=	$(this);
							$motclef_element.data('valeur_initial',$motclef_element.val())
						}
					)
					.bind
					(
						'focus'
						,
						function()
						{
							var $motclef_element	=	$(this);
							if ($motclef_element.val()==$motclef_element.data('valeur_initial'))
							{
								$motclef_element.val('');
							}
						}
					)
					.bind
					(
						'blur'
						,
						function()
						{
							var $motclef_element	=	$(this);
							if ($motclef_element.val()=='')
							{
								$motclef_element.val($motclef_element.data('valeur_initial'));
							}
						}
					)
				.end()
				.each
				(
					function()
					{
						var $motclef_element	=	$(this);
						var innerWidth				=	$motclef_element.innerWidth();
						$motclef_element
							.autocomplete
							(
								'/ajax/ajax_recherche.php'
								,
								{
									delay: 100,
									selectFirst: false,
									matchContains: true,
									width:	innerWidth
								}
							)
							.result
							(
								function(e,data)
								{
									if (e.type=='result')
									{
										$motclef_element
											//.val('"'+$motclef_element.val()+'"')
											.parents('form:first')
												.bind
												(
													'submit'
													,
													function()
													{
															return false;
													}
												)
											.end()
										;
										window.location.href	=	'/search/?motclef="'+$motclef_element.val()+'"';
									}
								}
							)
						;
					}
				)
			;
		}
  	
		// Gestion des champs NewsLetter
		var $nl_email_elements	=	$('#header_newsletter input[type=text][name="newsletter_email"]');
		if ($nl_email_elements.length)
		{
			$nl_email_elements
				.each
				(
					function()
					{
						var $nl_email_element	=	$(this);
						$nl_email_element.data('valeur_initial',$nl_email_element.val())
					}
				)
				.bind
				(
					'focus'
					,
					function()
					{
						var $nl_email_element	=	$(this);
						if ($nl_email_element.val()==$nl_email_element.data('valeur_initial'))
						{
							$nl_email_element.val('');
						}
					}
				)
				.bind
				(
					'blur'
					,
					function()
					{
						var $nl_email_element	=	$(this);
						if ($nl_email_element.val()=='')
						{
							$nl_email_element.val($nl_email_element.data('valeur_initial'));
						}
					}
				)
			;
		}
		/*
		// Gestion de la dispo au survol
		$produit_elements	=	$('div.prod');
		if ($produit_elements.length>0)
		{
			$produit_elements
				.each
				(
					function()
					{
						var	$produit_element	=	$(this);
						$produit_element
							.hover
							(
								function()
								{
									$produit_element.data('hover',1);
									if (!$produit_element.is('.survol_eval'))
									{
										var	$a_element	=	$produit_element.find('a[href]:first'),regexp	=	/-([0-9]+)\.html/;
										var 	a_href		=	$a_element.attr('href');
										if (!(regexp.exec(a_href)))
											$produit_element.addClass('survol_eval');
										else
										{
											var	a_href_details	=	a_href.match(regexp);
											var	produit_id		=	a_href_details[1];
											$produit_element.addClass('survol survol_eval');
											$
												.get
												(
													'/ajax/produit_attributs.php',
													{produit_id:produit_id},
													function(data)
													{
														if (data!='')
														{
															var $survol_element	=	$(data),survol_largeur	=	0;
															$survol_element.css({left:$survol_element.outerWidth()});
															$produit_element.append($survol_element);
															$survol_element
																.data('hauteur',$survol_element.height())
																.data('position_Y',$survol_element.position().top)
																.css({top:$survol_element.data('position_Y')+$survol_element.data('hauteur'),left:0,height:0})
																.bind
																(
																	'click',
																	function()
																	{
																		window.location.href	=	a_href;
																	}
																)
															;
															if ($produit_element.data('hover')==1)
																$produit_element.trigger('mouseenter');
														}
													}
												)
											;
										}
									}
									
									var $survol_element	=	$produit_element.find('ul.survol_dispo');
									if ($survol_element.length==1)
										$survol_element
											.stop()
											.animate
											(
												{
													top:$survol_element.data('position_Y'),
													height:$survol_element.data('hauteur')
												}
											)
										;
								},
								function()
								{
									$produit_element.data('hover',0);
									var $survol_element	=	$produit_element.find('ul.survol_dispo');
									if ($survol_element.length==1)
									{
										$survol_element
											.stop()
											.animate
											(
												{
													top:$survol_element.data('position_Y')+$survol_element.data('hauteur'),
													height:0
												}
											)
										;
									}
								}
							)
						;
					}
				)
			;
		}
		*/
		// GESTION DES TEASERS
		$teaserZone_element	=	$('#teaser_zone');
		if ($teaserZone_element.length==1)
		{
			$teaserZone_element
				.bind
				(
					'teaser_initialisation',
					function(evenement,teaser_nom)
					{
						// Paramêtres
						var boucles,blocs;
						blocs	=
							{
								'bloc1':
									{
										'redirection':'/redirect.php?name='+teaser_nom+'-bloc_big-',
										'source':'bloc1',
										'chemin':'/ressources/teasers/lbo/'+teaser_nom+'/bloc_big/',
										'cible':'#teaser_bloc1',
										'sens':'suivant',
										'control':'div#teaser_controlBloc1',
										'hover_cible':'#teaser_zoneBloc1',
										'interval':4000,
										'delai':1200,
										'animation_type':'fade',
										'depart':1500,
										'chargement_masque':true,
										'chargement_delai':500
									},
								'bloc2':
									{
										'redirection':'/redirect.php?name='+teaser_nom+'-bloc_small-',
										'source':'bloc2',
										'chemin':'/ressources/teasers/lbo/'+teaser_nom+'/bloc_small/',
										'cible':'#teaser_bloc2',
										'sens':'suivant',
										'control':false,
										'hover_cible':false,
										'interval':6000,
										'delai':1200,
										'animation_type':'fade',
										'depart':2000,
										'chargement_masque':true,
										'chargement_delai':500
									},
								'bloc3':
									{
										'redirection':'/redirect.php?name='+teaser_nom+'-bloc_small-',
										'source':'bloc3',
										'chemin':'/ressources/teasers/lbo/'+teaser_nom+'/bloc_small/',
										'cible':'#teaser_bloc3',
										'sens':'suivant',
										'control':false,
										'hover_cible':false,
										'interval':6000,
										'delai':1200,
										'animation_type':'fade',
										'depart':1000,
										'chargement_masque':true,
										'chargement_delai':500
									}
							}
						;
						// Fonctions
						function teaser_transition(bloc_element,sens,animation_temps,animation_type)
						{
							var $bloc_element	=	$(bloc_element);
							switch(animation_type)
							{
								case 'fade':
								default:
									if (sens=='suivant')
									{
										/*
										var $image_element	=	$bloc_element.children('img:not([class~="teaser_fading"])').last();
										$image_element
											.clone(true)
												.addClass('teaser_fading')
												.appendTo(bloc_element)
												.animate
												(
													{
														opacity:0
													},
													animation_temps
													,
													function()
													{
														$(this).remove();
													}
												)
												.end()
											//.prependTo($bloc_element)
											.parent()
												.prepend($image_element)
										;
										*/
										var $image_element	=	$(bloc_element).children('img:not([class~="teaser_fading"])').last();
										$image_element
											.addClass('teaser_fading')
											.animate
											(
												{
													opacity:0
												},
												animation_temps
												,
												function()
												{
													$image_element
														.parent()
															.prepend($image_element)
														.end()
														.css('opacity',1)
														.removeClass('teaser_fading')
													;
												}
											)
										;
									}
									else if (sens=='precedant')
									{
										//var $image_element	=	$bloc_element.children('img:not([class~="teaser_fading"])').first();
										var $image_element	=	$bloc_element.children('img:first');
										$image_element
											.css('opacity',0)
											.parent()
												.append($image_element)
										;
										$image_element
											.animate
											(
												{
													opacity:1
												},
												animation_temps
											)
										;
									}
									break;
							}
						}
						function	teaser_boucle($bloc_element,sens,animation_temps,animation_type)
						{
							var bloc	=	$bloc_element.data('bloc');
							teaser_transition($bloc_element,sens,animation_temps,animation_type);
							clearTimeout($bloc_element.data('timer'));
							$bloc_element.data('timer',setTimeout(function(){teaser_boucle($(bloc.cible),bloc.sens,bloc.delai,bloc.animation_type)},bloc.interval));
						}
						function	teaser_precedant($bloc_element,animation_temps,animation_type)
						{
							teaser_transition($bloc_element,'precedant',animation_temps,animation_type);
						}
						function	teaser_suivant($bloc_element,animation_temps,animation_type)
						{
							teaser_transition($bloc_element,'suivant',animation_temps,animation_type);
						}
						// Chargé le flux XML des teaser
						$.ajax
						(
							{
								url:'/ressources/teasers/lbo/0_xmls/'+teaser_nom+'.xml?nc=0',
								//dataType:'html',
								complete:
									function(XMLHttpRequest,textStatus)
									{
									}
									,
								success:
									function(data)
									{
										var $teaser_xml	=	$(data);
										// Chargement des Blocs
										$
											.each
											(
												blocs,
												function(index)
												{
													var	bloc	=	this;
													var $bloc_element	=	$(bloc.cible);
													if ($bloc_element.length==1)
													{
														$bloc_element.data('bloc',bloc);
														var $source_element	=
															$teaser_xml
																.find(bloc.source)
														;
														if ($source_element.length==1)
														{
															var image_nombre	=	$source_element.children().length;
															if (image_nombre>1)
															{
																var $hover_element;
																if (bloc.hover_cible===true)
																{
																	$hover_element	=	$bloc_element;
																}
																else if ($(bloc.hover_cible).length==1)
																{
																	$hover_element=$(bloc.hover_cible);
																}
																else
																	$hover_element=false;
																if ($hover_element&&$hover_element.length>=1)
																	$hover_element
																		.hover
																		(
																			function()
																			{
																				clearTimeout($bloc_element.data('timer'));
																			},
																			function()
																			{
																				$bloc_element.data('timer',setTimeout(function(){teaser_boucle($(bloc.cible),bloc.sens,bloc.delai,bloc.animation_type)},bloc.interval));
																			}
																		)
																	;
																// Paramétrage
																var $element_control	=
																	$bloc_element
																		.siblings(bloc.control)
																;
																if ($element_control.length==1)
																{
																	$element_control
																		.find('button#teaser_precedant')
																			.bind
																			(
																				'click',
																				function()
																				{
																					teaser_precedant($bloc_element,bloc.delai,bloc.animation_type);
																				}
																			)
																		.end()
																		.find('button#teaser_suivant')
																			.bind
																			(
																				'click',
																				function()
																				{
																					teaser_suivant($bloc_element,bloc.delai,bloc.animation_type);
																				}
																			)
																		.end()
																	;
																}
															}
															$source_element
																.children()
																	.each
																	(
																		function(index)
																		{
																			var source_element	=	this;
																			var $source_element	=	$(source_element);
																			var jpeg_source		=	$source_element.attr('jpeg');
																			
																			var $image_element =
																				$
																				(
																					'<img/>'
																					,
																					{
																						src:bloc.chemin+jpeg_source+'.jpg'
																					}
																				)
																					.bind
																					(
																						'click',
																						function()
																						{
																							window.location.href = bloc.redirection+jpeg_source+'&url='+$source_element.attr('lien');
																						}
																					)
																			;
																			if (index==1&&bloc.chargement_masque)
																			{
																				var $masque_element	=
																					$('<div></div>')
																						.addClass('teaser_masque')
																				;
																				var $sousMasque_element	=
																					$('<div></div>')
																						.addClass('teaser_masque teaser_sousMasque')
																				;
																				$bloc_element
																					.children('img:last')
																						.before($sousMasque_element)
																						.end()
																					.append($masque_element)
																				;
																				$image_element
																					.bind
																					(
																						'load',
																						function()
																						{
																							$masque_element
																								.animate
																								(
																									{
																										opacity:0
																									},
																									{
																										duration:bloc.chargement_delai,
																										complete:
																											function()
																											{
																												$(this).add($sousMasque_element).remove();
																												if (image_nombre>1)
																													$bloc_element.data('timer',setTimeout(function(){teaser_boucle($(bloc.cible),bloc.sens,bloc.delai,bloc.animation_type)},bloc.interval+bloc.depart));
																											}
																									}
																								)
																							;
																						}
																					)
																				;
																			}
																			$bloc_element.prepend($image_element);
																		}
																	)
															;
														}
													}
												}
											)
										;
									}
							}
						)
					}
				)
			;
		}
	}
);
function displayMSG(msg) {
   alert(msg);
}


function loadPageLivraison(){
	jQuery(".input-choix-livraison").click(function(){
		jQuery("#flag").attr('value','667');
		jQuery("#coordonnees").submit();
	});
}

/*=== MONDIAL RELAY ===*/
function updatePointRelais (addr1, addr2, cp, ville){
	document.getElementById('mondial_relay_addr1').value = addr1;
	document.getElementById('mondial_relay_addr2').value = addr2;
	document.getElementById('mondial_relay_cp').value = cp;
	document.getElementById('mondial_relay_ville').value = ville;
}

function loadPointMondialRelay(){
	var cp = document.getElementById('cp_mondial_relay').value;
	var pays = document.getElementById('pays_mondial_relay').value;
	
	var html = '<div class="wrap-mr"><div class="bloc_head medium default"><h3>Adresse de livraison</h3></div><div id="loader-mr" class="wrap-loader"><img src="/charte/process/ajax-loader.gif"></div></div>';
	document.getElementById('mondial_relay_content').innerHTML = html;
	document.getElementById('mondial_relay_content').style.display = 'block';
	
	new Ajax(
			'/ajax/loadPointMondialRelay.php',
			{
				data:"code_postal=" + cp+"&pays="+pays,
				onSuccess: function(req) {
						document.getElementById('mondial_relay_content').innerHTML = req;
						document.getElementById('mondial_relay_content').style.display = 'block';
				},
				evalScripts: true
			}
		).request();
}
/*=== MONDIAL RELAY ===*/

/*=== CHRONOPOST ===*/
	function updatePointRelaisChr (addr1, addr2, cp, ville){
	document.getElementById('chr_addr1').value = addr1;
	document.getElementById('chr_addr2').value = addr2;
	document.getElementById('chr_cp').value = cp;
	document.getElementById('chr_ville').value = ville;
}

function loadPointChronopost(){
	var cp = document.getElementById('cp_chr').value;
	
	var html = '<div class="wrap-mr"><div class="bloc_head medium default"><h3>Adresse de livraison</h3></div><div id="loader-mr" class="wrap-loader"><img src="/charte/process/ajax-loader.gif"></div></div>';
	document.getElementById('mondial_relay_content').innerHTML = html;
	document.getElementById('mondial_relay_content').style.display = 'block';
	
	new Ajax(
			'/ajax/loadPointChronopost.php',
			{
				data:"code_postal=" + cp,
				onSuccess: function(req) {
						document.getElementById('mondial_relay_content').innerHTML = req;
						document.getElementById('mondial_relay_content').style.display = 'block';
				},
				evalScripts: true
			}
		).request();
}
/*=== CHRONOPOST ===*/

/*===== CASQUETTE ====*/
function loadTemplateCasquette(idAttSelected){
	if(idAttSelected != 0){
		jQuery("#att-"+idAttSelected).trigger("click");
	}
	
	jQuery("#perso_id").click(function(){
		
		jQuery.ajax({
		 type: "POST",
	   url: '/ajax/perso_prix.php',
	   data:"produit_id="+jQuery("#produit_id").attr('value')+"&check="+jQuery(this).attr('checked'),
	   success: function(msg){
	     jQuery("#perso_prix_vo").html(msg);
	   }
		});
		
		if(jQuery(this).attr('checked') == false){
			jQuery("#txtperso_texte1").attr('disabled', true);
		}else{
			jQuery("#txtperso_texte1").attr('disabled', false);
		}
		
	});
	
	jQuery("#txtperso_texte1").focus(function(event){
		if(jQuery(this).attr('value') == 'Entre ton texte personnalisé...'){
			jQuery(this).attr('value', '');
		}
	});
	
	jQuery("#txtperso_texte1").blur(function(event){
		if(jQuery(this).attr('value') == '' || jQuery(this).attr('value') == ' '){
			jQuery(this).attr('value', 'Entre ton texte personnalisé...');
		}
	});
	
	jQuery("#btn_add_panier").click(function(){
		if(jQuery("#perso_id").attr('checked') == true && jQuery("#txtperso_texte1").attr('value') == 'Entre ton texte personnalisé...'){
			jQuery("#perso_id").trigger("click");
		}
		if(jQuery('#bouton_add_panier').attr('value') == 1){
			addPanier('produit');
		}else if(jQuery('#bouton_add_panier').attr('value') == -2){
			alert('Veuillez choisir une taille');
		}else if(jQuery('#bouton_add_panier').attr('value') == -1){
			alert('Ce produit ou cette taille n\'est pas disponible');
		}
	});
	
	var writeElement;
	
	jQuery("#txtperso_texte1").keydown(function(event){
		writeElement = true;
		var debug = false;
		// gestion suppression + navigation
		
		if(event.shiftKey){
			var keyException = new Array(59,219,107);
		}else{
			var keyException = new Array(49,51,52,53,54,56,57,59,219,107);

			if(navigator.appName == "Microsoft Internet Explorer"){
				keyException.push(187);
			}
		}
		
		// alert(event.keyCode);
		
			var addLettre = String.fromCharCode(event.keyCode);
			var newVal = jQuery(this).attr('value') + addLettre;
			
			if(newVal.length <= 9){
				if(in_array(event.keyCode, keyException)){
					if(debug) alert('keyException');
					writeElement = false;
				}
				var pattern = new RegExp("[a-z0-9A-Z?!,;:]");
				if(!pattern.test(newVal)){
					if(debug) alert('RegExp');
					writeElement = false;
				}
			}
			
			var keyAccept = new Array(8, 46, 37, 39);
			if(in_array(event.keyCode, keyAccept)){
				writeElement = true;
			}
		});
	
	jQuery("#txtperso_texte1").keyup(function(event){
		if(jQuery(this).attr('value') == ''){
			jQuery("#texte_broderie_perso").html('');
		}else{
			if(jQuery(this).attr('value').length <= 9 && writeElement == true){
				var img_src	=	'/perso_typo_image.php?configuration_prefix=casquette&ecriture_id=0&texte='+jQuery(this).attr('value')+'&ecriture_couleur='+jQuery("#casquette_couleur_font").attr('value')+'&fond_couleur='+jQuery("#casquette_couleur_bg").attr('value');
				jQuery("#texte_broderie_perso").html('<img src="'+img_src+'" border="0"/>');
			}else if(event.keyCode != 16 && jQuery(this).attr('value').length <= 9){
				var txt_input = jQuery(this).attr('value').substring(0,(jQuery(this).attr('value').length-1));
				jQuery(this).attr('value', txt_input);
				return false;
			}
		}
	});
}
function popupCasquette(){
    if (!fondDiv) {
        fondDiv = document.createElement('div');
        fondDiv.style.position = 'absolute';
        document.body.appendChild(fondDiv);
    }
    fondDiv.innerHTML = '';
    
    $(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({
        background: '#FFFFFF',
        width: '615px',
        height: '570px',
        position: 'absolute',
        // border: '1px solid #7f7f7f',
        top: '50%',
        left: '50%',
        marginLeft: '-307px',
        marginTop: (getScrollTop() - 280) + 'px',
        zIndex: '1600',
        visibility: 'hidden',
        overflow: 'auto'
    });
    
    $(fondDiv).onclick = function(){
        removeDivPanier();
    }
    
    new Ajax('/ajax/popupCasquette.php', {
        update: dataDiv,
        onSuccess: function(req){
        
            $$(fondDiv).setStyles({
                visibility: 'visible'
            });
            
            $$(dataDiv).setStyles({
                visibility: 'visible'
            });
            
        },
        evalScripts: true
    }).request();
}


function in_array(value, tableau){
    var a=false;
    for(var i=0;i<tableau.length;i++){
        if(value == tableau[i]){
            a=true;
            break;
        }
    }
    return a;
}
