        
/**
 * Liste d'elements et de methods d'intialisation
 * Les elements portant la class 'custom-events' 
 * ont une clef correspondant à leur id dans ce Hash
 * Cette fonction est executé sur l'evenement 'domready'
 * la fonction recoit l'element en parametre
 */
var eventAttachment = {
    'diaporama':        'init_diaporama',
    'caroussel':        'init_carousel',
//    'twitter':          'init_twitter',
    'addToFavorites':   'init_favorites',
    'viewer':           'init_visionneuse',
    'geoloc': 	        'init_googlemap',
    'gmap_fond_auto':   'init_gmap_fond_auto',
    'gmap_fond':        'init_gmap_fond',
    'intro_diapo':      'init_intro_diapo',
    'sites_affinitaires_accordion' : 'init_accordion',
    'tipafriend':       'init_tipafriend',
    'gm_fullscreen':    'init_gm_fullscreen',
    'contact_form':     'init_contact_form',
    'key':              'init_search_field',
    'addthis_button' :  'init_addthis_button',
    'bonplans':         'init_bonplans',
    'map_area'  :       'init_map_area',
    'filtres_avances' : 'init_filtres_avances',
    'dans_la_region' :  'init_dans_la_region',
    'click_dans_la_region' : 'init_click_dans_la_region',
	'tarif_recherche': 'init_tarif_recherche',
	'date_recherche': 'init_date_recherche',
	'carto_full_screen': 'init_carto_full_screen',
    'backtosearch':     'init_backtosearch',
    'offer_search':     'save_offersearch_params',
    'filtre_prox':      'init_filtre_prox',
    'bloc_recherche':   'init_bloc_recherche',
    'email_nl':         'init_email_nl'
};


/**
* Initialisation variable globale pour la visionneuse
*/
var viewer = null;


/**
* Initialisation des options globales de la visionneuse
*/
var viewerOptions = {
    "flowplayer" : {
        src : '/extension/crtbre_socle/design/socle/player/flowplayer.swf',
        options : {
            plugins : {
                controls : {
                    url : '/extension/crtbre_socle/design/socle/player/flowplayer.controls.swf',
                    backgroundImage : 'url(/extension/crtbre_socle/design/socle/player/fd_gris.png)'
                }
            }
        }
    },
    'animationSpeed':400,
    'fadeSpeed':400 
};


/**
* listes des fichiers JS a charger selon les besoins
*/
var SCRIPTS_ROOT = '/extension/crtbre_socle/design/socle/javascript/';
var LOADED_FILES = {};




var autoload_scripts = {
    visionneuse:{
        'visonneuse': SCRIPTS_ROOT + 'viewer.js'
    },
    diaporama:{
        'player': SCRIPTS_ROOT + 'player.js'
    },
    autocomplete:{
        'jq': SCRIPTS_ROOT + 'jquery.autocomplete.min.js'
    },
    flowplayer:{
        'main': SCRIPTS_ROOT + 'flowplayer-3.1.4.js',
        'controls': SCRIPTS_ROOT + 'flowplayer.controls-3.0.2.custom.js'
    },
    carousel:{
        'jq': SCRIPTS_ROOT + 'jquery-ui-1.8rc3.custom.min.js',
        'main': SCRIPTS_ROOT + 'jquery.jcarousel.min.js'
    },
    accordion:{
        'jq': SCRIPTS_ROOT +'jquery-ui-1.8rc3.custom.min.js'
    }
};

var autoload_css = {
};



/**
 * Intialisation globale de la page
 */
function init()
{
    $(document).ready(function (){
        addCustomEvents();
		init_externalLinks();
    });
}


/**
 * Detection des elements porteur de la classe custom-events
 * Et declenchement de la fonction associée
 */
function addCustomEvents()
{
    var items = $('.custom-events');

    items.each(function( key, item ){

        if( typeof( eventAttachment[item.id] ) != 'undefined' )
        {
        //  console.log( 'Executing ini function for element : '+ item.id );
            eval(eventAttachment[item.id]+'($("#'+ item.id +'"));');
        }
    });
}


function load_scripts( files, func )
{
    var length = 0;
    var i = 0;

    for( file in files ){ length++; }
    
    for( var file in files )
    {
        if( typeof( LOADED_FILES[file] ) == 'undefined' || LOADED_FILES[file] == false )
        {
            jQuery.getScript( files[file], function( data, textStatus ){
                i++;
                if( i == length )
                {
                    eval('func()');
                }
                LOADED_FILES[file] = true;
            });
        }
    }
}


