$(document).ready(function(){
				// centrer la page
				
				centrer2(".fond_neutre");
				placer_baspage();
				
				$(".open_me .onglet").each(function (i) {
					$(this).attr("open",0);
					$(this).attr("saveH",$(this).height());
				});
								
				$(".open_me .onglet").click(function(){
					
					$(".open_me").each(function (i) {
						$(this).fadeIn(400);
					})
					
					$(".open_me .onglet").each(function (i) {
						$(this).attr("click","false");
						$(this).fadeIn(100);
					})
					
					$(this).attr("click","true");
					
					$(".contenu", this).width($(this).width());
					
					tailleContenu = $(".contenu", this).height() ;
					tailleOnglet = $(this).height();
					
					
					
					$(".open_me .onglet").each(function (i) {
						if( $(this).attr("open") == 1) {
														
							$(".contenu", this).fadeOut(50,
								function() {
									$(this).parents(".onglet").animate({
											height: $(this).parents("div").attr("saveH")
										},
										100,
										function() {
											$(this).attr("open",0);
											
										}
									)}
							);
						}
					});
					
					if($(this).attr("open") == 0) {
						
						if(($.browser.msie) || ($.browser.opera)) {
							
							addPlace = 20;
						} else {
							addPlace = 10;
						}
						
						
						
						if(tailleContenu > 170) {
									// la taille de l'onglet est trop grande pour afficher les deux onglets
									
									$(".open_me").each(function (i) {
										
										if($(".onglet", this).attr("click") == "false") {
											
											$(this).fadeOut(150);
											
										}
									});
								}
						
						$(this).animate({
								
								height: tailleOnglet + tailleContenu + addPlace
							},
							150,
							function() {
								$(".contenu", this).fadeIn();
								$(this).attr("open",1);
							}
						);
					}
					
					
					
				});
				
				
				$("#demande_devis").click(function(){
					openwindow("#w_devis");
					
				})
				
				$("#mentions_legales").click(function(){
					openwindow("#w_mentions_legales");
					
				})
				
				$("#nous_contacter").click(function(){
					openwindow("#w_contact");
				})
				
				$(".accueil_miniature").mouseenter(function() {
					$(this).css("position","relative");
					$(".vignette_over",this).css("position","absolute");
					$(".vignette_over",this).css("top","0px");
					$(".vignette_over",this).css("left","0px");
					$(".vignette_over",this).fadeIn();
				});
				
				$(".accueil_miniature").mouseleave(function() {
					$(".vignette_over",this).fadeOut(200);
				});
				
				$(".logo").click(function(){
					$(location).attr("href","index.php");
				})
				
				/////////////////// PAGE RUBRIQUE
				
				if($(".rubrique_presentation").height() > 0) {	
					
					taille_col = $(".col_droite").height() - 50; 
					taille_col = 510; 
					//alert($(".col_droite").height());
					taille_chapo = $(".rubrique_chapo").height();  
					taille_texte = $(".rubrique_texte").height();  
					taille_titre = $(".col_droite h1").height(); 
					
					if ($(".actions").height()) {
						var dif = 50;
					} else {
						var dif = 0;
					}
					
					var new_taille = taille_col - taille_chapo - taille_titre - dif;
						
					
					
					if(taille_chapo == 0) {
						// nous n'avons pas de chapo
						$(".rubrique_chapo").css("padding","0px");
						new_taille = new_taille + 30;
					}
					
					$('.rubrique_texte').height(new_taille);
					
				}
				
				// gestions des formulaires en AJAX
				$("input").click(function(){
					
					if($(this).attr("type") == "submit") {
						//alert($(this).parent("form").attr("action"));
						form = $(this).parents("form");
						
						sub2(form,jQuery(".retour_AJAX", $(this).parents("div")));
						return false;
					}
				});
				
			 });
			 
			 function openwindow(div) {
				
				$("#popup_window").html($(div).html() + '<div id="popup_close"></div><div class="retour_AJAX"></div>');
				
				$("#popup_window").width(500);
				
				$("#popup_window").css("z-index","200");
				
				
				centrer("#popup_window");
				$("#popup_window").fadeIn(
					function() {
						
					}
				);
				
				$("#popup_close").click(function(){
					$("#popup_window").fadeOut();
				})
				
				//////////////////////// Gestion des formulaires
				$("input").click(function(){
					
					if($(this).attr("type") == "submit") {
						//alert($(this).parent("form").attr("action"));
						form = $(this).parents("form");
						
						sub2(form,jQuery(".retour_AJAX", $(this).parents("div")));
						return false;
					}
				});
				
			 }
			 
			 $("input").click(function(){
					
					if($(this).attr("type") == "submit") {
						//alert($(this).parent("form").attr("action"));
						form = $(this).parents("form");
						$(".retour_AJAX").css("border","1px red solid");
						sub2(form,$(".retour_AJAX"));
						return false;
					}
				});
			 
			 function centrer(div) {
				var wBrowser = $(window).width();
				var hBrowser = $(window).height();
				
				var top = (hBrowser - $(div).height()) / 2;
				var left = (wBrowser - $(div).width()) / 2;
				
				//alert($(div).height() + "----" + hBrowser);
				
				if(top<0) {
					top = 0;
				}
				
				if(left<0) {
					left = 0;
				}
				
				$(div).css("position","absolute");
				$(div).css("top",top);
				$(div).css("left",left);
				
			 }
			 
			 function centrer2(div) {
				// nous le centrons façon CSS
				// il est certainement déja centré
				var wBrowser = $(window).width();
				var hBrowser = $(window).height();
								
				$(div).css("position","absolute");
				
				$(div).css("left", "50%" );
				$(div).css("top", "50%" );
				
				var top = - $(div).height() / 2;
				var left = - $(div).width() / 2;
				
				$(div).css("margin-top", top);
				$(div).css("margin-left",  left);
				
				
			
				
				if(wBrowser < $(div).width()) {
					$(div).css("margin-left",  -wBrowser / 2);
				}
				
				if(hBrowser < $(div).height()) {
					$(div).css("margin-top",  -hBrowser / 2);
				}
				
			 }
			 
			 
			 function placer_baspage() {
				centrer(".bas_de_page");
				$(".fond_neutre").height();
				var hBrowser = $(window).height();
				var top = (hBrowser - $(".fond_neutre").height()) / 2 ;
				top = top + $(".fond_neutre").height() - 10;
				$(".bas_de_page").css("top",top);
				
			 }
			 
			 
			 
				
			$(window).resize(function(){
				centrer2(".fond_neutre");
				placer_baspage();
			});
