// JavaScript Document
function confirme_envoie_infos_mdp_perdu(lg){
	if(!lg) lg = 'fr';
	if($('container') != null){
			$('container').remove();
	}
	
	affichage_de_base(lg);
	
	var url='/tmpl_dev_shopping/'+lg+'/mon_compte/envoie_mdp_perdu_result.html';
	var get_html_infos = new Ajax(url, {
		method: 'get',
		update: $('infos_compte'),
		onSuccess: function(){
				$('loading').remove();
				//on realigne car l'element ne fait plus la meme taille
				valigncenter($('infos_compte'));
				
				$('fermer_confirme_creation_compte').addEvent('click', function(){
						var container = $('container');
						//effet de fondu avant la fermeture
						new Fx.Style(container, 'opacity', {
							onComplete : function(){
								//on detruit la galeries
								container.remove();
								if (window.ie && !window.ie7){
									$('container2').remove();
								}
								//window.location.href = '/pl/account.pl';
							}
						}).start(1,0);
				});
				
				var myFx = new Fx.Style($('infos_compte'), 'opacity').start(0,1);
		},
		onFailure: function(){
			//feinte pour le problème des accents
			var txt = new Element('span');
			txt.innerHTML = 'Un email contenant vos paramètres d\'identification vient de vous être envoyé.';
			alert(txt.innerHTML);
		}
	}).request();
}
function affichage_de_base(lg){
	if(!lg) lg = 'fr';
	if($('container') != null){
			$('container').remove();
	}
	
	//creation des elements
	container = new Element('div', {
										'styles': 
										{
											'display': 'block',
											'width': '100%',
											'height': '100%',
											'padding': '0px',
											'left': '0',
											'margin': '0px',
											'position': 'fixed',
											'top': '0',
											'text-align': 'center',
											'background-image': 'url(/images/overlay.png)',
											'z-index': '5'
										}
								  }
							);
	
	if (window.ie && !window.ie7){
		container.style.position = 'absolute';
		container.style.height = document.documentElement.clientHeight;
		container.style.background = 'none';
		container.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale, src='/images/overlay.png')";
		container.style.zIndex = '0';
		
		container2 = new Element('div', {
										'styles': 
										{
											'display': 'block',
											'width': '100%',
											'height': '100%',
											'padding': '0px',
											'left': '0',
											'margin': '0px',
											'position': 'absolute',
											'top': '0',
											'text-align': 'center',
											'z-index': '10'
										}
								  }
							);
		//pour ie6 (pour avoir les liens cliquables
		container2.setAttribute('id','container2');
		container2.injectInside(document.body);
	}
	
	container.setAttribute('id','container');
	container.injectInside(document.body);
	
	//afficher barre de chargement
	loading = new Element('div', {
										'styles': 
										{
											'display': 'block',
											'width': '220px',
											'height': '19px',
											'padding': '0px',
											'text-align': 'left',
											'margin':'0 auto',
											'background-image': 'url(/images/smoothgallery/loading-bar-black.gif)',
											'top' : '50%'
										}
								  }
						 );
	loading.setAttribute('id','loading');
	loading.injectInside(container);
	//centrer verticalement par rapport à la page
	valigncenter(loading);
	
	var infos_compte = new Element('div', {
													'styles': 
													{
														'display': 'block',
														'width': '350px',
														'height': '105px',
														'padding': '0px',
														'text-align': 'left',
														'margin':'0 auto',
														'z-index':'1000',
														'position':'absolute'
													}
											  }
										);
		 
	infos_compte.setAttribute('id','infos_compte');
	
	if (window.ie && !window.ie7){
		infos_compte.injectInside($('container2'));
	}else{
		infos_compte.injectInside($('container'));
	}
	
	valigncenter(infos_compte);
	var myFx = new Fx.Style(infos_compte, 'opacity').set(0);
}
function valigncenter(lmt)
{
	var page = document.documentElement;
	if(lmt && page)
	{
	    var containerHeight;
	    if (page.innerWidth)
	    {
            containerHeight = page.innerHeight;
		}
		else
		{
            containerHeight = page.clientHeight;
		}
	    var lmtHeight;
	    if (lmt.innerWidth)
	    {
            lmtHeight = lmt.innerHeight;
		}
		else
		{
            lmtHeight = lmt.offsetHeight;
		}
		var y = Math.ceil((containerHeight - lmtHeight) / 2);
		if(y < 0)
		{
			y = 0;
		}
		lmt.style.position = "relative";
		lmt.style.top = y + "px";
	}
	if (document.getElementById)
	{
		document.body.style.visibility = 'visible';
	}
}