/**
*  Formulaire de contact en ajax
*/
function init_contact_form(item) 
{

	$("#formajax").submit( function() {	
		
			 var dataString = '';
			 var dataSerialize = $('#formajax').serializeArray();
			 jQuery.each(dataSerialize, function(i, field){
					dataString = dataString + field.name+'='+field.value+'&';
			  });

		 $.ajax({  	
			   type: "POST",  
			   url: "/layout/set/ajax/contact/formulaire",  
			   data: dataString,  
			   dataType: 'text/html',
			   success: function(databack) {  				   	
				 $("#wrapper_contact").html(databack);  
			   },
			   error:function(XMLHttpRequest, textStatus, errorThrown) {
				   $("#wrapper_contact").html('Error has occure');  
			   }
			    
			 });  

		return false; // permet de rester sur la même page à la soumission du formulaire
	});

}
/**
* Tipafriend dans une lightbox
*/
function init_tipafriend(item) 
{
	$(item).colorbox({iframe:true, innerWidth:500, innerHeight:450});
}

/**
* Affiche la google map en full screen
*/
function init_gm_fullscreen(item){
	$(item).colorbox({iframe:true,  innerWidth:1000, innerHeight:600});
}
/**
* Initialise le diaporama
* Les variables globales playlist et options doivent être 
* déclarées et remplies au préalable
*/
function init_diaporama( item )
{
//    load_scripts( autoload_scripts.diaporama, function(){
        new Player( item, playlist, options );
//    });
}

/**
* Initialise le caraoussel sur l'élément Twitter
*/
function init_twitter( item )
{
 //   load_scripts( autoload_scripts.carousel, function(){
        $("#twitter ul").first().jcarousel( {scroll : 1} );
 //   });
}


function init_bonplans( item )
{
    $('#bonplans ul').first().jcarousel( {scroll : 5} );
}


/**
* Initialise le bouton "ajouter aux favoris"
*/
function init_favorites( item )
{
    item.click(function() { addToFavorites() } );
}

	
/**
* Fonction d'ajout aux favoris,
* déclanchée lors du clic sur le bouton "ajouter uax favoris"
*/
function addToFavorites()
{
    if ( navigator.appName != 'Microsoft Internet Explorer' )
    {
            window.sidebar.addPanel(document.title, window.location.href, "");
    }
    else
    {
            window.external.AddFavorite(window.location.href, document.title);
    }
}

/**
* Emulateur de target=_blank,
* Pour concilier en aparence des exigences contradictoires
* (validation XHTML stricte & ouverture des liens externes dans une nouvelle fenêtre).
*/
function init_externalLinks()
{
	$("a[rel=external]").click( function(event) {
		      window.open($(this).attr("href"));  
		      event.preventDefault();  
	    } );
}



/**
* Initialise la visionneuse de la page d'accueil
*/
function init_visionneuse( item )
{
    load_scripts( autoload_scripts.visionneuse, function(){
        viewer = new Viewer(item, viewerViews, viewerOptions);
        viewer.start();
    });
}



/***
*
* Affiche les points de la carte GOOGLE MAP
*
*/
function init_googlemap( item )
{
    // Chargement des scripts Gmap

    if (GBrowserIsCompatible())
    {           

        for(var j=0; j<listeMaps.length; j++)
        {

            var tab = listeMaps[j];
            var infobulle = 'html';
            
            if( item.hasClass('infobulle_ajax') )
            {
                infobulle = 'ajax';
            }

            displayMap(tab[0], tab[1], tab[2], tab[3], tab[4], tab[5], tab[6], infobulle);
        }
    }
}


/**
* Initialise la fonction d'affiche de +ou- de texte sur le chapeau

*/
function init_intro_diapo( item )
{
   $(".intro_diapo .lien_vue a").click(function () {
        var a = $(this);

        var action = a.hasClass('less')? 'less' : 'more' ;
        var otherAction = ( action == 'more' )? 'less' : 'more';
        
        $('#descr_'+ action).css( 'display', 'block' );
        $('#descr_'+ otherAction).css( 'display', 'none' );

        a.text( _( otherAction ) );
        a.removeClass( action );
        a.addClass( otherAction );

        return false;
    });
}


function _( key )
{
    if( typeof( i18n[key] ) == 'undefined' )
    {
        return key;
    }
    return i18n[key];
}

