$(function() {
	
    /* Debug CSS */

    if ($('.jlc-content-list-pdt').size() != 0) {

        $('.jlc-content-list-pdt').parent().css({
            left: 10,
            width: 996
        });

    }

    if ($.browser.mozilla) {

        $('.jlc-sub-menu').addClass('jlc-sub-menu-size');

        $('.jlc-form-login').addClass('jlc-form-login-ffox');

    }

    /* Slider */

    if ($('.jlc-slider-in .jlc-content-onglet').size() != 0) {

        $('.jlc-slider-in').each(function() {

            var $this = $(this),
            ul_list_tabs = $('<ul />').addClass('jlc-list-onglets');

            $('.jlc-content-onglet', $this).each(function() {

                var a = $('<a />').attr('href', '#' + $(this).attr('id')),
                li = $('<li />').append(a);

                ul_list_tabs.append(li);

            }).parent().prepend(ul_list_tabs);

            $('.jlc-list-onglets', $this).each(function() {

                if ($('li', this).size() < 2) $(this).hide();

            });

        });

    }

    $('ul.jlc-list-onglets').tabs({
        activeClass: 'jlc-activated',
        sliderAuto: true,
        intervaltime: 4000
    });

    $('a.jlc-link-newsletter').click(function() {

        $('#jlc-popin-newsletter').dialog('open');

        return false;

    });

    $('a.jlc-activation_link').click(function() {

        $('#jlc-popin-activation_link').dialog('open');

        return false;

    });

    $('a.jlc-password-forget').click(function() {

        $('#jlc-popin-password').dialog('open');

        return false;

    });

    $('a.jlc-infos-connexion').click(function() {

         $('#popup-login').dialog('open');

         return false;

    });

    $('#mc-popin-form-pdt .jlc-type-link button').click(function() {
    	if($('input[name="ref-1"]').val()){
    	 $('#link_popin_product').val('true');
    	 $('#link-productBox').css('color','');
    	}
    	else{
    		$('#link_popin_product').val('');
    	}
        $('#mc-popin-form-pdt').dialog('close');

        return false;

    });

    $('a.jlc-open').click(function() {

        $('#mc-popin-form').dialog('open');

        return false;

    });

    $('a.jlc-open-pdt, .jlc-watch-title p a.jlc-link-sn').click(function() {
        $('#mc-popin-form-pdt').dialog('open');

        return false;

    });

    $('.jlc-enregistrer_montre-page a.jlc-link-sn').click(function() {
        $('#mc-popin-form-add_montre').dialog('open');

        return false;

    });

    $('a.jlc-link-sn-add').click(function() {

        $('#mc-popin-form-add').dialog('open');

        return false;

    });

    $('a.popin-notice').click(function() {

        $('#jlc-popin-instructions').dialog('open');

        return false;

    });

    /* Tooltip */

    $('.jlc-hover-info, .jlc-list-click-product li a').hover(function() {

        $(this).children('.tooltip-content').css('display', 'block').mouseover(function() {

            $(this).hide();

        });

    }, function() {

        $(this).children('.tooltip-content').hide();

    });

    /* Layer */
    $('.jlc-watch-layer').layerBloc(function() {

        if ($('.jlc-watchfinder-page, jlc-content-mes-preferences').length == 0) {
            $('.jlc-watch-title-in, .jlc-bloc-img li a span, .jlc-bloc-img div a span, span.jlc-v-center, span.jlc-v-center-2').vAlign();
        }

    });

    if ($('.jlc-watchfinder-page, jlc-content-mes-preferences').length != 0) {
        $('.jlc-watch-title-in, .jlc-bloc-img li a span, .jlc-bloc-img div a span, span.jlc-v-center, span.jlc-v-center-2').vAlign();
    }

    /* Hover Point Vente */

    $('.jlc-content-bloc-small div a, .jlc-bloc-img div a').css({
        display: 'block',
        position: 'relative',
        textDecoration: 'none'
    }).live('mouseover', function(){

        $(this).find('span').css('display', 'block');

    }).live('mouseout', function() {

        $(this).find('span').hide();

    });

    $('.jlc-bloc-img li a').live('mouseover', function() {

        var $this = $(this);

        $this.find('.jlc-on-img').css('display', 'block');
        $this.find('.jlc-off-img').hide();

    }).live('mouseout', function() {

        var $this = $(this);

        $this.find('.jlc-on-img').hide();
        $this.find('.jlc-off-img').css('display', 'block');

    });

    /**************************************************************************/
    /**************************************************************************/
    /*                   Start => LE CLUB: Registration Form                  */
    /**************************************************************************/
    /**************************************************************************/
    var rules = {
    		'address1' : "required",
    		'postalcode' : "required",
    		'city' : "required",
    		'state' : "required",
    		'acceptTerms' : "required"
    };

    var ClubberForm = $('#jlc-clubber-form-validate');

    initClubberRegistrationForm(ClubberForm, rules);
    // Bind select Occupation event handler
    $('#occupationLabel').change(function(){
    	$(this).attr('original', $(this).children(':selected').attr('original'));
    	$('#occupationLabel_value').text( $("#occupationLabel option[value='"+$('#occupationLabel').val()+"']").text() );
      if ($(this).children(':selected').attr('original') == 'BRANCH_other') {
        $('#occupationOther').rules('add', 'required');
        $('#occupationOther').parent().show();
      } else {
        $('#occupationOther').parent().hide();
        $('#occupationOther').val('');
        $('#occupationOther').rules('remove', 'required');
        $('#occupationOther').parent().removeClass('jlc-error-element');
      }
    });
    $('#companyTitle').change(function(){
    	$(this).attr('original', $(this).children(':selected').attr('original'));
    	$('#companyTitle_value').text( $("#companyTitle option[value='"+$('#companyTitle').val()+"']").text() );
        if ($(this).children(':selected').attr('original') == 'Pers_company_title.10') {
          $('#companyTitleOther').rules('add', 'required');
          $('#companyTitleOther').parent().show();
        } else {
          $('#companyTitleOther').parent().hide();
          $('#companyTitleOther').val('');
          $('#companyTitleOther').rules('remove', 'required');
          $('#companyTitleOther').parent().removeClass('jlc-error-element');
        }
      });
    if ($("#occupationOther").val() !== "") {
        $("#occupationOther").parent().show();
      }
      if ($("#occupationOther").val() !== "") {
          $("#occupationOther").parent().show();
        }
      /**************************************************************************/
      /**************************************************************************/
      /*                   Start => LE CLUB: Edit Form                  */
      /**************************************************************************/
      /**************************************************************************/
      var profileRules = {
    	      'profile[firstname]': "required",
    	      'profile[lastname]': "required",
    	      'profile[nickname]': "required",
    	      'profile[languageWeb]': "required",
    	      'profile[email]': "required",
    	      'profile[phoneNumber]': "required",
    	      'profile[birthdate]': "required",
    	      'profile[address1]': "required",
    	      'profile[postalcode]': "required",
    	      'profile[city]': "required"};

    	    var profileForm = $('#jlc-form-edit-profile');
    	    initClubberRegistrationForm(profileForm, profileRules);

          // Bind select Occupation event handler
    	    $('#profile_occupationLabel').change(function(){
    	    	$(this).attr('original', $(this).children(':selected').attr('original'));
    	        $('#profile_occupationLabel_value').text( $("#profile_occupationLabel option[value='"+$('#profile_occupationLabel').val()+"']").text() );
    	      if ($('#profile_occupationLabel').val() == 'other') {
    	        //$('#profile_occupationOther').rules('add', 'required');
    	        $('#profile_occupationOther').parent().show();
    	      } else {
    	        $('#profile_occupationOther').parent().hide();
    	        $('#profile_occupationOther').val('');
    	       // $('#profile_occupationOther').rules('remove', 'required');
    	        $('#profile_occupationOther').parent().removeClass('jlc-error-element');
    	      }
    	    });

    	    $('#profile_companyTitle').change(function(){
    	    	$(this).attr('original', $(this).children(':selected').attr('original'));
    	        $('#profile_companyTitle_value').text( $("#profile_companyTitle option[value='"+$('#profile_companyTitle').val()+"']").text() );
    	        if ($('#profile_companyTitle').val() == '10') {
    	          //$('#profile_companyTitleOther').rules('add', 'required');
    	          $('#profile_companyTitleOther').parent().show();
    	        } else {
    	          $('#profile_companyTitleOther').parent().hide();
    	          $('#profile_companyTitleOther').val('');
    	          //$('#profile_companyTitleOther').rules('remove', 'required');
    	          $('#profile_companyTitleOther').parent().removeClass('jlc-error-element');
    	        }
    	      });

    	    $("input[id^='profile_address']").each(function(){
    	      if($(this).val() != '') {
    	        $(this).show();
    	      }
    	    })

    	    if ($("#profile_occupationOther").val() !== "") {
    	      $("#profile_occupationOther").parent().show();
    	    }
    	    
    	    if ($("#profile_companyTitleOther").val() !== "") {
  	          $("#profile_companyTitleOther").parent().show();
  	        }

	  /*********validate mode emploi ==> langue*******/
	  /***********************************************/

		var $modeEmploiLang = $('#jlc-form-validate-shop');
		var $modeEmploiLangValidator = $modeEmploiLang.validate({
				errorClass: 'jlc-error-element',
                showErrors: function(errorMap, errorList) {
                    if(($modeEmploiLangValidator.numberOfInvalids())>0)
					{ $modeEmploiLang.find('.jlc-form-error-bloc').show();}
                    else {
                        $modeEmploiLang.find('.jlc-form-error-bloc').hide();
					}

					

						if ($('#lang').val() == 0) {

							$('#lang').addClass('jlc-error-element');

							$modeEmploiLang.find('.jlc-form-error-bloc').show();

						} else {

                        $('#lang').removeClass('jlc-error-element');

                   

                }

                this.defaultShowErrors();

            	},
            	errorPlacement: function(error, element) {
					error.appendTo( element.prev() );
				},
				rules:{
					'lang': "required"
				}
			});
			$('.jlc-type-link button').click(function(){
				if($modeEmploiLang.valid()){
					$modeEmploiLang.find('.jlc-form-error-bloc').hide();
					$modeEmploiLang.submit();
				}
				return false;
			});
	  
      /**************************************************************************/
      /**************************************************************************/
      /*                   END => LE CLUB: Registration && Edit Form                  */
      /**************************************************************************/
      /**************************************************************************/

    /* Form validate */
    var $ContactForm = $('#jlc-form-validate');
    if ($ContactForm.size() != 0) {
        var ContactFormValidator = $ContactForm.validate({
            errorClass: 'jlc-error-element',
            showErrors: function(errorMap, errorList) {
        		var linkProduct =  (!($('input[name="ref-1"]').val()) && ($('#question').val() == '1.2'));
        		var linkGarde =  (!($('#gardeTemps_numGrave1').val()) && ($('#question').val() == '1.06'));
                if((ContactFormValidator.numberOfInvalids()) > 0) {
                    if (linkProduct) {
                        $('#link-productBox').css('color','#b80000');
                    }
                    else{
                    	 $('#link-productBox').css('color','');
                    }
                    if (linkGarde) {
                        $('#link-GardeBox').css('color','#b80000');
                    }
                    else{
                    	 $('#link-GardeBox').css('color','');
                    }
                    $('#jlc-form-validate').find('.jlc-form-error-bloc').show();
                    $('#jlc-form-validate').find('.jlc-form-success-bloc').hide();

                } else {
                    $('#jlc-form-validate').find('.jlc-form-error-bloc').hide();
                }

                if ($('#shopBox').is(':visible') && $('.jlc-form-error-bloc').is(':visible')) {

                    if ($('#form_shops').val() == 0) {

                        $('#shopBox').addClass('jlc-error-element');

                        $ContactForm.find('.jlc-form-error-bloc').show();

                    } else {

                        $('#shopBox').removeClass('jlc-error-element');

                    }

                }

                this.defaultShowErrors();

            },
            	errorPlacement: function(error, element) {
					error.appendTo( element.prev() );
				},
            rules: {
                'personal[civility]': 'required',
                'personal[lastname]': 'required',
                'personal[firstname]': 'required',
                'personal[email]': 'required',
                'personal[phoneNumber]': 'required',
                'personal[langue]': 'required',
                'personal[address1]': 'required',
                'personal[postalcode]': 'required',
                'personal[city]': 'required',
                'personal[countryCode]': 'required',
                'personal[aprouver]': 'required',
                'form[message]': 'required',
				'personal[check-1]': 'required',
				'personal[check-2]': 'required',
                'link_popin_product': 'required',
                'personal[password_confirm]': {
                    equalTo: '#personal_password'
                },
                'personal[email_confirm]': {
                    equalTo: '#personal_email'
                }
            },
            submitHandler: function(form) {

                if ($('#personal_receiveNewsLetter').is(':checked')) { receiveNewsletter = 1; } else { receiveNewsletter = 0; }

                    $ContactForm.find('.jlc-form-error-bloc').hide();

                    if ($('#shopBox').is(':visible') && $('.jlc-form-error-bloc').is(':visible')) {

                        if ($('#form_shops').val() == 0) {

                            $('#shopBox').addClass('jlc-error-element');

                            $ContactForm.find('.jlc-form-error-bloc').show();

                            return false;

                        }

                    }

                  /* get values from elements on the form: */
                  var civility          = $('input[name="personal[civility]"]:checked').val(),
					  //check1          = $('input[name="personal[check-1]"]:checked').val(),
					 // check3          = $('input[name="personal[check-3]"]:checked').val(),
                    lastname          = $('input[name="personal[lastname]"]').val(),
                    firstname         = $('input[name="personal[firstname]"]').val(),
                    nickname          = $('input[name="personal[pseudo]"]').val(),
                    email             = $('input[name="personal[email]"]').val(),
                    email_confirm     = $('input[name="personal[email_confirm]"]').val(),
                    password          = $('input[name="personal[password]"]').val(),
                    phoneNumber       = $('input[name="personal[phoneNumber]"]').val(),
                    address1          = $('input[name="personal[address1]"]').val(),
                    address2          = $('input[name="personal[address2]"]').val(),
                    address3          = $('input[name="personal[address3]"]').val(),
                    address4          = $('input[name="personal[address4]"]').val(),
                    postalcode        = $('#personal_postalcode').val(),
                    countryCode       = $('#personal_countryCode').val(),
                    city              = $('#personal_city').val(),
                    state             = $('#Region').val(),
                    languagePreferred = $('#personal_langue').val(),
                    languageWeb       = $('#lang_web').val(),
                    receiveNewsletter = receiveNewsletter,
                    type              = $('#question').val(),
                    message           = $('#form_message').val()
                    languageCatalogue = $('input[name="jlc-country"]:checked').val(),
                    numGrave1         = $('#gardeTemps_numGrave1').val(),
                    numGrave2         = $('#gardeTemps_numGrave2').val(),
                    numGrave3         = $('#gardeTemps_numGrave3').val(),
                    img1URL           = $('#img1URL').val(),
                    img2URL           = $('#img2URL').val(),
                    img3URL           = $('#img3URL').val(),
                    ref1              = $('input[name="ref-1"]').val(),
                    ref2              = $('input[name="ref-2"]').val(),
                    ref3              = $('input[name="ref-3"]').val(),
                    registerClubber   = $('input[name="personal[registerClubber]"]:checked').val(),
                    timeSlot          = $('#form_heure').val(),
                    rdvDate           = $('#date_rdv').val(),
                    memberId          = $('#memberId').val(),
                    idBoutique        = $('#form_shops').val(),
                    url = $('#jlc-form-validate').attr('action');
                
                  /* Send the data using post and get the results */
                  $.post(url, { memberId: memberId, civility: civility, lastname: lastname, firstname: firstname, nickname: nickname, email: email,
                	  postalcode: postalcode, password: password, phoneNumber: phoneNumber, countryCode: countryCode, city: city, state: state, languagePreferred: languagePreferred, languageWeb: languageWeb, receiveNewsletter: receiveNewsletter,
                      address1: address1, address2: address2, address3: address3, address4: address4,
                      type: type,
                      message: message,
                      languageCatalogue:languageCatalogue,
                      numGrave1: numGrave1,
                      numGrave2: numGrave2,
                      numGrave3: numGrave3,
                      img1URL: img1URL, img2URL: img2URL, img3URL: img3URL, ref1: ref1, ref2: ref2, ref3: ref3, timeSlot: timeSlot, rdvDate:rdvDate,  registerClubber:registerClubber, idBoutique:idBoutique},
                    function(data) {
                          if (data=="OK") {
                            $('#jlc-popin-contact-success').dialog({
                                autoOpen: false,
                                width: 352,
                                modal: true,
                                draggable: false
                            });
                            $('#jlc-popin-contact-success').dialog('open');
                              $ContactForm.find('.jlc-form-success-bloc').show();
                          }
                          else {
                              if ((data.substring(data.lastIndexOf("EmailExistException")))=="EmailExistException"){
                                  $ContactForm.find('input[name="personal[email]"]').parent().addClass('jlc-error-element');
                              }
                              if ((data.substring(data.lastIndexOf("NicknameExistException")))=="NicknameExistException"){
                                  $ContactForm.find('input[name="personal[pseudo]"]').parent().addClass('jlc-error-element');
                             }
                              $ContactForm.find('.jlc-form-error-bloc p').text(data.substring(0,data.indexOf("//",0)));
                              $ContactForm.find('.jlc-form-error-bloc').show();
                              $ContactForm.find('.jlc-form-success-bloc').hide();
                          }
                    }
                  );

            }

        });

        $('.jlc-type-link input', $ContactForm).click(function() {
            var productRef = true,
            retour = true;

            if (!($('input[name="ref-1"]').val()) && ($('#question').val() == '1.2')) {
                productRef = false;
            }

            if ($ContactForm.valid() && productRef) {

                $ContactForm.find('.jlc-form-error-bloc').hide();
                $('#link-productBox').css('color', '');

            } else {

                $ContactForm.find('.jlc-form-error-bloc').show();
                $('#link-productBox').css('color','#b80000');

                retour = false;
            }

            $('.jlc-line-form-radio', $ContactForm).each(function() {

                var $this = $(this),
                $parent = $this.parent();

                if ($this.find('div span').hasClass('jlc-error-element')) {

                    var span = $this.find('div span');

                    span.removeClass('jlc-error-element');

                    $parent.addClass('jlc-error-element');
                } else {
                    $parent.removeClass('jlc-error-element').find('.jlc-error-element').removeClass('jlc-error-element');
                }

            });

            return retour;

        });

    }

    /* begin Form Extrait d'archive Step2  validate*/
	var $ContactFormExtrait = $('#jlc-form-validate-spc');

    if ($ContactFormExtrait.length != 0) {

        var ContactFormValidator = $ContactFormExtrait.validate({
            errorClass: 'jlc-error-element',
            showErrors: function(errorMap, errorList) {

                if((ContactFormValidator.numberOfInvalids())>0){
                    $ContactFormExtrait.find('.jlc-form-error-bloc').show();
                }
                else
                    $ContactFormExtrait.find('.jlc-form-error-bloc').hide();
                this.defaultShowErrors();

            },
            rules: {
                'billiing_address[email_confirm]': {
                    equalTo: '#billiing_address_email'
                },
                'billiing_address[langue]': 'required'
            }
        });

    }

    /* end Form Extrait d'archive Step2  validate*/

    var $ContactFormPopin = $('#mc-popin-form form');

    if ($ContactFormPopin.length != 0) {

        var ContactFormPopinValidator = $ContactFormPopin.validate({

            errorClass: 'jlc-error-element',
            showErrors: function(errorMap, errorList) {

                if((ContactFormPopinValidator.numberOfInvalids()) > 0) {
                    $ContactFormPopin.find('.jlc-form-error-bloc').show();
                } else {
                    $ContactFormPopin.find('.jlc-form-error-bloc').hide();
                }

                this.defaultShowErrors();

            },
            rules:{
                'gardeTemps[numGrave1]': 'required'
            },
            submitHandler: function(form) {

                $ContactFormPopin.attr('target', 'upload_target');
                form.submit();

                document.getElementById('upload_target').onload = function() {

                    var response = frames['upload_target'].document.getElementById('response').innerHTML,
                    data = eval("("+response+")"); //Parsing JSON

                    $('#img1URL').val(data.img1URL);
                    $('#img2URL').val(data.img2URL);
                    $('#img3URL').val(data.img3URL);

                    if (data.errors != '') {
                        $('#popin-errors').html(data.errors);
                        $('#link_popin_support').val('');
                    } else {
                    	$('#link-GardeBox').css('color','');
                    	$('#link_popin_support').val('true');
                        $('#mc-popin-form').dialog('close');
                    }

                };

            }
        });

        $('#jlc-no-num', $ContactFormPopin).change(function() {

            $('input[name="gardeTemps[numGrave1]"]', $ContactFormPopin).rules('remove', 'required');
            $('input[name="gardeTemps[numGrave1]"]').val('');
            $('input[name="gardeTemps[numGrave2]"]').val('');
            $('input[name="gardeTemps[numGrave3]"]').val('');
            $('.jlc-l-float', $ContactFormPopin).each(function() {

                var $this = $(this);

                $('.jlc-l-float', $ContactFormPopin).removeClass('jlc-error-element');

                $this.removeClass('jlc-error-element').parent().removeClass('jlc-error-element');

            });

        });

        $('.jlc-type-link button', $ContactFormPopin).click(function(){
            var retour = true;

            if ($ContactFormPopin.valid()){

                $ContactFormPopin.find('.jlc-form-error-bloc').hide();

            } else {

                if (!$('#jlc-no-num', $ContactFormPopin).is(':checked')) {

                    $('.jlc-l-float', $ContactFormPopin).each(function() {

                        var self = $(this);

                        if (self.hasClass('jlc-error-element')) {

                            $('.jlc-l-float', $ContactFormPopin).addClass('jlc-error-element').css('background', 'none');

                            self.parent().addClass('jlc-error-element').css('background-position', '99% 24px');

                        }

                    });
                }

                retour = false;
            }

            $('.uploader', $ContactFormPopin).each(function() {

                var $this = $(this),
                $parent = $this.parent();

                if ($this.hasClass('jlc-error-element')) {

                    $this.removeClass('jlc-error-element');

                    $('.filename', $this).addClass('jlc-error-element');
                    $parent.addClass('jlc-error-element');

                } else {
                    $parent.removeClass('jlc-error-element').find('.jlc-error-element').removeClass('jlc-error-element');
                }

            });

            return retour;

        });

        $('.jlc-line-form input', $ContactFormPopin).each(function() {

            var $this = $(this);

            $this.focus(function() {

                $('.jlc-line-form-radio .radio .checked', $ContactFormPopin).removeClass('checked').find('input').removeAttr('checked');

                $('input[name="gardeTemps[numGrave1]"]', $ContactFormPopin).rules('add', 'required');

                $('.jlc-l-float', $ContactFormPopin).removeClass('jlc-error-element');

                $('.jlc-line-form-radio').parent().removeClass('jlc-error-element').find('div.jlc-error-element').removeClass('jlc-error-element');

            });

        });

    }

    /* Login box */

    $('#loginForm').submit(function(e) {

        e.preventDefault();

        var $form = $(this),
        email = $form.find('input[name="loginBox[email]"]').val(),
        password = $form.find('input[name="loginBox[password]"]').val(),
        url = $form.attr('action');

        $.post(url, {
            email: email,
            password: password
        }, function(data) {

            $('#result').html(data);

            if (data == 'OK') {
                location.reload();
            }

        });

    });

    //=============================== Connexion - STARTS =======================================
    $("#connexionForm").submit(function(event)
      {
        /* stop form from submitting normally */
          event.preventDefault();

          /* get values from elements on the form: */
          var $form = $(this),
              email = $form.find('input[name="loginBox[email]"]').val(),
              password = $form.find('input[name="loginBox[password]"]').val(),
              url = $form.attr('action');

          /* Send the data using post and get the results */
          $.post(url, { email: email, password: password },
            function(data) {
                if (data == 'OK'){
                    location.reload();
                }else{
                    $("#resulte").html(data);
                }
            }
          );
        });

    //=============================== Connexion - ENDS =======================================

    //================================= PRODUCTS STARTS ==================================
    $(".jlc-list-item > a.jlc-click-link").click( function (e) {
        e.preventDefault();

        var parent = $(this).parent();

        $(".jlc-hidden-content").removeClass('jlc-hidden-content').find("h2, .jlc-infos-watch, .jlc-close-bloc").hide();
        parent.addClass('jlc-hidden-content');
        $("h2, .jlc-infos-watch, .jlc-close-bloc", parent).show();
    });
    $('.jlc-close-bloc').click(function(e) {
        e.preventDefault();

        var self = $(this),
        parent = self.parent();

        parent.removeClass('jlc-hidden-content').find("h2, .jlc-infos-watch, .jlc-close-bloc").hide();
    });

    $('.add-to-wishlist').click(function() { $.get($(this).attr('href'), function(data){}); return false; });

    //================================== PRODUCTS ENDS ===================================
    //================================================== WatchFinder - STARTS ==================================================

    if ($('.jlc-watchfinder-page').length != 0) {

        if (!$('.jlc-watchfinder-page').hasClass('jlc-enregistrer_montre-page')) {

            $('.jlc-list-item').each(function(index) {

                if (index % 4 == 1) {
                    $(this).css('margin-right', 0);
                }

            });

        }

    }

    /* Up Down */
    $(".jlc-list-watch-click a").bind('click tap', function () {
        if ( $(this).parent().next(".jlc-watch-in:visible").length != 0 ) {
            $(this).parent().next('.jlc-watch-in').fadeOut("fast", function() {
                $(this).prev().removeClass("jlc-watch-actif");
                $(this).parent('li').next('li').children('.jlc-watch-in').animate({'left':'0'}, 350).fadeIn("1500", function () {
                    $(this).prev().addClass("jlc-watch-actif");

                    $('.jlc-watch-layer').layerBloc(function() {

                        if ($('.jlc-watchfinder-page, jlc-content-mes-preferences').length == 0) {
                            $('.jlc-watch-title-in').vAlign();
                        }

                    });

                    if ($('.jlc-watchfinder-page, jlc-content-mes-preferences').length == 0) {
                        $('.jlc-watch-title-in').vAlign();
                    }
                    
                });
            });
        }
        else {
            $(".jlc-watch-in").fadeOut("fast", function () {
                $(this).prev().removeClass("jlc-watch-actif");
            } );
            $(this).parent().next('.jlc-watch-in').animate({'left':'0'}, 350).fadeIn("1500", function () {
                $(this).prev().addClass("jlc-watch-actif");

                $('.jlc-watch-layer').layerBloc(function() {

                    if ($('.jlc-watchfinder-page, jlc-content-mes-preferences').length == 0) {
                        $('.jlc-watch-title-in').vAlign();
                    }

                });

                if ($('.jlc-watchfinder-page, jlc-content-mes-preferences').length == 0) {
                    $('.jlc-watch-title-in').vAlign();
                }

            });
        }
        return false;
    });

    $('.jlc-watch-in div a, .jcarousel-skin-default li a').live('mouseover touchstart', function(e){

        $(this).find('span').css('display','block');

    });
    $('.jlc-watch-in div a, .jcarousel-skin-default li a').live('mouseout touchend', function(e){

        $(this).find('span').css('display','none');

    });
    $('.jlc-watch-in div a.active-pref-mat, .jcarousel-skin-default li a.active-pref-mat').live('mouseout touchend', function(e){

        $(this).find('span').css('display','block');

    });
    $('.jlc-watch-in div a.active-pref-coll, .jcarousel-skin-default li a.active-pref-coll').live('mouseout touchend', function(e){

        $(this).find('span').css('display','block');

    });

    if ($('#carousel').length != 0) {
        $('#carousel').jcarousel({ scroll: 1 });
    }

    // Handling click actions
    $('#atmos-link').click(function() { filter[atmosSpec] = 'oui'; $('#style-click a').trigger('click'); });
    $('#atmos-news').click(function() { filter[newsSpec] = 'oui'; $('#shape-click a').trigger('click'); });
    $('.hf-link').live('click', function() { filter[profileSpec] = $(this).children('span.jlc-watch-title-in').text(); $('#shape-click a').trigger('click'); });
    $('.shape-link').live('click', function() { filter[shapeSpec] = $(this).children('span.jlc-watch-title-in').text(); $('#style-click a').trigger('click'); });
    $('.style-link').live('click', function() { filter[styleSpec] = $(this).children('span.jlc-watch-title-in').text(); $('#material-click a').trigger('click'); });
    $('.material-link').live('click', function() {
    	filter[materialSpec] = $(this).children('span.jlc-watch-title-in').text();
    	initMaterial = false;
    	$('#material-click a').trigger('click');
    	$('#more-criterias').trigger('click');
    });

    //================================================ Handling checkboxes actions ================================================
    $('#atmos-check').click(function() {
        if($(this).is(':checked')) {
            filter[atmosSpec] = 'oui';
            updateNbResults('', filter, '', 'checkbox');
        }
        else {
            delete filter[atmosSpec];
            updateNbResults('', filter, '', 'checkbox');
        }
    });

    $('#news-check').click(function() {
        if($(this).is(':checked')) {
            filter[newsSpec] = 'oui';
            updateNbResults('', filter, '', 'checkbox');
        }
        else {
            delete filter[newsSpec];
            updateNbResults('', filter, '', 'checkbox');
        }
    });

    $('.checkbox-check').live('click', function() {
        classes = $(this).attr('class').split(' ');
        spec = classes[1];
        if($(this).is(':checked')) {
            if(filter[spec] == '' || filter[spec] == undefined) { filter[spec] = $(this).parent().parent().next().text(); }
            else { filter[spec] = filter[spec]+'|'+$(this).parent().parent().next().text(); }
            updateNbResults('', filter, '', 'checkbox');
        }
        else {
            filterParts = filter[spec].split('|');
            name = $(this).parent().parent().next().text();
            filter[spec] = '';
            $.each(filterParts, function(key, value) {
                if(value != name) {
                    filter[spec] += value+'|';
                }
            });

            filter[spec] = filter[spec].substr(0, filter[spec].length - 1);
            if(filter[spec] == '') { delete filter[spec]; }
            updateNbResults('', filter, '', 'checkbox');
        }
    });
    //================================================/ Handling checkboxes actions ================================================

    $('#more-criterias').click(function() {
        url = $(this).attr('href')+'?more_criterias=1';
        window.location.replace(getFilterAsParams(url));
        return false;
    });

    $('#finder-submit').click(function() {
        url = $(this).attr('href')+'?finderAction=submit';
        window.location.replace(getFilterAsParams(url));
        return false;
    });

    if ($('form#search-watch').length != 0) {
        $('form#search-watch').validate();
    }


    //========================================================= START: Contact Form: Devenir membre===================================
    $(function(){
        /*Radio, Checkbox and select style*/
      $("input").not('p.jlc-type-link input, #jlc-header input, .jlc-bottom-watch input[type=submit], .jlc-input-ok').uniform();

         $('.jlc-line-check-club input').click(function(){

            var self = $(this),
            form_club = $('.jlc-line-form-club'),
            input_pseudo = $('#personal_pseudo, #billiing_address_pseudo'),
            input_password = $('#personal_password, #billiing_address_password'),
            input_confirmation = $('#personal_password_confirm, #billiing_address_password_confirm');

            $('.jlc-line-form-club input').val('');

            if (self.is(':checked')) {
                form_club.removeClass('jlc-none');

                input_pseudo.rules('add', 'required');
                input_password.rules('add', 'required');
                input_confirmation.rules('add', 'required');
            } else {
                form_club.addClass('jlc-none');

                input_pseudo.rules('remove', 'required');
                input_password.rules('remove', 'required');
                input_confirmation.rules('remove', 'required');
            }

        });

        $('.jlc-line-form-club input').val('');

        $('.jlc-line-form-pays').mouseenter(function() {

            $('.jlc-line-form-pays .option').click(function() {

                var self = $(this),
                form_etat = $('.jlc-line-form-etat');

                if (self.data('etat') == 1) {
                    form_etat.removeClass('jlc-none');
                } else {
                    form_etat.addClass('jlc-none');
                }

            });

            $(this).unbind('mouseenter');

        });

    });
    //========================================================= END: Contact Form: Devenir membre===================================


    //=================================================== WatchFinder - ENDS ===================================================

    //================================================== Preferences - STARTS ==================================================

    $("#progressbar").progressbar({ value: 28 });

    /* tooltip */
    $(".jlc-tabs-top-l, .jlc-tabs-top-r").hover(
        function() {
            $(this).children('.tooltip-content').css('display', 'block');
            $(this).children('a').addClass('hover-link-bg');
            $(this).parents('.jlc-content').css('z-index', '9');
        },
        function () {
            $(this).children('.tooltip-content').css('display', 'none');
            $(this).children('a').removeClass('hover-link-bg');
            $(this).parents('.jlc-content').css('z-index', '0');
        }
    );

    $('.preference').click(function() {
        var classes = $(this).attr('class').split(' ');
        if($(this).is(':checked')) {
            $.get('/club/getPreferenceUpdate', { code: classes[1], value: 'on' }, function(data) { if(data == 'ko') { $(this).removeAttr('checked'); } });
        }
        else {
            $.get('/club/getPreferenceUpdate', { code: classes[1], value: 'delete' }, function(data) { if(data == 'ko') { $(this).attr('checked','checked'); } });
        }
    });

    $('.prefered-material').click(function() {
        var classes = $(this).attr('class').split(' ');
        if($(this).hasClass('active-pref-mat')) {
            $.get('/club/getPreferenceUpdate', { code: classes[1], value: 'delete' }, function(data) { });
            $(this).removeClass('active-pref-mat');
        }
        else {
            $.get('/club/getPreferenceUpdate', { code: classes[1], value: 'on' }, function(data) { });
            $(this).addClass('active-pref-mat');
        }
    });

    $('.prefered-collection').click(function() {
        var classes = $(this).attr('class').split(' ');
        if($(this).hasClass('active-pref-coll')) {
            $.get('/club/getPreferenceUpdate', { code: classes[1], value: 'delete' }, function(data) { });
            $(this).removeClass('active-pref-coll');
        }
        else {
            $.get('/club/getPreferenceUpdate', { code: classes[1], value: 'on' }, function(data) { });
            $(this).addClass('active-pref-coll');
        }
    });

    $('.prefered-buying').click(function() {
        var classes = $(this).attr('class').split(' ');
        $.get('/club/getPreferenceUpdate', { code: classes[1], value: classes[2], step: 'buying' }, function(data) { });
    });

    $('#goto-shops').click(function(e) {
        e.preventDefault();
        $('.jlc-list-click-product li').eq(5).find('a').trigger('click');
        return false;
    });

    $('#goto-collection').click(function(e) {
        e.preventDefault();
        $('.jlc-list-click-product li').eq(0).find('a').trigger('click');
        return false;
    });

    //$("a#jlc-zoom-fiche").fancybox();

	/* Scroll */

    $('.jlc-content-in .scroll-pane').jScrollPane({
        maintainPosition: false
    });

    $('#jlc-content-tab-5').hide();
    
	$('#shop-pdf').live('click', function()
	{
		$(this).parents('form').attr('action', $(this).attr('href'));
		$(this).parents('form').attr('target', '_blank');
		$(this).parents('form').submit();
		return false;
	});
    
});

