
/**************************************************************

	Script		: Contact Post
	Version		: 1.0

**************************************************************/



function sendMyMail(){
	var objInfo={
	'prenom':$('formcontact_prenom').value,
	'nom':$('formcontact_nom').value,
	'email':$('formcontact_email').value,
	'message':$('formcontact_message').value
	}
	if(objInfo['email'] =='' || objInfo['email'].indexOf('@')==-1 ){
		
		hightlit('formcontact_email');
		return true;
	}
	
	
	$('formcontact_send').setStyles({display:'none'	});
	$('sendingtext').setStyles({display:'block',opacity:0	});
	new Fx.Style($('sendingtext'), 'opacity', {duration: 700} ).start(1);
	
	
	
	var arrInfo=[];
	for(var item in objInfo){
		arrInfo.push(item+'='+encodeURIComponent(objInfo[item]));
	}
	
	var strInfo=arrInfo.join('&');
	var postPage=['/_mailphp/con','tact_post','.','php'].join('');
	
	new Ajax(postPage,{postBody:strInfo, 
			onComplete: function(rep){
				if(rep=='ok'){
					fadeOutFadeInThanks();
				}else{
					alert('an error has occured, please reload this page '+rep)
					return true;
				}
			}
			,
			onFailure:function(){
				alert('error')
			}
	}).request();
}

function hightlit(what){
	var box=$(what);
	
	box.style.position='relative';
	box.style.left='0';
	
	var fx= box.effects({duration: 100, transition: Fx.Transitions.linear});
	
	fx.start({
		'left': -10
	}).chain(function(){
		this.start({'left': 10});
	}).chain(function(){
		this.start({'left': -10	});
	}).chain(function(){
		this.start({'left': 0});
	})
}

function fadeOutFadeInThanks(){
	$('contact_form').setStyles({opacity:1});
	new Fx.Style($('contact_form'), 'opacity', {duration: 500} ).start(0);
	
	var div = $('thanks_form').setStyles({
		display:'block',
		opacity: 0
	});
	new Fx.Style(div, 'opacity', {duration: 500} ).start(1);
	
}	

	


/*************************************************************/