function init_accordion(item) {
    load_scripts( autoload_scripts.accordion, function(){
        item.accordion();
    });
}

function init_search_field(item) {
    var value = item.val();

    var blur = (
        function (item, value) {
            return function () {
                if (item.val() == '') item.val(value);
                item.css('color', '#999');
            }
        }
    )(item, value);

    item.blur(blur);

    var focus = (
        function (item, value) {
            return function () {
                if (item.val() == value) item.val('');
                item.css('color', '#FFFFFF');
            }
        }
    )(item, value);

    item.focus(focus);
}

function init_addthis_button(item) {
    $(item).colorbox({iframe:true,  innerWidth:900, innerHeight:600});
}

function init_map_area(item) {
    var SpriteArea = function (_map, _image) {
        var instance = this;

        var i = 0;
        this.image = _image;
        this.map = _map;

        this.images = {};

        this.areaMouseOver = function (area) {
            var department = area.attr('departement');
            this.images[department].addClass('sprite-' + department + '_over');
        }

        this.areaMouseOut = function (area) {
            var department = area.attr('departement');
            this.images[department].removeClass('sprite-' + department + '_over');
        }

        this.refreshInput = function () {
            var areas = $('area.selected', this.map);
            var nums = [];
            for(var i = 0; i < areas.length; i++) {
                nums.push($(areas[i]).attr('departement'));
            }
            $("input[name=SearchDepartement]").val(nums.join(','));
        }

        this.areaClick = function(area) {
            var department = area.attr('departement');
            if (area.hasClass('selected')) {
                this.images[department].removeClass('sprite-' + department + '_focus');
                area.removeClass('selected');
                //$('#filtre_prox').removeAttr('disabled');
            } else {
                this.images[department].addClass('sprite-' + department + '_focus');
                area.addClass('selected');
                //$("#filtre_prox").attr('disabled', 'disabled');
            }
            this.refreshInput();
            return false;
        }

        var path = null;
        var department = null;
        var areas = $("area", this.map);

        var imageMap = this.image.children().last();
        for(i=0; i < areas.length; i++) {
            department = $(areas[i]).attr('departement');
            this.images[department] = $('<div class="sprite"></div>');
            imageMap.before(this.images[department]);
        }

        areas
            .mouseover(function () { instance.areaMouseOver($(this)); })
            .mouseout(function () { instance.areaMouseOut($(this)); })
            .click(function () { instance.areaClick($(this)); });

        var strNums = $("input[name=SearchDepartement]").val();
        if (strNums.length > 0) {
            var listNums = strNums.split(',');
            for(i in listNums) {
                $('area[departement=' + listNums[i] + ']', this.map).click();
            }
        }
    }
    
    var container = $(item);
    new SpriteArea($('map[name=map_departement]', container).first(), $('.images', container).first());
} 

function init_filtres_avances() {
    $('.filtres_avances h3').click(function () {
        $(this).next().toggle('blind', function () {
            var ul = $(this);
            var h3 = ul.prev();
            if (h3.hasClass("plus")) h3.removeClass("plus");
            else h3.addClass("plus");
        });
    });
}


/**
*  Bloc region rafraichissement ajax
*/
function init_dans_la_region(item) 
{
    refresh_dans_la_region( item );
}


/*
* 
*/
function init_click_dans_la_region(item) 
{
	$("#click_dans_la_region a").click( function(event) {
        event.preventDefault();

        refresh_dans_la_region( item );
	});
}

function refresh_dans_la_region( item )
{
    var dataString = '';

    $.ajax({  	
       type: "POST",  
       url: "/content/view/region/"+node_region_bloc,  
       data: dataString,  
       dataType: 'html',
       success: function(databack) {  				   	
         $("#ajaxregion").html(databack);  
       },
       error:function(XMLHttpRequest, textStatus, errorThrown) {
           $("#ajaxregion").html('Error has occure');  
       }
    });  
            

}

/**
* Slider pour les tarif dans la recherche
*/
function init_tarif_recherche(item) {

    new Slider($('#slider4'), {
        labels : label_tarif,
        values : valeur_tarif,
        change : function (ui, userValue) {
            $('#value').val(userValue);
        },
        jquery : {
            range : true, 
            values : valeur_defaut
        }
        
    });
				
}


