// JavaScript Document
function getRadioValue(radio){
    var lstRadios = document.getElementsByName(radio);
    for(var i=0; i<lstRadios.length; i++) if(lstRadios[i].checked) return lstRadios[i].value;
    return null;
}

$(document).ready(function() {

	trandosamdiml = 45;
	trandosaml = 30;
	trandodiml = 30;
	trandosamdim = 48;
	trandosam = 33;
	trandodim = 33;
	tdemip = 35;
	trepas = 17;
	
	//calcul du prix total en fonction de la sélection
	$("input[type=radio]").click(function() {
		tot = 0;

		if ($('input[type=radio][name=licence]:checked').attr('value') == 'o')
		{
			if ($('input[type=radio][name=rando]:checked').attr('value') == 'sd') { tot = tot + trandosamdiml; }
			if ($('input[type=radio][name=rando]:checked').attr('value') == 's') { tot = tot + trandosaml; }
			if ($('input[type=radio][name=rando]:checked').attr('value') == 'd') { tot = tot + trandodiml; }
		}
		
		if ($('input[type=radio][name=licence]:checked').attr('value') == 'n')
		{
			if ($('input[type=radio][name=rando]:checked').attr('value') == 'sd') { tot = tot + trandosamdim; }
			if ($('input[type=radio][name=rando]:checked').attr('value') == 's') { tot = tot + trandosam; }
			if ($('input[type=radio][name=rando]:checked').attr('value') == 'd') { tot = tot + trandodim; }
		}
		
		if ($('input[type=radio][name=option]:checked').attr('value') == 'demip') { tot = tot + tdemip; }
		if ($('input[type=radio][name=option]:checked').attr('value') == 'repas') { tot = tot + trepas; }
		
		$("#total").html(tot.toFixed(2)+" €");
		
	});
	//fin du calcul du prix
	
	$("#type1").click(function() {
		$("#infoi").fadeIn();
		$("#infor").fadeIn();
	});
	
	$("#type2").click(function() {
		$("#infoi").fadeOut();
		$("#infor").fadeOut();	
	});
	
	
	$("#licence1").click(function() {
		$("#divlicence").fadeIn();
		$("#randosamdim").html(trandosamdiml.toFixed(2)+" €"); 
		$("#randosam").html(trandosaml.toFixed(2)+" €"); 
		$("#randodim").html(trandodiml.toFixed(2)+" €");
	});

	$("#licence2").click(function() {
		//$("#divlicence").show(10); //permet de faire marcher la fonction ci-dessous
		$("#divlicence").fadeOut();
		$("#randosamdim").html(trandosamdim.toFixed(2)+" €"); 
		$("#randosam").html(trandosam.toFixed(2)+" €"); 
		$("#randodim").html(trandodim.toFixed(2)+" €");
	});
	
});



