function verif_mail(m){
	if (m.length < 1) return false;
	var i = m.indexOf('@');
	var j = m.indexOf('.',i);
	var k = m.length-1;
	if(i<1 || j==-1 || (j-i)==1 || j==k){ return false; }else{ return true; }
}
function testImput(type, imput, erreurMsg){
	var ok = true;
	if (type == 'text'){
		if ($(imput).val().length < 1) ok = false;
	}else if (type == 'mail'){
		if ($(imput).val().length < 1) ok = false;
		if (!verif_mail($(imput).val())) ok = false;
	}
	if (ok){
		$(imput).css({ background: '#ffffff' });
		return '';
	}else{
		$(imput).css({ background: '#ff6' });
		return erreurMsg;
	}
}

$(document).ready(function(){
	$('#contactForm').submit(function(){
		var message = '';
		message+= testImput('text', $('input[@name="nom"]', this), '- Champ "Votre nom" obligatoire<br/>');
		message+= testImput('mail', $('input[@name="mail"]', this), '- Adresse "Votre email" incorrecte<br/>');
		message+= testImput('text', $('textarea[@name="message"]', this), '- Champ "Votre message" obligatoire<br/>');
		if (message.length > 0){
			$('.submitOk', this).remove();
			$('.submitError', this).remove();
			$(this).prepend('<div class="submitError">'+message+'</div>');
			return false;
		}
	});
	$('a.targetBank').each(function(){
		$(this).attr('target','_blank');
	});
	$('div.site').mouseover(function(){
		$('p.desc', this).css('display','block');
	}).mouseout(function(){
		$('p.desc', this).css('display','none');
	});
});