/**
* Caldenrier pour la recherhce
*/
function init_date_recherche(item) {
    $("#date_recherche .debut img").click(function () {
        $("#datepicker_debut").focus();
    });
    $("#datepicker_debut").datepicker({ 
        dateFormat: 'dd-mm-yy',
        dayNamesMin: ['Di', 'Lu', 'Ma', 'Me', 'Je', 'Ve', 'Sa'],
        dayNames: ['Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'],
        dayNamesShort: ['Dim', 'Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam'],
        monthNames: ['Janvier','Février','Mars','Avril','Mai','Juin','Juillet','Août','Septembre','Octobre','Novembre','Décembre'],
        monthNamesShort: ['Jan','Fev','Mar','Avr','Mai','Jun','Jul','Aou','Sep','Oct','Nov','Dec']
    });

    $("#date_recherche .fin img").click(function () {
        $("#datepicker_fin").focus();
    });
    $("#datepicker_fin").datepicker({
        dateFormat: 'dd-mm-yy',
        dayNamesMin: ['Di', 'Lu', 'Ma', 'Me', 'Je', 'Ve', 'Sa'],
        dayNames: ['Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'],
        dayNamesShort: ['Dim', 'Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam'],
        monthNames: ['Janvier','Février','Mars','Avril','Mai','Juin','Juillet','Août','Septembre','Octobre','Novembre','Décembre'],
        monthNamesShort: ['Jan','Fev','Mar','Avr','Mai','Jun','Jul','Aou','Sep','Oct','Nov','Dec']
    });
}


/**
* FULLSCREEN
*/
var blockCarto, cartoDiv, mapTypeControl, mapLargecontrol;
function init_carto_full_screen(item) {

    var style_map =	$("#map").attr('style');
    var window_larg = (document.documentElement.clientWidth);
    var window_haut = (document.documentElement.clientHeight);
    

    blockCarto = {
        'width': $('#map').css('width'),
        'height': $('#map').css('height'),
        'top': $('#map').css('top')
    };

    cartoDiv = {
        height: $('#cartodiv').css('height')
    }

    var diff = ( parseInt(cartoDiv.height) - parseInt( blockCarto.height ) );
	
	$("#img_carte_full_img").click(function () {
        
        map.savePosition();
        var position_y = $(window).scrollTop();
        
        $(".carto").addClass('carte_fullscreen_carto');
        
        $("body").addClass("fullscreen");
        
        $(".carte_fullscreen_carto").css({
                'top' : position_y
        });
        $("#map").css({
                'width': window_larg-5, 
                'height': (window_haut - diff)
        }); 
        $('#carto_full_screen').css('z-index', '-1000');

        if( $('.carto_form') )
        {
            $('.carto_form').css('width', $('#map').css('width'));
        }
      
        if( listeMaps[0][5] == 0 )
        {
            map.enableScrollWheelZoom();
            map.enableDragging();
            map.enableContinuousZoom();
            map.enableDoubleClickZoom();

            //map.setUIToDefault();
			//map.addControl(new GMenuMapTypeControl(), new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(25,0)));
            mapTypeControl = new GMapTypeControl();
            mapLargecontrol = new GLargeMapControl3D();

            map.addControl(mapTypeControl,  new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(30,0)));
            map.addControl(mapLargecontrol);
       } 
        map.checkResize();
        map.returnToSavedPosition();
	});	 

    $("#close_map").click(function() {
        $("#map").removeClass('carte_fullscreen_map');
            
        // IE Workarround : Disable remove class...
        //$("body").removeClass("fullscreen");
        // ... and reset manually the property
        $('body').css('overflow', 'auto');
        
        $("#map").css({
                'width': blockCarto.width, 
                'height': blockCarto.height
        });
        
        $('#cartodiv').css('height', cartoDiv.height);

        // IE & Jquery workarround : 
        // IE needs position to be set on 'auto' and jQuery refuse to dot it in this context
        // Let's do it old school...
        /*
        var style = $('#map').attr('style');
        var myregexp = new RegExp( "(^.*position ?: ?)([^;]+)(;.*)$", 'gi');
        style = style.replace( myregexp, '$1auto$3');

        $('#map').attr('style', style);
*/

        $(".carto").removeClass('carte_fullscreen_carto');
        $(".carto").css("top", "auto");

        if( $('.carto_form') )
        {
            $('.carto_form').css('width', $('#map').css('width'));
        }
      

        if( listeMaps[0][5] == 0 )
        {
            map.disableScrollWheelZoom();
            map.disableDragging();
            map.disableContinuousZoom();
            map.disableDoubleClickZoom();
    	    map.disableGoogleBar(); 	
            map.removeControl( mapTypeControl);
            map.removeControl(mapLargecontrol);

            $('#map>div:first').css('position', 'relative');
        }
        if( listeMaps[0][6] == 0 )
        {
        	map.disableInfoWindow();
        }

        map.checkResize();
        map.returnToSavedPosition();
    
        $('#carto_full_screen').css('display', 'block');
        $('#carto_full_screen').css('z-index', '10');
    });
}


