$(function(){
	$('#msgBox #closeBox').click(function(){
			$('#msgBox').animate({
				opacity: 0
			}, 500,function(){$(this).hide().css('opacity', '1');});
			return false;});
	$('#validAlert').click(function(){
		if ($('#mailAlert').val() == '')
		{
			popMsgBox("Veuillez remplir le champs <br />'Votre adresse e-mail'.");
			return false;
		}
		var values;
		values = '';
		$('#f_recrutement').find('select').each(function(){
			var length = $(this).get(0).options.length;
			var tout = $(this).get(0).options[0].selected ? 1 : 0;
			for (i = 1; i < length; i++)
				if ($(this).get(0).options[i].selected || tout == 1)
				{
					values += values.length > 0 ? '|' : '';
					values += $(this).get(0).options[i].value;
				}
		});
		var mail = $('#mailAlert').val();
		$.post("/plugins/recrutement/ajax/alerteMail.php", {values: values, mail : mail},
				function(data){
					popMsgBox(data);
				});
		return false;
	});
});

function popMsgBox(msg)
{
	switch (msg)
	{
		case '#OK#':
			msg = 'Vous &ecirc;tes d&eacute;sormais inscrit aux alertes e-mails aux crit&egrave;res s&eacute;lectionn&eacute;s. <br />Vous allez recevoir un e-mail de confirmation &agrave; l\'adresse saisie.';
			break;
		case '#DOUBLON#':
			msg = 'Vous &ecirc;tes d&eacute;j&agrave; inscrit aux alertes e-mail.';
			break;
		case '#ERROR_FORMAT#':
			msg = 'Veuillez entrer une adresse<br />e-mail valide.';
			break;
	}
	if (!$.browser.msie)
		$('#msgBox').css('bottom', 92 + parseInt($('#result_displayer').height()) + ($('.jobBottomButton').height() ?  parseInt($('.jobBottomButton').height()) + 15 : 0) + 'px');
	$('#msgBox > p').html(msg).parent().show();
}