// Scripts JQuery communs à tout le site ADH
$(function() {
	// correction transparence des PNG
	$('img[@src$=.png]').ifixpng();
	
	// idem pour les PDF internes...
	$("a[@href$='.pdf']").each(function() {
		$(this).click(function(){window.open(this.href);return false;});
	})
		
	// Assure la création des boîtes à coins arrondis
	$('div.rdbx').prepend('<div class="hd">'+'<div class="c"></div>'+'</div>').append('<div class="ft">'+'<div class="c"></div>'+'</div>');
	
      		
	// Premier élément du menu a un bord gauche différent dans IE 6
	$("#menu ul li:first").addClass("premier");
	// On ajoute aussi le bas de chaque sous-menu
	$("#menu ul li ul").each(function() {
		$(this).append('<li class="end"></li>');
	});

	// hauteur identique pour les différents composants de la boîte principale
	// $('#contenu, #focus').equalHeight();
	
});

/**
 * EqualHeight 1.0
 *
 * Makes all matched elements equal height. Does not work in
 * browsers that do not support min-height (no IE.. who cares)
 *
 * Usage: jQuery('#content, #sub-content').equoalHeight();
 *
 * @class equalHeight
 *
 * Copyright (c) 2008 Andreas Lagerkvist (andreaslagerkvist.com)
 * Released under a GNU General Public License v3 (http://creativecommons.org/licenses/by/3.0/)
 */
jQuery.fn.equalHeight = function() {
	var height = 0, 
		maxHeight = 0;

	// Store the tallest element's height
	this.each(function() {
		var t = jQuery(this);
		height = t.height() + parseInt(t.css('paddingTop'), 10) + parseInt(t.css('paddingBottom'), 10) + parseInt(t.css('borderTopWidth'), 10) + parseInt(t.css('borderBottomWidth'), 10);
		maxHeight = (height > maxHeight) ? height : maxHeight;
	});

	// Set element's min-height to tallest element's height
	return this.each(function() {
		var t = jQuery(this);
			mh = maxHeight - (parseInt(t.css('paddingTop'), 10) + parseInt(t.css('paddingBottom'), 10) + parseInt(t.css('borderTopWidth'), 10) + parseInt(t.css('borderBottomWidth'), 10));
		t.css({minHeight: mh +'px'});
	});
};
