/**
 * Renvoi une erreur si '-' est mis dans la valeur du select par défaut
 * @author: jmartin
 */
$.validator.addMethod("selectNotEmpty", function(value, element) {
									return !/\-/.test(value);
									}, jQuery.validator.messages.required
);

jQuery(function($){
  
	
	
	/*
	$('#profilRecherche').validate({   
		submitHandler: function(form) {
			form.submit();
		},
		rules: 
		{
			'checkSelectChild': 'required',
			'candidature[zipcode]': 'required',
			'candidature[city]': 'required',
			'candidature[annonce]': { required: true, maxlength: 300 }
		},
		messages: 
		{
			'checkSelectChild': 'Merci de sélectionner un ou plusieurs secteurs/sous secteur',
			'candidature[zipcode]': 'Merci de saisir le code postal',
			'candidature[city]': 'Merci de saisir la ville',
			'candidature[annonce]': { required : 'Annonce manquante', maxlength : '300 caractères max'}
		},
		wrapper: "p",
		errorLabelContainer: "#jqueryvalidate"

	});
	*/
	// Checkbox de profilRecherchAjout pour la diffusion dans la presse
	/*
	$('#candidature_diff_presse').change(function(){
		if($(this).is(':checked'))
		{
			$('#candidature_diff_texte').show();
		}
		else
		{
			$('#candidature_diff_texte').hide();
		}
	});
	$('#candidature_diff_texte').hide();
	if($("input#candidature_diff_presse").attr("checked")) {
		$('#candidature_diff_texte').show();
	}
	*/
	/*
	$('#candidature_secteurs_parent_1').change(function(){
		if($(this).is(':checked'))
		{
			$('#options_restauration').show();
		}
		else
		{
			$('#options_restauration').hide();
		}
	});
	*/
	/*
	$('#profilRecherche #options_restauration').hide();
	if($("input#candidature_secteurs_parent_1").attr("checked")) {
		$('#profilRecherche#options_restauration').show();
	}
	*/
	
	
	
	$(".text-input").each(
			function(){
				$( this ).bind (
					"focus",
					function(){
						$(this).parent().parent().addClass('grey-bg');
					}
				);
				
				$( this ).bind (
					"blur",
					function(){
						$(this).parent().parent().removeClass('grey-bg');
					}
				);
			}
		);

		$('.f-help').each(
			function(){
				if ($(this)) {
					$(this).bind (
						"mouseover",
						function(){
							$(this).children('.help-block').addClass('show');
						}
					);
					
					$(this).bind (
						"mouseout",
						function(){
							$(this).children('.help-block').removeClass('show');
						}
					);
				}
			}
		);
	
		
		//Tableau de bord - Mon profil
		$('#account_asso_actif').change(function(){
			if($(this).is(':checked'))
				$('#bloc_associe_candidat').show();
			else
				$('#bloc_associe_candidat').hide();
		});
		$('#bloc_associe_candidat').hide();
		if($("input#account_asso_actif").attr("checked")) {
			$('#bloc_associe_candidat').show();
		}
});



// Garder de côté pour l'exemple..
//hide and reveal the "other" option in the sources form
/*
var option_other = $('#frmEnquiry #enquiry_other_source').parent();
option_other.hide();
$('#enquiry_source').change(function(){
  if($('option:selected', this).text() == 'Other')
  {
    $(option_other).show();
  }
  else
  {
    option_other.hide();
  }
});
*/
