/****************************************************
 * limousin-environnement.fr                 navig.js
 *
 * (c) KurTZdev.com   10-2011
*****************************************************
*/ 
 
var pel = new Class({	  	   
	
	Implements: [Options],

	// initialisation
	initialize: function() {  
  		this.idPage = $('page').get('class');
 
		// démarrage
		this.activeNavigationHaute(); 
		this.activeInscriptionNewsletter(); 
		this.activeBoutonMailChristine();
	},              
 
	
	// Navigation haute
	activeNavigationHaute : function() {
 		$$('#navigation_header li').each(function(nav) {
			if (nav.hasClass(this.idPage)) {
				nav.addClass('actif');
			};
		}.bind(this));
 		$$('header h1').addEvent('click', function(e) {
			window.location = '/actualites/';
		});
		
		
		$('navigation_annuaire').addEvent('click', function(e) {
			window.location = '/annuaire/';
		});		
		
		$('navigation_membres').addEvent('click', function(e) {
			window.location = '/pages/inscription.html';
		});
		
		$('navigation_calendrier').addEvent('click', function(e) {
			window.location = '/calendrier/';
		});
	},
 
 

 	changeImageHeader : function(e) {
		var hasard=Math.floor(Math.random()*9);
		if (hasard==0) {hasard=1};
		$('image_header').setStyle('background-image', 'url(assets/components/pel/templates/images/photo_'+hasard+'.jpg)');
	},
	
	
	activeInscriptionNewsletter : function() {
		$('bt_newsletter').addEvent('click', this.inscriptionNewsletter);
	},
	
	
	
	inscriptionNewsletter : function() {   
		var email_newsletter = $('email_newsletter').get('value');
		req = new Request({
			url: 'assets/components/pel/ajax/inscriptionNewsletter',
			method:'get',
			data:{
				action:'inscription_newsletter',
				email_newsletter:email_newsletter 
			},
			onSuccess: function(retourAjax) {    
				alert(retourAjax);   
			}, 
			onFailure: function(retourAjax) {
				alert(retourAjax);     
			}
		});
		req.send();
	},
	
	
	
	activeBoutonMailChristine : function() {
		$('bt_christine').addEvent('click', function() {
			window.location = "mailto:cwatson@limousin-environnement.fr";
		});
	}
	        
	  
	
	







	
	
}); // fin classe PEL

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

	var Pole = new pel();
 

	$$('li.competence').each(function(competence) {
		if (competence.get('html')=='') {
			competence.hide();
		};
	});

	$$('div.annu_url').each(function(url) {
		if (url.get('html')=="") {
			url.hide();
		};
	})


	Pole.changeImageHeader();




});


