function init_backtosearch( item )
{
    var classes = item.attr('class');
    var cookie_name = classes.split(' ')[0];

    if( $.cookie( cookie_name ) )
    {
        item.attr(
            'href', 
            item.attr('href') +'/'+ $.cookie( cookie_name )
        );
    }
}


function save_offersearch_params( item )
{
    var url = document.location.href + '';
    var paramsExists = url.indexOf('(');

    if( NODE_ID != 'undefined' )
    {
        var cookie_name = 'back_'+ NODE_ID;

        if( paramsExists > -1 )
        {
            var params = url.substr( paramsExists, url.length );
            $.cookie( cookie_name, params, { expires: 7, path:'/' } );
        }
        else
        {
            $.cookie( cookie_name, null, { expires: 0, path:'/'});
        }
    }
}


var map, mgr, bubble,bubbleImage ,bubbleImageSize ,bubbleContentSize ,bubbleContentOffset ,bubbleAnchor ,bubbleShowTime ,bubbleTurnoverTimer, customMapNorthEast, customMapSouthWest, bounds, southWest, northEast,  lngSpan, latSpan, initCenter;

// Clique automatique sur la carte
function init_gmap_fond_auto( item )
{
    init_gmap_fonds( item, Array( 80, 56 ), Array( 83, 53 ), true );
	// lancement de la rotation
    list_markers = $.shuffle( list_markers );

	startBubbleTurnover();
}


function init_gmap_fond( item )
{
    init_gmap_fonds( item, Array( 282, 252 ), Array( 240, 232 ), false );
}

