/**
 * AJAXFORM $.la.verifyParrainage(nom,prenom,mail,m1,m2,m3,idForm)
 * 
 * MUSILINE $.la.radio.popUpRadio() $.la.radio.lancePopUpRadio()
 * 
 * PROGRAMME $.la.programme.display_en_ce_moment()
 * $.la.programme.display_prochaine_diffusion()
 * 
 * MODALBOX $.la.modalbox.truc()
 */
(function($){

    $.la = $.la||{};
    $.la.decalage_horaire = $.la.decalage_horaire || 3600;
    $.la.sHost = '';
    
    $.extend(true,$.la,
    {
        tb_pathToImage: 'http://www.june.fr/design/june/images/loading.gif',
        promo: {
           	container:'#container',
        	containerBody:'body',

        	localCss:function(obj){
        		return '.banner_cnter {display:none !important; }';
        }
        },
        /*
    				var habillage_june = {
    					bodybgcolor:'#FFFFFF',
    					bodybgimage:'http://video.premiere.fr/thotnet/JUNE/habillage/hab_monshowroom_june_sans.jpg',
    					url:'http://fr.a2dfp.net/c?i2as_s=102519&i2as_ad=20014',
    					newwindow:true,
    					top:'200px',
    					color:'#f3599a',
                                        height:'1850px'
    				};
    				showHabillage(habillage_june);
    				javascript:var habillage_june = {bodybgcolor:'#FFFFFF', bodybgimage:'http://video.premiere.fr/thotnet/JUNE/habillage/hab_monshowroom_june_sans.jpg', url:'http://fr.a2dfp.net/c?i2as_s=102519&i2as_ad=20014', newwindow:true, top:'200px'};$.la.promo.showSkin(habillage_june);

    	*/     
        action:{
            verifyAuthentification: function ( loginUrl, formId, params )
            {
                if(typeof params === 'undefined'){
                    params = {};
                }

               
                if($.la.action.isLogged())
                {
                    $('#' + formId).submit();
                }
                else
                {
                    $.la.action.baseIdForm = formId;
                    window.location.href  = $.la.sHost+loginUrl;
                }
            }
        },
        /* MODALBOX */
        modalbox:{
            /*
	    	 * onclick="$.la.modalbox.ldapOpenLoginBoxRegistered();
	    	 * 
	    	 */	
            accordionSpeed: 'fast',
            accordion:function(obj,callback){
                //{'id1':false,'id2':true,etc}

                for(var id in obj) {
                    $('#' + id).slideUp($.la.modalbox.accordionSpeed);
                    $('#' + id).prev('h3').children('a').removeClass("opened");
                }
                for(var id in obj) {
                    if(obj[id] == true){
                        $('#'+ id).slideDown($.la.modalbox.accordionSpeed);
                        $('#' + id).prev('h3').children('a').addClass("opened");
                    }
                }
            },
    		
            ldapOpenCloseLoginBoxRegistered:function(id){
                // context : ldap, action : Open,  quelle modal ? : LoginBox quel onglet ? : Registered
                //h3 a  + #ldapLoginBoxRegistered
                var obj = {};
                $("h3 + div").each(function(i){
                    var currentId = $(this).attr('id');
                    if(currentId !=''){
                        obj[currentId] = false;
                        if(currentId == id){
                            if($('#' + id).css('display') == 'none'){
                                obj[currentId] = true;
                            }
                        }
                    }
                });
                $.la.modalbox.accordion(obj,null);
            }
        },
    	
        /* AJAXFORM */
        carouselEmission:function(){
            var largitem=$('.carousel_emissions ul li').width()+1;
            var largcarousel=($('.carousel_emissions ul li').length)*largitem;
            var diff=largcarousel-(largitem*4);
            $('.carousel_emissions ul').css({
                width:largcarousel+'px'
            });
            $('.carousel_emissions .bt_prec a').attr('href',$('.carousel_emissions ul li:eq(0) a').attr('href'));
            $('.carousel_emissions .bt_suiv a').attr('href',$('.carousel_emissions ul li:eq(3) a').attr('href'));

            $('.carousel_emissions .bt_prec em').bind('click', function() {
                var pos=Math.abs($('.carousel_emissions ul').css('left').slice(0,-2));
                if (!$('.carousel_emissions ul').is(':animated')) {
                    if (pos==43) {
                        $('.carousel_emissions ul').animate({
                            left:'-='+diff+'px'
                        },500,function(){
                            pos=Math.abs($('.carousel_emissions ul').css('left').slice(0,-2));
                            pos_url=parseInt((pos+43)/largitem);
                            $('.carousel_emissions .bt_prec a').attr('href',$('.carousel_emissions ul li:eq('+pos_url+') a').attr('href'));
                            $('.carousel_emissions .bt_suiv a').attr('href',$('.carousel_emissions ul li:eq('+parseInt(pos_url+3)+') a').attr('href'));
                        });
                    }else{
                        $('.carousel_emissions ul').animate({
                            left:'+='+largitem+'px'
                        },300,function(){
                            pos_url=parseInt((pos+43)/largitem)-1;
                            $('.carousel_emissions .bt_prec a').attr('href',$('.carousel_emissions ul li:eq('+pos_url+') a').attr('href'));
                            $('.carousel_emissions .bt_suiv a').attr('href',$('.carousel_emissions ul li:eq('+parseInt(pos_url+3)+') a').attr('href'));
                        });
                        return false;
                    }
                }
            });

            $('.carousel_emissions .bt_suiv em').bind('click', function() {
                var pos=Math.abs($('.carousel_emissions ul').css('left').slice(0,-2));
                if (!$('.carousel_emissions ul').is(':animated')) {
                    if (pos==parseInt(diff-43)) {
                        $('.carousel_emissions ul').animate({
                            left:'+='+parseInt(pos+43)+'px'
                        },500,function(){
                            pos=Math.abs($('.carousel_emissions ul').css('left').slice(0,-2));
                            pos_url=parseInt((pos+43)/largitem);
                            $('.carousel_emissions .bt_prec a').attr('href',$('.carousel_emissions ul li:eq('+pos_url+') a').attr('href'));
                            $('.carousel_emissions .bt_suiv a').attr('href',$('.carousel_emissions ul li:eq('+parseInt(pos_url+3)+') a').attr('href'));
                        });
                    }else{
                        $('.carousel_emissions ul').animate({
                            left:'-='+largitem+'px'
                        },300,function(){
                            pos_url=parseInt((pos+43)/largitem)+1;
                            $('.carousel_emissions .bt_prec a').attr('href',$('.carousel_emissions ul li:eq('+pos_url+') a').attr('href'));
                            $('.carousel_emissions .bt_suiv a').attr('href',$('.carousel_emissions ul li:eq('+parseInt(pos_url+3)+') a').attr('href'));
                        });
                        return false;
                    }
                }
            });


            var pos=0;

        /* $('.carousel_emissions ul').draggable({
                containment:'.carousel_emissions_cnt',
                handle:$('.carousel_emissions ul'),
                axis:'x',
                start:function(e){
                    pos_d=e.pageX;
                },
                stop:function(e){
                    pos=Math.abs($('.carousel_emissions ul').css('left').slice(0,-2));
                    pos_f=e.pageX;
                    v=1;
                    mvt=pos_f-pos_d;
                    if (Math.abs(mvt)>=50){
                        v=5;
                    }
                    if (mvt<=0){
                        if (!$('.carousel_emissions ul').is(':animated')) {
                            $('.carousel_emissions ul').animate({
                                left:'-='+parseInt((largitem*v)-Math.abs(mvt))+'px'
                            },500,function(){
                                pos=Math.abs($('.carousel_emissions ul').css('left').slice(0,-2));
                                pos_url=parseInt((pos+43)/largitem);
                                $('.carousel_emissions .bt_prec a').attr('href',$('.carousel_emissions ul li:eq('+pos_url+') a').attr('href'));
                                $('.carousel_emissions .bt_suiv a').attr('href',$('.carousel_emissions ul li:eq('+parseInt(pos_url+3)+') a').attr('href'));
                            });
                        }
                    }else{
                        if (!$('.carousel_emissions ul').is(':animated')) {
                            $('.carousel_emissions ul').animate({
                                left:'+='+parseInt((largitem*v)-Math.abs(mvt))+'px'
                            },500,function(){
                                pos=Math.abs($('.carousel_emissions ul').css('left').slice(0,-2));
                                pos_url=parseInt((pos+43)/largitem);
                                $('.carousel_emissions .bt_prec a').attr('href',$('.carousel_emissions ul li:eq('+pos_url+') a').attr('href'));
                                $('.carousel_emissions .bt_suiv a').attr('href',$('.carousel_emissions ul li:eq('+parseInt(pos_url+3)+') a').attr('href'));
                            });
                        }
                    }
                }
            });*/
        },
        carouselADecouvrir:function()
        {
            var largitem_r=$('.carousel_adecouvrir ul li').width();
            var largcarousel_r=($('.carousel_adecouvrir ul li').length)*largitem_r;
            var diff_r=largcarousel_r-(largitem_r);
            $('.carousel_adecouvrir ul').css({
                width:largcarousel_r+'px'
            });

            $('.carousel_adecouvrir .bt_prec').bind('click', function() {
                var pos_r=Math.abs($('.carousel_adecouvrir ul').css('left').slice(0,-2));
                if (!$('.carousel_adecouvrir ul').is(':animated')) {
                    if (pos_r==0) {
                        $('.carousel_adecouvrir ul').animate({
                            left:'-='+diff_r+'px'
                        },500);
                    }else{
                        $('.carousel_adecouvrir ul').animate({
                            left:'+='+largitem_r+'px'
                        },300);
                        return false;
                    }
                }
            });

            $('.carousel_adecouvrir .bt_suiv').bind('click', function() {
                var pos_r=Math.abs($('.carousel_adecouvrir ul').css('left').slice(0,-2));
                if (!$('.carousel_adecouvrir ul').is(':animated')) {
                    if (pos_r==diff_r) {
                        $('.carousel_adecouvrir ul').animate({
                            left:'+='+pos_r+'px'
                        },500);
                    }else{
                        $('.carousel_adecouvrir ul').animate({
                            left:'-='+largitem_r+'px'
                        },300);
                        return false;
                    }
                }
            });
        },
        carouselALaUne:function()
        {
            var largitem_a=$('.carousel_alaune ul li').width();
            var largcarousel_a=($('.carousel_alaune ul li').length)*largitem_a;
            $('.carousel_alaune ul').css({
                width:largcarousel_a+'px'
            });

            $('.carousel_alaune .bt').bind('click', function() {
                var param=$('.carousel_alaune .bt').index(this);
                $('.carousel_alaune ul').animate({
                    left:'-'+largitem_a*param+'px'
                },500);
            });


            $('.bloc_programme_nav a').bind('click',function(){
                $('.bloc_programme_nav a[class*=on]').removeClass('on');
                $(this).addClass('on');
                return false;
            });
        },
        carouselProgramme:function()
        {
            var largitem_p=$('.carousel_programme ul li').width();
            var largcarousel_p=($('.carousel_programme ul li').length)*largitem_p;
            $('.carousel_programme ul').css({
                width:largcarousel_p+'px'
            });

            /*$('.carousel_programme .bt_prec').bind('click', function() {
                    $('.bloc_programme_nav a[class*=on]').removeClass('on');
                    $('.carousel_programme ul li:empty').remove();
                    $('.carousel_programme ul li:first').before('<li style="display:none"></li>');
                    if (!$('.carousel_programme ul li').is(':animated')) {
                            $('.carousel_programme ul li').animate({opacity:'0'},300,function(){
                                    $('.carousel_programme ul li:first').after($('.carousel_programme ul li:last'));
                            }).animate({opacity:'1'},700,function(){
                                    var param=$('.carousel_programme ul li:eq(2)').attr('class').slice(4);
                                    $('.bloc_programme').attr('class','bloc bloc_programme bloc_auprogramme');
                                    $('.bloc_programme').addClass('bloc_programme_j'+param);
                            });
                    }
            });

            $('.carousel_programme .bt_suiv').bind('click', function() {
                    $('.bloc_programme_nav a[class*=on]').removeClass('on');
                    $('.carousel_programme ul li:empty').remove();
                    $('.carousel_programme ul').append('<li style="display:none;"></li>');
                    if (!$('.carousel_programme ul li').is(':animated')) {
                            $('.carousel_programme ul li').animate({opacity:'0'},300,function(){
                                    $('.carousel_programme ul li:last').before($('li:first','.carousel_programme ul'));
                            }).animate({opacity:'1'},700,function(){
                                    var param=$('.carousel_programme ul li:eq(1)').attr('class').slice(4);
                                    $('.bloc_programme').attr('class','bloc bloc_programme bloc_auprogramme');
                                    $('.bloc_programme').addClass('bloc_programme_j'+param);
                            });
                    }
            });*/

            $('.carousel_programme a').bind('click',function(){
                var param=$(this).parent().attr('class').slice(4);
                $('.bloc_programme_nav a[class*=on]').removeClass('on');
                $('.bloc_programme').attr('class','bloc bloc_programme bloc_auprogramme');
                $('.bloc_programme').addClass('bloc_programme_j'+param);
                return false;
            })

        },
        carouselDiaporama:function()
        {
            /* Carrousel */
            var largitem_m=$('.carousel ul li').width()+4;
            var largcarousel_m=($('.carousel ul li').length)*largitem_m;
            var diff_m=largcarousel_m-(largitem_m*5);

            $('.carousel ul').css({
                width:largcarousel_m+'px'
            });
            $('.carousel ul li a:first').addClass('on');

            $('.carousel .bt_prec').bind('click', function() {
                var pos_m=Math.abs($('.carousel ul').css('left').slice(0,-2));
                var param=$('.carousel ul li').index($('.carousel ul li   a[class*=on]').parents('li'))-1;
                if (!$('.carousel ul').is(':animated')) {
                    if (pos_m==0 && param>=0) {
                        $('.carousel ul li a[class*=on]').removeClass('on');
                        $('.carousel ul li:eq('+param+') .visuel a').addClass('on');
                        return false;
                    }else if (param<=-1){
                        return false;
                    }else{
                        $('.carousel ul').animate({
                            left:'+='+largitem_m+'px'
                        },300,function(){
                            $('.carousel ul li a[class*=on]').removeClass('on');
                            $('.carousel ul li:eq('+param+') .visuel a').addClass('on');
                        });
                        return false;
                    }
                }
            });

            $('.carousel .bt_suiv').bind('click', function() {
                var pos_m=Math.abs($('.carousel ul').css('left').slice(0,-2));
                var param=$('.carousel ul li').index($('.carousel ul li a[class*=on]').parents('li'))+1;
                if (!$('.carousel ul').is(':animated')) {
                    if (pos_m==diff_m && param<$('.carousel ul li').length) {
                        $('.carousel ul li a[class*=on]').removeClass('on');
                        $('.carousel ul li:eq('+param+') .visuel a').addClass('on');
                        return false;
                    }else if(param>=$('.carousel ul li').length) {
                        return false;
                    }else{
                        $('.carousel ul').animate({
                            left:'-='+largitem_m+'px'
                        },300,function(){
                            $('.carousel ul li a[class*=on]').removeClass('on');
                            $('.carousel ul li:eq('+param+') .visuel a').addClass('on');
                        });
                        return false;
                    }
                }
            });
        },
        programme:
        {
            display_grille:function(hourCourante,date)
            {
                var liAAfficher = new Array();
                var dateGrille = new Date();
                dateGrille.setTime(date*1000);
                var dateCourante = new Date();
                
                if (hourCourante == -1)
                {
                    hourCourante = parseInt(dateCourante.getHours(),10);
                }
                else
                {
                    if (hourCourante ==24)
                    {
                        dateGrille.setDate(dateGrille.getDate()+1);
                    }
                    $('a.on').removeClass('on');
                    $('li.cache').each(function(i){
                        $(this).hide();
                    });
                    $('ul#second').html('');
                }
                var hourDebut = hourCourante;
                var hourFin = 8;
                dateGrille.setMinutes(0)
                dateGrille.setSeconds(0);
                if(hourCourante != 5 )
                {
                    switch (hourCourante%4)
                    {
                        case 0:
                            hourFin = hourCourante+4;
                            break;
                        case 1:
                            hourDebut = hourCourante-1 ;
                            hourFin = hourCourante+3;
                            break;
                        case 3:
                            hourDebut = hourCourante-3 ;
                            hourFin = hourCourante+1;
                            break;
                        case 2:
                            hourDebut = hourCourante-2;
                            hourFin = hourCourante+2;
                            break;
                    }
                }
                $('li#interval-'+hourDebut+' a').addClass('on');
                if (hourDebut == 0)
                {
                    hourDebut = 0;
                    hourFin = 8;
                }
                if (hourDebut == 24)
                {
                    hourDebut = 0;
                    hourFin = 5;
                }
                
                dateGrille.setHours(hourDebut);
                var timestampDebut = Math.floor(dateGrille.getTime()/1000);
                dateGrille.setHours(hourFin);
                var timestampFin = Math.floor(dateGrille.getTime()/1000);
               
                $('li.cache').each(function(i){
                    tmp = $(this).attr('id').split('-');
                    ts = tmp[1];
                    if (ts>timestampDebut && ts<timestampFin)
                    {
                        liAAfficher.push($(this));                      
                    }
                });
               
                var lenghtFirstUl = Math.ceil(liAAfficher.length/2);
            
                for(i=0;i<lenghtFirstUl;i++)
                {
                    liAAfficher[i].show();
                }
                var htmlSecondUl = '';
                for(i=lenghtFirstUl;i<liAAfficher.length;i++)
                {
                    htmlSecondUl = htmlSecondUl + '<li>'+ liAAfficher[i].html() +'</li>';
                }
                $('ul#second').html(htmlSecondUl);
            }
		
        },
        menu :
        {
            montreRubriqueActuelle:function(idLi)
            {
                var menuActif = '<strong>' + $('a#'+idLi).html()+ '</strong>';
                $('a#'+idLi).html(menuActif);
            }
        },
        Gallery:
        {
            tabDesc:[],
            tabTitre:[],
            tabWidth:[],
            tabCopyright:[],
            countCourant:0,
            countPhoto:0,
            init: function()
            {
                /* Loading first diapo */
                var first_diapo = $('.carousel .carousel_cnt ul li a:first');
                var first_diapo_url = first_diapo.attr("href");
                
                var img = new Image();

                
                $(img).attr('src', first_diapo_url)
         
                $(img).load(function () {
                    $(this).hide();						// cache l'image
                    $('#parent #loadingItem').hide();
                    $('#image_actuelle').append(this);			// ajoute l'image
                    $(this).fadeIn();
                // affiche l'image
                });
                
                // Load first titre
                $('#titre').html($.la.Gallery.tabTitre[0]);

                // Padding pour les photos
                // var padding = (615-parseInt($.la.Gallery.tabWidth[0],10))/2;
                //$('#image_actuelle').css('margin-left',padding+'px');
                 
                // Load first description
                $('#description').html($('#description_cachee_0').html());

                //Load first Copyright
                $('#credit').html('&copy; '+$.la.Gallery.tabCopyright[0]);
                // mode_affichage - square
                /*if 	( mode_affichage == 'square'){
                        $('.galerie .carousel').addClass("carousel_p");
                }*/

                var url_diapo_zoom = first_diapo_url.replace('diapo_grande_613_406', 'reference');
                $('#zoom').attr('href',url_diapo_zoom);
                

                $.la.carouselDiaporama();

                $('.media .visuel .bt_suiv').bind('click', function() {

                       
                    if ($.la.Gallery.countPhoto < ($('.carousel #carousel_diapo ul li a').length-2))
                    {
                        $('#a_'+$.la.Gallery.countCourant).removeClass('on');
                        $.la.Gallery.countPhoto = $.la.Gallery.countPhoto + 2;
                        $.la.Gallery.countCourant = $.la.Gallery.countCourant + 1;

                        $('#a_'+$.la.Gallery.countCourant).addClass('on');
                      
                       
                        var url_diapo = $('.carousel #carousel_diapo ul li a')[$.la.Gallery.countPhoto].href;
                        var img = new Image();
                                                                     
                        $(img)
                        .load(function () {
                            $(this).hide();						// cache l'image
                            $('#image_actuelle').empty().append(this);			// ajoute l'image
                            $(this).fadeIn();
                        // affiche l'image
                        })
                        .attr('src', url_diapo);

                        // Load first titre
                        $('#titre').html($.la.Gallery.tabTitre[$.la.Gallery.countCourant]);

                        // var padding = (615-parseInt($.la.Gallery.tabWidth[$.la.Gallery.countCourant],10))/2;
                        //$('#image_actuelle').css('margin-left',padding+'px');

                        // Load first description
                        $('#description').html($('#description_cachee_'+$.la.Gallery.countCourant).html());
                       
                        

                        //Load first Copyright
                        $('#credit').html('&copy; '+$.la.Gallery.tabCopyright[$.la.Gallery.countCourant]);

                        /* Change thickbox zoom href */
                        var url_diapo_zoom = url_diapo.replace('diapo_grande_613_406', 'reference');
                        $('#zoom').attr('href',url_diapo_zoom);
                        
                    }
                    return false;
                });

                //.media .visuel .bt_suiv'
                //.media .visuel .bt_prec

                $('.media .visuel .bt_prec').bind('click', function() {

                    if ($.la.Gallery.countPhoto > 0)
                    {
                        $('#a_'+$.la.Gallery.countCourant).removeClass('on');
                        $.la.Gallery.countCourant = $.la.Gallery.countCourant - 1;
                        $.la.Gallery.countPhoto = $.la.Gallery.countPhoto -2 ;
                        $('#a_'+$.la.Gallery.countCourant).addClass('on');
                        var url_diapo = $('.carousel #carousel_diapo ul li a')[$.la.Gallery.countPhoto].href;
                        var img = new Image();

                        $(img)
                        .load(function () {
                            $(this).hide();						// cache l'image
                            $('#image_actuelle').empty().append(this);			// ajoute l'image
                            $(this).fadeIn();
                        // affiche l'image
                        })
                        .attr('src', url_diapo);

                        // Load first titre
                        $('#titre').html($.la.Gallery.tabTitre[$.la.Gallery.countCourant]);

                        //var padding = (615-parseInt($.la.Gallery.tabWidth[$.la.Gallery.countCourant],10))/2;
                        //$('#image_actuelle').css('margin-left',padding+'px');

                        // Load first description
                        $('#description').html($('#description_cachee_'+$.la.Gallery.countCourant).html());

                        //Load first Copyright
                        $('#credit').html('&copy; '+$.la.Gallery.tabCopyright[$.la.Gallery.countCourant]);

                        /* Change thickbox zoom href */
                        var url_diapo_zoom = url_diapo.replace('diapo_grande_613_406', 'reference');
                        $('#zoom').attr('href',url_diapo_zoom);

                    }
                    return false;
                });



                $('.carousel #carousel_diapo ul li a').each(function(count) {

                   
                    /* On vignette click */
                    $(this).bind('click', function() {

                        var url_diapo = this.href;
                        var img = new Image();

                        $(img)
                        .load(function () {
                            $(this).hide();						// cache l'image
                            $('#image_actuelle').empty().append(this);			// ajoute l'image
                            $(this).fadeIn();
                        // affiche l'image
                        })
                        .attr('src', url_diapo);

                        $('#a_'+$.la.Gallery.countCourant).removeClass('on');
                        $.la.Gallery.countCourant=Math.floor(count/2);
                        $('#a_'+$.la.Gallery.countCourant).addClass('on');
                        $.la.Gallery.countPhoto = count;
                        // Load first titre
                        $('#titre').html($.la.Gallery.tabTitre[$.la.Gallery.countCourant]);

                        //var padding = (615-parseInt($.la.Gallery.tabWidth[$.la.Gallery.countCourant],10))/2;
                        //$('#image_actuelle').css('margin-left',padding+'px');

                        // Load first description
                        $('#description').html($('#description_cachee_'+$.la.Gallery.countCourant).html());

                        //Load first Copyright
                        $('#credit').html('&copy; '+$.la.Gallery.tabCopyright[$.la.Gallery.countCourant]);

                        /* Change thickbox zoom href */
                        var url_diapo_zoom = url_diapo.replace('diapo_grande_613_406', 'reference');
                        $('#zoom').attr('href',url_diapo_zoom);
              

                        return false;
                    });
                });

                //  var first_url_diapo_reference = first_diapo_url.replace(/preview_gallery/g,'reference');
                $('#zoom').bind('click', function() {
                   
                    $.la.modalbox.call($('#zoom').attr('href'),{
                        height:406
                    });
                    return false;
                });
            //
            /* Initialize lightbox */


                
            }

        },
        sondage:
        {
            voteSondage: function (nodeId,iChoice){
                var d = new Date();
            	d.setTime(d.getTime() + 86400000);
                $.la.cookie.set('snd_'+nodeId, 1,d);
                $.ajax({
                    url: $.la.sHost+'/modeSondage/sondage',
                    data: 'node=' + escape(nodeId) + '&choice=' + escape(iChoice),
                    dataType: 'xml',
                    success: function (xmlDoc){
                        $.la.sondage.renderSondage(xmlDoc);
                    }
                });
            },

            checkRenderSondage: function (nodeId){
                if($.la.cookie.get('snd_'+nodeId)){
                    $.ajax({
                        url: $.la.sHost+'/modeSondage/sondage',
                        data: 'node=' + escape(nodeId),
                        dataType: 'xml',
                        success: function (xmlDoc){
                            $.la.sondage.renderSondage(xmlDoc);
                        }
                    });
                }
            },

            renderSondage: function (xmlDoc){
                var result = '<ul>';
                var max =0;
                        

                $('list', xmlDoc).each(function (i){
                    var aPercent = parseInt($('percent', $(this)).text(),'10');
                    if(aPercent > max)
                    {
                        max = aPercent ;
                        valeur = i;
                    }
                });

                $('list', xmlDoc).each(function (i){
                               

                    var name = $('name', $(this)).text();
                    var valPercent = $('percent', $(this)).text();
                               
                    result += '<li>';
                    result +=   '<strong>'+valPercent+' %</strong>';
                    result +=   name;
                    result +=   '</li>';
                         
                });
                result += '</ul>';
                      
                $('#sondage').html(result);
            }

        },
        
        header: {
            getActionLinks: function() {
                if ($.la.action.isLogged()) {
                    $('.notlogguedin').css("display","none");
                    $('.logguedin').css("display","block");
                    if ($.la.cookie.get("login_june") != '') {
                        $('.logguedin li:first').html('Bonjour ' + $.la.cookie.get("login_june"));
                    }
                }
                else {
                    $('.notlogguedin').css("display","block");
                    $('.logguedin').css("display","none");
                }
            }

        }

    });
    if (document.location.href.indexOf('//local.') !== -1){
        $.la.sHost = 'http://local.june.fr';
    }
    else if (document.location.href.indexOf('//dev.') !== -1){
        $.la.sHost = 'http://dev.june.fr';
    }
    else if (document.location.href.indexOf('//test.') !== -1){
        $.la.sHost = 'http://test.june.fr';
    }
    else if (document.location.href.indexOf('//ori-www.') !== -1){
        $.la.sHost = 'http://ori-www.june.fr';
    }
    else if (document.location.href.indexOf('//adm.') !== -1){
        $.la.sHost = 'http://adm.june.fr';
    }
    else{
        $.la.sHost = 'http://www.june.fr';
    }
})(jQuery);
		
var tb_pathToImage = jQuery.la.tb_pathToImage;