// ©2010 Max Barel a_x@ac-mb.info

$('body').hide();var img_fleche=$.browser.msie?'<img src="img/fl_droite.gif"/>':'<img src="img/fl_droite.png"/>';$.browser.msie6=$.browser.msie&&($.browser.version)<7;var mkt,menu,page,m_gauche,cube,cube_intro,texte,tx_struct;$(function(){var to_menu;boite_biscuits();mkt=$('#mkt');menu=$('#menu');page=$('#page');m_gauche=$('#m_gauche');cube=$('#cube').click(masquer);cube_intro=$('#cube_intro');texte=$('#texte');cube_intro.find('img').click(animation);if($.browser.msie&&!biscuits.JPB_intro||!$.browser.msie&&cube_intro.hasClass('anim_init')){if($.browser.msie6)message_IE6();biscuit('JPB_intro','vue');if(/JPB_intro/.test(document.cookie)){page.hide();m_gauche.hide();$('img',cube).hide();$('img:first',cube_intro)[$.browser.msie||$.browser.mozilla||$.browser.opera?'each':'load'](function(){masquer(1);setTimeout(animation,2000);});}
else message_cookie();}
else{biscuit('JPB_intro','vue');if($.browser.msie6){defile_titres();flecher_menu();}
else{page.css({left:mkt.width(),width:page.width(),rigth:'auto'}).animate({left:'320px'},800,function(){page.removeAttr('style');defile_titres();flecher_menu();});}}
$('body').show();$('a.focus').delay_init(300).hover(function(){var self=this;$(this).delay(function(){arbre_pour_feuille($('#'+$(self).attr('href')),'focus');menu.montrer();replier_menu('actif',null,'focus');deplier_menu('focus');affiche_note('#info_lien',self);});},function(){$(this).delay(function(){replier_menu('focus',null,'actif');deplier_menu('actif');$('li.focus',menu).removeClass('focus');menu.cacher();note_def();});});menu.cacher=function(){menu.to_cache=setTimeout(function(){menu.animate({top:Math.max(menu.position-menu.height()+20,0)});},1000);menu.visible=false;};menu.montrer=function(){menu.to_cache&&clearTimeout(menu.to_cache);menu.animate({top:menu.position});menu.visible=true;};page.scroll(function(){menu.position=page.scrollTop();menu.css({top:menu.visible?menu.position:Math.max(menu.position-menu.height()+20,0)});}).trigger('scroll');menu.hover(menu.montrer,menu.cacher);function trouve_asc(el){var asc_t,p_el=$(el).prev(),asc;if(p_el.length&&el.tagName==p_el[0].tagName)el.asc=p_el[0].asc;else{switch(el.tagName.toLowerCase()){case'p':asc_t='h2,h3,h4,h5,h6';break;case'table':case'ol':case'ul':asc_t='h2,h3,h4,h5,h6';break;case'h6':asc_t='h2,h3,h4,h5';break;case'h5':asc_t='h2,h3,h4';break;case'h4':asc_t='h2,h3';break;case'h3':asc_t='h2';break;default:return;}
asc=p_el.filter(asc_t);while(!asc.length&&p_el.length){p_el=p_el.prev();asc=p_el.filter(asc_t);};el.asc=asc[0];}
return el.asc;}
if(!$.browser.msie6){tx_struct=$('h3,h4,h5,h6, p:not(.tempus_fugit):not(td>p), ul,ol,table','#texte.plier');if(tx_struct.length){tx_struct.hide();setTimeout(function(){tx_struct.each(function(){var asc=trouve_asc(this);if(asc)asc.desc=$(asc.desc||[]).add(this);});$('h2,h3,h4,h5,h6',texte).click(function(){var $this=$(this);if($this.hasClass('ouvert')){this.desc&&this.desc.slideUp().filter('.ouvert').trigger('click');$this.removeClass('ouvert');}else{this.desc&&this.desc.slideDown();$this.addClass('ouvert');}});note_def('#info_texte',true);},820);}}
$('tr:even',texte).addClass('odd');$('img.zoom',texte).each(function(){this.nat_h=$(this).attr('height')||$(this).height();$(this).css({height:'120px',width:'auto'})}).hover(function(){$(this).animate({height:this.nat_h})},function(){$(this).animate({height:'120px'})});$('a.dmsq').one('click.dmsq',function(ev){var cible=this;$.get('dmsq.php?a='+this.href.replace(/^.*#/,''),function(data){cible.href='mailto:'+data;$(cible).text(data);});});$('#menu li a').each(function(){var self=$(this);self.parent().attr('id',self.attr('href'));});if(menu[0].className){arbre_pour_feuille($('#'+menu[0].className),'actif');pages_vue(menu[0].className,true);}
$('li',menu).bind('mouseenter',function(){to_menu&&clearTimeout(to_menu);var self=$(this),branche=self.parent();self.addClass('focus');var l_cour=$('>li.focus',branche);to_menu=setTimeout(function(){if(l_cour.length>1){replier_menu('focus',branche);$('li.focus',branche).not(self).removeClass('focus');}
replier_menu('actif',branche,'focus');deplier_menu('focus',branche);},200);}).bind('mouseleave',function(){to_menu&&clearTimeout(to_menu);var self=$(this),branche=self.parent();if(!$('>ul:visible',this).length)self.removeClass('focus');to_menu=setTimeout(function(){replier_menu('focus',branche,'actif');deplier_menu('actif',branche);self.removeClass('focus');$('li.focus',branche).removeClass('focus');},1000);});$('#menu a, a.focus').click(function(){var href=this.href;page.css({left:'320px',width:page.width(),rigth:'auto'}).animate({left:mkt.width()},800,function(){window.location=href;});return false;});$(window).resize(defile_titres);});function affiche_note(note,cible){if(typeof note=='string')note=$(note);$('div.note:visible:not(#questions)').not(note).fadeOut();$('p.lien_vu',note).hide();note.fadeIn(function(){if(cible){if(!note[0].fl)note[0].fl=$(img_fleche).appendTo(note);if(cible.href){if(!window.pointeur_lien)pointeur_lien=$('<div class="info_lien"></div>').appendTo(texte);cible=$(cible);var pos=cible.position(),h=cible.height(),top_fl=cible.offset().top-note[0].fl.offset().top-h+4;if(top_fl<0)pointeur_lien.css({top:pos.top+h+3,width:0,height:0,'border-width':'1px 0 0 1px'}).show().animate({width:pos.left,height:-top_fl-3});else pointeur_lien.css({top:pos.top+h-top_fl,width:0,height:0,'border-width':'0 0 1px 1px'}).show().animate({width:pos.left,height:top_fl+3});$('p.lien_vu.'+pages_vue(cible.attr('href')),note).slideDown();}}});}
function note_def(note,cible){if(note){if(typeof note=='string')note=$(note);note_def.note=note;}
window.pointeur_lien&&pointeur_lien.hide();$('div.note:visible:not(#questions)').not(note_def.note).fadeOut(function(){window.pointeur_lien&&pointeur_lien.hide();});note_def.note.length&&note_def.note.fadeIn(600);if(cible){if(!note[0].fl)note[0].fl=$(img_fleche).appendTo(note);}}
note_def.note=[];function de_plier_texte(){tx_struct.plier=!tx_struct.plier;tx_struct[tx_struct.plier?'show':'hide']();$('h2,h3,h4,h5,h6',texte)[tx_struct.plier?'addClass':'removeClass']('ouvert');}
var biscuits={};function boite_biscuits(){if(document.cookie){var bis=document.cookie.split(';');for(var i in bis){var b=$.trim(bis[i]).split('=');biscuits[b[0]]=b[1];}}}
function biscuit(nom,valeur){var dt=new Date()
bis=[nom+'='+valeur];dt.setTime(dt.getTime()+1*24*60*60*1000);bis.push('expires='+dt.toGMTString());document.cookie=bis.join(';');biscuits[nom]=valeur;}
function pages_vue(nom_page,affirmatif){var vu=biscuits.JPB_pages_vues&&biscuits.JPB_pages_vues.search(nom_page)!=-1;if(affirmatif&&!vu){biscuit('JPB_pages_vues',(biscuits.JPB_pages_vues&&biscuits.JPB_pages_vues.split(',')||[]).concat([nom_page]).join(','));}
return vu;}
function arbre_pour_feuille(el,classe){if(el.is('li')){arbre_pour_feuille(el.parent().parent(),classe);el.addClass(classe);}}
function flecher_menu(){$('li img',menu).remove();$('li:has(ul:visible)',menu).each(function(){var self=$(this);$(img_fleche).appendTo(self).css({top:self.position().top});});}
function replier_menu(classe,branche,nop_class){var h_menu=menu.height(),top_to=classe=='actif'?-h_menu+'px':h_menu+'px';$('li.'+classe+(nop_class?':not(.'+nop_class+')':'')+'> ul:visible',branche||menu).animate({top:top_to},function(){$(this).hide();flecher_menu();});}
function deplier_menu(classe,branche){var h_menu=menu.height(),top_from=classe=='actif'?-h_menu+'px':h_menu+'px';$('li.'+classe+'> ul:hidden',branche||menu).css({top:top_from}).show().animate({top:0},flecher_menu);}
function masquer(n){var m_h=mkt.innerWidth(),m_v=mkt.innerHeight(),p_w=page.width();mkt.cube_pos=cube.offset();cube_intro.removeAttr('style').show();mkt.fadeOut(function(){page.css({left:m_h,width:p_w,rigth:'auto'});m_gauche.css({top:m_v});if(n===1){$('img',cube).show();page.show();m_gauche.show();}});}
function animation(){var pos=cube_intro.offset();cube_intro.css({top:pos.top,left:pos.left,margin:'auto'});cube_intro.animate({top:mkt.cube_pos.top,left:mkt.cube_pos.left,width:'320px',height:'240px'},1000,function(){mkt.show();m_gauche.animate({top:'240px'},800,function(){if(!/avocat-juriste/.test(window.location.href||window.location))window.location='avocat-juriste';else{page.animate({left:'320px'},800,function(){if(!$.browser.msie6)page.removeAttr('style');defile_titres();flecher_menu();});}});});}
function defile_titres(ev){if(ev&&ev.type=='resize'){$(window).delay(defile_titres,500);return}
$('.defile').stop().removeAttr('style').removeClass('defile').unbind('mouseenter mouseleave').find('img').remove();if(!defile_titres.div)defile_titres.div=$('<div><h2 style="float:left;font-family: Tahoma, sans-serif"></h2></div>').css({width:'10000px'}).prependTo(page);else defile_titres.div.show();var dbl=defile_titres.div.find('h2');$('#texte h2').each(function(){dbl[0].innerHTML=this.innerHTML;var self=$(this),dec=dbl.width()-self.width()-30;if(dec>0){this.dec=dec;this.indent=parseInt(self.css('text-indent'));self.addClass('defile');$(img_fleche).prependTo(self);}});defile_titres.div.hide();$('.defile').hover(function(){$(this).animate({textIndent:this.indent-this.dec-30},this.dec*10,'linear');},function(){$(this).stop().removeAttr('style');});}
$.fn.delay_init=function(t_def){return this.each(function(){this.t_def=t_def});};$.fn.delay=function(f,t){return this.each(function(){var t_=t||this.t_def||100,self=this;this.t_id&&clearTimeout(this.t_id);this.t_id=setTimeout(f,t_);});};$.fn.delay_clear=function(){return this.each(function(){this.t_id&&clearTimeout(this.t_id);});};$.fn.delay_anim=function(prop,speed,easing,callback){return this.each(function(){var t=this.t_def||100,self=$(this);this.t_id&&clearTimeout(this.t_id);this.t_id=setTimeout(function(){self.animate(prop,speed,easing,callback)},t);});};function message_cookie(){alert('Votre navigateur est réglé pour refuser les cookies. Cela bloque la fonction d\'information sur les pages vues.\nYour browser is set up to refuse cookies. This prevents the feature of information about pages seen.');}
function message_IE6(){alert('Vous utilisez Internet Explorer 6 ou inférieur. Ce navigateur est largement dépassé et compromet le fonctionnement fluide des effets. Il est recommandé d\'utiliser un navigateur moderne (Firefox, Chrome, Safari) ou, au minimum, IE7.');}