// le parametre Pictopersonnalise permet d avoir des picto personnalise pour une rubrique : ex : decouvrir 
function init_gmap_fonds( item, pop_sizes, pop_anchor, pictoPersonnalise  )
{


    /* Prérequis :
    - chargement de la librairie EBubble (bulle d'info)
    */

    tilesPath = "/extension/crtbre_portail/design/crtbre/images/fondcarte/";// chemin vers les PNG constituant le fond de carte
    markers = []; // store les marqueurs à afficher

    // BULLE
    //bubbleImage = "http://econym.org.uk/gmap/chrome.png"; 
    bubbleImage = "bubble.png"; // image représentant la bulle
    //bubbleImageSize = new GSize(297,243); // taille de l'image représentant la bulle
    bubbleImageSize = new GSize( pop_sizes[0],pop_sizes[1] ); // taille de l'image représentant la bulle
    //bubbleContentSize = new GSize(224,126); // taille du contenu de la bulle
    bubbleContentSize = new GSize( pop_sizes[0],pop_sizes[1] ); // taille du contenu de la bulle
    //bubbleContentOffset = new GPoint(36,28); // position du coin supérieur gauche du contenu de la bulle
    bubbleContentOffset = new GPoint(0,0); // position du coin supérieur gauche du contenu de la bulle
    //bubbleAnchor = new GPoint(175,238); // position de l'ancre de la bulle
    bubbleAnchor = new GPoint( pop_anchor[0], pop_anchor[1] ); // position de l'ancre de la bulle


    // ROTATION
    bubbleShowTime = 5000; // temps d'affichage de la bulle
    bubbleTurnoverTimer = null;

    // Définition des extremités du fond de carte
    customMapNorthEast = new GLatLng(49.75,-0.95);
    customMapSouthWest = new GLatLng(46.685,-5.565);

    if (GBrowserIsCompatible()) {
            
        // Copyright
        myGCopyrightCollection = new GCopyrightCollection();
        myGCopyrightCollection.addCopyright(new GCopyright('Demo', new GLatLngBounds(new GLatLng(-90,-180), new GLatLng(90,180)),0,'<Insérer un copyright> &copy; 2010'));
        
        // Construction du fond de carte
        myGTileLayer = new GTileLayer(myGCopyrightCollection,8,9); 
        myGTileLayer.getTileUrl = function (a,b) { return tilesPath + tileToQuadKey(a.x,a.y,b) + ".png"; }
        myGTileLayer.isPng = function () { return true; };
        myGmapType = new GMapType([myGTileLayer], G_SATELLITE_MAP.getProjection(), "Topo",{errorMessage: "Out of map"});

        // Chargement de la map
        map = new GMap2(document.getElementById('map'));
        initCenter = new GLatLng(48.150000,-3.180000);
        map.setCenter(initCenter,8);
        map.setMapType(myGmapType);
        
        // Suppression des effets de zoom et drag&drop
        map.disableDragging();
        map.disableContinuousZoom();
        map.disableDoubleClickZoom();
        map.disableScrollWheelZoom();
        
        //BULLE
        bubble = new EBubble(map, bubbleImage, bubbleImageSize, bubbleContentSize, bubbleContentOffset, bubbleAnchor);
        
        // Les markers seront affichés via le manager
        mgr = new MarkerManager(map);
        
        // Détection des bords de la map
        bounds = map.getBounds();
        southWest = bounds.getSouthWest();
        northEast = bounds.getNorthEast();
        lngSpan = northEast.lng() - southWest.lng();
        latSpan = northEast.lat() - southWest.lat();
        

    }
    else{
        alert('Désolé, mais votre navigateur n\'est pas compatible avec Google Maps');
    }

    infobulle = 'html';
    params  = null;
	
     for(i=0; i < datas.length; i++)
        {
            data = datas[i];

/*
			if (pictoPersonnalise && picto_perso_js != '')
			{
				var picto_map_perso = new GIcon(G_DEFAULT_ICON);
				picto_map_perso.image =  "/extension/crtbre_portail/design/crtbre/images/picto_carto/"+picto_perso_js[data["node_id"]];
				picto_map_perso.shadow =  "/extension/crtbre_portail/design/crtbre/images/picto_carto/ombre_picto.png";
				picto_map_perso.iconSize = new GSize(25, 31);
				var icon = picto_map_perso;
			}
			else 
			{
				 var icon = eval( data["icon"] );
			}
*/
			var icon = eval( data["icon"] );
            var latitude = data["latitude"];
            var longitude = data["longitude"];
            var label = data["label"];
            var node_id = data["node_id"];
            var text = $('#location_' + node_id).html();

            addMarker( latitude, longitude, text, icon );
        }



        // affichage des markers
        displayMarkers();
}


function init_filtre_prox( item )
{
    item.autocomplete('/extension/crtbre_socle/bin/autocomplete.php', {
        minChars : 1, 
        autoFill : true
    });
    
    if( $('#bloc_recherche').length )
    {
        toogleTextInputValue( item, ' '+_('Ville') );
    }
}


function toogleTextInputValue( item, defaultValue )
{
    item.focus(function(){
        if( item.val() == defaultValue )
        {
            item.val('');
        }
    });

    item.blur(function(){
        if( item.val() == '' )
        {
            item.val( defaultValue );
        }
    });

}

function init_bloc_recherche( item )
{
    $('#onglet_ev').click( function( event ){
        $('#onglet_ev').addClass('selected');
        $('#onglet_lieu').removeClass('selected');
        $('#lien_lieu').css('display', 'none');
        $('#lien_ev').css('display', 'inline');
        $('#types_lieux').css('display', 'none');
        $('#date_recherche').css('display', 'block');

        $('#datepicker_fin').attr('disabled', '');
        $('#datepicker_debut').attr('disabled', '');


        $('#path').attr('value', $('#path_ev').attr('value'));
    });

    $('#onglet_lieu').click( function( event ){
        $('#onglet_lieu').addClass('selected');
        $('#onglet_ev').removeClass('selected');
        
        $('#datepicker_fin').attr('disabled', 'disabled');
        $('#datepicker_debut').attr('disabled', 'disabled');
        $('#types_lieux').css('display', 'block');
        $('#date_recherche').css('display', 'none');
        $('#lien_ev').css('display', 'none');
        $('#lien_lieu').css('display', 'inline');
        $('#path').attr('value', $('#path_lieu').attr('value'));
    });
    
    $('#Searchbloc').click( function( event ){
        if( $('#filtre_prox').val() == ' '+_('Ville') )
        {
            $('#filtre_prox').val('');
        }
    });

}


function init_email_nl( item )
{
    toogleTextInputValue( item, _('Votre email') );
}