$(function() {

    $('.jlc-watch-layer').layerBloc(function() {

        if ($('.jlc-watchfinder-page, jlc-content-mes-preferences').length == 0) {
            $('.jlc-watch-title-in').vAlign();
        }

    });

    if ($('.jlc-watchfinder-page, jlc-content-mes-preferences').length != 0) {
        
        $('.jlc-watch-title-in').vAlign();

        if ($('#mycarousel').length != 0) {

            $('#mycarousel').jcarousel({
                scroll: 1
            });

        }

        if ($('#carousel').length != 0) {

            $('#carousel').jcarousel({
                scroll: 1
            });

        }

        if ($('.mycarousel').length != 0) {

            $('.mycarousel').jcarousel({
                scroll: 1
            });

        }

        $('.jlc-watch-size-2 .jlc-watch-layer').layerBloc(function() {

            $('.jlc-watch-size-2 .jlc-watch-title-in').vAlign();

        });

        $('.jlc-watch-in').hide();

        $(".jlc-list-watch-click:first a").trigger('click');

    }

/* Newsletter Form validate */
	var $NewsletterForm = $('#jlc-newsletter-form');

	if ($NewsletterForm.size() != 0) {
		 var NewsletterFormValidator = $NewsletterForm.validate({
			 errorClass: 'jlc-error-element',
			 showErrors: function(errorMap, errorList) {
				 if((NewsletterFormValidator.numberOfInvalids()) > 0) {

					 $NewsletterForm.find('.jlc-form-error-bloc').show();
					 $NewsletterForm.find('.jlc-form-success-bloc').hide();

				 } else {
					 $NewsletterForm.find('.jlc-form-error-bloc').hide();
				 }
				 this.defaultShowErrors();
			 },

			 submitHandler: function(form) {
				 //e.preventDefault();
				   /* get values from elements on the form: */
				   var civility = $('input[name="civility"]:checked', form).val(),
					 lastname = $('input[name="lastname"]', form).val(),
					 firstname = $('input[name="firstname"]', form).val(),
					 email = $('input[name="email"]', form).val(),
					 url = '/club/getNewsletter';

				   /* Send the data using post and get the results */
					$.get(url, {
                        civility: civility,
						email: email ,
						lastname: lastname,
						firstname: firstname,
						countryCode: __COUNTRY__,
						languageWeb: __LANG__
					}, function(data){
						if (data=="OK") {
							$('#jlc-popin-newsletter').dialog('close');

							$('#jlc-newsletter-success').dialog({
								autoOpen: false,
								width: 352,
								modal: true,
								draggable: false
							});
							$('#jlc-newsletter-success').dialog('open');
							$('#jlc-newsletter-success').show();
						  }
						} );

			 },
			 rules: {
				 'civility': 'required',
				 'lastname': 'required',
				 'firstname': 'required',
				 'email': 'required'
			 }
	    });
	}

    //charger les régions des pays via le webservice
	$('#personal_countryCode').change(function(){
		  $("#personal_state option[value="+$('#personal_countryCode').val()+"]").attr("selected", "selected");
		  selected = $("#personal_state");
		  var res;
		  if(selected[0].options[selected[0].selectedIndex].text=='True'){
			  $('#contact_state_result').css('display','block');
			  if ($('#personal_countryCode').val() != ''){
				  if (res)
				  {
					res.abort();
				  }
				 res = $.ajax({
					url: '/'+ __COUNTRY__ +'/'+ __LANG__ + '/contact/getStates',
					data: {
						 countrycode: $('#personal_countryCode').val(),
						 codeLang: __LANG__
						},
					success: function(data){
						$('#contact_state_result').html(data);
						$('#Region').uniform();
					}
				  })
			  }
			 }
		  else{
			  $('#contact_state_result').css('display','none');
			  if ($('#personal_countryCode').val() != ''){
				  if (res)
				  {
					res.abort();
				  }
			  }
		  }
	});

        /* Popin */

    $('#jlc-popin-ie6').dialog({
        autoOpen: false,
        width: 352,
        modal: true,
        draggable: false
    });

    $('#jlc-popin-password').dialog({
        autoOpen: false,
        width: 352,
        modal: true,
        draggable: false
    });

    $('#popup-login').dialog({
        autoOpen: false,
        width: 352,
        modal: true,
        draggable: false
    });

    $('#mc-popin-form').dialog({
        autoOpen: false,
        width: 684,
        modal: true,
        draggable: false
    });

    $('#mc-popin-form-pdt').dialog({
        autoOpen: false,
        width: 684,
        modal: true,
        draggable: false,
        close: function(event, ui) {$(".product-autocomplate").autocomplete( "disable" )},
        open: function(event, ui) {$(".product-autocomplate").autocomplete( "enable" )}
    });

    $('#mc-popin-form-add').dialog({
        autoOpen: false,
        width: 684,
        modal: true,
        draggable: false
    });

    $('#mc-popin-form-add_montre').dialog({
        autoOpen: false,
        width: 684,
        modal: true,
        draggable: false
    });

    $('#jlc-popin-instructions').dialog({
        autoOpen: false,
        width: 352,
        modal: true,
        draggable: false
    });

    $('#jlc-popin-password').dialog({
        autoOpen: false,
        width: 352,
        modal: true,
        draggable: false
    });

    $('#jlc-popin-activation_link').dialog({
        autoOpen: false,
        width: 352,
        modal: true,
        draggable: false
    });

    $('#jlc-popin-newsletter').dialog({
        autoOpen: false,
        width: 352,
        modal: true,
        draggable: false
    });

    $('.ui-dialog').hide();

    if ($.browser.msie) {
        
        if ($.browser.version <= 6) {
            $('#jlc-popin-ie6').dialog('open');
        }

    }

});

    //=================================================== Preferences - ENDS ===================================================

    // Update the number of search results
    function updateNbResults(spec, filter, model, template, countresult)
    {
        var specParam = '';
        var filterParam = '';
        var templateParam = '';
        if (typeof(countresult)=="undefined")  countresult = 1 ;  
        if(spec) { specParam = spec; }
        if(filter) { filterParam = JSON.stringify(filter); }
        if(! template) { templateParam = model; }
        else { templateParam = template; }
        
        
        $.get(finderURL, { spec: specParam, filter: filterParam, model: model, template: templateParam, countresult: countresult }, function(data) {
        	
        	if(specParam && data) {
                if(templateParam == 'checkbox')
                {	if(typeof(data.count)!='undefined')
                						{
                	                     $('.jlc-watch-title p span').text(data.count);
                						}
                						
                    if(model != '') {
                        var data = $.map(data.items, function(obj, index) { if(obj.name != '') return { name : obj.name, image : obj.image, index: index }; });

                        $('#'+model+'-models').prepend($('#'+model+'-model').tmpl(data, { length: data.length }));
                        
                        $('#'+model+'-models input').not('p.jlc-type-link input, #jlc-header input, div.jlc-bottom-watch input, .jlc-input-ok').uniform();
                        	
                        $('.jlc-content-in .scroll-pane').jScrollPane({
                            maintainPosition:false
                        });

                        if ($('#mycarousel').length != 0) {

                            $('#mycarousel').jcarousel({
                                scroll: 1
                            });

                        }

                        if ($('#carousel').length != 0) {

                            $('#carousel').jcarousel({
                                scroll: 1
                            });

                        }

                        if ($('.mycarousel').length != 0) {

                            $('.mycarousel').jcarousel({
                                scroll: 1
                            });

                        }

                    }
                } else {
                    $('#'+model+'-models').html(data);

                    if ($('#mycarousel').length != 0) {

                        $('#mycarousel').jcarousel({
                            scroll: 1
                        });

                    }

                    if ($('#carousel').length != 0) {

                        $('#carousel').jcarousel({
                            scroll: 1
                        });

                    }

                    if ($('.mycarousel').length != 0) {

                        $('.mycarousel').jcarousel({
                            scroll: 1
                        });

                    }

                }
            } else if(templateParam == 'checkbox' && specParam == '') { $('.jlc-watch-title p span').text(data.count); }
        });
    }

    function getFilterAsParams(url) {
        $.each(filter, function(key, value) { url += '&filter['+key+']='+value; });
        return url;
    }

    function initShapeFilter() {
        delete filter[shapeSpec];
        delete filter[styleSpec];
        delete filter[materialSpec];
    }

    function initStyleFilter() {
        delete filter[styleSpec];
        delete filter[materialSpec];
    }

    function initMaterialFilter() {
        delete filter[materialSpec];
    }

    function initSpecs()
    {
        window.profileSpec    = 2901;
        window.atmosSpec    = 2903;
        window.newsSpec     = 2902;
        window.shapeSpec    = 3001;
        window.styleSpec    = 1801;
        window.materialSpec   = 2801;
        window.braceletSpec   = 1601;
        window.movementSpec   = 201;
        window.functionsSpec  = 3;
    }

    function closeTranslationBox() { $('#jlc-popin-inline-edit').dialog('close'); }

	function deleteShop()
	{
		$.post('/club/get_update', { shopId: 'NULL' });
		$.get('/club/getPreferenceUpdate', { shopId: 'NULL' }, function() {
	    $('#current-shop').hide();
	    $('#shops-list').show();
	    $('#shops-list').find('.jlc-content-title h2').show();
	    $('#shop-details .jlc-content-title-emplty').css('min-height', '30px').css('margin-top', '14px');
	}); }

	function editShop() {
	    $('#current-shop').hide();
	    $('#shops-list').show();
	    $('#shops-list').find('.jlc-content-title h2').hide();
	    $('#shop-details .jlc-content-title-emplty').css('min-height', '0').css('margin-top', '3px');
	}
	

