/*
 * PagesJaunes Javascript YES 10.1.11.637
 *
 * @author 	pagesjaunes.fr
 * @version 10.1.11.637
 * 
 * @see yes.js
 * @see yes.config.js
 * @see yes.envoibloc.js
 * @see yes.affinement.js
 * 
 * up-to-date: 2010-01-11T10:42:43+01:00 by a4i_onejs | artwai.fr 
 */

var yes={config:{},init_frwk:function()
{}}
pj.add_lib(yes);yes.config.envoibloc={SELECTOR:'.YES_envoibloc',CLLOADING:'envoibloc-loading',MESSAGELOADING:'chargement',CLREADY:'envoibloc-ready',CLOPEN:'envoibloc-open',CLCLOSEBTN:'.envoibloc-closebtn'};$.extend(pj.addContext.config,[['idContext','idContext'],['idPortail','portail']]);yes.config.affinement={CONTAINER_ID:'#YES_filtre',CHANGE_ETAT:'.critChangeVu',SELECT_AND_VALID:'.critDirect',critNoSubmit:'critNoSubmit',EREG_POS_ELT:/[rg]([0-9]+)/gi,SELECT_SOURCE_NO_VALID:'.critListNoSubmit',SELECT_DEST_NO_VALID:'.critSelect',TOUT_EFFACER:'.critEff',TOUT_EFFACER_QUOI:'.critSel',SELECTOR_VALIDATE:'.affVal',critSelectedTargetPrefix:'critSelectedTarget_',clAnnuler:'btClose',wording:{effcrit:'Effacer le crit\xe8re'}};pj.add_lib(yes.envoibloc={init_frwk:function()
{pj.firstScanCallThat(yes.config.envoibloc.SELECTOR,function(elt){$(elt).click(yes.envoibloc.open)});},init:function(a)
{r=$(a).attr("rel");if(r)
{a.blocref=$("#"+r);a.url=$(a).attr("href");var i=a.url.indexOf("#");if(i!=-1){a.ong=a.url.substr(i+1);a.url=a.url.substr(0,i);}
else
{pj.log.push_ERROR("yes.envoibloc ",pj.log.setEltIdentity("onglet not define for {EltIdentity} ",$(a)))}
a.blocref.ready=function(s)
{a.blocref.removeClass(yes.config.envoibloc.CLLOADING);a.blocref.addClass(yes.config.envoibloc.CLREADY);a.blocref.html(s);pj.firstScan(a.blocref);others=$('a[rel='+$(a).attr('rel')+'][class*=YES_envoibloc]:not([href$='+a.ong+'])');others.each(function(i,othera)
{othera.finished=yes.envoibloc.updateFirstResponse;yes.envoibloc.searchotherbloc(othera);});};a.blocref.show=function(s)
{a.blocref.find(yes.config.envoibloc.CLCLOSEBTN).click(function()
{a.blocref.slideUp("fast");a.blocref.removeClass(yes.config.envoibloc.CLOPEN);return false;});yes.envoibloc.affectonglet(a);a.blocref.find(pj.config.onglet.SELECTOR+':not([rel])').attr("rel",a.blocref.attr("id"));pj.onglet.activate(a);}}
else
{}},open:function()
{if(!this.blocref)
{yes.envoibloc.init(this);}
if(this.blocref.hasClass(yes.config.envoibloc.CLREADY)&&!$(this).hasClass(pj.config.onglet.SELECTOR)){yes.envoibloc.affectonglet(this);pj.onglet.activate(this);}
if(this.blocref.hasClass("open"))
{}
else if(this.blocref.hasClass(yes.config.envoibloc.CLREADY))
{this.blocref.addClass(yes.config.envoibloc.CLOPEN);this.blocref.slideDown("fast");}
else
{this.blocref.html(yes.config.envoibloc.MESSAGELOADING);this.blocref.addClass(yes.config.envoibloc.CLLOADING);this.blocref.slideDown("fast");this.blocref.addClass(yes.config.envoibloc.CLOPEN);yes.envoibloc.searchbloc(this);}
return false;},searchbloc:function(a){$.ajax({type:"GET",url:a.url,data:pj.config.commun.REQUETE_AJAX_PARAM,dataType:"html",success:a.blocref.ready,complete:a.blocref.show});},searchotherbloc:function(othera)
{$.ajax({type:"GET",url:$(othera).attr('href').substr(0,$(othera).attr('href').indexOf('#')),data:pj.config.commun.REQUETE_AJAX_PARAM,dataType:"html",success:othera.finished,callerobj:othera});},updateFirstResponse:function(s,status)
{blocrel=$('#'+$(this.callerobj).attr('rel'));tmpJQuery=$(s);tmpJQuery.hide();blocrel.append(tmpJQuery);blocrel.find(yes.config.envoibloc.CLCLOSEBTN).click(function()
{blocrel.slideUp("fast");blocrel.removeClass(yes.config.envoibloc.CLOPEN);return false;})
blocrel.url=$(this.callerobj).attr("href");var i=blocrel.url.indexOf("#");blocrel.ong=blocrel.url.substr(i+1);blocrel.find('dl[class*='+blocrel.ong+']').slideUp("fast");pj.firstScan(blocrel);},affectonglet:function(a){$(a).addClass(pj.config.onglet.SELECTOR.substr(1));$(a).click(function(){yes.envoibloc.open;pj.onglet.activate(a);});}});yes.affinement={init_frwk:function()
{pj.firstScanCallThat(yes.config.affinement.CONTAINER_ID,yes.affinement.init);pj.firstScanCallThat(yes.config.affinement.CHANGE_ETAT,function($elt)
{$elt.click(function(e)
{e.preventDefault();yes.affinement.showLoading();$.get(pj.urlAddParams($(this).attr('href'),pj.config.commun.REQUETE_AJAX_PARAM),yes.affinement.majContainer);});});},_container:undefined,getContainer:function(elt)
{if(undefined==yes.affinement._container)
{yes.affinement._container=undefined==elt?$(yes.config.affinement.CONTAINER_ID):elt.parent(yes.config.affinement.CONTAINER_ID);}
return yes.affinement._container;},majContainer:function(html)
{yes.affinement.getContainer().replaceWith(html);yes.affinement._container=undefined;pj.firstScan(yes.affinement.getContainer().parent());},showLoading:function()
{return yes.affinement.getContainer().addClass(pj.config.commun.CLASSE_CHARGEMENT_EN_COURS);},init:function($elt)
{(yes.affinement._container=$elt).find(':radio,:checkbox').click(yes.affinement.affinx).end().find(yes.config.affinement.TOUT_EFFACER).click(yes.affinement.toutEffacer).end().find('.'+yes.config.affinement.clAnnuler+' a').click(yes.affinement.annuler).end().find('label').hover
(function(){$(this).addClass('hover')},function(){$(this).removeClass('hover')}).click(function(){$(this).removeClass('hover')}).end();},affinx:function(e)
{var $form=yes.affinement._container.find('form:first'),$this=$(this);if($this.is(yes.config.affinement.SELECT_AND_VALID))
{$form.submit();}
else if($this.is('.'+yes.config.affinement.critNoSubmit))
{if($this.is("[class*='"+yes.config.affinement.critSelectedTargetPrefix+"']"))
{if(undefined==this.critSelectedTarget)
{var pattern="("+yes.config.affinement.critSelectedTargetPrefix+"[a-zA-Z0-9]+)",re=new RegExp(pattern,"gi"),parts=re.exec(this.className);if(parts)
{this.critSelectedTarget=parts[1];}
else
{pj.log.push_ERROR("yes.affinement",pj.log.setEltIdentity("Pattern not found "+pattern+" in {EltIdentity}",$this));e.preventDefault();e.stopPropagation();}
delete re;}
if(undefined!=this.critSelectedTarget)
{var targetDtSelector='dt.'+this.critSelectedTarget,targetUlSelector=targetDtSelector+' + dd ul',$targetDt=$(targetDtSelector);$targetUl=$(targetUlSelector);if($targetDt&&$targetUl)
{if(this.checked)
{if(pj.ie)
{$this.attr('defaultChecked','defaultChecked');}
var $p=$this.parent();$p.after($('<li class="critSelected critFor_'+$this.attr('id')+'">'+$p.text()+'</li>')).find('label').attr('title',yes.config.affinement.wording.effcrit).end().find('span').hide();$targetUl.append($p);}
else
{var $pos=$form.find('li.critFor_'+$this.attr('id'));if(0==$pos.length)
{$this.parent().remove();}
else
{if(pj.ie)
{$this.attr('defaultChecked',false);}
$pos.replaceWith
($this.parent().find('label').attr('title',false).end().find('span').show().end());}}
var nb=$targetUl.find('li').length;$targetDt.removeClass('critNone').removeClass('critOne').removeClass('critMany').addClass(0>=nb?'critNone':1==nb?'critOne':'critMany');$form.find('.critSelectButtons .btContrib')[0==$form.find(yes.config.affinement.SELECT_DEST_NO_VALID+' li').length?'hide':'show']();}
else
{pj.log.push_ERROR("yes.affinement",pj.log.setEltIdentity("Element not found "+targetDtSelector+" or "+targetUlSelector+" for {EltIdentity}",$this));e.preventDefault();e.stopPropagation();}}}
else
{if(this.checked)
{if(pj.ie){$this.attr('defaultChecked','defaultChecked');}
$this.addClass('critSel').parent().find('label').attr('title',yes.config.affinement.wording.effcrit).end().find('span').hide();$form.find(yes.config.affinement.SELECTOR_VALIDATE).show().end().find(yes.config.affinement.SELECT_DEST_NO_VALID).show().find('dd ul').prepend($this.parent());}
else
{function local_getPos(o){return parseInt(o.attr('id').replace(yes.config.affinement.EREG_POS_ELT,'$1'))}
var fromcont=$form.find(yes.config.affinement.SELECT_DEST_NO_VALID),destcont=$form.find(yes.config.affinement.SELECT_SOURCE_NO_VALID),found=false,pos_reset=local_getPos($this);destcont.find('li input').each(function()
{var $inputthis=$(this);if(local_getPos($inputthis)>pos_reset)
{$inputthis.closest('li').before($this.parent());found=true;return false;}});if(!found)
{destcont.append($(this).parent())}
if(pj.ie){$this.attr('defaultChecked',false);}
$this.removeClass('critSel').parent().find('label').attr('title',false).end().find('span').show();if(0==fromcont.find('li:not(:has('+yes.config.affinement.TOUT_EFFACER+'))').length)
{fromcont.hide();$form.find(yes.config.affinement.SELECTOR_VALIDATE).hide();}}}}
else
{yes.affinement.showLoading();pj.form.request($form,{success:yes.affinement.majContainer});}},unCheckAll:function()
{$(this).closest(yes.config.affinement.CONTAINER_ID).find(yes.config.affinement.SELECT_DEST_NO_VALID).find(':radio, :checkbox').attr('checked',false);},toutEffacer:function(e)
{if(!$(this).hasClass(yes.config.affinement.SELECT_AND_VALID))
{e.preventDefault();}
yes.affinement.unCheckAll.call(this);yes.affinement.showLoading();var $form=yes.affinement._container.find('form:first');if(!$(this).hasClass(yes.config.affinement.SELECT_AND_VALID))
{pj.form.request($form,{success:yes.affinement.majContainer});}
else if(!$(this).is('input:submit'))
{$form.submit();}},annuler:function(e)
{e.preventDefault();var $cnt=$(this).closest(yes.config.affinement.CONTAINER_ID),$btn=$cnt.find(yes.config.affinement.TOUT_EFFACER).filter(':first');if(0==$btn.length)
{$cnt.find('form:first').append($('<input type="hidden" name="effacer" value="annuler"/>')).submit();}
else
{$btn.closest('p').hide().end().val('annuler').click();}}}
pj.add_lib(yes.affinement);yes.version='10.1.11.637';