$(document).ready(function(){

	$("form p input[name='recherche']").bind("click",function(){
		if($(this).val()=='Mots clés')$(this).val("");
	});

	/* Comportement Rollover avec class="rollover" */
	$("img.rollover").each(function(){
		attachRollOverEvent(this);
	});


	/* Remplacement image actif avec class="actif" */
	$("img.actif").each( function(){
		attachActif(this);
	});

	/* Fancybox Propriétés */
  $("a.fancy").fancybox({ 'overlayShow': true, 'overlayOpacity': 0.70, 'hideOnContentClick': true });
  $("a#fenetre").fancybox({ 'overlayShow': true, 'zoomSpeedOut':0, 'zoomSpeedIn':0, 'overlayOpacity': 0.70, 'hideOnContentClick': true });

  $("a.fancyMap").live('click',function(e){
  	$(this).fancybox({ 'overlayShow': true, 'overlayOpacity': 0.70, 'hideOnContentClick': true });
  	e.preventDefault();
  	var moi=$(this);
  	setTimeout(function(){
  		moi.click();
  	},500);
  });


  	$('#menuPrincipal li:not({".geoloc", ".actif"}) a.titre').next().hide();

  	$('#menuPrincipal li:not({".geoloc"}) a.titre').bind("click",function(e) {
		$(this).next().toggle('slow').prev().parent().toggleClass("actif");
		e.preventDefault();
	});

	/*$("#contentActu").cycle({
        fx:      'scrollHorz',
        timeout:  0,
        height: 191,
        prev:    '#prev',
        next:    '#next'
    });*/

	$("#slider").easySlider({
		controlsShow: false,
		vertical: false,
		auto: true,
		pause: 6000,
		controlsFade : false,
		continuous:	true
	});


	$('#bandeau').cycle({
    fx:    'fade',
    speed:  2500,
    timeout:  6500
	});

		/* Tableau 1 sur 2 */
	$("#body table tr:even").addClass("even");
	$("#body table tr:odd").addClass("odd");

	$("a#proposition").fancybox({'overlayShow': true, 'zoomSpeedOut':0, 'zoomSpeedIn':0, 'overlayOpacity': 0.70, 'hideOnContentClick': false, frameHeight:475,frameWidth:600, padding:0});



}); /* fin doc ready */


/* ======== Fonctions ========================================================================== */

/* Comportement Rollover avec class="rollover" */
attachRollOverEvent = function(imageId){
	$(imageId).mouseover( function(){ $(this).attr("src", $(this).attr("src").replace('.','_roll.')) } );
	$(imageId).mouseout( function(){ $(this).attr("src", $(this).attr("src").replace('_roll','')) } );
}

/* Change image pour les "actif" */
attachActif = function(imageId){
	$(imageId).attr("src", $(imageId).attr("src").replace('.','_roll.'));
}

/* Impression des documents */
function imprimer(){
	if(window.print) window.print();
	else alert("Désolé mais votre navigateur ne supporte pas cette fonctionnalité. Pour la plupart des navigateurs, vous pouvez imprimer cette page  en allant dans le menu 'Fichier' > 'Imprimer'");
}

/* Ajouter aux favoris */

function favoris() {
if ( navigator.appName != 'Microsoft Internet Explorer' )
{ window.sidebar.addPanel("le nom du site","http://www.tonsite.com",""); }
else { window.external.AddFavorite("http://www.tonsite.com","le nom du site"); } }




function isset(  ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: FremyCompany
    // +   improved by: Onno Marsman
    // *     example 1: isset( undefined, true);
    // *     returns 1: false
    // *     example 2: isset( 'Kevin van Zonneveld' );
    // *     returns 2: true

    var a=arguments; var l=a.length; var i=0;

    if (l==0) {
        throw new Error('Empty isset');
    }

    while (i!=l) {
        if (typeof(a[i])=='undefined' || a[i]===null) {
            return false;
        } else {
            i++;
        }
    }
    return true;
}