/*
 *
 *  Cette partie est lancÃ©e une fois la page chargÃ©e complÃ©tement.
 *  
 */
$(document).ready(function() {

    //le click sur le logo renvoit à l'accueil en français !!!
    
    $("#bt_logo").bind('click',function() {
            afficher_accueil();
        });
        
    //le click sur le bouton français renvoit à l'accueil français
    $("#bt_french").bind('click',function() {
        afficher_accueil();
    });

    //le click sur le bouton english renvoit à l'accueil anglaise
    $("#bt_english").bind('click',function() {
        afficher_english();
    });

    //le click sur le bouton ok de recherche simple renvoit vers la page de recherche simple
    $("#bt_search_simple").bind('click',function() {
        afficher_search_simple();
    });
    
    //le click sur le bouton ok de recherche avancée renvoit vers la page de recherche avancée

    $("#bt_search_complex").bind('click',function() {
        afficher_search_complex();
    });
   
    // We only want these styles applied when javascript is enabled
    $('div.navigation').css({'width' : '140px', 'float' : 'left'});
    $('div.content').css('display', 'block');

	/* Paramétrage de la fonction de mapping : chaque zone sera entourée de noir sur un fond noir avec beaucoup d'opacité.			
	*/
	$.fn.maphilight.defaults = {
			fill: true,
			fillColor: '000000',
			fillOpacity: 0.2,
			stroke: true,
			strokeColor: '000000',
			strokeOpacity: 1,
			strokeWidth: 1,
			fade: true,
			alwaysOn: false
		};

		/* Application du mapping sur la carte */
		$("#carte").maphilight();

		/* Affichage du nom de la région lors de son survol */
		$("area").hover(
		      function () {
		        $("#lbl_region").text($(this).attr("tooltip"));
		      }, 
		      function () {
		        $("#lbl_region").text("Cliquer sur une région");
		      }
		);


    // Initially set opacity on thumbs and add
    // additional styling for hover effect on thumbs
    var onMouseOutOpacity = 0.67;


    var galleryAdv = $('#gallery').galleriffic('#thumbs', {
                delay:                  2000,
                numThumbs:              6,
                preloadAhead:           10,
                enableTopPager:         true,
                enableBottomPager:      true,
                imageContainerSel:      '#slideshow',
                controlsContainerSel:   '#controls',
                captionContainerSel:    '#caption',
                loadingContainerSel:    '#loading',
                renderSSControls:       true,
                renderNavControls:      true,
                playLinkText:           'Lecture diaporama',
                pauseLinkText:          'Arrêt diaporama',
                prevLinkText:           'Photo précédente',
                nextLinkText:           'Photo suivante',
                nextPageLinkText:       'Suivant',
                prevPageLinkText:       'Précédent',
                enableHistory:          true,
                autoStart:              false,
                onChange:               function(prevIndex, nextIndex) {
                        $('#thumbs ul.thumbs').children()
                                .eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
                                .eq(nextIndex).fadeTo('fast', 1.0);
                },
                onTransitionOut:        function(callback) {
                        $('#caption').fadeTo('fast', 0.0);
                        $('#slideshow').fadeTo('fast', 0.0, callback);
                },
                onTransitionIn:         function() {
                        $('#slideshow').fadeTo('fast', 1.0);
                        $('#caption').fadeTo('fast', 1.0);
                },
                onPageTransitionOut:    function(callback) {
                        $('#thumbs ul.thumbs').fadeTo('fast', 0.0, callback);
                },
                onPageTransitionIn:     function() {
                        $('#thumbs ul.thumbs').fadeTo('fast', 1.0);
                }
        });


});

function afficher_accueil() {
    window.location=$('#lien_site_francais').attr('href');
}

function afficher_english() {
    window.location=$('#lien_site_english').attr('href');
}

function afficher_search_simple() {
    window.location=$('#lien_search_simple').attr('href');
}

function afficher_search_complex() {
    window.location=$('#lien_search_complex').attr('href');
}

