$(document).ready(function() {

			// Arrondis de bloc
				$('.rounded').prepend('<div class="tl"></div><div class="tr"></div><div class="bl"></div><div class="br"></div>');

				// Arrondis de bloc
				$('.roundedWhite').prepend('<div class="tl"></div><div class="tr"></div><div class="bl"></div><div class="br"></div>');

				// Arrondis de bloc
				$('.roundedBottom').prepend('<div class="tl"></div><div class="tr"></div><div class="bl"></div><div class="br"></div>');

				// Arrondis de bloc espace membres
				$('.roundedMembre').prepend('<div class="tl"></div><div class="tr"></div><div class="bl"></div><div class="br"></div>');

				// Arrondis de bloc espace proximite
				$('.roundedProxi').prepend('<div class="tl"></div><div class="tr"></div><div class="bl"></div><div class="br"></div>');

				// Gestion du menu des deux espaces particuliers et entreprise
				$("#offres .espace").hide();
				$(".current").show();
				$("body#generique .espace").show();
				$("#offres h1").click(function() {
					if (!$(this).next(".espace").is(":visible")) {
						$(".espace").slideUp("fast");
						$(this).next(".espace").slideDown("fast");
					}
				});

				$("#voussexe").click(function() {
					$("#voussexe").removeClass("validation_error");
				});
				$("#voussexe").click(function() {
					$("#voussexe").removeClass("validation_error");
				});

				// Gestion des sous menus des deux espaces particuliers et
				// entreprise */
				$(".espace .content").hide();
				$(".espace .current").show();
				$(".espace h3").click(function() {
					$(".content").slideUp("fast");
					if ($(this).next(".content").is(":visible")) {
						$(this).next(".content").slideUp("slow");
						$(this).next(".content").removeClass("current");
					} else {
						$(this).next(".content").slideDown("fast");
						$(this).next(".content").addClass("current");
					}
				});

				// Gestion des onglets de la page régions */
				$(".extendedRegion").hide();
				$(".extendeReg1").show();
				$(".par_region h2.onglet").click(function() {
					$(".extendedRegion").hide();
					// $("#menu").show();
						$(this).next().show();
						$(this).children(".extendedRegion").show();
					});

				// Gestion des complément informations devis personnalisé étape
				// 1 */
				$("#contenuDevisEtapes h4.more").click(function() {
					if ($(this).hasClass("moins")) {
						$(this).removeClass("moins");
						$(this).addClass("plus");
						$(this).next().hide();
					} else {
						// symbole + ou -
						$(".questions h4.more").removeClass("moins");
						$(".questions h4.more").addClass("plus");
						$(this).removeClass("plus");
						$(this).addClass("moins");

						// affichage de la zone étendue
						$(this).next().show();
					}
				});

				// Niveau de garantie choix

				$(".star_couv li")
						.click(
								function() {
									$(
											"#star11,#star12,#star13,#star21,#star22,#star23,#star31,#star32,#star33,#star41,#star42,#star43")
											.removeClass("current");
									$(
											"#rescouv11,#rescouv12,#rescouv13,#rescouv21,#rescouv22,#rescouv23,#rescouv31,#rescouv32,#rescouv33,#rescouv41,#rescouv42,#rescouv43")
											.hide();
								});

				// Règle du maximum (aucun minimum accépté)
				$("#star13, #star23, #star33, #star43")
						.click(
								function() {
									for (i = 1; i <= 4; i++) {
										valeur = document
												.getElementById('garantie' + i).value;
										if (valeur != '3' && valeur != '2') {
											$("#star" + i + "1").removeClass(
													"active");
											$("#star" + i + "2").addClass(
													"active");
											$(".star_content" + i).removeClass(
													"star1").addClass("star2")
													.removeClass("star3");
											document
													.getElementById('garantie' + i).value = '2';
										}
									}
								});

				// -------------------------------------------
				// Soins de ville
				// -------------------------------------------
				$("#star11")
						.click(
								function() {
									if ((document.getElementById('garantie2').value == '3')
											|| (document
													.getElementById('garantie3').value == '3')
											|| (document
													.getElementById('garantie4').value == '3')) {
										document.getElementById('garantie1').value = '2';
										$("#garantie_niv1").val(2);
										$("#star11,#star13").removeClass(
												"active");
										$("#star12").addClass("active current");
										$(".star_content1")
												.removeClass("star1").addClass(
														"star2").removeClass(
														"star3");
										$("#rescouv12").show();
										tb_show(
												'',
												'/global/includes/devis/thickbox.php?TB_iframe=true&height=150&width=300&inlineId=myOnPageContent&infodevis=4',
												'');
									} else {
										document.getElementById('garantie1').value = '1';
										$("#garantie_niv1").val(1);
										$("#star12,#star13").removeClass(
												"active");
										$(this).addClass("active current");
										$(".star_content1").addClass("star1")
												.removeClass("star2")
												.removeClass("star3");
										$("#rescouv11").show();
									}
									afficheOffre();
								});
				$("#star12").click(
						function() {
							document.getElementById('garantie1').value = '2';
							$("#garantie_niv1").val(2);
							$("#star11,#star13").removeClass("active");
							$(this).addClass("active current");

							$(".star_content1").removeClass("star1").addClass(
									"star2").removeClass("star3");
							$("#rescouv12").show();
							afficheOffre();
						});

				$("#star13").click(
						function() {
							document.getElementById('garantie1').value = '3';
							$("#garantie_niv1").val(3);
							$("#star11, #star12").removeClass("active");
							$(this).addClass("active current");
							$(".star_content1").removeClass("star1")
									.removeClass("star2").addClass("star3");
							$("#rescouv13").show();
							afficheOffre();
						});

				// -------------------------------------------
				// Hospitalisation
				// -------------------------------------------
				$("#star21")
						.click(
								function() {
									if ((document.getElementById('garantie1').value == '3')
											|| (document
													.getElementById('garantie3').value == '3')
											|| (document
													.getElementById('garantie4').value == '3')) {
										document.getElementById('garantie2').value = '2';
										$("#garantie_niv2").val(2);
										$("#star22,#star23").removeClass(
												"active");
										$(this).addClass("active current");

										$(".star_content2")
												.removeClass("star1").addClass(
														"star2").removeClass(
														"star3");
										$("#rescouv21").show();
										tb_show(
												'',
												'/global/includes/devis/thickbox.php?TB_iframe=true&height=150&width=300&inlineId=myOnPageContent&infodevis=4',
												'');
									} else {
										document.getElementById('garantie2').value = '1';
										$("#garantie_niv2").val(1);
										$("#star22,#star23").removeClass(
												"active");
										$(this).addClass("active current");
										$(".star_content2").addClass("star1")
												.removeClass("star2")
												.removeClass("star3");
										$("#rescouv21").show();
									}
									afficheOffre();
								});
				$("#star22").click(
						function() {
							document.getElementById('garantie2').value = '2';
							$("#garantie_niv2").val(2);
							$("#star21,#star23").removeClass("active");
							$(this).addClass("active current");

							$(".star_content2").removeClass("star1").addClass(
									"star2").removeClass("star3");
							$("#rescouv22").show();
							afficheOffre();
						});

				$("#star23").click(
						function() {
							document.getElementById('garantie2').value = '3';
							$("#garantie_niv2").val(3);
							$("#star21, #star22").removeClass("active");
							$(this).addClass("active current");

							$(".star_content2").removeClass("star1")
									.removeClass("star2").addClass("star3");
							$("#rescouv23").show();
							afficheOffre();
						});

				// -------------------------------------------
				// Optique
				// -------------------------------------------
				$("#star31")
						.click(
								function() {
									if ((document.getElementById('garantie1').value == '3')
											|| (document
													.getElementById('garantie2').value == '3')
											|| (document
													.getElementById('garantie4').value == '3')) {
										document.getElementById('garantie3').value = '2';
										$("#garantie_niv3").val(2);
										$("#star31,#star33").removeClass(
												"active");
										$("#star32").addClass("active current");

										$(".star_content3")
												.removeClass("star1").addClass(
														"star2").removeClass(
														"star3");
										$("#rescouv32").show();
										tb_show(
												'',
												'/global/includes/devis/thickbox.php?TB_iframe=true&height=150&width=300&inlineId=myOnPageContent&infodevis=4',
												'');
									} else {
										document.getElementById('garantie3').value = '1';
										$("#garantie_niv3").val(1);
										$("#star32,#star33").removeClass(
												"active");
										$(this).addClass("active current");
										$(".star_content3").addClass("star1")
												.removeClass("star2")
												.removeClass("star3");
										$("#rescouv31").show();
									}
									afficheOffre();
								});
				$("#star32").click(
						function() {
							document.getElementById('garantie3').value = '2';
							$("#garantie_niv3").val(2);
							$("#star31,#star33").removeClass("active");
							$(this).addClass("active current");

							$(".star_content3").removeClass("star1").addClass(
									"star2").removeClass("star3");
							$("#rescouv32").show();
							afficheOffre();
						});

				$("#star33").click(
						function() {
							document.getElementById('garantie3').value = '3';
							$("#garantie_niv1").val(3);
							$("#star31, #star32").removeClass("active");
							$(this).addClass("active current");

							$(".star_content3").removeClass("star1")
									.removeClass("star2").addClass("star3");
							$("#rescouv33").show();
							afficheOffre();
						});

				// -------------------------------------------
				// Dentaire
				// -------------------------------------------
				$("#star41")
						.click(
								function() {
									if ((document.getElementById('garantie1').value == '3')
											|| (document
													.getElementById('garantie2').value == '3')
											|| (document
													.getElementById('garantie3').value == '3')) {
										document.getElementById('garantie4').value = '2';
										$("#garantie_niv1").val(2);
										$("#star41,#star43").removeClass(
												"active");
										$("#star42").addClass("active current");

										$(".star_content4")
												.removeClass("star1").addClass(
														"star2").removeClass(
														"star3");
										$("#rescouv42").show();
										tb_show(
												'',
												'/global/includes/devis/thickbox.php?TB_iframe=true&height=150&width=300&inlineId=myOnPageContent&infodevis=4',
												'');
									} else {
										document.getElementById('garantie4').value = '1';
										$("#garantie_niv4").val(1);
										$("#star42,#star43").removeClass(
												"active");
										$(this).addClass("active current");
										$(".star_content4").addClass("star1")
												.removeClass("star2")
												.removeClass("star3");
										$("#rescouv41").show();
									}
									afficheOffre();
								});
				$("#star42").click(
						function() {
							document.getElementById('garantie4').value = '2';
							$("#garantie_niv1").val(2);
							$("#star41,#star43").removeClass("active");
							$(this).addClass("active current");

							$(".star_content4").removeClass("star1").addClass(
									"star2").removeClass("star3");
							$("#rescouv42").show();
							afficheOffre();
						});

				$("#star43").click(
						function() {
							document.getElementById('garantie4').value = '3';
							$("#garantie_niv1").val(3);
							$("#star41, #star42").removeClass("active");
							$(this).addClass("active current");

							$(".star_content4").removeClass("star1")
									.removeClass("star2").addClass("star3");
							$("#rescouv43").show();
							afficheOffre();
						});

				$("#child_display").click(function() {
					if ($(this).hasClass("plus")) {
						document.getElementById('enfantsnombre').value = 0;
						for (i = 1; i <= 8; i++) {
							$("#etape1enfant" + i).hide();
						}
						$("#gratuit3").hide();
						$("#gratuit4").hide();
					}
				});

				$("#conjointdiplay").click(function() {
					if ($(this).hasClass("moins")) {
						document.getElementById('conjointassure').value = '1';
					} else {
						document.getElementById('conjointassure').value = '0';
					}
				});

				$("#enfantsnombre").ready(
						function() {
							if(document
									.getElementById('enfantsnombre')){
							var nbaAfficher = document
									.getElementById('enfantsnombre').value;
							for (i = 1; i <= 8; i++) {
								if (i <= nbaAfficher) {
									$("#etape1enfant" + i).show();
								} else {
									$("#etape1enfant" + i).hide();
								}
								if (nbaAfficher >= 3) {
									$("#gratuit3").show();
								} else {
									$("#gratuit3").hide();
								}
								if (nbaAfficher >= 4) {
									$("#gratuit4").show();
								} else {
									$("#gratuit4").hide();
								}
							}
							}
						});

				$("#enfantsnombre").change(
						function() {
							var nbaAfficher = document
									.getElementById('enfantsnombre').value;
							for (i = 1; i <= 8; i++) {
								if (i <= nbaAfficher) {
									$("#etape1enfant" + i).show();
								} else {
									$("#etape1enfant" + i).hide();
								}
							}
							if (nbaAfficher >= 3) {
								$("#gratuit3").show();
							} else {
								$("#gratuit3").hide();
							}
							if (nbaAfficher >= 4) {
								$("#gratuit4").show();
							} else {
								$("#gratuit4").hide();
							}
						});

				$("#etape1region").ready(function() {
					regionchange();
				});

				$("#etape1region").change(function() {
					regionchange();
				});

				$("#vousregimess")
						.change(
								function() {
									if (document.getElementById('etape1region').value != 'LORRAINE'
											&& document
													.getElementById('vousregimess').value == 'RL') {
										document.getElementById('etape1region').value = 'LORRAINE';
										regionchange();
									}
								});

				// Gestion des offres de l’onglet actualités par région */
				$("#right .offres .extended").hide();
				$("#right .offres h2").click(
					function() {
					if ($(this).hasClass("moins")) {
						$(this).removeClass("moins");
						$(this).addClass("plus");
						$(this).next().hide();
					} else {
						// symbole + ou -
						$("#right .offres h2").removeClass("moins");
						$("#right .offres h2").addClass("plus");
						$(this).removeClass("plus");
						$(this).addClass("moins");

						// affichage de la zone étendue
						$(".extended").hide();
						$(this).next().show();
					}
				});

				// Gestion par ville de l’onglet nous trouver par région */
				$(".extendeReg3 .infos p").hide();
				$(".extendeReg3 .infos h5").click(function() {
					if ($(this).hasClass("up")) {
						$(this).removeClass("up");
						$(this).addClass("down");
						$(this).next().hide();
					} else {
						// symbole + ou -
						$("#agenda_Region h3").removeClass("up");
						$("#agenda_Region h3").addClass("down");
						$(this).removeClass("down");
						$(this).addClass("up");

						// affichage de la zone étendue
						$(".extended").hide();
						$(this).next().show();
					}
				}
			);

				// Gestion de l’agenda par région */
				$("#agenda_Region .extended").hide();
				$("#agenda_Region h3").click(
				function() {
					if ($(this).hasClass("up")) {
						$(this).removeClass("up");
						$(this).addClass("down");
						$(this).next().hide();
					} else {
						// symbole + ou -
						$("#agenda_Region  .extended").hide();
						$("#agenda_Region h3").removeClass("up");
						$("#agenda_Region h3").addClass("down");
						$(this).removeClass("down");
						$(this).addClass("up");

						// affichage de la zone étendue
						$(".extended").hide();
						$(this).next().show();
					}
				}
			);

				/* cyglage home */
				$("#cyclageHome")
				.before('<div id="nav" class="nav">')
				.cycle( {
					fx : 'fade',
					speed : 'fast',
					timeout : 5000,
					pager : '#nav'
				});

				$(".videoAccueil").click(function() {
					var id = $(this).attr("id");
					id = str_replace('video_', '', id);
					$("#cyclageHome").hide();
					// $("#nav").hide();
						$("#cache_" + id).show();
						var theFile = $("#name_" + id).attr('title');
						createPlayer(theFile, id);
					});

				$(".close").click(function() {
					player.sendEvent('STOP');
					$(".videoAcc").hide();
					$("#cyclageHome").show();
					// $("#nav").show();
					});

				$('A[rel="directory"]').attr("target", "_blank");
				$('A[rel="directory"]').addClass("more");
				$('A[rel="directory"]').text("Toutes les informations sanitaires");

			});
