$("document").ready(function(){
	 $("#recaptcha_image  img").attr('alt', 'Captcha');
	  $("#recaptcha_table #recaptcha_reload_btn").click(
		function(){
			//Recaptcha.reload ();
			setTimeout(function(){$("#recaptcha_image  img").attr('alt', 'Captcha')},1000);

	  });
	  
   $(".block-menu li").focusin(function() {
     $(this).addClass("tabulation"); 
    });
  
    $(".block-menu li").focusout(function() {
     $(this).removeClass("tabulation");
    }); 
	
	$(".block-menu li a").click(function(e) {
     $(this).parent().removeClass("tabulation"); 
	 if (e.ctrlKey) {
          $(this).parent().addClass("notab");
        }
    });
   
   /* reflesh Photothèque page */
   $.fn.refreshList = function() {
	 $('div.check-photos').find(':checkbox').each(function(){ 
	  var title = this.title;
	  if($(this).is(':checked')){
	  $('<div />')
		.text($(this).parent().text())
		.appendTo('#dynamicList');
	 var show = true;
	 }
	  if(show){
		  $('#no-image').attr('style','display:none');
		  }
	});
	
	$('div.check-photos').find(':checkbox').click(function(){ 
	 var title = this.title;
	 var $this = $(this);
	 var sstr = '';
	 
	 $('div.check-photos').find(':checkbox').each(function(){ 
		 var title = this.title;
		 if($(this).is(':checked')){
		 sstr = sstr+', '+$(this).parent().text();		 
	  }
	});
	 sstr = sstr.substring(1);
	 if(sstr){
	 	 $('#dynamicList textarea').val(sstr);
	 	 $('#no-image').attr('style','display:none');
	 }else{
	 	 $('#dynamicList textarea').val($('#no-image').text());
	 	 $('#no-image').removeAttr('style');
	 }
	 
	 if($(this).is(':checked')){
	   $(this).attr('checked','checked');
	   $('<div />')
	    .text($(this).parent().text())
		.appendTo('#dynamicList');
		
		
	   } else {
	   $(this).removeAttr('checked');
	   
	   $('#dynamicList div').each(function(){
	     if($(this).text() === $this.parent().text()){
		   $(this).remove();
		 }
	   });
	  
	   
	 }  
	});
  }
  $('#dynamicList').refreshList();
  $('.view-photo form').submit(function() {
        var $fields = $(this).find('input:checked');
        if (!$fields.length) {
            alert('Vous devez sélectionner au moins une image!');
            return false; // The form will *not* submit
        }
  });
  
  
  function textZoom(i){
    var newSize = fontSize;
    if(i<0 && fontSize>=125) {
      newSize -= 25;
    }
    if(i>0 && fontSize<=175) {
      newSize += 25;
    }
    fontSize = newSize;
    $('#content-area').css('font-size', newSize+'%');
    $('#spec-content').css('font-size', newSize+'%');
    if(100 == newSize) {
      $('#content-area').css('font-size', '100%');
      $('#spec-content').css('font-size', '100%');
    }
  }
	var fontSize = 100;
  $('#zoom_minify').click(function(){
    textZoom(-25);
    return false;

  });
  $('#zoom_magnify').click(function(){
    textZoom(25);
    return false;
	});
	
	/* view-form-page*/
  $('.view-form-page form')
  .bind('invalid-form.validate', function() {
		$('.top-messages').html('Votre formulaire n’a pu être envoyé.<br/> Merci de corriger les erreurs de saisie suivantes afin de poursuivre :');
		$('.item-label em').addClass('redstart');
  })
  .validate({
    errorElement: 'em',
	ignoreTitle: true,
	rules: {
	  'submitted[prenom]': {
	    required: true
	  },
	  'submitted[nom]': {
	    required: true
	  },
	  'submitted[contactinfo][email]': {
	    required: true,
	    email : true
	  }
	
	},
	messages:{
	 'submitted[prenom]' : {
	    required : 'Merci de renseigner une valeur.'
	 },
	 'submitted[nom]' : {
	    required : 'Merci de renseigner une valeur.'
	 },
	 'submitted[contactinfo][email]' : {
	    required : 'Merci de renseigner une valeur.',
	    email : 'Saisir un email de type adresse@site.com.'
	 }
	
	},
	
    errorPlacement: function(error, element) {
	   
			error.insertBefore( element.parent().parent());
			element.prev().addClass('error');
	}
  
  });
  
  $('.view-login-page form')
  .bind('invalid-form.validate', function() {
		$('.item-label em').addClass('redstart');
  })
  .validate({
    errorElement: 'em',
	ignoreTitle: true,
	messages: {
			'submitted[ident]': 'Merci de renseigner une valeur',
			'submitted[passe]': 'Merci de renseigner une valeur'
		},

    errorPlacement: function(error, element) {
	   
			error.insertBefore( element.parent().prev());

	}
  
  });
  
  $('.view-photo form')
  .bind('invalid-form.validate', function() {
		$('.item-label em').addClass('redstart');
  })
  .validate({
    errorElement: 'em',
	ignoreTitle: true,
	messages: {
	  'submitted[contactinfo][email]' : {
	    required : 'Merci de renseigner une valeur.',
	    email : 'Saisir un email de type adresse@site.com.'
	 }
			
    },

    errorPlacement: function(error, element) {
	   
			error.insertBefore( element.parent().parent());

	}
  
  });

  /* form validate end*/

  
   $.fn.vAlign = function(){
     return this.each(function(i){ 
	   var text = $(this).find('a').html().toLowerCase();
	   if(text.indexOf('<br>') >= 0 ){
	    $(this).find('a').css('padding-top','5px');
	    $(this).find('a').css('padding-bottom','5px');
	   } else {
	    $(this).find('a').css('padding-top','10px');
	   }

	 }); 
   }; 
  
  $('.block-menu li').vAlign();
 
  $.fn.imgWidth  = function(){
    var imgw = $(this).find('img').width();
	$(this).css('width',imgw);
  }; 
  $('.img-left').each(function(){$(this).imgWidth();});
//  $('.img-left').next().find('.icon-2').css('clear','both');
  
  
  $.fn.supCon  = function(){
    return this.each(function(){ 
	   $(this).closest('li').addClass('sup');
      }); 
  }; 
  $('.icon-2 li sup').supCon();
  /* pdf line break */
  /* $.fn.lineBreak  = function(){
    
    return this.each(function(){
	  var lists_a = $(this).find('a').width();
	  var intLen = 23;
	  var lists_a_ht = $(this).find('a').text();
	  var strTemp = "";
	  //if( lists_a > 163 ){
	     //$(this).find('a').css({'word-wrap':'break-word','width':'163px','display':'inline-block'});
	     //$(this).find('a').css({'table-layout':'fixed','word-break':'break-all','overflow':'hidden'});
      //}
	  while (lists_a_ht.length > intLen) {
         strTemp += lists_a_ht.substr(0, intLen) + " ";
         lists_a_ht = lists_a_ht.substr(intLen, lists_a_ht.length);
      }
	  strTemp += " " + lists_a_ht;
	  $(this).find('a').text(strTemp);
	});
  }; 
  $('.lists-1 li').lineBreak();  */
  
  
 
  

 
	
	

});



