window.addEvent('domready', function()
{
	//var mainPath = '';
	var mainPath = 'fileadmin/templates/';
	if(typeof sIFR == "function"){
		   //replaceElement(sSelector, sFlashSrc, sColor, sLinkColor, sHoverColor, sBgColor, nPaddingTop, nPaddingRight, nPaddingBottom, nPaddingLeft, sFlashVars, sCase, sWmode){
		//sIFR.replaceElement("#main h1", mainPath+"flash/arialNarrow.swf", "#ffffff", null, null, null, 5, 10, 5, 4, "offsetTop=2", null, "transparent");
		//sIFR.rollback("#content_wrapper h1");
		sIFR.replaceElement("#content_wrapper h1", mainPath+"flash/arialNarrow.swf", "#8a7f1d", null, null, null, 5, 10, 5, 4, "offsetTop=2", null, "transparent");
	}else{
		//alert('not passed');
	}
	var flashvars = {
	};
	var params = {
		menu:"false",
		wmode:"transparent",
		scaleMode:"noScale"
	};
	var attributes = {
		id: "anim",
		name: "anim"
	};
	//alert(t);
	swfobject.embedSWF(mainPath+"flash/header.swf","anim_c", "500", "242", "8", mainPath+"flash/expressInstall.swf", flashvars, params, attributes);
	
	if($('affairesContainer'))
	{
		if($$('#affairesContainer .article').length > 2)
		{
			var scrollerAccueil = new fmcScroller (
			{
				'list':$$('#affairesContainer .article'),
				'container':'affairesWrapper',
				'scrollerContainer':'affairesContainer',
				'scrollerDirection':'horizontal',
				'btnPrec':$('prev'),
				'btnSuiv':$('next'),
				'margin':0,
				'nbByStep':1,
				'defilement':{
					'interval':2000, 
					'pauseOnMouseOver':true, 
					'pauseButton':false
				}
			});
		}
	}
	
	if($('actus'))
	{
		if($$('#news_slider .news').length > 2)
		{
			var scrollerAccueil = new fmcScroller (
			{
				'list':$$('#news_slider .news'),
				'container':'news_slider',
				'scrollerContainer':'news_slider_wrapper',
				'scrollerDirection':'horizontal',
				'btnPrec':$('reas_prec'),
				'btnSuiv':$('reas_suiv'),
				'margin':10,
				'nbByStep':2
			});
		}
	}
	if($$('.acc_images_item').length > 1)
	{
		$$('.acc_images_item').each(function(el, index)
		{
			el.getLast().setStyle('opacity', '0');
			el.fx = el.getLast().effect('opacity', {duration: 500, transition: Fx.Transitions.Sine.easeInOut, wait:false});
			el.addEvent('mouseenter', function(e)
			{
				var e = new Event(e);
				e.stop();
				this.fx.start(.9);
			});
			el.addEvent('mouseleave', function(e)
			{
				var e = new Event(e);
				e.stop();
				this.fx.start(0);
			});
		});
	}
/*	
	$$('#menu li').each(function(el, index)
	{
		el.addEvents(
		{
			'mouseenter':function(e)
			{
				this.addClass('over');
				if(this.getChildren()[1])
				{
					this.h = this.getChildren()[1].getCoordinates().height;
					this.getChildren()[1].setStyle('margin-top',- this.h/2 + this.getCoordinates().height/2);
				}
			},
			'mouseleave':function(e)
			{
				this.removeClass('over');
			}
		});
	});
*/
	
	/*
	
	formulaire
	
	*/
	if(window.ie)
	{
		var fields = $$('input','textarea')
		fields.each(function(el,i){
			if(el.getTag() == 'input' && el.getProperty('type') == 'text' || el.getTag() == 'textarea')
			{
				el.addEvent('focus',function(e)
				{
					this.addClass('focus');
				});
				el.addEvent('blur',function(e)
				{
					this.removeClass('focus');
				});
			}
		});
		$('menu').addEvent('mouseenter', function()
		{
			if($('signature')) $('signature').setStyle('display','none');
		});
		$('menu').addEvent('mouseleave', function()
		{
			if($('signature')) $('signature').setStyle('display','block');
		});
	}
	if(window.ie6)
	{
		/* 
		MENU
		Suckerfish Alternative for IE, using MOOTOOLS.
		*/
		$$('#menu li').each(function(el, index)
		{
			el.addEvents(
			{
				'mouseenter':function(e)
				{
					this.addClass('over');
				},
				'mouseleave':function(e)
				{
					this.removeClass('over');
				}
			});
		});
		
		/* 
		formulaire Fast search
		*/
		
		$$($('fastsearchText'), $('fastsearchSubmit')).each(function(el, index)
		{
			el.addEvents({
				'mouseenter':function(e)
				{
					//alert(this.value);
					this.addClass('over');
					this.overed = true;
				},
				'mouseleave':function(e)
				{
					if(!this.focused)
					{
						this.removeClass('over');
					}
					this.overed = false;
				},
				'focus':function(e)
				{
					this.focused = true;
					this.addClass('over');
				},
				'blur':function(e)
				{
					this.focused = false;
					if(!this.overed)
					{
						this.removeClass('over');
					}
				}
			});
		});
	}
	// INITIALISATION DE LA GALERIE DU DETAIL DES PRODUITS.
	if($('galleryProduit'))
	{
		// photos/materiel/grandes/materiel-de-carriere-1.jpg
		var images = $$('.gallery-miniatures a');

		if(images.length > 0)
		{
			var bigLink = new Element('a', {
				href:images[0].rel,
				rel:'lightbox'
			}).injectInside('galleryProduit');
			var bigImage = new Element('img', {src:images[0].href}).injectInside(bigLink);
			var act = images[0];
			act.addClass('actual');
			images.each(function(el,index)
			{
				el.addEvent('click', function(e)
				{
					var e=new Event(e);
					e.stop();
					this.blur();
					if(act != this)
					{
						act.removeClass('actual');
						act = this;
						bigImage.src = this.href;
						bigLink.href = el.rel;
						act.addClass('actual');
					}
				});
			});
		}
	}
	if(typeof Lightbox == "function" || typeof Lightbox == "object")
	{
		Lightbox.init({"descriptions": true, "showControls": false});
	}else{
		//alert(typeof Lightbox);
	}
});

