﻿function inmailer (){
	$('maildebug').innerHTML="";
					var emailFilter=/^.+@.+\..{2,4}$/;
					if(!emailFilter.test($('pommoemail').value)) 
					{
						$('maildebug').innerHTML="l'adresse email que tu as saisie n'est pas valide.";
					}else{
						$('maildebug').innerHTML="ajout de l'email en cours.....";
						var url = "http://mjs69.fr/wp-content/plugins/wp-pommo/wp-pommo-api.php";
						new Ajax(url, {
							method: 'post',
							data : 'pommoemail='+$('pommoemail').value,
							update: $('maildebug')
							}).request();
					}
					return false;
}

var Site = {
	
	start: function(){
	if ($('footer')) Site.parseFooter();
	if ($('phplistrequired')) Site.parseRequired();
	new SmoothScroll();
	Lightbox.init.bind(Lightbox);
	if ($('mailpommo')) Site.parsePommo();
},

parseRequired:function(){

			var fx = new Fx.Styles($('phplistrequired'), {duration:120, wait:false});
			fx.start({'color': '#666'}).chain( function(){fx.start({'color': '#fff'});}).chain( function(){fx.start({'color': '#666'});}).chain( function(){fx.start({'color': '#fff'});}).chain( function(){fx.start({'color': '#666'});}).chain( function(){fx.start({'color': '#fff'});}).chain( function(){fx.start({'color': '#666'});}).chain( function(){fx.start({'color': '#fff'});}).chain( function(){fx.start({'color': '#666'});}).chain( function(){fx.start({'color': '#fff'});});
},
	parseFooter:function(){
		var list = $$('.tfoot');
		list.each(function(element) {
			//var fx = new Fx.Styles(element, {duration:200, wait:false});
			$(element).addEvents({
				'mouseenter': function() { 
						var list2 = $ES('h2',element);
						list2.each(function(element2){	var fx = new Fx.Styles(element2, {duration:200, wait:false});fx.start({'color': '#fff'}); });
						var list2 = $ES('a',element);
						list2.each(function(element2){
							var fx = new Fx.Styles(element2, {duration:200, wait:false});fx.start({'color': '#eee'}); 
							$(element2).addEvents({
								'mouseenter': function() {var fx3 = new Fx.Styles(element2, {duration:10, wait:false});fx3.start({'color': '#dc192c'}); },
								'mouseleave': function() {var fx3 = new Fx.Styles(element2, {duration:10, wait:false});fx3.start({'color': '#eee'}); }
							});
						});	
				},
				'mouseleave': function() { 
						var list2 = $ES('h2',element);
						list2.each(function(element2){	var fx = new Fx.Styles(element2, {duration:200, wait:false});fx.start({'color': '#333'}); });
						var list2 = $ES('a',element);
						list2.each(function(element2){
							var fx = new Fx.Styles(element2, {duration:200, wait:false});fx.start({'color': '#333'}); 
							$(element2).removeEvents('mouseenter', 'mouseleave');
							});	
						}
			});
			
		//	alert("ee");
		});

	
	}, 
	gogo:function(elmt){
		var list = $$(elmt);
		list.each(function(element) {
		/*var fx = new Fx.Styles(element, {duration:200, wait:false});
		fx.start({'color': '#eee'}).chain( function(){fx.start({'color': '#333'});}).chain( function(){fx.start({'color': '#eee'});}).chain( function(){fx.start({'color': '#333'});}).chain( function(){fx.start({'color': '#eee'});}).chain( function(){fx.start({'color': '#333'});});*/
		
		var list2 = $ES('h2',element);
						list2.each(function(element2)
						{	
							var fx = new Fx.Styles(element2, {duration:200, wait:false});
							fx.start({'color': '#eee'}).chain( function(){fx.start({'color': '#333'});}).chain( function(){fx.start({'color': '#eee'});}).chain( function(){fx.start({'color': '#333'});}).chain( function(){fx.start({'color': '#eee'});}).chain( function(){fx.start({'color': '#333'});});
						});
		var list2 = $ES('a',element);
		list2.each(function(element2)
						{	
							var fx = new Fx.Styles(element2, {duration:200, wait:false});
							fx.start({'color': '#eee'}).chain( function(){fx.start({'color': '#333'});}).chain( function(){fx.start({'color': '#eee'});}).chain( function(){fx.start({'color': '#333'});}).chain( function(){fx.start({'color': '#eee'});}).chain( function(){fx.start({'color': '#333'});});
						});
		
		});
		
	} ,
	parsePommo : function(){
		$('pommoemail').addEvents({
				'mousedown': function() 
				{ 
					if($('pommoemail').value=="ton email"){$('pommoemail').value='';}
				}
			});
			
		$('gocontact').addEvents({
				'mousedown': function() 
				{ 
					inmailer();
				}
			});
	}

};



window.addEvent('domready', Site.start);