/* SACD 2008 */
/* COMMON JAVASCRIPT FUNCTIONS */

/* ENABLE ROLLOVER ON TARGETED IMAGES (ALL BROWSERS) */
function imgRollover(elt) {
    jQuery(elt).each( function() {
		jQuery(this).hover(
			function() {
				jQuery(this).attr("src", jQuery(this).attr("src").replace("-off","-on"));
			},
			function () {
				jQuery(this).attr("src", jQuery(this).attr("src").replace("-on","-off"));
			}
		);
	});
}

/* SAME HEIGHT FOR SAME CLASS ELEMENTS */
function sameHeight(elt) {
	var heightBlockMax=0;
	jQuery(elt).each(function(){ if( jQuery(this).height() > heightBlockMax ) heightBlockMax = jQuery(this).height(); }); // get max height
	if (jQuery.browser.msie) {
		if (parseInt(jQuery.browser.version) <= "6") {
			jQuery(elt).each(function(){ jQuery(this).css("height",heightBlockMax); }); // assign max height
		} else {
			jQuery(elt).each(function(){ jQuery(this).css("min-height",heightBlockMax); }); // assign max height
		}
	} else {
		jQuery(elt).each(function(){ jQuery(this).css("min-height",heightBlockMax); }); // assign max height
	}
	heightBlockMax=0;
}

function shadowBox(elt) {
	jQuery(elt).each(function(){
		jQuery(this).attr("src", jQuery(this).attr("src").replace(".png",".gif"));
	});
	var newHeight = jQuery('#contentContainerCenter').height();
	jQuery('#contentContainerCenter '+elt).css("height",newHeight);
}

/* SUCKERFISH DROPDOWN MENUS */
function mySuperfish(elt) {
	jQuery(elt).superfish({
		dropShadows : false,
		delay: 0
	}).find('ul').bgIframe();
}

/* FONT RESIZER */
function fontResize(elt) {
 	jQuery("#content").prepend('<ul id="fontResizeTool"><li><span class="increaseFont" title="Cliquez pour agrandir la taille du texte">+</span></li><li><span class="decreaseFont" title="Cliquez pour diminuer la taille du texte">-</span></li><li><span class="resetFont" title="Cliquez pour remettre la taille du texte d\'origine">x</span></li></ul>');
// Reset Font Size
 		var originalFontSize = jQuery(elt).css('font-size');
 	    jQuery(".resetFont").click(function(){
 	    jQuery(elt).css('font-size', originalFontSize);
 	  });
 	  // Increase Font Size
 	  jQuery(".increaseFont").click(function(){
 	    var currentFontSize = jQuery(elt).css('font-size');
 	    var currentFontSizeNum = parseFloat(currentFontSize, 10);
 	    var newFontSize = currentFontSizeNum*1.2;
 	    jQuery(elt).css('font-size', newFontSize);
 	    return false;
 	  });
 	  // Decrease Font Size
 	  jQuery(".decreaseFont").click(function(){
 	    var currentFontSize = jQuery(elt).css('font-size');
 	    var currentFontSizeNum = parseFloat(currentFontSize, 10);
 	    var newFontSize = currentFontSizeNum*0.8;
 	    jQuery(elt).css('font-size', newFontSize);
 	    return false;
 	  });
 }

/* SLIDESHOW */
function mySlideshow(elt) {
	jQuery(elt).cycle('fade');
}

/* LIGHTBOX */
function myLightbox(elt) {
	jQuery(elt).lightbox({
		fileLoadingImage: 'img/loading.gif',
		fileBottomNavCloseImage: 'img/closelabel.gif'
	});
}

jQuery(document).ready(function() {

    /* ADD hasJS CLASS TO BODY FOR ABS/REL POSITIONNING */
	jQuery("body").addClass("hasJS");

    /* HIDE QUICK LINKS */
	jQuery('#quickAccess').addClass('offLeft');

    /* ENABLE ROLLOVER ON TARGETED IMAGES (ALL BROWSERS) */
    if (jQuery('.swapImg').size() > 0) { initImgRollOver = imgRollover(".swapImg"); }

    /* SUCKERFISH DROPDOWN MENUS */
    if (jQuery('ul#mainNav').size() > 0) { initMainNav = mySuperfish("ul#mainNav"); }

    /* SHADOW BOX REPLACEMENT */
    if (jQuery.browser.msie && jQuery('.bgContentContainer').size() > 0) {
		if (parseInt(jQuery.browser.version) <= "6") {
			initShadowBox = shadowBox('.bgContentContainer');
		}
	}

    /* SLIDESHOW */
    if (jQuery('ul#articleSlideshow').size() > 0) { initSlideshow = mySlideshow("ul#articleSlideshow"); }

	/* FONT RESIZER */
    fontResize('#content');

	/* LIGHTBOX */
	if (jQuery('.lightbox').size() > 0) { initLightbox = myLightbox(".lightbox"); }

});























/* END */