var chemin_absolu = "/";
$(document).ready(
	function(){
		/* HOVER boutons du menu_haut */
		$('#menu_haut .bouton').hover(
			function(){
				$(this).css("cursor", "pointer");
				$(this).css("background-image", "url('"+chemin_absolu+"img/bouton_hover.gif')");
			},
			function(){
				$(this).css("cursor", "auto");
				$(this).css("background-image", "url('"+chemin_absolu+"img/bouton.gif')");
			}
		);
		/* CLICK boutons du menu_haut */
		$('.bouton').click(
			function(){ window.location.href = $(this).find('a').attr('href'); }
		);
		
		/* HOVER bouton le_terrain du menu_bas */
		$('#menu_bas .bouton#le_terrain').hover(
			function(){ $(this).find('img').attr("src", chemin_absolu+"img/btn_le_terrain_hover.jpg"); },
			function(){ $(this).find('img').attr("src", chemin_absolu+"img/btn_le_terrain.jpg"); }
		);
		/* HOVER bouton le_constructeur du menu_bas */
		$('#menu_bas .bouton#le_constructeur').hover(
			function(){ $(this).find('img').attr("src", chemin_absolu+"img/btn_le_constructeur_hover.jpg"); },
			function(){ $(this).find('img').attr("src", chemin_absolu+"img/btn_le_constructeur.jpg"); }
		);
		/* HOVER bouton le_financement du menu_bas */
		$('#menu_bas .bouton#le_financement').hover(
			function(){ $(this).find('img').attr("src", chemin_absolu+"img/btn_le_financement_hover.jpg"); },
			function(){ $(this).find('img').attr("src", chemin_absolu+"img/btn_le_financement.jpg"); }
		);
		
		/* HOVER icone del gestion */
		$('.img_del').hover(
			function(){ $(this).css("cursor", "pointer"); }
		);
		/* HOVER CLICK del gestion */
		$('.img_del').click(
			function(){ $('#del_'+this.id.substr(8, 13)).slideToggle("normal"); }
		);
		
		/* HOVER icone del non gestion */
		$('.del .non').hover(
			function(){ $(this).css("cursor", "pointer"); }
		);
		/* CLICK icone del non gestion */
		$('.del .non').click(
			function(){ $('#del_'+this.id.substr(4, 9)).slideToggle("normal"); }
		);
		
		/* CLICK checkbox modif photo */
		$('.div_checkbox input').click(
			function(){ $('#div_file'+this.id.substr(4, 5)).slideToggle("normal"); }
		);
		
		/* HOVER miniature */
		$('.miniature').hover(
			function(){
				$(this).css("cursor", "pointer");
				$('#agrandi_'+this.id.substr(7, 13)+' img').attr('src', $('#'+this.id+' img').attr('src'));
			}
		);
		
		/* TEXTAREA maxlenth */
		$('textarea[maxlength]').keyup(
			function(){
				var max = parseInt($(this).attr('maxlength'));
				if($(this).val().length > max){
					$(this).val($(this).val().substr(0, $(this).attr('maxlength')));
				}
				$(this).parent().find('.charsRemaining').html('You have ' + (max - $(this).val().length) + ' characters remaining');
			}
		);
		
		/* BOUTONS carousel */
		$('#car_precedent').hover(
			function(){ $(this).css("cursor", "pointer"); }
		);
		$('#car_precedent').click(
			function(){ stepcarousel.stepBy('mygallery', -1); }
		);
		$('#car_suivant').hover(
			function(){ $(this).css("cursor", "pointer"); }
		);
		$('#car_suivant').click(
			function(){ stepcarousel.stepBy('mygallery', 1); }
		);
		
		/* PNG Fix pour IE6 */
		$(document).pngFix();
	}
);