window.addEvent('domready',function(){
	$$('.btn_print').each(function(item){
		item.addEvent('click',function(e){
			e.stop();
			var idmag = $('idMag');
			window.open('index.php?option=com_bois_et_chiffons&view=magasin&mag_id='+ idmag.value +'&print=1','popup_print_magasin','status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,height=500,width=750,directories=no,location=no');
		});
	});
	$$('.btn_print_job').each(function(item){
		item.addEvent('click',function(e){
			e.stop();
			var idJob = $('idJob');
			window.open('index.php?tmpl=component&option=com_brc_job&c=posting&view=posting&id='+ idJob.value +'&Itemid=18&print=1','popup_print_job','status=no,toolbar=no,scrollbars=no,titlebar=no,menubar=no,resizable=yes,height=500,width=750,directories=no,location=no');
		});
	});
	$$('.popup').each(function(item){
		item.addEvent('click',function(e){
			new Event(e).stop();
			var href=this.href;
			var regExp=new RegExp("tmpl=component");
			if(!regExp.test(href)){
				regExp=new RegExp("[\?]");
				if(regExp.test(href)) href +='&tmpl=component';
				else  href +='?tmpl=component';
			}
			window.open(href,'_BLANK','width=740,height=450,menubar=yes,resizable=no');
		});
	});

	$$('.open_popup_form').each(function(item){
		item.addEvent('click',function(e){
			new Event(e).stop();
			var href=this.href;
			var regExp=new RegExp("tmpl=component");
			href = 'index.php?option=com_bois_et_chiffons&view=abonnementnewsletter&Itemid=14&tmpl=component&email='+$('form_newsletter').getElement('input[name=email]').get('value');
			window.open(href,'_BLANK','width=740,height=450,menubar=yes,resizable=no');
		});
	});

});
window._alert = window.alert;

window.alert = function(text,original){
	if(!original)
		Slimbox.showText(text);
	else
		window._alert(text);
}

function desactiveLienAccueil(){
	window.addEvent('domready',function(){
		$$('.lien_accueil').each(function(item){
			item.addClass('lien_inactif');
			item.addEvent('click',function(e){
				var event=new Event(e);
				e.stop();
			});
		});
	});
}

window.addEvent('domready', function() {
if($('ajaxForm')) $('ajaxForm').addEvent('submit', function(e) {
		e.stop();
		//Empty the log and show the spinning indicator.
		var div_result = $$('.popinResult')[0].empty().addClass('ajax-loading');
		this.set('send', {onComplete: function(response) {
			div_result.removeClass('ajax-loading');
			div_result.set('html', response);
			div_result.setStyle('visibility','visible');
			
			$$('.hidePopin').each(function(item){
			item.addEvent('click',function(){
			$('popinPoints').empty();
			$('popinPoints').setStyle('visibility','hidden');
		});
	});
		}});
		this.send();
	});
});