var player = null;
function playerReady(thePlayer) {
	player = window.document[thePlayer.id];
}

function regionchange() {
	$("#REGION_option0").hide();
	$("#REGION_AUTRES").hide();
	$("#REGION_BRETAGNE").hide();
	$("#REGION_CHAMPAGNE_ARDENNES").hide();
	$("#REGION_FRANCHE_COMTE").hide();
	$("#REGION_LORRAINE").hide();
	$("#REGION_PICARDIE").hide();
	$("#REGION_REGION_PARISIENNE").hide();
	if(document.getElementById('etape1region')){
	var regionaAfficher = document.getElementById('etape1region').value;
	if (regionaAfficher != ''
			&& document.getElementById('vousregimess').value == 'RL'
			&& regionaAfficher != 'LORRAINE') {
		document.getElementById('vousregimess').value = 'RG';
	}
	// $("#optionselect").show();
	$("#REGION_" + regionaAfficher).show();
	}
}

function createPlayer(theFile, idVid) {
	var flashvars = {
		file : theFile,
		autostart : "true",
		controlbar : "over",
		playlist : "none"
	}
	var params = {

	}
	var attributes = {
		id : "videoPlus_" + idVid,
		name : "videoPlus_" + idVid
	}
	swfobject.embedSWF("/global/swf/player.swf", "videoPlus_" + idVid, "460", "225", "9.0.115", false, flashvars, params, attributes);
}

