function verif_nombre(champ) {
	var chiffres = new RegExp("[0-9]");
	var verif;
	var points = 0;
	
	for(x = 0; x < champ.value.length; x++) {
		verif = chiffres.test(champ.value.charAt(x));
		//if(champ.value.charAt(x) == "."){points++;}
		if(points > 1){verif = false; points = 1;}
		if(verif == false){champ.value = champ.value.substr(0,x) + champ.value.substr(x+1,champ.value.length-x+1); x--;}
	}
}

function checkSend(e) {
	e.stop()
	var email = new RegExp('^([a-z0-9_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,4}$')
	var error = false
	if('' != $F('edtSendEmail1') && !email.exec($F('edtSendEmail1'))) {
		$('edtSendEmail1').addClassName('error')
		error = true
	}
	else 
		$('edtSendEmail1').removeClassName('error')
	if('' != $F('edtSendEmail2') && !email.exec($F('edtSendEmail2'))) {
		$('edtSendEmail2').addClassName('error')
		error = true
	}
	else 
		$('edtSendEmail2').removeClassName('error')
	if('' != $F('edtSendEmail3') && !email.exec($F('edtSendEmail3'))) {
		$('edtSendEmail3').addClassName('error')
		error = true
	}
	else 
		$('edtSendEmail3').removeClassName('error')
	if (false == error) {
		//TODO: Envoyer les mails...
		$('edtSendEmail1').clear()
		$('edtSendEmail2').clear()
		$('edtSendEmail3').clear()
		$('send_quizz').hide()
	}
}

function closePopup(e) {
	e.stop()
	$('blog').hide()
}

function openExtLink(e)
{
	e.stop()
	mylink = e.element()
	if (!mylink.href)
		mylink = mylink.up('a')
	window.open(mylink.href, 'link')
} // openExtLink

function showSendPopup(e) {
	e.stop()
	if($('blog'))
		$('blog').hide()
	if(!$('send_quizz'))
		new Ajax.Updater('main', '/_send.php', {
			insertion: 'top',
			onComplete: function() {
				Event.observe('send_quizz', 'submit', checkSend)
			}
		})
	else
		$('send_quizz').show()
}

function showBlogPopup(e) {
	e.stop()
	if($('send_quizz'))
		$('send_quizz').hide()
	if(!$('blog'))
		new Ajax.Updater('main', '/_blog.php', {
			insertion: 'top',
			onComplete: function() {
				Event.observe('blog_close', 'click', closePopup)
			}
		})
	else
		$('blog').show()
}

function highlightButton(e) {
	var input = e.element()
	var src = input.readAttribute('src')
	var length = src.length
	if(!src.include('_on.png'))
		input.writeAttribute('src', src.substr(0, length - 4) + '_on.png')
}

function resetButton(e) {
	var input = e.element()
	var src = input.readAttribute('src')
	var length = src.length
	if(src.include('_on.png'))
		input.writeAttribute('src', src.substr(0, length - 7) + '.png')
}

function showCredits(e) {
// e.stop()
	window.open('/credits', 'credits', 'width=300px, height=250px')
}

function showRules(e) {
//	e.stop()
	window.open('/reglement', 'rules', 'width=800px, height=550px')
}

function showGift(e) {
//	e.stop()
	window.open('/dotation', 'gift', 'width=500px, height=350px')
}
/*
function launchEvents() {
	if($('form_messages'))
		new Effect.Fade('form_messages', { delay: 4 });
	$$('a[class~=nofollow').each(function(a) {
		Event.observe(a, 'click', openExtLink)
	})
	if($('send_link')) {
		Event.observe('send_link', 'click', showSendPopup)
	}
	if($('blog_link')) {
		Event.observe('blog_link', 'click', showBlogPopup)
	}
	$$('input[type="image"]').each(function(input) {
		Event.observe(input, 'mouseover', highlightButton)
		Event.observe(input, 'mouseout', resetButton)
	})
	Event.observe('credits', 'click', showCredits)
	Event.observe('rules', 'click', showRules)
	Event.observe('gift', 'click', showGift)
} // launchEvents

Event.observe(window, 'load', launchEvents)*/