
var iFrameForm;var trigger_hashchange=1;var hashchangefunc=function(hash){if(trigger_hashchange==1){hash=hash.length>0?hash:'[empty]';getLink(hash);}else{trigger_hashchange=1;}};var titles={'tenant_lease':'Bureau','tenant_leases':'Mes Locations','tenant_landlord':'Propriétaires','tenant_payments':'Paiements','tenant_messages':'Messages','tenant_documents':'Modèles de lettres','tenant_mesdocuments':'Mes Documents','tenant_profile':'Mon Compte','tenant_search':'Recherche','tenant_forum':'Forum','landlord_dashboard':'Bureau','landlord_properties':'Mes Locaux','landlord_buildings':'Mes Immeubles','landlord_tenants':'Mes Locataires','landlord_leases':'Mes Locations','landlord_leases_revision':'Revision de loyer','landlord_payments':'Finances','landlord_bilan':'Bilan Financier','landlord_notices':'Rappels','landlord_messages':'Messages','landlord_documents':'Modèles de lettres','landlord_mesdocuments':'Mes Documents','landlord_prestataires':'Prestataires','landlord_evaluation':'Evaluation','landlord_profile':'Mon Compte','landlord_multiproprietaires':'Multi-propriétaires','landlord_search':'Recherche','landlord_forum':'Forum','landlord_credits':'Mes crédits'};function setLinks(blockId,sel){if(!sel)sel='a[class^=dynamic-link]';var contentLinks=$(blockId).getElements(sel);contentLinks.each(function(dLink){var h=dLink.href;if(h.indexOf("#")<0){return true;}
if(h==window.location.href+'#'){return true;}
if(h.indexOf("nogo")>-1){return true;}
dLink.addEvent('click',function(e){getLink(h);return true;});});}
function getLink(h){if(h.indexOf("#nogo")>-1){return false;}
h=h.replace('#','');$$('.tipAct').fireEvent('mouseleave');var req=new Request({method:'get',url:h,evalScripts:true,onRequest:function(){showLoader();},onSuccess:function(response){return afterResponse(response,h);},onFailure:function(){hideLoader();}}).send('&a=1&rand='+parseInt(Math.random()*10000));}
function submitForm(f){showLoader();var h=$(f).getProperty('action');h+='&a=1&rand='+parseInt(Math.random()*10000);$$('.tipAct').fireEvent('mouseleave');$(f).set('send',{evalScripts:true,onComplete:function(response){return afterResponse(response,h);}});$(f).send(h);return false;}
function submitFormChangeHash(f){var h=$(f).getProperty('action');if(h.indexOf('?')){h+='&';}else{h+='?'}
h+=$(f).toQueryString();window.location.href=h;return false;}
function submitIframeForm(f){var h=$(f).getProperty('action');iFrameForm=new iFrameFormRequest(f,{onRequest:function(){showLoader();},onComplete:function(response){afterResponse(response,h);}});iFrameForm.formEvent();iFrameForm.send();}
function changeHashNoEvent(h){if(h!=window.location.hash){trigger_hashchange=0;window.location.hash=h;}}
function afterResponse(response,h){$('content-wrap').set('html',response);if($$('span.close')!=''){Site.closeMsg();}
if($$('em.fold')!=''){Site.fold('em.fold','div.toggled');}
if($$('div.bottom ul li')!=''){Site.showList('div.bottom ul li');}
if($$('div.top ul li')!=''){Site.showList('div.top ul li');}
if($$('a.getM')!=''){Site.getM('390','480');}
if($$('a.tipAct')!=''){Site.tips('.tipAct','tipRel',1);}
var hideAlerts=Cookie.read('hideAlerts');if(hideAlerts=='1'){$$('.notice').hide();$$('.tipster').hide();}
$$("div.notice span.close").addEvents({click:function(e){var myCookie=Cookie.write('hideAlerts','1',{duration:365,path:"/"});}})
var interface_page=callback='';var re=/\/(tenant|landlord)\/(.+?)$/;var m=h.match(re);if(!m){m=window.location.href.match(re);}
if(m){m[2]=m[2].replace(/\/\d+\//,'/');}
if(m){callback=m[1]+'_'+m[2].replace(/^(.*?)\/(.*?)\/.*$/,'$1\/$2').replace('/','_').replace('#','').replace(/^(.*)\?.*$/,'$1').replace(/_$/,'');}
if(m){interface_page=m[1]+'_'+m[2].replace(/^(.*?)\/.*$/,'$1').replace('#','').replace(/^(.*)\?.*$/,'$1');}
if(callback){if(window[callback]){eval(callback+'();');}}
if(interface_page){if(titles[callback]){if($('titleh1')){$('titleh1').set('html',titles[callback]);}}else if(titles[interface_page]){if($('titleh1')){$('titleh1').set('html',titles[interface_page]);}}
lis=$('nav').getElements('li');lis.each(function(li){a_el=li.getElements('a.tipsTop');a_el.removeClass('current');a_el_href=a_el.get('href').toString();m=a_el_href.match(re);a_el_page='';if(m){a_el_page=m[1]+'_'+m[2].replace('#','');}
if(interface_page==a_el_page){a_el.addClass('current');}else if((interface_page=='landlord_buildings'&&a_el_page=='landlord_properties')||(interface_page=='landlord_notices'&&a_el_page=='landlord_leases')||(interface_page=='landlord_revision'&&a_el_page=='landlord_leases')||(interface_page=='landlord_bilan'&&a_el_page=='landlord_payments')||(interface_page=='landlord_documents'&&a_el_page=='landlord_mesdocuments')||(interface_page=='landlord_evaluation'&&a_el_href=='javascript:;')){a_el.addClass('current');}});}
hideLoader();window.scroll(0,0);return true;}
function showLoader(){txt='Chargement...';wrapId='single';msgId='loader';background='#333';postop=170;if(!$(wrapId)){wrapId='content-wrap';postop=150;}
if($('msg')){$('msg').dispose();}
var container=new Element('div',{'id':'msg','styles':{'display':'block','position':'absolute','top':postop+'px','opacity':'100','zIndex':'10000'}}).inject(wrapId,'top');var bHolder=new Element('b',{'styles':{'display':'block','background':'transparent','overflow':'hidden'}}).inject(container,'top');var bOne=new Element('b',{'styles':{'height':'1px','background':background,'margin':'0 5px','display':'block','overflow':'hidden'}}).inject(bHolder,'top');var bTwo=new Element('b',{'styles':{'height':'1px','background':background,'margin':'0 3px','display':'block','overflow':'hidden'}}).inject(bOne,'after');var bThree=new Element('b',{'styles':{'height':'1px','background':background,'margin':'0 2px','display':'block','overflow':'hidden'}}).inject(bTwo,'after');var bFour=new Element('b',{'styles':{'height':'2px','background':background,'margin':'0 1px','display':'block','overflow':'hidden'}}).inject(bThree,'after');var contWrap=new Element('div',{'styles':{'background':background,'display':'block','padding':'0 5px'}}).inject(bFour,'after');var content=new Element('div',{'id':msgId}).set('text',txt).inject(contWrap);var cloneBholder=bHolder.clone(false).inject(contWrap,'after');var cloneBfour=bFour.clone().inject(cloneBholder);var cloneBthree=bThree.clone().inject(cloneBfour,'after');var cloneBtwo=bTwo.clone().inject(cloneBthree,'after');var cloneBone=bOne.clone().inject(cloneBtwo,'after');var dimMsg=container.getSize();var dimWrp=$(wrapId).getSize();var diff=Math.ceil((dimWrp.x-dimMsg.x)/2);container.setStyles({'width':dimMsg.x+'px','left':diff+'px'});}
function hideLoader(){if($('msg')){$('msg').dispose();}}
var map;var geocoder;var infowindow;function gmInitialize(){var myLatlng=new google.maps.LatLng(48.8580,2.35);var myOptions={zoom:8,center:myLatlng,mapTypeId:google.maps.MapTypeId.ROADMAP}
map=new google.maps.Map(document.getElementById("map_canvas"),myOptions);geocoder=new google.maps.Geocoder();infowindow=new google.maps.InfoWindow();}
function gmFindAddress(country,city,address){geocoder.geocode({'address':country+', '+city+', '+address},function(results,status){if(status==google.maps.GeocoderStatus.OK){map.setCenter(results[0].geometry.location);map.setZoom(13);var marker=new google.maps.Marker({map:map,position:results[0].geometry.location});infowindow.setContent(address+', '+city+', '+country);infowindow.open(map,marker);}else{gmFindCity(country,city);}});}
function gmFindCity(country,city){geocoder.geocode({'address':country+', '+city},function(results,status){if(status==google.maps.GeocoderStatus.OK){map.setCenter(results[0].geometry.location);map.setZoom(13);var marker=new google.maps.Marker({map:map,position:results[0].geometry.location});infowindow.setContent(results[0].formatted_address);infowindow.open(map,marker);}});}
function nl2br(str,is_xhtml){var breakTag='';breakTag='<br />';if(typeof is_xhtml!='undefined'&&!is_xhtml){breakTag='<br>';}
return(str+'').replace(/([^>]?)\n/g,'$1'+breakTag+'\n');}
function loadScript(url){var script=document.createElement("script");script.type="text/javascript";script.src=url;document.body.appendChild(script);}
function loadScriptCallback(url,callback){var script=document.createElement("script");script.type="text/javascript";script.src=url;var done=false;script.onload=script.onreadystatechange=function()
{if(!done&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete"))
{done=true;callback();script.onload=script.onreadystatechange=null;document.body.removeChild(script);}};document.body.appendChild(script);}
function alertBox(msg,url){AlertBox.confirm(msg,{onComplete:function(returnvalue){if(returnvalue){getLink(url);}}});return false;}
function alertBoxDeleteChBoxs(msg,h){var data='';var inputs=$(document.body).getElements('input[type=checkbox]:checked');inputs.each(function(ch){if(ch.get('name')=='ids[]');data+='&ids[]='+ch.get('value');});AlertBox.confirm(msg,{onComplete:function(returnvalue){if(returnvalue){var req=new Request({method:'post',url:h,evalScripts:true,onRequest:function(){showLoader();},onSuccess:function(response){return afterResponse(response,h);},onFailure:function(){hideLoader();}}).send(data+'&a=1&rand='+parseInt(Math.random()*10000));}}});return false;}
function alertDeletePropertyBox(msg,url){window.lert_payment_keep=false;msg='<strong>'+msg+'</strong>';msg+='<br /><input type="checkbox" name="keep" id="lert_payment_keep" onclick="window.lert_payment_keep=this.checked;" /> Garder les  données des opérations financières';AlertBox.confirm(msg,{onComplete:function(returnvalue){if(returnvalue){getLink(url+'&keep='+(window.lert_payment_keep?'1':'0'));}}});return false;}
function alertBoxDeletePropertyChBoxs(a,b){window.lert_payment_keep=false;a="<strong>"+a+"</strong>";a+='<br /><input type="checkbox" name="keep" id="lert_payment_keep" onclick="window.lert_payment_keep=this.checked;" /> Garder les  données des opérations financières';var c="";var d=$(document.body).getElements("input[type=checkbox]:checked");d.each(function(a){if(a.get("name")=="ids[]");c+="&ids[]="+a.get("value")});AlertBox.confirm(a,{onComplete:function(a){if(a){var d=(new Request({method:"post",url:b,evalScripts:true,onRequest:function(){showLoader()},onSuccess:function(a){return afterResponse(a,b)},onFailure:function(){hideLoader()}})).send(c+"&keep="+(window.lert_payment_keep?"1":"0")+"&a=1&rand="+parseInt(Math.random()*1e4))}}});return false}
function alertDeleteLeaseBox(msg,url){window.lert_payment_keep=false;msg='<strong>'+msg+'</strong>';msg+='<br /><input type="checkbox" name="keep" id="lert_payment_keep" onclick="window.lert_payment_keep=this.checked;" /> Garder les  données des opérations financières';AlertBox.confirm(msg,{onComplete:function(returnvalue){if(returnvalue){getLink(url+'&keep='+(window.lert_payment_keep?'1':'0'));}}});return false;}
function alertBoxDeleteLeaseChBoxs(a,b){window.lert_payment_keep=false;a="<strong>"+a+"</strong>";a+='<br /><input type="checkbox" name="keep" id="lert_payment_keep" onclick="window.lert_payment_keep=this.checked;" /> Garder les  données des opérations financières';var c="";var d=$(document.body).getElements("input[type=checkbox]:checked");d.each(function(a){if(a.get("name")=="ids[]");c+="&ids[]="+a.get("value")});AlertBox.confirm(a,{onComplete:function(a){if(a){var d=(new Request({method:"post",url:b,evalScripts:true,onRequest:function(){showLoader()},onSuccess:function(a){return afterResponse(a,b)},onFailure:function(){hideLoader()}})).send(c+"&keep="+(window.lert_payment_keep?"1":"0")+"&a=1&rand="+parseInt(Math.random()*1e4))}}});return false}
function setSelectDateFromCalendar(f){$$("."+f+"_dp").each(function(el){if(!isNaN(el.get('value'))){d=new Date(el.get('value')*1000);$(f+"Year").set('value',d.getFullYear());m=d.getMonth()*1+1;if(m.toString().length<2)m='0'+m;$(f+"Month").set('value',m);$(f+"Day").set('value',d.getDate());return;}});}
function alertDeletePaymentRecurringBox(a,b){window.lert_payment_delete_recurring=false;a="<strong>"+a+"</strong>";a+='<br /><input type="checkbox" name="keep" id="lert_payment_delete_recurring" onclick="window.lert_payment_delete_recurring=this.checked;" /> Supprimer tous les enregistrements existants du paiement récurrent.';AlertBox.confirm(a,{onComplete:function(a){if(a){getLink(b+"&delete_recurring="+(window.lert_payment_delete_recurring?"1":"0"))}}});return false}
function setCalendarDateFromSelect(f){var y=$(f+"Year").get('value');var m=$(f+"Month").get('value');var day=$(f+"Day").get('value');var d=new Date();d.setYear(y);d.setMonth(m-1);d.setDate(day);var ts=Math.round(d.getTime()/1000);$$("."+f+"_dp").each(function(el){el.set('value',ts);});}
function attachDatePicker(f){var dt=$(f+'_dt').getCoordinates();new DatePicker('.'+f+'_dp',{pickerClass:'datepicker_vista',toggleElements:'.'+f+'_dt',position:{x:dt.left-175,y:dt.top+20},onClose:function(){setSelectDateFromCalendar(f);}});}
function onChangeGoTo(url,s){v=s.options[s.selectedIndex].value;if(v){url=url.replace('%s',v);window.location.href=url;}}
var Site={start:function(){if($('nav')){var topMenu=new MenuMatic();if($$('.tipsTop')!=''){Site.tips('.tipsTop','tipTop',0,8,-55);}}
if($('personal')!=''){Site.showList('#personal ul li');}
if($$('span.close')!=''){Site.closeMsg();}
if($$('em.fold')!=''){Site.fold('em.fold','div.toggled');}
if($$('div.bottom ul li')!=''){Site.showList('div.bottom ul li');}
if($$('div.top ul li')!=''){Site.showList('div.top ul li');}
if($$('a.getM')!=''){Site.getM('390','480');}
if($$('a.tipAct')!=''){Site.tips('.tipAct','tipRel',1);}
if($("tips")){var randomtips=$("tips").getElements('li');var length=randomtips.length;var ran=Math.floor(Math.random()*length);randomtips[ran].show();}},tips:function(els,tClass,fixed,x,y){if(!els){return false;}
var els=$$(els),tOpts={fadeIn:1,fixed:(fixed)?false:true,className:tClass,showDelay:100,hideDelay:100},tip=new MyTips($merge(tOpts,{offset:{x:(x)?x:16,y:(y)?y:16}}));tip.setTip(els);},getM:function(w,h){var mW=w.toInt(),inW=mW-18,mH=h.toInt(),inH=mH-8,tW=mW-8,cW=mW-8,cH=mH-65;var modal=new Element('div',{'styles':{'width':mW+'px','height':mH+'px','display':'block','zIndex':'0','position':'absolute','left':'-9999px'}});var mask;modal.inject($('whiteMask'),'after');var r={noCache:true,link:'cancel',update:$(modal),onSuccess:function(){Site.mShow(w,h,modal);sizes=window.getSize();scrollito=window.getScroll();modal.setStyles({'left':(scrollito.x+(sizes.x-w)/2).toInt(),'top':(scrollito.y+(sizes.y-h)/2).toInt()});var close=$$('span.closeM,a.close');close.each(function(el){el.addEvents({mouseenter:function(){el.swapClass('closeM','closeMO');},mouseleave:function(){el.swapClass('closeMO','closeM')},click:function(e){if(e){e.stop();}
Site.mHide(mask,modal);}});});},onFailure:function(){alert('problem.');}};$$('a.getM').each(function(el){el.addEvent('click',function(e){if(e){e.stop();}
var req=new Request.HTML($merge(r,{method:'get',url:el.get('href')})).send();});});},mHide:function(a,b){b.setStyle('display','none');},mShow:function(w,h,m){var mW=w.toInt(),inW=mW-18,mH=h.toInt(),inH=mH-8,tW=mW-8,cW=mW-8,cH=mH-65,mIn=$('modalIn'),mCont=mIn.getElement('div.content'),mEdges=mIn.getElements('div.top,div.bottom');mIn.setStyles({'width':inW+'px','height':inH+'px'});mCont.setStyles({'width':cW+'px','height':cH+'px'});$$(mEdges).each(function(el){el.setStyle('width',tW+'px');});$(m).setStyles({'display':'block','zIndex':'65500'}).position();},showList:function(els){if(!els){return false;}
var els=$$(els);els.each(function(el){if(el.getElement('ul')!=null){var sub=el.getElement('ul'),sy=sub.getSize().y;sub.setStyle('opacity',0);sub.set('morph',{duration:'150'});sub.getElements('li').setStyle('opacity',0);el.addEvents({mouseenter:function(){if(sub.get('id')=='FilterListContainer'){}else{sub.morph({'height':sy+'px','opacity':1,onComplete:function(){sub.getElements('li').setStyle('opacity',1);}});}},click:function(event){if(sub.get('id')=='FilterListContainer'){if(typeof window.FilterListContainerClick!="undefined "&&window.FilterListContainerClick==false){window.FilterListContainerClick=true;}else{var li_opacities=0;try{li_opacities=sub.getElements('li').getStyle('opacity').toString();}catch(err){}
var target_type='';try{target_type=event.target&&event.target.get('text').toString().match(/Filtrer par/)?'b':'';}catch(err){}
if(target_type==''){try{target_type=event.target&&event.target.innerText.toString().match(/Filtrer par/)?'b':'';}catch(err){}}
if(target_type=='b'&&li_opacities=='1'){hidePaymentListFilter();}else if(target_type&&(target_type=='select'||target_type=='img'||target_type=='input')){}else{sub.morph({'height':sy+'px','opacity':1,onComplete:function(){sub.getElements('li').setStyle('opacity',1);}});}}}},mouseleave:function(event){if(sub.get('id')=='FilterListContainer'){coord=sub.getCoordinates();sizes=sub.getSize();if((event.page.x>0&&event.page.x<=coord.left)||(event.page.x>0&&event.page.x>=coord.left+sizes.x)){try{if(event.relatedTarget&&event.relatedTarget.get('tag')=='td'){hidePaymentListFilter();}}catch(err){}}
try{if(event.relatedTarget&&event.relatedTarget.get('id')=='single'){}}catch(err){}}else{sub.morph({'height':0,'opacity':0,onComplete:function(){sub.getElements('li').setStyle('opacity',0);}});}}});}});},closeMsg:function(){var close=$$('span.close');close.each(function(el){var msg=el.getParent('div');el.addEvents({mouseenter:function(){el.swapClass('close','closeO');},mouseleave:function(){el.swapClass('closeO','close')},click:function(e){e.stop();msg.setStyle('display','none');}});});},fold:function(toggler,toggled){if(!toggler&&!toggled){return false;}
var toggler=$$(toggler),toggled=$$(toggled);toggler.each(function(el,i){var tfx=new Fx.Reveal(toggled[i],{onStart:function(){(tfx.hiding&&el.hasClass('fold'))?el.swapClass('fold','unfold'):el.swapClass('unfold','fold');},onComplete:function(){(tfx.hiding&&el.hasClass('fold'))?el.swapClass('fold','unfold'):el.swapClass('unfold','fold');}});el.addEvents({mouseenter:function(){el.hasClass('fold')?el.swapClass('fold','foldO'):el.swapClass('unfold','unfoldO');},mouseleave:function(){el.hasClass('foldO')?el.swapClass('foldO','fold'):el.swapClass('unfoldO','unfold');},click:function(e){e.stop();tfx.toggle();}});});}};function debugmsg(msg){if(window.console){console.log(msg);}
if(document.getElementById('debugdiv')){document.getElementById('debugdiv').innerHTML+=msg;}}
window.addEvent('domready',Site.start);

