/*----------------------------------------------------------------------------//
// Javascript pour le site client  -------------------------------------------//
//----------------------------------------------------------------------------//
// Client : CQIB
// Date   : 03 novembre 2009
//----------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------*/
// Inclusion dynamique des fichiers externes javascripts
/*----------------------------------------------------------------------------*/
function importJavascript(src)
{
	document.write("<script type=\"text/javascript\" src=\"" + src + "\"></scr" + "ipt>");
}
function importCss(href, media)
{
	document.write('<link rel="stylesheet" type="text/css" media="' + media + '" href="' + href + '" />');
}

/*----------------------------------------------------------------------------*/
// Importations de fichiers
/*----------------------------------------------------------------------------*/
importJavascript("/includes/js/swfobject.js");

/* Carousel de logo > Pied de page */
importJavascript("/includes/js/plugins/jquery.jcarousellite.js");

/* Abso Accordeon > Colonne de gauche */
importJavascript("/includes/js/plugins/abso.accordeon.js");

/* Easy Slider > Galerie photo interieur */
importJavascript("/includes/js/plugins/jquery.easyslider.js");
importCss("/includes/js/plugins/jquery.easyslider.css", "screen");

/*----------------------------------------------------------------------------*/
// Declarations jQuery
/*----------------------------------------------------------------------------*/
jQuery(document).ready(function(){
	
	// Plan du site
	if(jQuery("ul#PlanSite")) {		
		
		jQuery("ul#PlanSite li:first").css("border-top","0px");
		jQuery("ul#PlanSite li.PlanSiteSousItem:nth-child(2n+1)").each(function() {
			var curr_height = jQuery(this).height();
			var next_height = jQuery(this).next().height();
			if(next_height != null) {
				if(next_height > curr_height)
					jQuery(this).height(next_height);
				else
					jQuery(this).next().height(curr_height);
			}
		});
		jQuery("ul#PlanSite li.PlanSiteSousItem:nth-child(2n+1)").css("clear","both");
		
	}
	
	// Ajustement Colonne
	jQuery("#BarreLaterale div:last-child").css("margin-bottom","0px");
	equalHeight(jQuery("#BarreLaterale, #Contenu"), false);

});

/* - Fonction : Equalcols height
   ------------------------------------*/
function equalHeight(group, important) {
    tallest = 0;
    important = (important == false ? "" : " !important");
	totalCounter = 0;
    group.each(function() {
        thisHeight = jQuery(this).height();
        if(thisHeight > tallest) {
            tallest = thisHeight;
        }
		totalCounter++;
    });
	if(totalCounter != group.length) 
		return false;
	group.each(function() {
		css = (jQuery(this).attr("style")?jQuery(this).attr("style"):"");
		jQuery(this).attr("style", css+"height:" + tallest + "px" + important + ";");
    });
}
function clearEqualHeight(group) {
	group.each(function() {
        jQuery(this).css("height","");
    });
}
