main = {
	
	openFormById: function(mId){
		if(this._activeId != null){
			var tE = $(this._activeId);
			tE.setStyle('display','none');	
		}
		//---
		var tE = $('contact_main');
		tE.setStyle('display','none');
		//---
		var tE = $(mId);
		tE.setStyle('display','block');
		//--
		var tE = $('footer'); /*ie6 fix, footer need to be touch*/
		tE.setStyle('position','relative');
		tE.setStyle('position','absolute');
		//--
		this._scrollFx.toElement(mId);
		//--
		this._activeId = mId;
	},
	
	closeFormById: function(mId){
		var tE = $(mId);
		tE.setStyle('display','none');
		//---
		var tE = $('contact_main');
		tE.setStyle('display','block');
		//--
		var tE = $('footer'); /*ie6 fix, footer need to be touch*/
		tE.setStyle('position','relative');
		tE.setStyle('position','absolute');
		//---
		this._scrollFx.toElement('contact_main');
		//---
		this._activeId = null;		
	},
	
	closeActiveForm: function(){
		if(this._activeId != null){
			this.closeFormById(this._activeId);
		}
	},
	
	sendMailData: function(mType){
		var _self = this;
		
		if(mType != "dist_form"){
			var tQ = $('formulaire').toQueryString();		
			var tUrl = "../php/mail.php?"+ tQ;
		}else{
			var tQ = $('formulaire_dist').toQueryString();		
			var tUrl = "../php/mail_dist.php?"+ tQ;
		}
		var myAjax = new Ajax(tUrl, {method: 'get', onComplete: function(mResponse){
			_self._scrollFx.toElement(_self._activeId).chain(function(){
				_self.closeActiveForm();
			});
		}}).request();
	},
	
	empty: function(){},
	
	
	/* Main initiation function
	--------------------------------------------------------------*/
	init: function(){
		if(this._INIT == null){
			this._INIT = true;
			//---
			this._scrollFx = new Fx.Scroll(window, {
				wait: false,
				duration: 500,
				offset: {'x': 0, 'y': -50}
			});
			//---
			this.startUp();
		}
	},
	
	startUp: function(){
		//nothing
	},
	
	/* Window events handling
	--------------------------------------------------------------*/
	onWindowDomReady: function(){
		this.init();
	},
	
	onWindowLoad: function(){
		this.init();
	}
};



// Window Events ---------------------------------------------

window.addEvent('domready', function() {
	main.onWindowDomReady();
});

window.addEvent('load', function() {
	main.onWindowLoad();
});



function testSaisie2(mType){
	
	if(mType != "dist_form"){
		var formulaire2 = document.forms["formulaire"];	
	}else{
		var formulaire2 = document.forms["formulaire_dist"];
	}
	
	/* ----------------------------------------------------------- Validation et message d'erreur ---------------------------*/
	if (formulaire2.elements["nom"].value == "")  {window.alert("Nom obligatoire"); formulaire2.elements["nom"].focus();  return false;}
	if (formulaire2.elements["entreprise"].value == "") {window.alert("Entreprise obligatoire"); formulaire2.elements["entreprise"].focus(); return false;}
	if (formulaire2.elements["adresse"].value == "") {window.alert("Adresse obligatoire"); formulaire2.elements["adresse"].focus(); return false;}
	if (formulaire2.elements["telephone"].value == "") {window.alert("Téléphone obligatoire"); formulaire2.elements["telephone"].focus(); return false;}
	if (formulaire2.elements["courriel"].value == "") {window.alert("Courriel obligatoire"); formulaire2.elements["courriel"].focus(); return false;}
	
	var email = formulaire2.elements["courriel"]; 
	
	if(email.value.indexOf("@") == "-1" || email.value.indexOf(".") == "-1"){ 
		window.alert("Courriel invalide"); 
		return false; 
	}
	
	main.sendMailData(mType);
	
}