//=================================================== Point of Sales - START ===================================================

$(function() {



    $('#jlc-form-validate-shops').validate({
        submitHandler: function(form) {

            var $this = form;

            $('#pos-search_country').parent().removeClass('jlc-error-element');
            $('#pos-search_state').removeClass('jlc-error-element');
            $('#pos-search_city').removeClass('jlc-error-element');

            if ($('#pos-search_country').val() != 0 && $('#pos-search_country').val() != '') {

               if ($('#pos-search_state').is(':visible')) {
                   
                   if ($('#Region').val() == 0 || $('#Region').val() == '') {
                       
                       $('#pos-search_state').addClass('jlc-error-element');

                       return false;

                   }

               }

               if ($('#pos-search_city').is(':visible')) {
                   $('#pos-search_city').addClass('jlc-error-element');
                   if ($('#idCity').val() != 0 && $('#idCity').val() != '') {
                       
                       $('#pos-search_country').parent().removeClass('jlc-error-element');
                       $('#pos-search_state').removeClass('jlc-error-element');
                       $('#pos-search_city').removeClass('jlc-error-element');

                       form.submit();

                   }

                   //$('#pos-search_city').addClass('jlc-error-element');

                   return false;

               }

               $('#pos-search_country').parent().removeClass('jlc-error-element');
               $('#pos-search_state').removeClass('jlc-error-element');
               $('#pos-search_city').removeClass('jlc-error-element');

               form.submit();

            }

            $('#pos-search_country').parent().addClass('jlc-error-element');
            
            return false;

        }
        
    });

    // Load states or cities in Point of Sales & Services Centers index page :
    $('#pos-search_country').each(modifySelect).change(function(){

        var $this = $(this);

        if ($this.val() == 0) return false;

        $('#pos-search_country').parent().removeClass('jlc-error-element');

        $("#pos-search_withState option[value="+$this.val()+"]").attr("selected", "selected");
        selected = $("#pos-search_withState");
        var res;
        if(selected[0].options[selected[0].selectedIndex].text=='True'){
            $('#pos-search_state').css('display','block');
            $('#pos-search_city').css('display','none');
                if ($this.val() != '' || $this.val() != 0){
                        if (res)
                        {
                            res.abort();
                        }
                     res = $.ajax({
                            url: '/' + __COUNTRY__ + '/' + __LANG__ + '/shops/getStates',
                            data: {
                         countrycode: $this.val(), codeLang: __LANG__
                            },
                            success: function(data){
                                    $('#pos-search_state').html(data);
                                    $('#Region').each(modifySelect).change(function() {
                                            
                                        $('#pos-search_state').removeClass('jlc-error-element');

                                    });
                                    $('#pos-search_state .select').addClass('inline-translate-select').attr('original', 'SHOPS_SEARCH_STATE');

                                    $('#pos-search_state').removeClass('jlc-error-element');
                            }
                        })
                }
            }
        else{
            $('#pos-search_state').css('display','none');
            $('#pos-search_city').css('display','block');
            if ($this.val() != '' || $this.val() != 0){
                        if (res)
                        {
                            res.abort();
                        }
                     res = $.ajax({
                            url: '/' + __COUNTRY__ + '/' + __LANG__ + '/shops/getCities',
                            data: {
                         countrycode: $this.val(), codeLang: __LANG__
                            },
                            success: function(data){
                                if(data == ''){
                                    $('#pos-search_city').css('display','none');
                                }
                                else{
                                        $('#pos-search_city').html(data);
                                        $('#idCity').each(modifySelect).change(function() {
                                            
                                            $('#pos-search_city').removeClass('jlc-error-element');

                                        });
                                        $('#pos-search_city .select').addClass('inline-translate-select').attr('original', 'SHOPS_SEARCH_CITY');
                                }
                            }
                        })
                }
        }
    });
	var $modeEmploiForm = $('form.jlc-form-validate-shops-modeEmploi');
	var shippingRecipientFormValidator = $modeEmploiForm.validate({
		errorClass: 'jlc-error-element',
		showErrors: function(errorMap, errorList) {
			if((shippingRecipientFormValidator.numberOfInvalids())>0)
				$modeEmploiForm.find('.jlc-form-error-bloc').show();
			else
				$modeEmploiForm.find('.jlc-form-error-bloc').hide();
			this.defaultShowErrors();
		},
		errorPlacement: function(error, element) {
			error.appendTo( element.prev() );
		},
		highlight: function(element){
		  element = $(element);
		  if(element.get(0).tagName == 'SELECT'){
			element.parents('div.jlc-line-form').addClass('jlc-error-element');
		  }
		  else {
			element.addClass('jlc-error-element');
		  }
		},
		unhighlight: function(element){
		  element = $(element);
		 if(element.get(0).tagName == 'SELECT'){
			element.parents('div.jlc-line-form').removeClass('jlc-error-element');
		  }
		  else{
			element.removeClass('jlc-error-element');
		  }
		},
		rules: { 
			'product': { required: true }, 
			'lang': { required: true }
		}
	});
	$('form.jlc-form-validate-shops-modeEmploi .jlc-type-link button').click(function(){
		if($modeEmploiForm.valid()){
			$modeEmploiForm.find('.jlc-form-error-bloc').hide();
			$modeEmploiForm.submit();
		}
		return false;
	});
});
