$(document).ready(function(){

	$("#moteur-bouton").bind("click",function(e){
		e.preventDefault();

		var famille=$("#m_famille").val();
		$("div.catalogue-vignettes").load("ajax_formes_liste.php",{id_famille: famille},function(){
			//attachRollOverEvent("div.catalogue-vignettes div.moteur-centre a.left img.rollover");
			setTimeout('attachRollOverEvent("div.catalogue-vignettes div.moteur-centre a.left img.rollover")', 500);
		});

	});


	$("#close-360").bind("click",function(){/* Fermeture de thickbox sur le bouton id="close-360" */
		self.parent.tb_remove();
	});






	attachRollOverEvent("img.rollover");/* Comportement Rollover avec class="rollover" */
	attachActif("img.actif");



	/* Tableau 1 sur 2 */
	$("#body table tr:even").addClass("even");
	$("#body table tr:odd").addClass("odd");
});

/* Comportement Rollover avec class="rollover" */
attachRollOverEvent = function(imageId){
	$(imageId).mouseover( function(){
		var b=$(this).attr("src").match(/[\/|\\]([^\\\/]+)$/);
//		alert( $(this).attr("src").replace(b[1],'') + b[1] );
		$(this).attr("src", $(this).attr("src").replace(b[1],'') + b[1].replace('.','_roll.'));
	} );
	$(imageId).mouseout( function(){
		var b=$(this).attr("src").match(/[\/|\\]([^\\\/]+)$/);
		$(this).attr("src", $(this).attr("src").replace(b[1],'') + b[1].replace('_roll',''));
	} );
}
/* Change image pour les "actif" */
attachActif = function(imageId){
	/*$(imageId).attr("src", $(imageId).attr("src").replace('.','_actif.'));*/
	var b=$(imageId).attr("src").match(/[\/|\\]([^\\\/]+)$/);
	$(imageId).attr("src", $(imageId).attr("src").replace(b[1],'') + b[1].replace('.','_actif.'));
}


/* Ajouter aux favoris */
function favoris(){
	if(document.all){
		window.external.AddFavorite(location.href, document.title)
	}
	else{
		alert('Votre navigateur ne supporte pas cette fonctionnalité. Pour la plupart des navigateurs, vous pouvez faire CTRL + D pour ajouter cette page dans vos favoris.');
	}
};
