
function checkChildren(cid){var check=$(cid);var cfield=cid.replace(/^p(.*)\-\d+$/,'$1');var frm=check.form;var t=false;for(i=0;i<frm.elements.length;i++){if(frm.elements[i].type=='checkbox'){if(frm.elements[i].id.substring(0,cfield.length)!=cfield)
t=false;if(t){frm.elements[i].checked=check.checked;}
if(frm.elements[i].id==cid)
t=true;}}}
function checkParent(cid,child){var frm=child.form;var cfield=cid.replace(/^p(.*)\-\d+$/,'$1');if(!child.checked)
$(cid).checked=false;var t=false;var c=0,s=0;for(i=0;i<frm.elements.length;i++){if(frm.elements[i].type=='checkbox'){if(frm.elements[i].id.substring(0,cfield.length)!=cfield)
t=false;if(t){c++;if(frm.elements[i].checked)
s++;}
if(frm.elements[i].id==cid)
t=true;}}
if(c==s)
$(cid).checked=true;}
function checkProduit(cbox,id,first){produits.checkProduit(cbox,id,first);}
function checkSection(cbox){produits.checkSection(cbox);}
function folderExpand(folderId){f=$(folderId);if(f){if(f.attributes['class'].value=='fields-collapsed')
f.attributes['class'].value='fields';else
f.attributes['class'].value='fields-collapsed';}}
function sectionExpand(id){f=$('titre-section-'+id);if(f){if(f.attributes['class'].value=='section-collapsed'){f.attributes['class'].value='section-expanded';}else{f.attributes['class'].value='section-collapsed';}}}
function submitContactCCI(frm){var parametres=getFormValues(frm);if(parametres.nom==''){window.alert('Veuillez entrer votre nom.');frm.nom.focus();return false;}
if((parametres.email=='')&&(parametres.tel=='')){window.alert('Veuillez entrer votre adresse e-mail ou votre numéro\nde téléphone pour permettre au conseiller de vous contacter.');frm.email.focus();return false;}
parametres.send='1';var a=new Ajax.Updater('sem-contact','./contact_cci.php',{method:'post',asynchronous:false,parameters:$H(parametres).toQueryString()});return false;}
function submitContact(frm){var parametres=getFormValues(frm);if(parametres.nom==''){window.alert('Veuillez entrer votre nom.');frm.nom.focus();return false;}
if((parametres.email=='')&&(parametres.tel=='')){window.alert('Veuillez entrer votre adresse e-mail ou votre numéro\nde téléphone pour permettre au responsable Sémaphore de vous répondre.');frm.email.focus();return false;}
if(parametres.sujet==''){window.alert('Veuillez entrer le sujet de votre message.');frm.sujet.focus();return false;}
parametres.send='1';var a=new Ajax.Updater('sem-contact','./contact_resp.php',{method:'post',asynchronous:false,parameters:$H(parametres).toQueryString()});return false;}
function submitContactGestionnaire(frm){var parametres=getFormValues(frm);if(parametres.sujet==''){window.alert('Veuillez entrer le sujet de votre message.');frm.sujet.focus();return false;}
parametres.send='1';var a=new Ajax.Updater('sem-contact','./contact_gest.php',{method:'post',asynchronous:false,parameters:$H(parametres).toQueryString()});return false;}
function submitLostPasswd(frm){var parametres=getFormValues(frm);if(parametres.email==''){window.alert('Veuillez entrer votre identifiant !');frm.email.focus();return false;}
parametres.send='1';var a=new Ajax.Updater('sem-contact','./lost_passwd.php',{method:'post',asynchronous:false,parameters:$H(parametres).toQueryString()});return false;}
var checkRequete={ref:'window.checkRequete',container:tabs.requete.block,form:'semRequete',formID:'sem-requete-form',tabRequete:tabs.requete,tabResult:tabs.result,formComment:'sem-form-comment',formData:null,oldData:null,checkTimer:null,change:false,produits:null,moyens:null,moyensOrig:Object(),req:0,onChange:false,changeTimer:null,departement:'0',fired:0,onFire:false,firedTimer:null,showResult:false,init:function(){this.form=window.document.forms[this.form];this.container=$(this.container);this.formComment=$(this.formComment);this.departement=this.getFormDepartement();if(this.form.moyen){for(var i=1;i<this.form.moyen.options.length;i++){this.moyensOrig[this.form.moyen.options[i].value]=this.form.moyen.options[i].text;}}
if(typeQuest==4){if(this.form.departement.type=='select-one')
bindEvent(this.form.departement,'change',this.changeDepartement);listNom.init();}else{listAPE.init();listCommune.init();listMots.init();}
for(var i=0;i<this.form.elements.length;i++){var elt=this.form.elements[i];if((elt.type=='text')||(elt.type=='textarea')||(elt.type=='select-one')||(elt.type=='radio')||(elt.type=='checkbox')){if(!elt.onchange)
bindEvent(elt,'change',this.formChange);}}
if(this.departement!='0')this.getMaj();this.checkTimer=setTimeout(this.ref+".check()",10);this.formChange();},getFormDepartement:function(){var dep='0';if(this.form.departement){if(this.form.departement.type=='select-one')
dep=this.form.departement.options[this.form.departement.selectedIndex].value;else
dep=this.form.departement.value;}
return dep;},changeDepartement:function(){if(this.ref!='window.checkRequete')
return checkRequete.changeDepartement();this.getMaj();this.formChange();},formChange:function(){if(this.ref!='window.checkRequete')
return checkRequete.formChange();this.showTab(0);if(this.onChange&&this.changeTimer){clearTimeout(this.changeTimer);this.changeTimer=null;}
this.onChange=true;this.changeTimer=setTimeout(this.ref+'.formChanged()',700);},formChanged:function(){this.onChange=false;if(this.changeTimer){clearTimeout(this.changeTimer);this.changeTimer=null;}
this.check();},restore:function(){this.showTab(0);if(this.form.moyen)
for(var i=1;i<this.form.moyen.options.length;i++){this.form.moyen.options[i].text=this.moyensOrig[this.form.moyen.options[i].value];}
tabs.result.scroll2Top();produits.setCadreResume('');produits.setCadreProduits('');},check:function(){if(this.checkTimer){clearTimeout(this.checkTimer);this.checkTimer=null;}
if(this.req>0||this.onChange||this.onFire){this.checkTimer=setTimeout(this.ref+".check()",400);}else{if(this.formValid()){var sData=Object.toJSON(this.formData);if(sData!=this.oldData){this.oldData=sData;produits.change=true;if(this.form.moyen)
this.req=2;else
this.req=1;this.restore();var ajaxProduit=new Ajax.Request('./prereq.php',{method:'post',asynchronous:true,parameters:this.formData,onComplete:this.disposeProduits});if(this.form.moyen){var ajaxMoyens=new Ajax.Request('./moyens.php',{method:'post',asynchronous:true,parameters:this.formData,onComplete:this.disposeMoyens});}}else{this.showProduits();this.showMoyens();}}}},formValid:function(){this.formData=$(this.formID).serialize(true);this.departement=this.formData.departement;var valid=false;if(typeQuest==4){valid=(this.formData.departement!='0')&&this.formData.nom!='';}else{valid=(this.formData.departement!='0')&&((this.formData.commune=='')||listCommune.valid)&&((this.formData.ape=='')||listAPE.valid)&&(this.formData.activite!='0')&&((this.form.domaine!=undefined&&this.formData.domaine!='0')||(this.form.domaines!=undefined&&this.formData.domaines!=undefined)||(this.form.domaine==undefined&&this.form.domaines==undefined));}
if(!valid)this.formComment.innerHTML='';return valid;},saveRequete:function(archive,theme,libelle){this.archiveResponse=null;this.formData=$(this.formID).serialize(true);this.formData.libelle=libelle;this.formData.theme=theme;this.formData.archive=archive;this.formData['save']=1;var ajaxArchive=new Ajax.Request('./archive.php',{method:'post',asynchronous:false,parameters:this.formData,onSuccess:function(transport,json){checkRequete.archiveResponse=json;}});return this.archiveResponse;},deleteRequete:function(archive){this.archiveResponse=null;this.formData=$(this.formID).serialize(true);this.formData['delete']=1;this.formData.archive=archive;var ajaxArchive=new Ajax.Request('./archive.php',{method:'post',asynchronous:false,parameters:this.formData,onSuccess:function(transport,json){checkRequete.archiveResponse=json;}});return this.archiveResponse;},disposeProduits:function(transport,requete){if(this.ref!='window.checkRequete')
return checkRequete.disposeProduits(transport,requete);this.produits=requete;this.form.requete.value=requete.id;this.form.start.value=0;this.req--;this.showProduits();},disposeMoyens:function(transport,requete){if(this.ref!='window.checkRequete')
return checkRequete.disposeMoyens(transport,requete);this.moyens=requete;this.req--;this.showMoyens();},showProduits:function(){var comment='';if(!this.produits||this.produits.nbResult==null){this.showTab(0);}else{if(this.produits.overflow){this.showTab(0);comment="<div align=\"center\"><span class=\"warning\">Le moteur de recherche a identifi&eacute; plus de "+this.produits.maxProduits+" dispositifs sur "
+this.produits.totalProduits+" existant dans votre d&eacute;partement.</span>";if(typeQuest!=4)comment+=" Vous pouvez affiner votre recherche en utilisant des crit&egrave;res compl&eacute;mentaires.";comment+="</div>";if($('sem-form-moyen'))
$('sem-form-moyen').attributes['class'].value='fields';}else{this.showTab(this.produits.nbResult==null?0:this.produits.nbResult);if(this.produits.nbResult==0){comment="<div align=\"center\"><span class=\"warning\">S&eacute;maphore n'a pu trouver de dispositif en prenant en compte tous vos crit&egrave;res<br />de recherche sur "
+this.produits.totalProduits+" dispositifs existant dans votre d&eacute;partement.</span></div>";}else{comment='<div align="center"><b><a href="javascript:void(0);" onclick="tabActivate(\'result\');">'+this.produits.nbResult
+(this.produits.nbResult>1?' dispositifs répondent':' dispositif réponds')+" aux critères s&eacute;lectionn&eacute;s.</a></b>";if(this.produits.ignoreMots||this.produits.ignoreFiliere){if(this.produits.ignoreMots&&!this.produits.ignoreFiliere)comment+="<br /><small><i>Pour obtenir ce r&eacute;sultat, les mots clefs ont &eacute;t&eacute; ignor&eacute;s.</i></small>";if(!this.produits.ignoreMots&&this.produits.ignoreFiliere)comment+="<br /><small><i>Pour obtenir ce r&eacute;sultat, la fili&egrave;re a &eacute;t&eacute; ignor&eacute;e.</i></small>";if(this.produits.ignoreMots&&this.produits.ignoreFiliere)comment+="<br /><small><i>Pour obtenir ce r&eacute;sultat, la fili&egrave;re et les mots clefs ont &eacute;t&eacute; ignor&eacute;s.</i></small>";}else{if(typeQuest!=4)comment+='<br />Vous pouvez affiner votre recherche en utilisant les crit&egrave;res ci-dessous.';}
comment+='</div>';this.showTab(this.produits.nbResult);if(this.showResult){this.showResult=false;tabActivate('result');}}}}
this.formComment.innerHTML=comment;if(comment!='')
showElement(this.formComment);else
hideElement(this.formComment);},showMoyens:function(){if(this.moyens&&this.form.moyen){var moyen,s;for(var i=0;i<this.form.moyen.options.length;i++){moyen=this.form.moyen.options[i].value;if(moyen!='0'){if(this.moyens[moyen]){this.form.moyen.options[i].text=this.moyens[moyen].label+' ('+this.moyens[moyen].count+' dispositif'+(this.moyens[moyen].count>1?'s':'')+')';}else{this.form.moyen.options[i].text=this.moyensOrig[moyen];}}}}},showTab:function(c){this.tabResult.setRSS('');if(c>0){this.tabResult.setTitle('R&eacute;sultats <small>('+c+' dispositifs)</small>');if((this.tabResult.state=='hidden')||(this.tabResult.state=='disabled')){this.tabResult.setState('fired');this.fired=1;this.firedTimer=setTimeout(this.ref+".fire()",200);}}else{if(this.req==2){this.tabResult.setTitle('<img src="/images/loading.gif" width="16" height="16" border="0" alt="loading" align="left" />&nbsp;Recherche...&nbsp;');}else{this.tabResult.setTitle('R&eacute;sultats');}
this.tabResult.setState('disabled');}},fire:function(){if(this.ref!='window.checkRequete')
return checkRequete.fire();this.onFire=true;if((this.fired>8)||(this.fired==0)){clearTimeout(this.firedTimer);this.firedTimer=null;this.fired=0;this.onFire=false;}else{if(this.fired%2==1){this.tabResult.setState('inactive');this.firedTimer=setTimeout(this.ref+'.fire()',200);}
if(this.fired%2==0){this.tabResult.setState('fired');this.firedTimer=setTimeout(this.ref+'.fire()',100);}}
this.fired++;},getMaj:function(){this.departement=this.getFormDepartement();if(this.departement=='0'){tabs.maj.setState('hidden');$('sem-maj-produits-lien').innerHTML='';}else{var ajaxMaj=new Ajax.Request('./maj.php',{method:'post',asynchronous:true,parameters:{departement:this.departement},onComplete:this.disposeMaj});}},disposeMaj:function(transport){if(this.ref!='window.checkRequete')
return checkRequete.disposeMaj(transport);var maj=transport.responseText.evalJSON(false);tabs.maj.setState('hidden');tabs.maj.setContent('');$('sem-maj-produits-lien').innerHTML='';if(maj&&maj.produits.length>0){tabs.maj.setTitle('Nouveaut&eacute;s <small>('+(Prototype.Browser.IE?maj.departement.departement:maj.departement.nom)+')</small>');tabs.maj.setRSS('/rss/maj.xml?departement='+this.departement);$('sem-maj-produits-lien').innerHTML='&nbsp;<a href="javascript:void(0);" onclick="tabActivate(\'maj\');">'+maj.produits.length
+(maj.produits.length>1?' nouveaux dispositifs':' nouveau dispositif')+' dans votre d&eacute;partement</a>';var first=true,last=false,produit;var txt='<div id="sem-maj-resume" class="sem-texte">'+maj.message+'</div>\n';txt+='<div id="sem-maj-produits" class="section"><div class="section-shadow">';for(var i=0;i<maj.produits.length;i++){produit=maj.produits[i];if(i==maj.produits.length-1)last=true;txt+='  <div id="maj-produit-'+produit.id+'" class="short-produit'+(first?' first':'')+(last?' last':'')+'">\n';txt+='  <div class="pcheck">';txt+='<div id="sem-maj-produit-action-'+produit.id+'" class="action">'+this.lienFiche(produit.id,false)+'</div>'+(i+1)+'</div>\n';txt+='  <div id="sem-maj-produit-resume-'+produit.id+'" class="presume">\n';txt+='    <div class="pnom"><a href="javascript:void(0);" onclick="window.checkRequete.showFiche('+produit.id+', \''+this.departement+'\');">'+produit.nom
+'</a></div>\n';txt+='    <div class="pvalidation">'+produit.dateLong+'</div>\n';txt+='    <div class="porganisme">'+produit.sigleOrganisme+'</div>\n';txt+=produit.description;txt+='  </div>\n';txt+='  <div id="sem-maj-produit-'+produit.id+'" class="sem-produit"></div>\n';txt+='</div>\n';first=false;}
txt+='</div></div>\n';tabs.maj.setContent(txt);tabs.maj.scroll2Top();}},showFiche:function(id,dep){showElement('sem-maj-produit-'+id);if($('sem-maj-produit-'+id).innerHTML==''){$('sem-maj-produit-action-'+id).innerHTML='Chargement en cours <img src="/images/loading.gif" width="16" height="16" border="0" alt="loading" align="absbottom" />';var a=new Ajax.Updater('sem-maj-produit-'+id,'./fiche.php',{method:'post',asynchronous:false,parameters:{maj:1,produit:id,departement:dep}});}
hideElement('sem-maj-produit-resume-'+id);this.showLienFiche(id,true);},showLienFiche:function(id,expanded){$('sem-maj-produit-action-'+id).innerHTML=this.lienFiche(id,expanded);},lienFiche:function(id,expanded){var txt='';if(!expanded)
txt+='<a href="javascript:void(0);" onclick="window.checkRequete.showFiche('
+id
+', \''
+this.departement
+'\');"><img src="/images/picto/expand.png" width="16" height="16" border="0" align="absbottom" alt="Afficher le descriptif complet" title="Afficher le descriptif complet" /></a>';else{txt+='<a href="javascript:void(0);" onclick="window.checkRequete.showWFiche('+id+');"><img src="/images/picto/window.png" width="16" height="16" border="0" align="absbottom" alt="Afficher dans une nouvelle fen&ecirc;tre" title="Afficher dans une nouvelle fen&ecirc;tre" /></a> &nbsp;';if(produits.usePDF)
txt+='<a href="javascript:void(0);" onclick="window.checkRequete.showPDFFiche('+id+');"><img src="/images/picto/pdf.png" width="16" height="16" border="0" align="absbottom" alt="Format PDF" title="Format PDF" /></a> &nbsp;';if(produits.usePrint)
txt+='<a href="javascript:void(0);" onclick="window.checkRequete.printFiche('+id+');"><img src="/images/picto/print.png" width="16" height="16" border="0" align="absbottom" alt="Imprimer" title="Imprimer..." /></a> &nbsp;';txt+='<a href="javascript:void(0);" onclick="window.checkRequete.hideFiche('+id+');"><img src="/images/picto/collapse.png" width="16" height="16" border="0" align="absbottom" alt="Afficher le r&eacute;sum&eacute;" title="Afficher le r&eacute;sum&eacute;" /></a>';}
return txt;},showWFiche:function(id){var w=openWindow('produit'+id,'wfiche.php?maj=1&departement='+this.departement+'&produit='+id,800,600,'yes');},printFiche:function(id){var w=openWindow('produit'+id,'wfiche.php?maj=1&departement='+this.departement+'&produit='+id+'&print=1',800,600,'yes');},hideFiche:function(id){hideElement('sem-maj-produit-'+id);showElement('sem-maj-produit-resume-'+id);this.showLienFiche(id,false);}};var produits={ref:'window.produits',divProduits:'sem-result-produits',divResume:'sem-result-resume',divControl:'sem-result-control',form:'semProduits',useBasket:false,usePrint:false,usePDF:false,data:null,req:false,change:true,tBasket:null,selected:null,departement:'0',requete:0,onShow:false,getData:function(){if(this.change){if(!this.req){if(checkRequete.formValid()){this.departement=checkRequete.departement;this.req=true;tabs.result.scroll2Top();this.setCadreResume('<p><img src="/images/loading.gif" width="16" height="16" border="0" alt="loading" align="left" />&nbsp;Chargement en cours...</p>\n');this.setCadreProduits('');tabs.result.scroll2Top();var params=checkRequete.formData;if(this.onShow)params.show='1';var myAjax=new Ajax.Request('./produits.php',{method:'post',asynchronous:true,parameters:params,onComplete:this.dispose});}}}
this.onShow=false;},dispose:function(transport){if(this.ref!='window.produits')
return produits.dispose(transport);this.data=transport.responseJSON;this.requete=parseInt(this.data.id);this.req=false;this.change=false;this.display();},display:function(){if(this.data){var txt='<form id="sem-liste-produits" name="'+this.form+'">\n';$('sem-result-pages').innerHTML='';if(this.data.nbResult>0){var first=true,last=false,produit,t='';var sections=this.data.sections;for(var i=0;i<this.data.produits.length;i++){produit=this.data.produits[i];last=false;if(t!=produit.section){first=true;t=produit.section;if(i!=0)txt+='</div></div>\n';txt+='<div class="section-expanded" id="titre-section-'+produit.section+'"><div class="titre-section"><h1><div class="section-sign"><a href="javascript:void(0);" onclick="sectionExpand('+produit.section+');">&nbsp;&nbsp;&nbsp;</a></div>';if(this.data.produits.length==1){txt+='<a href="javascript:void(0);" onclick="javascript:sectionExpand('+produit.section+');">'
+sections[produit.section].title+' <small>('+sections[produit.section].count+')</small>'
+(sections[produit.section].subTitle?'<br /><small class="subtitle">'+sections[produit.section].subTitle+'</small>':'')+'</a>';if(this.useBasket)txt+='<input type="hidden" name="produits" value="'+produit.id+'" />';}else{if(this.useBasket){txt+='<input type="checkbox" name="sections" value="'+produit.section+'" onclick="checkSection(this);" '
+(sections[produit.section].selected?' checked="checked"':'')+' />&nbsp;';}
txt+='<a href="javascript:void(0);" onclick="javascript:sectionExpand('+produit.section+');">'
+sections[produit.section].title+' <small>('+sections[produit.section].count+')</small>'
+(sections[produit.section].subTitle?'<br /><small class="subtitle">'+sections[produit.section].subTitle+'</small>':'');}
txt+='</a></h1></div>\n';txt+='<div class="section" id="section-'+produit.section+'">\n';}
if(i==this.data.produits.length-1)last=true;else
if(t!=this.data.produits[i+1].section)last=true;txt+='  <div id="produit-'+produit.id+'" class="short-produit'+(this.useBasket&&produit.selected?' produit-checked':'')+(first?' first':'')+(last?' last':'')+'">\n';txt+='  <div class="pcheck"><div id="sem-produit-action-'+produit.id+'" class="action">'+this.lienFiche(produit.id,false)+'</div>';if(this.useBasket){txt+='<input type="checkbox" name="produits" value="'+produit.id+'"'+(produit.selected?' checked="checked"':'')
+' class="pcheck" onclick="checkProduit(this, '+produit.id+', '+(first?'true':'false')+');" />';}
txt+=(produit.number+1)+'</div>\n';txt+='  <div id="sem-produit-resume-'+produit.id+'" class="presume">\n';txt+='    <div class="pnom"><a href="javascript:void(0);" onclick="window.produits.showFiche('+produit.id+');">'+produit.nom+'</a></div>\n';if((this.data.sort==4)&&(produit.popularite!=''))
txt+='    <div class="ppopularite">Popularit&eacute; : '+produit.popularite+'</div>\n';if(this.data.sort!=2)
txt+='    <div class="porganisme">'+produit.organisme+'</div>\n';if(this.data.sort==5)
txt+='    <div class="pvalidation">Validation : '+produit.dateValidation+'</div>\n';txt+=produit.resume;txt+='  </div>\n';txt+='  <div id="sem-produit-'+produit.id+'" class="sem-produit"></div>\n';txt+='</div>\n';first=false;}}
txt+='</div></div>\n';txt+='</form>\n';if(this.data.rss){tabs.result.setRSS(this.data.rss);}
this.setCadreResume(this.data.resume);this.setCadreProduits(txt);tabs.result.scroll2Top();txt='';if((this.data.range!=0)&&(this.data.nbResult>this.data.count)){if(this.data.start>0)
txt+='&nbsp;<a href="javascript:void(0);" onclick="window.produits.changeStart('+(this.data.start-this.data.range)+');">&lt;</a> ';else
txt+='&nbsp;&lt; ';for(var i=0;i<this.data.nbResult/this.data.range;i++){if(i*this.data.range!=this.data.start)
txt+='<a href="javascript:void(0);" onclick="window.produits.changeStart('+(i*this.data.range)+');">'+(i+1)+'</a> ';else
txt+='<span class="red">'+(i+1)+'</span> ';}
if(this.data.start+this.data.range<this.data.nbResult)
txt+='<a href="javascript:void(0);" onclick="window.produits.changeStart('+(this.data.start+this.data.range)+');">&gt;</a>';else
txt+='&gt;';$('sem-result-pages').innerHTML=txt;}}else{this.setCadreResume('');this.setCadreProduits('');}},setCadreResume:function(txt){$(this.divResume).innerHTML=txt;},setCadreProduits:function(txt){$(this.divProduits).innerHTML=txt;},setCadreControl:function(txt){$(this.divControl).innerHTML=txt;},selectProduits:function(sel){var frm=document.forms[this.form];var first;for(var i=0;i<frm.elements.length;i++){if((frm.elements[i].type=='checkbox')&&(frm.elements[i].name=='sections'))
first=true;if((frm.elements[i].type=='checkbox')&&(frm.elements[i].name=='produits')){if(sel==1){frm.elements[i].checked=true;}
if(sel==2){frm.elements[i].checked=false;}
if(sel==3){frm.elements[i].checked=!frm.elements[i].checked;}
this.checkProduit(frm.elements[i],frm.elements[i].value,first,true);first=false;}}
var myAjax=new Ajax.Request('./basket.php',{method:'post',asynchronous:true,parameters:{requete:checkRequete.form.requete.value,selection:sel},onComplete:this.disposeBasket});document.frmControl.elements['selection'].selectedIndex=0;},disposeBasket:function(transport,selected){if(this.ref!='window.produits')
return produits.disposeBasket(transport,selected);this.selected=selected;if(selected.count==0){$('sem-result-basket').innerHTML='';}else{var txt='('+selected.count+(selected.count>1?' dispositifs retenus':' dispositif retenu')+') ';txt+='<a href="javascript:void(0);" onclick="window.produits.printPDFBasket();"><img src="/images/picto/pdf.png" width="16" height="16" border="0" align="absbottom" alt="Export PDF" title="Exporter la s&eacute;lection en PDF" /></a>&nbsp;';$('sem-result-basket').innerHTML=txt;}},changeSort:function(sort){checkRequete.form.sort.value=sort;this.change=true;this.getData();},changeRange:function(range){checkRequete.form.range.value=range;checkRequete.form.start.value=0;this.change=true;this.getData();},changeStart:function(start){checkRequete.form.start.value=start;this.change=true;this.getData();},checkProduit:function(cbox,id,first,noBasket){var frm=document.forms[this.form];var section='';var f=false,s=false;var allChecked=false,sectChecked=false;this.checkStyleProduit(cbox,id,first);for(i=0;i<frm.elements.length;i++){if((frm.elements[i].type=='checkbox')&&(frm.elements[i].name=='sections')){if(!f){section=frm.elements[i];allChecked=true;}else{if(!s){sectChecked=allChecked;s=true;}}}
if((frm.elements[i].type=='checkbox')&&(frm.elements[i].name=='produits')){if(frm.elements[i].value==id)
f=true;if(!frm.elements[i].checked)
allChecked=false;}}
if(!s)
sectChecked=allChecked;section.checked=sectChecked;if(this.tBasket)
clearTimeout(this.tBasket);if(!noBasket)
this.tBasket=setTimeout('produits.basket()',1000);},checkStyleProduit:function(cbox,id,first){$('produit-'+id).attributes['class'].value=(cbox.checked?'short-produit produit-checked':'short-produit')+(first?' first':'');},checkSection:function(sbox){var frm=document.forms[this.form];var section=sbox.value;var f=false,first=false;for(i=0;i<frm.elements.length;i++){if((frm.elements[i].type=='checkbox')&&(frm.elements[i].name=='sections')){f=(frm.elements[i].value==section);first=true;}
if((frm.elements[i].type=='checkbox')&&(frm.elements[i].name=='produits')){if(f){frm.elements[i].checked=sbox.checked;this.checkStyleProduit(frm.elements[i],frm.elements[i].value,first);first=false;}}}
if(this.tBasket)
clearTimeout(this.tBasket);this.tBasket=setTimeout(this.ref+'.basket()',500);},basket:function(){var frm=document.forms[this.form];var lproduits={requete:checkRequete.form.requete.value};for(var i=0;i<frm.elements.length;i++){if((frm.elements[i].type=='checkbox')&&(frm.elements[i].name=='produits')){lproduits['produits['+frm.elements[i].value+']']=frm.elements[i].checked?'1':'';}}
var myAjax=new Ajax.Request('./basket.php',{method:'post',asynchronous:true,parameters:lproduits,onComplete:this.disposeBasket});this.tBasket=null;},infoCommune:function(){if(this.data.infoCommune){$('sem-help').innerHTML='<div id="sem-info-close"></div>'+this.data.infoCommune;showHelp();}},showFiche:function(id,dep){if(dep)this.departement=dep;showElement('sem-produit-'+id);if($('sem-produit-'+id).innerHTML==''){$('sem-produit-action-'+id).innerHTML='Chargement en cours <img src="/images/loading.gif" width="16" height="16" border="0" alt="loading" align="absbottom" />';var a=new Ajax.Updater('sem-produit-'+id,'./fiche.php',{method:'post',asynchronous:false,parameters:{produit:id,requete:this.requete}});}
hideElement('sem-produit-resume-'+id);this.showLienFiche(id,true);},showLienFiche:function(id,expanded){$('sem-produit-action-'+id).innerHTML=this.lienFiche(id,expanded);},lienFiche:function(id,expanded){var txt='';if(!expanded)
txt+='<a href="javascript:void(0);" onclick="window.produits.showFiche('+id+');"><img src="/images/picto/expand.png" width="16" height="16" border="0" align="absbottom" alt="Afficher le descriptif complet" title="Afficher le descriptif complet" /></a>';else{txt+='<a href="javascript:void(0);" onclick="window.produits.showWFiche('+id+');"><img src="/images/picto/window.png" width="16" height="16" border="0" align="absbottom" alt="Afficher dans une nouvelle fen&ecirc;tre" title="Afficher dans une nouvelle fen&ecirc;tre" /></a> &nbsp;';if(this.usePDF)
txt+='<a href="javascript:void(0);" onclick="window.produits.showPDFFiche('+id+');"><img src="/images/picto/pdf.png" width="16" height="16" border="0" align="absbottom" alt="Format PDF" title="Format PDF" /></a> &nbsp;';if(this.usePrint)
txt+='<a href="javascript:void(0);" onclick="window.produits.printFiche('+id+');"><img src="/images/picto/print.png" width="16" height="16" border="0" align="absbottom" alt="Imprimer" title="Imprimer..." /></a> &nbsp;';txt+='<a href="javascript:void(0);" onclick="window.produits.hideFiche('+id+');"><img src="/images/picto/collapse.png" width="16" height="16" border="0" align="absbottom" alt="Afficher le r&eacute;sum&eacute;" title="Afficher le r&eacute;sum&eacute;" /></a>';}
return txt;},showWFiche:function(id){var w=openWindow('produit'+id,'wfiche.php?requete='+this.requete+'&produit='+id,800,600,'yes');},printFiche:function(id){var w=openWindow('produit'+id,'wfiche.php?requete='+this.requete+'&produit='+id+'&print=1',800,600,'yes');},showPDFFiche:function(id){window.location='pfiche.php?requete='+this.requete+'&produit='+id;},printPDFBasket:function(){window.location='pfiche.php?requete='+this.requete;},hideFiche:function(id){hideElement('sem-produit-'+id);showElement('sem-produit-resume-'+id);this.showLienFiche(id,false);}};tabs.result.onShow=function(){produits.onShow=true;produits.getData();checkRequete.fired=0;};var listCommune={ref:'window.listCommune',container:'sem-requete',pasteDiv:'sem-paste-communes',commentDiv:'sem-communes-label',form:'semRequete',textField:'commune',depField:'departement',dep:'0',currentValue:'',oldValue:'',choice:'',valid:false,mouse:false,req:false,checkTimer:null,resultCache:Object(),selectedIndex:null,data:null,visible:false,oldIndex:null,init:function(){this.form=window.document.forms[this.form];this.pasteDiv=$(this.pasteDiv);this.textField=this.form[this.textField];if(Prototype.Browser.IE)
bindEvent(this.textField,'keydown',this.IEkeypress);else
bindEvent(this.textField,'keypress',this.keypress);bindEvent(this.textField,'focus',this.doStart);bindEvent(this.textField,'blur',this.doStop);this.textField.autocomplete='off';this.depField=this.form[this.depField];this.dep=checkRequete.getFormDepartement();if(this.depField.type=='select-one')
bindEvent(this.depField,'change',this.changeDepartement);this.commentDiv=$(this.commentDiv);this.container=$(this.container);this.pasteDiv.style.visibility='hidden';this.pasteDiv.style.display='block';this.validate();},doStart:function(){if(this.ref!='window.listCommune')
return listCommune.doStart();if(!this.checkTimer)
this.check();this.mouse=false;},doStop:function(){if(this.ref!='window.listCommune')
return listCommune.doStop();if(!this.mouse){clearTimeout(this.checkTimer);this.checkTimer=null;this.req=false;this.hide();this.validate();}else{this.mouse=false;}},changeDepartement:function(){if(this.ref!='window.listCommune')
return listCommune.changeDepartement();this.dep=checkRequete.getFormDepartement();this.choice='';if(this.dep=='0'){this.textField.value='';this.textField.disabled=true;this.warning(false);this.valid=false;tabs.maj.setState('hidden');$('sem-maj-produits-lien').innerHTML='';}else{this.textField.disabled=false;checkRequete.getMaj(this.dep);}
if(this.dep=='75'){this.textField.value='Paris';this.cache('Paris',['Paris']);this.warning(false);this.choice='Paris';this.valid=true;}else{this.validate();}
checkRequete.formChange();},show:function(){this.pasteDiv.style.left=domOffset.left(this.textField)+'px';var t;if(Prototype.Browser.IE){t=Element.cumulativeOffset(this.textField)[1]-6;if(this.pasteDiv.clientHeight>100)this.pasteDiv.style.height='100px';}else
t=Element.cumulativeOffset(this.textField)[1]-Element.cumulativeScrollOffset(this.textField)[1]+this.textField.clientHeight+2;if(t+this.pasteDiv.clientHeight<this.container.clientHeight){this.pasteDiv.style.top=t+'px';}else{this.pasteDiv.style.top=(t-this.textField.clientHeight-this.pasteDiv.clientHeight-4)+'px';}
this.pasteDiv.style.width=this.textField.clientWidth+'px';this.pasteDiv.style.visibility='visible';this.visible=true;},hide:function(){this.pasteDiv.style.visibility='hidden';this.visible=false;this.selectedIndex=null;this.oldIndex=null;this.pasteDiv.scrollTop=0;this.pasteDiv.innerHTML='';this.pasteDiv.style.height='auto';},IEkeypress:function(e){listCommune.keypress(e);},keypress:function(e){if(this.ref!='window.listCommune')
return listCommune.keypress(e);if(this.visible){if(!e)
var e=window.event;if(e.keyCode){k=e.keyCode;}else if(e.which)
k=e.which;if(k==40)
this.down();if(k==38)
this.up();if(k==27)
this.hide();if((k==13)&&(this.selectedIndex!=null))
this.choose(this.selectedIndex);}else{if(this.currentValue!=this.value)
this.doStart();}},down:function(){if(this.data&&(this.data.length>0)){if(this.selectedIndex==null)
this.selectedIndex=0;else if(this.selectedIndex<this.data.length-1)
this.selectedIndex++;this.showSelected(false);}},up:function(){if((this.selectedIndex!=null)&&this.data&&(this.data.length>0)){if(this.selectedIndex>0)
this.selectedIndex--;this.showSelected(true);}},showSelected:function(pos){var cells=this.pasteDiv.getElementsByTagName('td');if(this.oldIndex!=null)
cells[this.oldIndex].attributes['class'].value='';cells[this.selectedIndex].attributes['class'].value='selected';if(pos!=null){if(pos&&this.pasteDiv.scrollTop>cells[this.selectedIndex].offsetTop)
cells[this.selectedIndex].scrollIntoView(pos);if(!pos&&cells[this.selectedIndex].offsetTop>this.pasteDiv.scrollTop+this.pasteDiv.clientHeight-cells[this.selectedIndex].clientHeight)
cells[this.selectedIndex].scrollIntoView(pos);}
this.oldIndex=this.selectedIndex;},cellMouseOver:function(c){this.selectedIndex=c;this.showSelected(null);},cellMouseDown:function(c){this.mouse=true;this.choose(c);this.hide();this.textField.focus();this.valid=true;},cache:function(k,v){if(!this.resultCache[this.dep])
this.resultCache[this.dep]=Object();this.resultCache[this.dep][k]=v;},getCache:function(value){if(!this.resultCache[this.dep])
return null;return this.resultCache[this.dep][value];},check:function(){if(!this.req){this.currentValue=this.textField.value;if(this.oldValue!=this.currentValue){this.valid=false;var suggestions=this.getCache(this.currentValue);if(suggestions){this.data=suggestions;if((suggestions.length>1)||(this.currentValue!=suggestions[0]))
this.dispose(null,this.data);}else{this.callSuggestions(this.currentValue);}}
this.oldValue=this.currentValue;}
this.checkTimer=setTimeout(this.ref+".check()",200);return true;},callSuggestions:function(valeur){if((valeur.length==0)||(this.dep.length<2)){this.hide();}else{if(!this.req){this.req=true;var parametres={departement:this.dep,js:1,letter:valeur};var myAjax=new Ajax.Request('/ajax/communes.php',{method:'post',asynchronous:true,parameters:$H(parametres).toQueryString(),onComplete:this.dispose});}}},dispose:function(transport,json){if(this.ref!='window.listCommune')
return listCommune.dispose(transport,json);if(transport!=null)json=transport.responseJSON;this.req=false;if(json)this.setData(json);},setData:function(data){this.data=data;this.cache(this.currentValue,data);this.selectedIndex=null;this.oldIndex=null;this.pasteDiv.scrollTop=0;if(data.length>0){var txt='<table border="0" cellspacing="0" cellpadding="2" width="100%">';for(var i=0;i<data.length;i++){txt+='<tr><td onmouseover="'+this.ref+'.cellMouseOver('+i+');" onmousedown="'+this.ref+'.cellMouseDown('+i+');" class="">'+data[i]+'</td></tr>';}
txt+='</table>';this.pasteDiv.style.height='auto';this.pasteDiv.innerHTML=txt;this.show();}else{this.pasteDiv.innerHTML='';this.hide();}},validate:function(transport,json){if(this.ref!='window.listCommune')
return listCommune.validate(transport,json);if(transport!=null)json=transport.responseJSON;if(!transport){if(this.dep=='0'){this.textField.value='';this.textField.disabled=true;this.valid=false;}else{this.textField.disabled=false;if(this.textField.value!=''){if(this.textField.value!=this.choice){var commune;if((commune=this.getCache(this.textField.value))&&(commune.length==1)){this.data=commune;this.choose(0);}else{this.req=true;this.valid=false;var parametres={departement:this.dep,js:1,exact:1,letter:this.textField.value};var myAjax=new Ajax.Request('/ajax/communes.php',{method:'post',asynchronous:true,parameters:$H(parametres).toQueryString(),onComplete:this.validate});}}else{this.warning(false);this.valid=true;}}else{this.warning(false);}}}else{this.req=false;if(json&&(json.length==1)){this.textField.value=json[0];this.choice=json[0];this.warning(false);this.valid=true;}else{this.warning(true);this.valid=false;}}},warning:function(f){if(f){this.commentDiv.innerHTML='<span class="warning">Commune inconnue dans ce d&eacute;partement !</span>';showElement(this.commentDiv);}else{hideElement(this.commentDiv);this.commentDiv.innerHTML='';}},choose:function(i){if(this.ref!='window.listCommune')
return listCommune.choose(i);hideElement(this.commentDiv);this.commentDiv.innerHTML='';this.textField.value=this.data[i];this.choice=this.data[i];this.cache(this.data[i],[this.data[i]]);this.doStop();this.hide();this.valid=true;}};var listMots={ref:'window.listMots',container:'sem-requete',pasteDiv:'sem-paste-mots',form:'semRequete',textField:'mots',currentValue:'',oldValue:'',choice:'',mouse:false,req:false,checkTimer:null,resultCache:Object(),selectedIndex:null,data:null,visible:false,oldIndex:null,init:function(){this.form=window.document.forms[this.form];this.pasteDiv=$(this.pasteDiv);this.textField=this.form[this.textField];if(Prototype.Browser.IE)
bindEvent(this.textField,'keydown',this.IEkeypress);else
bindEvent(this.textField,'keypress',this.keypress);bindEvent(this.textField,'focus',this.doStart);bindEvent(this.textField,'blur',this.doStop);this.textField.autocomplete='off';this.container=$(this.container);this.pasteDiv.style.visibility='hidden';this.pasteDiv.style.display='block';},doStart:function(){if(this.ref!='window.listMots')
return listMots.doStart();if(!this.checkTimer)
this.check();this.mouse=false;},doStop:function(){if(this.ref!='window.listMots')
return listMots.doStop();if(!this.mouse){clearTimeout(this.checkTimer);this.checkTimer=null;this.req=false;this.hide();}else{this.mouse=false;}},show:function(){this.pasteDiv.style.left=domOffset.left(this.textField)+'px';var t;if(Prototype.Browser.IE){t=Element.cumulativeOffset(this.textField)[1]-6;if(this.pasteDiv.clientHeight>100)this.pasteDiv.style.height='100px';}else
t=Element.cumulativeOffset(this.textField)[1]-Element.cumulativeScrollOffset(this.textField)[1]+this.textField.clientHeight+2;if(t+this.pasteDiv.clientHeight<this.container.clientHeight){this.pasteDiv.style.top=t+'px';}else{this.pasteDiv.style.top=(t-this.textField.clientHeight-this.pasteDiv.clientHeight-4)+'px';}
this.pasteDiv.style.width=this.textField.clientWidth+'px';this.pasteDiv.style.visibility='visible';this.visible=true;},hide:function(){this.pasteDiv.style.visibility='hidden';this.visible=false;this.selectedIndex=null;this.oldIndex=null;this.pasteDiv.scrollTop=0;this.pasteDiv.innerHTML='';this.pasteDiv.style.height='auto';this.mouse=false;},IEkeypress:function(e){listMots.keypress(e);},keypress:function(e){if(this.ref!='window.listMots')
return listMots.keypress(e);if(this.visible){if(!e)
var e=window.event;if(e.keyCode){k=e.keyCode;}else if(e.which)
k=e.which;if(k==40)
this.down();if(k==38)
this.up();if(k==27)
this.hide();if((k==13)&&(this.selectedIndex!=null))
this.choose(this.selectedIndex);}else{if(this.currentValue!=this.value)
this.doStart();}},down:function(){if(this.data&&(this.data.length>0)){if(this.selectedIndex==null)
this.selectedIndex=0;else if(this.selectedIndex<this.data.length-1)
this.selectedIndex++;this.showSelected(false);}},up:function(){if((this.selectedIndex!=null)&&this.data&&(this.data.length>0)){if(this.selectedIndex>0)
this.selectedIndex--;this.showSelected(true);}},showSelected:function(pos){var cells=this.pasteDiv.getElementsByTagName('td');if(this.oldIndex!=null)
cells[this.oldIndex].attributes['class'].value='';cells[this.selectedIndex].attributes['class'].value='selected';if(pos!=null){if(pos&&this.pasteDiv.scrollTop>cells[this.selectedIndex].offsetTop)
cells[this.selectedIndex].scrollIntoView(pos);if(!pos&&cells[this.selectedIndex].offsetTop>this.pasteDiv.scrollTop+this.pasteDiv.clientHeight-cells[this.selectedIndex].clientHeight)
cells[this.selectedIndex].scrollIntoView(pos);}
this.oldIndex=this.selectedIndex;},cellMouseOver:function(c){this.selectedIndex=c;this.showSelected(null);},cellMouseDown:function(c){this.mouse=true;this.choose(c);this.hide();this.textField.focus();},cache:function(k,v){this.resultCache[k]=v;},getCache:function(value){return this.resultCache[value];},check:function(){if(!this.req){this.currentValue=this.textField.value;if(this.oldValue!=this.currentValue){var suggestions=this.getCache(this.currentValue);if(suggestions){this.data=suggestions;if((suggestions.length>1)||(this.currentValue!=suggestions[0]))
this.dispose(null,this.data);}else{this.callSuggestions(this.currentValue);}}
this.oldValue=this.currentValue;}
this.checkTimer=setTimeout(this.ref+".check()",200);return true;},callSuggestions:function(valeur){if(valeur.length==0){this.hide();}else{if(!this.req){this.req=true;var parametres={js:1,letter:valeur};var myAjax=new Ajax.Request('/ajax/mots.php',{method:'post',asynchronous:true,parameters:parametres,onComplete:this.dispose});}}},dispose:function(transport,json){if(this.ref!='window.listMots')
return listMots.dispose(transport,json);if(transport!=null)json=transport.responseJSON;this.req=false;if(this.data=json)this.setData(json);},setData:function(data){this.data=data;this.cache(this.currentValue,data);this.selectedIndex=null;this.oldIndex=null;this.pasteDiv.scrollTop=0;if(data.length>0){var txt='<table border="0" cellspacing="0" cellpadding="2" width="100%">';for(var i=0;i<data.length;i++){txt+='<tr><td onmouseover="'+this.ref+'.cellMouseOver('+i+');" onmousedown="'+this.ref+'.cellMouseDown('+i+');" class="">'+data[i]+'</td></tr>';}
txt+='</table>';this.pasteDiv.style.height='auto';this.pasteDiv.innerHTML=txt;this.show();}else{this.pasteDiv.innerHTML='';this.hide();}},choose:function(i){this.textField.value=this.data[i];this.choice=this.data[i];this.cache(this.data[i],[this.data[i]]);this.hide();this.doStop();}};var listAPE={ref:'window.listAPE',container:'sem-requete',pasteDiv:'sem-paste-ape',commentDiv:'sem-ape-label',form:'semRequete',textField:'ape',actField:'activite',btnPaste:'ape_paste',currentValue:'',oldValue:'',choice:'',valid:false,mouse:false,req:false,checkTimer:null,resultCache:Object(),selectedIndex:null,data:null,visible:false,oldIndex:null,init:function(){this.form=window.document.forms[this.form];this.pasteDiv=$(this.pasteDiv);this.textField=this.form[this.textField];if(Prototype.Browser.IE)
bindEvent(this.textField,'keydown',this.IEkeypress);else
bindEvent(this.textField,'keypress',this.keypress);bindEvent(this.textField,'focus',this.doStart);bindEvent(this.textField,'blur',this.doStop);this.textField.autocomplete='off';this.actField=this.form[this.actField];bindEvent(this.actField,'change',this.changeActivite);this.btnPaste=this.form[this.btnPaste];bindEvent(this.btnPaste,'click',this.btnClick);this.commentDiv=$(this.commentDiv);this.container=$(this.container);this.pasteDiv.style.visibility='hidden';this.pasteDiv.style.display='block';if(this.textField.value!='')
this.validate();},doStart:function(){if(this.ref!='window.listAPE')
return listAPE.doStart();this.mouse=false;if(!this.checkTimer)
this.check();this.textField.focus();},doStop:function(){if(this.ref!='window.listAPE')
return listAPE.doStop();if(!this.mouse){clearTimeout(this.checkTimer);this.checkTimer=null;this.req=false;this.hide();if(this.textField.value!=''){if(this.textField.value!=this.choice){var ape;if((ape=this.getCache(this.textField.value))&&(ape.length==1)){this.data=ape;this.choose(0);}else{this.commentDiv.innerHTML='<span class="warning">Code NAF incorrect !</span>';}}}}else{this.mouse=false;}},changeActivite:function(){if(this.ref!='window.listAPE')
return listAPE.changeActivite();if(!this.visible){this.textField.value='';this.commentDiv.innerHTML='';this.currentValue='';this.choice='';this.valid=false;}
checkRequete.formChange();},btnClick:function(){if(this.ref!='window.listAPE')
return listAPE.btnClick();this.oldValue=' ';if(this.valid&&this.choice==this.textField.value)
this.textField.value='';this.doStart();},show:function(){this.pasteDiv.style.left=domOffset.left(this.textField)+'px';var t;if(Prototype.Browser.IE){t=Element.cumulativeOffset(this.textField)[1]-6;if(this.pasteDiv.clientHeight>100)this.pasteDiv.style.height='100px';}else
t=Element.cumulativeOffset(this.textField)[1]-Element.cumulativeScrollOffset(this.textField)[1]+this.textField.clientHeight+2;if(t+this.pasteDiv.clientHeight<this.container.clientHeight){this.pasteDiv.style.top=t+'px';}else{this.pasteDiv.style.top=(t-this.textField.clientHeight-this.pasteDiv.clientHeight-4)+'px';}
this.pasteDiv.style.visibility='visible';this.visible=true;},hide:function(){this.pasteDiv.style.visibility='hidden';this.visible=false;this.selectedIndex=null;this.oldIndex=null;this.pasteDiv.scrollTop=0;this.pasteDiv.innerHTML='';this.pasteDiv.style.height='auto';},IEkeypress:function(e){listAPE.keypress(e);},keypress:function(e){if(this.ref!='window.listAPE')
return listAPE.keypress(e);if(this.visible){if(!e)
var e=window.event;if(e.keyCode){k=e.keyCode;}else if(e.which)
k=e.which;if(k==40)
this.down();if(k==38)
this.up();if(k==27)
this.hide();if((k==13)&&(this.selectedIndex!=null))
this.choose(this.selectedIndex);}else{if(this.currentValue!=this.value)
this.doStart();}},down:function(){if(this.data&&(this.data.length>0)){if(this.selectedIndex==null)
this.selectedIndex=0;else if(this.selectedIndex<this.data.length-1)
this.selectedIndex++;this.showSelected(false);}},up:function(){if((this.selectedIndex!=null)&&this.data&&(this.data.length>0)){if(this.selectedIndex>0)
this.selectedIndex--;this.showSelected(true);}},showSelected:function(pos){var cells=this.pasteDiv.getElementsByTagName('td');if(this.oldIndex!=null)
cells[this.oldIndex].attributes['class'].value='';cells[this.selectedIndex].attributes['class'].value='selected';if(pos!=null){if(pos&&this.pasteDiv.scrollTop>cells[this.selectedIndex].offsetTop)
cells[this.selectedIndex].scrollIntoView(pos);if(!pos&&cells[this.selectedIndex].offsetTop>this.pasteDiv.scrollTop+this.pasteDiv.clientHeight-cells[this.selectedIndex].clientHeight)
cells[this.selectedIndex].scrollIntoView(pos);}
this.oldIndex=this.selectedIndex;},cellMouseOver:function(c){this.selectedIndex=c;this.showSelected(null);},cellMouseDown:function(c){this.mouse=true;this.choose(c);this.hide();this.textField.focus();},cache:function(k,v){if(k=='')
k='z';this.resultCache[k]=v;},getCache:function(value){return this.resultCache[value];},check:function(){if(!this.req){this.currentValue=this.textField.value;var value=this.currentValue?this.currentValue:'z';if(this.oldValue!=this.currentValue){this.valid=false;this.commentDiv.innerHTML='';var suggestions=this.getCache(value);if(suggestions){this.data=suggestions;if((suggestions.length>1)||(this.currentValue!=suggestions[0]))
this.dispose(null,this.data);}else{this.callSuggestions(value);}}
this.oldValue=this.currentValue;}
this.checkTimer=setTimeout(this.ref+".check()",200);return true;},callSuggestions:function(valeur){if(!this.req){this.req=true;var parametres={js:1,letter:valeur};var myAjax=new Ajax.Request('/ajax/ape.php',{method:'post',asynchronous:true,parameters:$H(parametres).toQueryString(),onComplete:this.dispose});}},dispose:function(transport,json){if(this.ref!='window.listAPE')
return listAPE.dispose(transport,json);if(transport!=null)json=transport.responseJSON;this.req=false;if(json)this.setData(json);},setData:function(data){this.data=data;this.cache(this.currentValue,data);this.selectedIndex=null;this.oldIndex=null;this.pasteDiv.scrollTop=0;if(data.length>0){var ape=data[0].split(/ - /g);if((data.length==1)&&(this.currentValue.length==5)){this.choose(0);}else{var txt='<table border="0" cellspacing="0" cellpadding="2" width="100%">';for(var i=0;i<data.length;i++){ape=data[i].split(/ - /g);txt+='<tr><td onmouseover="'+this.ref+'.cellMouseOver('+i+');" onmousedown="'+this.ref+'.cellMouseDown('+i+');" class=""><strong>'+ape[0]
+'</strong> - '+ape[1]+'</td></tr>';}
txt+='</table>';this.pasteDiv.style.height='auto';this.pasteDiv.innerHTML=txt;this.show();}}else{this.pasteDiv.innerHTML='';this.commentDiv.innerHTML='';this.hide();}},validate:function(transport,json){if(this.ref!='window.listAPE')
return listAPE.validate(transport,json);if(transport!=null)json=transport.responseJSON;if(!transport){if(this.textField.value!=''){if(this.textField.value!=this.choice){this.valid=false;var ape;if((ape=this.getCache(this.textField.value))&&(ape.length==1)){this.data=ape;this.choose(0);}else{this.req=true;var parametres={js:1,letter:this.textField.value};var myAjax=new Ajax.Request('/ajax/ape.php',{method:'post',asynchronous:true,parameters:$H(parametres).toQueryString(),onComplete:this.validate});}}else{this.valid=true;}}else{this.warning(false);this.valid=false;}}else{this.req=false;if(json&&(json.length==1)){var ape=json[0].split(/ - /g);this.cache(ape[0],json);this.data=json;this.choose(0);}else{this.warning(true);}}},warning:function(f){if(f){this.commentDiv.innerHTML='<span class="warning">Code NAF incorrect !</span>';}else{this.commentDiv.innerHTML='';}},reset:function(){this.textField.value='';this.currentValue='';this.oldValue='';},choose:function(i){var ape=this.data[i].split(/ - /g);if(ape[0].length==5){this.textField.value=ape[0];this.choice=ape[0];this.cache(ape[0],[this.data[i]]);this.commentDiv.innerHTML=ape[1];setSelectValue(this.actField,ape[2]);this.doStop();this.hide();this.valid=true;}else{this.valid=false;this.textField.value=ape[0];this.choice=ape[0];this.commentDiv.innerHTML='';this.doStart();}}};var listNom={ref:'window.listNom',container:'sem-requete',pasteDiv:'sem-paste-nom',form:'semRequete',textField:'nom',currentValue:'',oldValue:'',choice:'',mouse:false,req:false,checkTimer:null,resultCache:Object(),selectedIndex:null,data:null,visible:false,oldIndex:null,departement:'',init:function(){this.form=window.document.forms[this.form];this.pasteDiv=$(this.pasteDiv);this.textField=this.form[this.textField];if(Prototype.Browser.IE)
bindEvent(this.textField,'keydown',this.IEkeypress);else
bindEvent(this.textField,'keypress',this.keypress);bindEvent(this.textField,'focus',this.doStart);bindEvent(this.textField,'blur',this.doStop);this.textField.autocomplete='off';this.container=$(this.container);this.pasteDiv.style.visibility='hidden';this.pasteDiv.style.display='block';},doStart:function(){if(this.ref!='window.listNom')
return listNom.doStart();if(!this.checkTimer)
this.check();this.mouse=false;},doStop:function(){if(this.ref!='window.listNom')
return listNom.doStop();if(!this.mouse){clearTimeout(this.checkTimer);this.checkTimer=null;this.req=false;this.hide();}else{this.mouse=false;}},show:function(){this.pasteDiv.style.left=domOffset.left(this.textField)+'px';var t;if(Prototype.Browser.IE){t=Element.cumulativeOffset(this.textField)[1]-6;if(this.pasteDiv.clientHeight>100)this.pasteDiv.style.height='100px';}else
t=Element.cumulativeOffset(this.textField)[1]-Element.cumulativeScrollOffset(this.textField)[1]+this.textField.clientHeight+2;if(t+this.pasteDiv.clientHeight<this.container.clientHeight){this.pasteDiv.style.top=t+'px';}else{this.pasteDiv.style.top=(t-this.textField.clientHeight-this.pasteDiv.clientHeight-4)+'px';}
this.pasteDiv.style.width=this.textField.clientWidth+'px';this.pasteDiv.style.visibility='visible';this.visible=true;},hide:function(){this.pasteDiv.style.visibility='hidden';this.visible=false;this.selectedIndex=null;this.oldIndex=null;this.pasteDiv.scrollTop=0;this.pasteDiv.innerHTML='';this.pasteDiv.style.height='auto';this.mouse=false;},IEkeypress:function(e){listNom.keypress(e);},keypress:function(e){if(this.ref!='window.listNom')
return listNom.keypress(e);if(this.visible){if(!e)
var e=window.event;if(e.keyCode){k=e.keyCode;}else if(e.which)
k=e.which;if(k==40)
this.down();if(k==38)
this.up();if(k==27)
this.hide();if((k==13)&&(this.selectedIndex!=null))
this.choose(this.selectedIndex);}else{if(this.currentValue!=this.value)
this.doStart();}},down:function(){if(this.data&&(this.data.length>0)){if(this.selectedIndex==null)
this.selectedIndex=0;else if(this.selectedIndex<this.data.length-1)
this.selectedIndex++;this.showSelected(false);}},up:function(){if((this.selectedIndex!=null)&&this.data&&(this.data.length>0)){if(this.selectedIndex>0)
this.selectedIndex--;this.showSelected(true);}},showSelected:function(pos){var cells=this.pasteDiv.getElementsByTagName('td');if(this.oldIndex!=null)
cells[this.oldIndex].attributes['class'].value='';cells[this.selectedIndex].attributes['class'].value='selected';if(pos!=null){if(pos&&this.pasteDiv.scrollTop>cells[this.selectedIndex].offsetTop)
cells[this.selectedIndex].scrollIntoView(pos);if(!pos&&cells[this.selectedIndex].offsetTop>this.pasteDiv.scrollTop+this.pasteDiv.clientHeight-cells[this.selectedIndex].clientHeight)
cells[this.selectedIndex].scrollIntoView(pos);}
this.oldIndex=this.selectedIndex;},cellMouseOver:function(c){this.selectedIndex=c;this.showSelected(null);},cellMouseDown:function(c){this.mouse=true;this.choose(c);this.hide();this.textField.focus();},typeNom:function(){var t=0;for(var i=0;i<this.form.type_nom.length;i++)
if(this.form.type_nom[i].checked)
t=this.form.type_nom[i].value;return t;},cache:function(k,v){this.departement=checkRequete.getFormDepartement();var t=this.typeNom();if(!this.resultCache[t])
this.resultCache[t]=Object();if(!this.resultCache[t][this.departement])
this.resultCache[t][this.departement]=Object();this.resultCache[t][this.departement][k]=v;},getCache:function(value){this.departement=checkRequete.getFormDepartement();var t=this.typeNom();if(!this.resultCache[t])
return null;if(!this.resultCache[t][this.departement])
return null;return this.resultCache[t][this.departement][value];},check:function(){if(!this.req){this.currentValue=this.textField.value;if(this.oldValue!=this.currentValue){var suggestions=this.getCache(this.currentValue);if(suggestions){this.data=suggestions;if((suggestions.length>1)||(this.currentValue!=suggestions[0]))
this.dispose(null,this.data);}else{this.callSuggestions(this.currentValue);}}
this.oldValue=this.currentValue;}
this.checkTimer=setTimeout(this.ref+".check()",200);return true;},callSuggestions:function(valeur){if(valeur.length==0){this.hide();}else{if(!this.req){this.req=true;var parametres={js:1,nom:valeur,type_nom:this.typeNom(),departement:checkRequete.getFormDepartement()};var myAjax=new Ajax.Request('/ajax/nom.php',{method:'post',asynchronous:true,parameters:parametres,onComplete:this.dispose});}}},dispose:function(transport,json){if(this.ref!='window.listNom')
return listNom.dispose(transport,json);if(transport!=null)json=transport.responseJSON;this.req=false;if(json)this.setData(json);},setData:function(data){this.data=data;this.cache(this.currentValue,data);this.selectedIndex=null;this.oldIndex=null;this.pasteDiv.scrollTop=0;if(data.length>0){var txt='<table border="0" cellspacing="0" cellpadding="2" width="100%">';for(var i=0;i<data.length;i++){txt+='<tr><td onmouseover="'+this.ref+'.cellMouseOver('+i+');" onmousedown="'+this.ref+'.cellMouseDown('+i+');" class="">'+data[i]+'</td></tr>';}
txt+='</table>';this.pasteDiv.style.height='auto';this.pasteDiv.innerHTML=txt;this.show();}else{this.pasteDiv.innerHTML='';this.hide();}},choose:function(i){this.textField.value='"'+this.data[i]+'"';this.choice=this.data[i];this.cache(this.data[i],[this.data[i]]);this.hide();this.doStop();}};