function afficheCarte() {
	$(".extendeReg1").hide();
	$(".extendeReg2").hide();
	$(".extendeReg3").show();
	$(".extendeReg3 .infos p").show();
}

function afficheOffre() {
	if (!((document.getElementById('garantie1').value == 0)
			|| (document.getElementById('garantie2').value == 0)
			|| (document.getElementById('garantie3').value == 0) || (document
			.getElementById('garantie4').value == 0))) {

		$("#proposition").show();
		var valeuroffre = Math.pow(10,
				document.getElementById('garantie1').value - 1)
				+ Math.pow(10, document.getElementById('garantie2').value - 1)
				+ Math.pow(10, document.getElementById('garantie3').value - 1)
				+ Math.pow(10, document.getElementById('garantie4').value - 1);
		for (i = 0; i < 24; i++) {
			var valeur2 = document.getElementById('offreval_' + i).value;
			var val2C = parseInt(valeur2 / 100);
			var val2D = parseInt(valeur2 / 10) - 10 * val2C;
			var val2U = parseInt(valeur2) - 10 * val2D - 100 * val2C;
			var valC = parseInt(valeuroffre / 100);
			var valD = parseInt(valeuroffre / 10) - 10 * valC;
			var valU = parseInt(valeuroffre) - 10 * valD - 100 * valC;
			if ((val2U <= valU) && (val2D <= valD) && (val2C <= valC)) {
				$("#offre_" + i).show();
			} else {
				$("#offre_" + i).hide();
			}
		}
	}
}