jQuery(document).ready(function($)
{


		$("#enfant1").hide(); 
		$("#enfant2").hide(); 
		$("#enfant3").hide(); 
	/*$('.zone .impot .next a').click(function(e)
	{
		e.preventDefault();

		$nextTab = $(this).attr("href");

		$('.zone .tab').hide();
		$($nextTab).show();

		$('html,body').animate({
			scrollTop: $($nextTab).offset().top
		}, 'fast');
	});*/

	$('.tab').keyup(function(e)
	{
		if(e.keyCode == 13)
		{
			$currentTab = $(this).attr('id');
			$globalError 	= false;

			$(this).formValidation($currentTab);

			var $verif=$('#'+$currentTab).verifForm();

			if(($verif)&&($currentTab == 'fTab'))
			{
				$('#formulaire').submit();
				return true;
			}

			// modif pour éviter de passer au tab suivant quand on est sur un textarea
			if($('textarea').is(':focus'))return false;
			if (($verif)&&($currentTab != 'fTab'))			
			{		
				$nextTab = $('.next a', this).attr('href');

				$('.zone .tab').hide();
				$($nextTab).show();

				$('html,body').animate(
				{
					scrollTop: $($nextTab).offset().top
				}, 'fast');

				$('.next a', this).beforeShowTab();
		
				return false;
			}
		
			return false;
		}
	});

	$('.mutuelle ul li a').click(function(e){

		e.preventDefault();
		$('.mutuelle a').removeClass('on');
		$(this).addClass('on');
		$('.slc-CHAMP21').val($(this).text());
		$(this).prev().prop("checked", true);
	});

	$('.have-mutu a').click(function(e)
	{
		e.preventDefault();
		$('.have-mutu a.input-bool').removeClass('on');
		$(this).addClass('on');
		$('.mutuelle1').val( $(this).attr('alt') );

		/*if( $(this).attr('title') == '1') {
			$('.end-contrat').show();
		} else {
			$('.end-contrat').hide();
		}*/

	});

	$('div.selectlist ul li a').click(function(e){

		e.preventDefault();

		$select_class = $(this).parent().parent().parent().attr('class');

		$arr = $select_class.split(' ');
		$arr = $arr[1];

		$('.'+$arr+' ul li a').removeClass('on');
		$(this).addClass('on');
		$(this).prev().prop("checked", true);
	});

	// VERTICALLY ALIGN FUNCTION
	$.fn.vAlign = function() {
		return this.each(function(i){
		var ah = $(this).height();
		var ph = $(this).parent().height();
		var mh = Math.ceil((ph-ah) / 2);
		$(this).css('padding-top', mh);
		});
	};
	$('.regime a span, .regime-conjoint a span, .revenu a span, .placement a span, .type a span, .chequier a span, .revenu-month a span').vAlign();

	$('.slider a').click(function(e)
	{
		e.preventDefault();
		$curForm =  $(this).parent().parent('ul');
		$('li a', $curForm).removeClass('on');
		$(this).addClass('on');
		$curForm.next('input').val($(this).text());
	});

	$('.regime a').click(function(e)
	{
		e.preventDefault();
		$('.regime a').removeClass('on');
		$(this).addClass('on');
		$('#regime').val($(this).attr('param'));
	});
	
	$('.logement a').click(function(e)
	{
		e.preventDefault();
		$('.logement a').removeClass('on');
		$(this).addClass('on');
		$('.logement').val($(this).text());
	});
	$('.residence a').click(function(e)
	{
		e.preventDefault();
		$('.residence a').removeClass('on');
		$(this).addClass('on');
		$('.residence').val($(this).text());
	});
	$('.placement a').click(function(e)
	{
		e.preventDefault();
		$('.placement a').removeClass('on');
		$(this).addClass('on');
		$('#placement').val($(this).text());
	});
	$('.suspend a').click(function(e)
	{
		e.preventDefault();
		$('.suspend a').removeClass('on');
		$(this).addClass('on');
		$('#suspend').val($(this).attr('param'));
	});
	$('.suspend2 a').click(function(e)
	{
		e.preventDefault();
		$('.suspend2 a').removeClass('on');
		$(this).addClass('on');
		$('#suspend2').val($(this).attr('param'));
		
		if($('#suspend2').val()=="Elevée (Tous risques)")
		{
			$('#idGarantiNeuf').show();
			$('#Assist').hide();
		}
		else {
				$('#Assist').show();
				$('#idGarantiNeuf').hide();
			}	
	});
	
	
	$('.suspend3 a').click(function(e)
	{
		e.preventDefault();
		$('.suspend3 a').removeClass('on');
		$(this).addClass('on');
		$('#suspend3').val($(this).text());
	});
	$('.suspend4 a').click(function(e)
	{
		e.preventDefault();
		$('.suspend4 a').removeClass('on');
		$(this).addClass('on');
		$('#suspend4').val($(this).attr('param'));
	});
	$('.suspend5 a').click(function(e)
	{
		e.preventDefault();
		$('.suspend5 a').removeClass('on');
		$(this).addClass('on');
		$('#suspend5').val($(this).attr('param'));
	});
	$('.two2 a').click(function(e)
	{
		e.preventDefault();
		$('.two2 a').removeClass('on');
		$(this).addClass('on');
		$('#two2').val($(this).text());
	});
	$('.two3 a').click(function(e)
	{
		e.preventDefault();
		$('.two3 a').removeClass('on');
		$(this).addClass('on');
		$('#two3').val($(this).text());
	});
	$('.two4 a').click(function(e)
	{
		e.preventDefault();
		$('.two4 a').removeClass('on');
		$(this).addClass('on');
		$('#two4').val($(this).text());
	});
	$('.two5 a').click(function(e)
	{
		e.preventDefault();
		$('.two5 a').removeClass('on');
		$(this).addClass('on');
		$('#two5').val($(this).text());
	});
	$('.look-search a').click(function(e)
	{
		e.preventDefault();
		$('.look-search a').removeClass('on');
		$(this).addClass('on');
		$('#look-search').val($(this).text());
	});
	
	$('.already-assur a').click(function(e)
	{
		e.preventDefault();
		$('.already-assur a').removeClass('on');
		$(this).addClass('on');
		$('#already-assur').val($(this).attr('param'));
	});
	$('.second-driver a').click(function(e)
	{
		e.preventDefault();
		$('.second-driver a').removeClass('on');
		$(this).addClass('on');
		$('#second-driver').val($(this).text());
	});
	
	$('.type a').click(function(e)
	{
		e.preventDefault();
		$('.type a').removeClass('on');
		$(this).addClass('on');
		$('#type').val($(this).text());
	});
	$('.two a').click(function(e)
	{
		e.preventDefault();
		$('.two a').removeClass('on');
		$(this).addClass('on');
		$('.two').val($(this).text());
		$('#two').val($(this).text());
		
	});
	
	

	$('.regime-conjoint a').click(function(e)
	{
		e.preventDefault();
		$('.regime-conjoint a').removeClass('on');
		$(this).addClass('on');
		$('.CHAMP201').val($(this).attr('param'));
	});

	$('.infoconjoint a.input-bool').click(function(e)
	{
		e.preventDefault();
		$('.infoconjoint a.input-bool').removeClass('on');
		$(this).addClass('on');
		$('.CHAMP12').val($(this).text());
		$('.mutuelle1').val( $(this).attr('title') );

		if($('.CHAMP12').val() == 'Oui'){
			$('.info-conjoint').show();
		}
		else {
			$('.info-conjoint').hide();
		}
	});
	$('select.date1').change(function(e)
	{
		e.preventDefault();
		if($('.day1').val() < 10 && $('.month1').val() < 10){
			$('#concatdate1').val('0'+ $('.day1').val() +'/0' + $('.month1').val() +'/'+ $('.year1').val());
		}else if($('.day1').val() < 10 || $('.month1').val() < 10){
			if($('.day1').val() < 10){
				$('#concatdate1').val('0'+ $('.day1').val() +'/'+ $('.month1').val() +'/'+ $('.year1').val());
			}else{
				$('#concatdate1').val($('.day1').val() +'/0' + $('.month1').val() +'/'+ $('.year1').val());
			}
		}else if($('.day1').val() >= 10 && $('.month1').val() >= 10){
			$('#concatdate1').val($('.day1').val() +'/'+ $('.month1').val() +'/'+ $('.year1').val());
		}
	});
	$('select.date2').change(function(e)
	{
		e.preventDefault();
		if($('.day2').val() < 10 && $('.month2').val() < 10){
			$('#concatdate2').val('0'+ $('.day2').val() +'/0' + $('.month2').val() +'/'+ $('.year2').val());
		}else if($('.day2').val() < 10 || $('.month2').val() < 10){
			if($('.day2').val() < 10){
				$('#concatdate2').val('0'+ $('.day2').val() +'/'+ $('.month2').val() +'/'+ $('.year2').val());
			}else{
				$('#concatdate2').val($('.day2').val() +'/0' + $('.month2').val() +'/'+ $('.year2').val());
			}
		}else if($('.day2').val() >= 10 && $('.month2').val() >= 10){
			$('#concatdate2').val($('.day2').val() +'/'+ $('.month2').val() +'/'+ $('.year2').val());
		}
	});
	$('select.date3').change(function(e)
	{
		e.preventDefault();
		if($('.day3').val() < 10 && $('.month3').val() < 10){
			$('#concatdate3').val('0'+ $('.day3').val() +'/0' + $('.month3').val() +'/'+ $('.year3').val());
		}else if($('.day3').val() < 10 || $('.month3').val() < 10){
			if($('.day3').val() < 10){
				$('#concatdate3').val('0'+ $('.day3').val() +'/'+ $('.month3').val() +'/'+ $('.year3').val());
			}else{
				$('#concatdate3').val($('.day3').val() +'/0' + $('.month3').val() +'/'+ $('.year3').val());
			}
		}else if($('.day3').val() >= 10 && $('.month3').val() >= 10){
			$('#concatdate3').val($('.day3').val() +'/'+ $('.month3').val() +'/'+ $('.year3').val());
		}
	});
	$('select.date4').change(function(e)
	{
		e.preventDefault();
		if($('.day4').val() < 10 && $('.month4').val() < 10){
			$('#concatdate4').val('0'+ $('.day4').val() +'/0' + $('.month4').val() +'/'+ $('.year4').val());
		}else if($('.day4').val() < 10 || $('.month4').val() < 10){
			if($('.day4').val() < 10){
				$('#concatdate4').val('0'+ $('.day4').val() +'/'+ $('.month4').val() +'/'+ $('.year4').val());
			}else{
				$('#concatdate4').val($('.day4').val() +'/0' + $('.month4').val() +'/'+ $('.year4').val());
			}
		}else if($('.day4').val() >= 10 && $('.month4').val() >= 10){
			$('#concatdate4').val($('.day4').val() +'/'+ $('.month4').val() +'/'+ $('.year4').val());
		}
	});
	$('select.date5').change(function(e)
	{
		e.preventDefault();
		if($('.day5').val() < 10 && $('.month5').val() < 10){
			$('#concatdate5').val('0'+ $('.day5').val() +'/0' + $('.month5').val() +'/'+ $('.year5').val());
		}else if($('.day5').val() < 10 || $('.month5').val() < 10){
			if($('.day5').val() < 10){
				$('#concatdate5').val('0'+ $('.day5').val() +'/'+ $('.month5').val() +'/'+ $('.year5').val());
			}else{
				$('#concatdate5').val($('.day5').val() +'/0' + $('.month5').val() +'/'+ $('.year5').val());
			}
		}else if($('.day5').val() >= 10 && $('.month5').val() >= 10){
			$('#concatdate5').val($('.day5').val() +'/'+ $('.month5').val() +'/'+ $('.year5').val());
		}
	});
	$('select.date6').change(function(e)
	{
		e.preventDefault();
		if($('.day6').val() < 10 && $('.month6').val() < 10){
			$('#concatdate6').val('0'+ $('.day6').val() +'/0' + $('.month6').val() +'/'+ $('.year6').val());
		}else if($('.day6').val() < 10 || $('.month6').val() < 10){
			if($('.day6').val() < 10){
				$('#concatdate6').val('0'+ $('.day6').val() +'/'+ $('.month6').val() +'/'+ $('.year6').val());
			}else{
				$('#concatdate6').val($('.day6').val() +'/0' + $('.month6').val() +'/'+ $('.year6').val());
			}
		}else if($('.day6').val() >= 10 && $('.month6').val() >= 10){
			$('#concatdate6').val($('.day6').val() +'/'+ $('.month6').val() +'/'+ $('.year6').val());
		}
	});
	$('select.date7').change(function(e)
	{
		e.preventDefault();
		if($('.day7').val() < 10 && $('.month7').val() < 10){
			$('#concatdate7').val('0'+ $('.day7').val() +'/0' + $('.month7').val() +'/'+ $('.year7').val());
		}else if($('.day7').val() < 10 || $('.month7').val() < 10){
			if($('.day7').val() < 10){
				$('#concatdate7').val('0'+ $('.day7').val() +'/'+ $('.month7').val() +'/'+ $('.year7').val());
			}else{
				$('#concatdate7').val($('.day7').val() +'/0' + $('.month7').val() +'/'+ $('.year7').val());
			}
		}else if($('.day7').val() >= 10 && $('.month7').val() >= 10){
			$('#concatdate7').val($('.day7').val() +'/'+ $('.month7').val() +'/'+ $('.year7').val());
		}
	});
	
	
		$('select.date8').change(function(e)
	{
		e.preventDefault();
		if($('.day8').val() < 10 && $('.month8').val() < 10){
			$('#concatdate8').val('0'+ $('.day8').val() +'/0' + $('.month8').val() +'/'+ $('.year8').val());
		}else if($('.day8').val() < 10 || $('.month8').val() < 10){
			if($('.day8').val() < 10){
				$('#concatdate8').val('0'+ $('.day8').val() +'/'+ $('.month8').val() +'/'+ $('.year8').val());
			}else{
				$('#concatdate8').val($('.day8').val() +'/0' + $('.month8').val() +'/'+ $('.year8').val());
			}
		}else if($('.day8').val() >= 10 && $('.month8').val() >= 10){
			$('#concatdate8').val($('.day8').val() +'/'+ $('.month8').val() +'/'+ $('.year8').val());
		}
	});
	
	$('select.date21').change(function(e)
	{
		e.preventDefault();
		if($('.day21').val() < 10 && $('.month21').val() < 10){
			$('#concatdate21').val('0'+ $('.day21').val() +'/0' + $('.month21').val() +'/'+ $('.year21').val());
		}else if($('.day21').val() < 10 || $('.month21').val() < 10){
			if($('.day21').val() < 10){
				$('#concatdate21').val('0'+ $('.day21').val() +'/'+ $('.month21').val() +'/'+ $('.year21').val());
			}else{
				$('#concatdate21').val($('.day21').val() +'/0' + $('.month21').val() +'/'+ $('.year21').val());
			}
		}else if($('.day21').val() >= 10 && $('.month21').val() >= 10){
			$('#concatdate21').val($('.day21').val() +'/'+ $('.month21').val() +'/'+ $('.year21').val());
		}
	});
	$('select.date22').change(function(e)
	{
		e.preventDefault();
		if($('.day22').val() < 10 && $('.month22').val() < 10){
			$('#concatdate22').val('0'+ $('.day22').val() +'/0' + $('.month22').val() +'/'+ $('.year22').val());
		}else if($('.day22').val() < 10 || $('.month22').val() < 10){
			if($('.day22').val() < 10){
				$('#concatdate22').val('0'+ $('.day22').val() +'/'+ $('.month22').val() +'/'+ $('.year22').val());
			}else{
				$('#concatdate22').val($('.day22').val() +'/0' + $('.month22').val() +'/'+ $('.year22').val());
			}
		}else if($('.day22').val() >= 10 && $('.month22').val() >= 10){
			$('#concatdate22').val($('.day22').val() +'/'+ $('.month22').val() +'/'+ $('.year22').val());
		}
	});
	
/*	$('.imgDate').DatePicker({
		format:'d / m / Y',
		date: $('#inputDate').val(),
		current: $('#inputDate').val(),
		starts: 1,
		position: 'right',
		onBeforeShow: function(){
			$('#inputDate').DatePickerSetDate($('#inputDate').val(), true);
		},
		onChange: function(formated, dates){
			$('#inputDate').val(formated);
			$('.imgDate').DatePickerHide();
		}
	});*/
	$('select.date23').change(function(e)
	{
		e.preventDefault();
		if($('.day23').val() < 10 && $('.month23').val() < 10){
			$('#concatdate23').val('0'+ $('.day23').val() +'/0' + $('.month23').val() +'/'+ $('.year23').val());
		}else if($('.day23').val() < 10 || $('.month23').val() < 10){
			if($('.day23').val() < 10){
				$('#concatdate23').val('0'+ $('.day23').val() +'/'+ $('.month23').val() +'/'+ $('.year23').val());
			}else{
				$('#concatdate23').val($('.day23').val() +'/0' + $('.month23').val() +'/'+ $('.year23').val());
			}
		}else if($('.day23').val() >= 10 && $('.month23').val() >= 10){
			$('#concatdate23').val($('.day23').val() +'/'+ $('.month23').val() +'/'+ $('.year23').val());
		}
	});
	$('select.date24').change(function(e)
	{
		e.preventDefault();
		if($('.day24').val() < 10 && $('.month24').val() < 10){
			$('#concatdate24').val('0'+ $('.day24').val() +'/0' + $('.month24').val() +'/'+ $('.year24').val());
		}else if($('.day24').val() < 10 || $('.month24').val() < 10){
			if($('.day24').val() < 10){
				$('#concatdate24').val('0'+ $('.day24').val() +'/'+ $('.month24').val() +'/'+ $('.year24').val());
			}else{
				$('#concatdate24').val($('.day24').val() +'/0' + $('.month24').val() +'/'+ $('.year24').val());
			}
		}else if($('.day24').val() >= 10 && $('.month24').val() >= 10){
			$('#concatdate24').val($('.day24').val() +'/'+ $('.month24').val() +'/'+ $('.year24').val());
		}
	});
	
	
	
	
	$('select.date19').change(function(e)
	{
		e.preventDefault();
		if($('.day19').val() < 10 && $('.month19').val() < 10){
			$('#concatdate19').val('0'+ $('.day19').val() +'/0' + $('.month19').val() +'/'+ $('.year19').val());
		}else if($('.day19').val() < 10 || $('.month19').val() < 10){
			if($('.day19').val() < 10){
				$('#concatdate19').val('0'+ $('.day19').val() +'/'+ $('.month19').val() +'/'+ $('.year19').val());
			}else{
				$('#concatdate19').val($('.day19').val() +'/0' + $('.month19').val() +'/'+ $('.year19').val());
			}
		}else if($('.day19').val() >=10 && $('.month19').val() >= 10){
			$('#concatdate19').val($('.day19').val() +'/'+ $('.month19').val() +'/'+ $('.year19').val());
		}
	});
	
	
	
	$('.remboursement a').click(function(e)
	{
		e.preventDefault();
		$('.remboursement a').removeClass('on');
		$(this).addClass('on');
		$('.remboursement').val($(this).attr('param'));
	});
	$('.dentaire a').click(function(e)
	{
		e.preventDefault();
		$('.dentaire a').removeClass('on');
		$(this).addClass('on');
		$('.dentaire').val($(this).attr('param'));
	});
	$('.optique a').click(function(e)
	{
		e.preventDefault();
		$('.optique a').removeClass('on');
		$(this).addClass('on');
		$('.optique').val($(this).attr('param'));
	});
	$('.hospitalisation a').click(function(e)
	{
		e.preventDefault();
		$('.hospitalisation a').removeClass('on');
		$(this).addClass('on');
		$('.hospitalisation').val($(this).attr('param'));
	});
	$('.mutuelle a').click(function(e)
	{
		e.preventDefault();
		$('.mutuelle a').removeClass('on');
		$(this).addClass('on');
		$('.CHAMP21').val($(this).attr('param'));
	});
	$('.have-mutu a').click(function(e)
	{
		e.preventDefault();
		$('.have-mutu a').removeClass('on');
		$(this).addClass('on');
		$('.mutu').val($(this).text());
	});
	$('.montantcredit li').click(function(e)
	{
		e.preventDefault();
		$('.montantcredit li').removeClass('active');
		$(this).addClass('active');
		$('#montantcredit').val($(this).text());$('#idEstimation').hide();$('#idCalculer').show();
	});
	$('#bloc-slider a.btn-left').click(function(e)
	{
		e.preventDefault();
		$(this).addClass('active');
		$('#montantcredit').val($('#bloc-slider li.active').text());$('#idEstimation').hide();$('#idCalculer').show();
	});
	$('#bloc-slider a.btn-right').click(function(e)
	{
		e.preventDefault();
		$(this).addClass('active');
		$('#montantcredit').val($('#bloc-slider li.active').text());$('#idEstimation').hide();$('#idCalculer').show();
	});
	$('.top.off a').click(function(){

		$nextTab = $(this).attr("href");

				$('.zone .tab').hide();
				$($nextTab).show();

				$('html,body').animate({
					scrollTop: $($nextTab).offset().top
				}, 'fast');
	});

	$('.you-are input').click(function(){
		$('.switch-you-are > div').hide();

		$('#you-are-'+$(this).val()).show();

	});
	$('.revenu a').click(function(e)
	{
		e.preventDefault();
		$('.revenu a').removeClass('on');
		$(this).addClass('on');
		$('#revenu').val($(this).attr('param'));
	});
	$('.compte a').click(function(e)
	{
		e.preventDefault();
		$('.compte a').removeClass('on');
		$(this).addClass('on');
		$('#compte').val($(this).text());
	});
	$('.chequier a').click(function(e)
	{
		e.preventDefault();
		$('.chequier a').removeClass('on');
		$(this).addClass('on');
		$('#chequier').val($(this).text());
	});

	$('.salaire-on a').click(function(e)
	{
		e.preventDefault();
		$('.salaire-on a').removeClass('on');
		$(this).addClass('on');
		$('#salaire-on').val($(this).text());
	});
	$('.nationalite a').click(function(e)
	{
		e.preventDefault();
		$('.nationalite a').removeClass('on');
		$(this).addClass('on');
		$('#nationalite').val($(this).text());
	})
	$.fn.DynamicField = function(nbrText, result, klass, maxField){

		//var nbrText = $(this).parent().prev('span.nbr');

		if(klass == 'plus')
		{
			if(nbrText.text() == 0) {
				$('#dynamic-field0', this).clone().insertAfter('#dynamic-field0', this).find("*[id]").andSelf().each(function() { $(this).show(); $(this).attr("id", "dynamic-field1"); $('#dynamic-field1', this).show(); });
				$('tr.key', this).show();
			}
			else {
				$('#dynamic-field1', this).clone().insertAfter("#dynamic-field"+nbrText.text()).find("*[id]").andSelf().each(function() { $(this).attr("id", "dynamic-field"+result); });

				if(maxField == 3) {
					$('#dynamic-field'+result+' h3 span').html(result);
					$('#dynamic-field'+result+' h3 em').html('&egrave;me');

				}
			}

			//$('#dynamic-field'+result+' input').val('');
			$('#dynamic-field'+result+' input').css('background', '#FFF');
		}
		else
		{
			$('#dynamic-field'+nbrText.text(), this).remove();
			if(nbrText.text() == 1) {
				//$('tr.key', this).hide();
			}
		}
	}

	$('div.quantity-verti .quantity span').click(function()
	{
		$class 		= $(this).attr('class');
		$nbr		= $(this).parent().prev('span.nbr');
		$selected 	= $(this).parent().parent();
		$max		= 4;

		if($selected.parent().is('h3')) {
			$selected = $selected.parent('h3');
		}

		if ( $(this).parent().parent().attr('class').match(/\max3/) ) {
			if($nbr.text() == '3+') {
				$nbr.text('3');
			}
			$max = 3;
		}

		if( $class == 'plus') {
			if($nbr.text() < $max) {
				$result = parseInt($nbr.text())+1;
				$selected.next('table.dynamic-table').DynamicField($nbr, $result, $class, $max);
				$(this).parent().parent().children('.mask').append( '<span class="mask'+$result+'"></span>' );
			}
		}
		else {
			if($nbr.text() > 0) {
				$result = parseInt($nbr.text())-1;
				$selected.next('table.dynamic-table').DynamicField($nbr, $result, $class, $max);
				$(this).parent().parent().children('div.mask').children('.mask'+$nbr.text()).remove();
			}
		}
		if($max == 3 && $result == 3) {
			$nbr.text( $result+'+' );
		} else {
			$nbr.text( $result );
		}
	});

	$('.quantity-hori a').click(function(e){
		e.preventDefault();

		$class 		= $(this).attr('class');
		$current 	= $(this).parent().children('span.nbr');
		$limit		= $(this).parent().children('span.limit');
		$limitstart = $(this).parent().children('span.limitstart');
		$start 		= $(this).parent().children('span.start');
		$end		= $(this).parent().children('span.years');

		$limitstart = $limitstart.text() ? $limitstart.text() : 0;
		$limit 		= $limit.text() ? $limit.text() : 6;

		//$auto-quantity = $(this).parent().attr('class').match(/\auto-quantity/);

		if( $class == 'plus' )
		{
	
			if( $start.text() == '-' ) {
				$start.text('');
				$current.text(1);
				$end.text( 'an' );
			}
			else if($current.text() != $limit)
			{
				$end.text( 'ans' );
				if( parseInt($current.text()) == ($limit-1) ) {
					$end.text( 'ans et +' );
				}

				$(this).parent().children('div.mask').append( '<span class="mask'+(parseInt($current.text())+1)+'"></span>' );

				// if we must add table
				$(this).parent().parent().next('table.dynamic-table').each(function(){
					$(this).DynamicField($current, (parseInt($current.text())+1), $class, 0);
				});

				$current.text( parseInt($current.text())+1 );
			}
		}
		else if( $class = 'mine' )
		{

			// if we must remove table
			$(this).parent().parent().next('table.dynamic-table').each(function(){
				$(this).DynamicField($current, (parseInt($current.text())+1), $class, 0);
			});

			if( $start.text() == '' && $current.text() == 1 )
			{
				if ( ($current.text()-1) == $limitstart && !$(this).parent().attr('class').match(/\auto-quantity/) ) {
					$current.text(0);
				}
				$start.text('-');
			}
			else if ( $start.text() == 1 )
			{
				$end.text( 'an' );
			}
			else if ( $current.text() != $limitstart && $start.text() != '-')
			{
				$current.text( parseInt($current.text())-1 );

				if( $current.text() == 1 ) {
					$end.text( 'an' );
				} else {
					$end.text( 'ans' );
				}
			}

			$(this).parent().children('div.mask').children('.mask'+(parseInt($current.text())+1)).remove();
		}

		if( $(this).parent().children('span.limit').length > 0 )
		{
			if( $(this).parent().children('span.limit').attr('class').match(/\maxplus/) )
			{
				if(($current.text()) == $limit) {
					$(this).parent().children('span.end').text('+');
				} else {
					$(this).parent().children('span.end').text('');
				}
			}
		}
		/* $('#enfant').val($('span.nbr').text()); */
		
		
		

		
		$('#dont').val($('.dont span.nbr').text());
		$('#piecep').val($('.piecep span.nbr').text());
		
		
		

/* Affichage enfants */

$('#nbenfant').val($('span.nbr').text());
	
		if($('#nbenfant').val() == 0){
			$("#enfant1").hide(); 
			$("#enfant2").hide(); 
			$("#enfant3").hide();  
		}
		else if($('#nbenfant').val() == "1"){
			$("#enfant1").show(); 
			$("#enfant2").hide(); 
			$("#enfant3").hide();  
		}
		else if($('#nbenfant').val() == "2"){
			$("#enfant1").show(); 
			$("#enfant2").show(); 
			$("#enfant3").hide();  
		}
		else if($('#nbenfant').val() == "3"){
			$("#enfant1").show(); 
			$("#enfant2").show(); 
			$("#enfant3").show();  
		}
		
		
/* Affichage sinistres */
$('#nbsinistre').val($('.sinistre span.nbr').text());		
		
		if($('#nbsinistre').val() == 0){
		$("#intitule_sinistre").hide(); 
			$("#sinistre1").hide(); 
			$("#sinistre2").hide(); 
			$("#sinistre3").hide();  
		}
		else if($('#nbsinistre').val() == "1"){
		$("#intitule_sinistre").show(); 
			$("#sinistre1").show(); 
			$("#sinistre2").hide(); 
			$("#sinistre3").hide();  
		}
		else if($('#nbsinistre').val() == "2"){
		$("#intitule_sinistre").show(); 
			$("#sinistre1").show(); 
			$("#sinistre2").show(); 
			$("#sinistre3").hide();  
		}
		else if($('#nbsinistre').val() == "3"){
		$("#intitule_sinistre").show(); 
			$("#sinistre1").show(); 
			$("#sinistre2").show(); 
			$("#sinistre3").show();  
		}
		
		
		/* Affichage credits en cours */	
$('#nbcredits').val($('.rachat_nbcredits span.nbr').text());		
		
		if($('#nbcredits').val() == 0){
		$("#intitule_nbcredits").hide(); 
			$("#credit_1").hide(); 
			$("#credit_2").hide(); 
			$("#credit_3").hide();  
			$("#credit_4").hide(); 
		}
		else if($('#nbcredits').val() == "1"){
		$("#intitule_nbcredits").show(); 
			$("#credit_1").show(); 
			$("#credit_2").hide(); 
			$("#credit_3").hide();  
			$("#credit_4").hide(); 
		}
		else if($('#nbcredits').val() == "2"){
		$("#intitule_nbcredits").show(); 
			$("#credit_1").show(); 
			$("#credit_2").show(); 
			$("#credit_3").hide();  
			$("#credit_4").hide();  
		}
		else if($('#nbcredits').val() == "3"){
		$("#intitule_nbcredits").show(); 
			$("#credit_1").show(); 
			$("#credit_2").show(); 
			$("#credit_3").show();  
			$("#credit_4").hide();  
		}
		else if($('#nbcredits').val() == "4"){
		$("#intitule_nbcredits").show(); 
			$("#credit_1").show(); 
			$("#credit_2").show(); 
			$("#credit_3").show();  
			$("#credit_4").show();  
		}
		
		
		
	});
	
	
	$('select.sit-fam-maried').change(function(){
	 	if($(this).val() == 'Celib')
	 	{
	 		$('div.since').hide();
	 	} else {
	 		$('div.since').show();
	 	}
	});

	$('.info-conjoint').hide();
	$('#tab3 .bloc, #fTab .bloc, .grey-box').corner("15px");


	$('.letterOnly').filter_input({regex:'[^0-9]'});
	$('.numberOnly').filter_input({regex:'[0-9]'});

	$('.dateOnly').filter(function() {
        return this.value.match("^\d{1,2}\/\d{1,2}\/\d{4}$");
    }).addClass("inputError");

	$('.compare-table .checkall').toggle(function() {
		$('.compare-table input[type="checkbox"]').attr('checked', true);
	}, function() {
		$('.compare-table input[type="checkbox"]').attr('checked', false);
	});

	

	$('.plus-info-conso').click(function(e)
	{
		e.preventDefault();
		$('plus-info').show();
	});
	
		function lanceSimulation()
		{
		var $montant=$('#montantcredit').val();
		if ($montant.indexOf(" ")!=-1){$montant=$montant.substring(0,$montant.length-2);$montant=1*$montant;};
		
		var $duree=60;
		if($('#CHAMP3b_12').is(':checked'))$duree=12;if($('#CHAMP3b_24').is(':checked'))$duree=24;if($('#CHAMP3b_36').is(':checked'))$duree=36;if($('#CHAMP3b_48').is(':checked'))$duree=48;if($('#CHAMP3b_60').is(':checked'))$duree=60;if($('#CHAMP3b_72').is(':checked'))$duree=72;if($('#CHAMP3b_84').is(':checked'))$duree=84;
		var $credit=$('#TYPECNT_ID').val();
		$('#idCalculer').hide();
		$('#idWait').show();
		showNewSimu('affichepropal',$montant,$duree,$credit);
		$simulCredit=true;
		$('#montantcredit').val($montant);


		}
	
	$('#btn-calcul').click(function(e)
	{
		e.preventDefault();
		lanceSimulation();

	});
	
	
		$('.clduree').click(function(e)
	{
		$('#idEstimation').hide();
		$('#idCalculer').show();
	});
	
	$('#TYPECNT_ID').change(function() 
		{
		$('#idEstimation').hide();
		$('#idCalculer').show();
	});
		
	


		
	
});
			

