
function getValues(f,nameToIgnore)
{var tabIgnoredName=nameToIgnore.split(",");var chaine="";var bool=true;var numberAff=0;for(i=0;i<=f.elements.length-1;i++)
{if(f.elements[i].type=='reset'||f.elements[i].type=='submit'||f.elements[i].type=='button'||!f.elements[i].name)
continue;if(tabIgnoredName.indexOf(f.elements[i].name)!=-1)
{chaine+=f.elements[i].name+"="+encodeURIComponent(f.elements[i].value)+"&";continue;}
if(f.elements[i].type=='radio')
{if(f.elements[i].checked)
chaine+=f.elements[i].name+"="+encodeURIComponent(f.elements[i].value)+"&";continue;}
if(f.elements[i].type=='checkbox')
{if(f.elements[i].checked)
if(f.elements[i].value!="null")
chaine+=f.elements[i].name+"="+f.elements[i].value+"&";else
chaine+=f.elements[i].name+"=1&";else
if(f.elements[i].value=="null")
chaine+=f.elements[i].name+"=0&";continue;}
if(f.elements[i].name=='email')
{if(!verifMail(f.elements[i].value))
{f.elements[i].style.border='1px solid #FF0000';MochaUI.notification(lang.windows.emailNotValid);bool=false;}
else
f.elements[i].style.border='1px solid #00FF00';}
else
{if(f.elements[i].value.length==0)
{f.elements[i].style.border='1px solid #FF0000';if(numberAff<1)
{MochaUI.notification(lang.windows.fieldRequired);numberAff++;}
bool=false;}
else
f.elements[i].style.border='1px solid #00FF00';}
chaine+=f.elements[i].name+"="+encodeURIComponent(f.elements[i].value)+"&";}
if(bool)
{return chaine;for(i=0;i<=f.elements.length-1;i++)
if(f.elements[i].type=='reset'||f.elements[i].type=='submit')
f.elements[i].disabled=true;}
return false;}
function verifMail(email)
{var verif=/^[a-zA-Z0-9]+[a-zA-Z0-9._-]*@[a-zA-Z0-9]+[a-zA-Z0-9.-]*\.[a-zA-Z]{2,4}$/;if(verif.exec(email)==null)
return false;else
return true;}
function resetForm(f)
{if(confirm(lang.windows.cancelForm))
{for(i=0;i<=f.elements.length-1;i++)
if(f.elements[i].type!='reset'&&f.elements[i].type!='submit'&&f.elements[i].type!='radio'&&f.elements[i].type!='checkbox')
f.elements[i].style.border='1px solid #C0C0C0';return true;}
else
return false;}
function connexion(form,champs)
{var chaine=getValues(form,champs);if(chaine!=false)
{var req=new Request.JSON({url:'moteur/connexion.php?type=connexion&location='+dhtmlHistory.currentLocation,method:'post',data:chaine,onSuccess:function(json){if(json.success!=1&&json.success!=2)
alertWindow(json.retour,lang.windows.error);else
{MochaUI.notification(json.retour);if(json.success==2)
window.location.reload();initializeContent(json.home);}}});req.send();}
return false;}
function deconnexion()
{var req=new Request.JSON({url:'moteur/connexion.php?type=deconnexion',method:'get',onSuccess:function(json){if(json.success!=1&&json.success!=2)
alertWindow(json.retour,lang.windows.error);else
{MochaUI.notification(json.retour);if(json.success==2)
window.location.reload();initializeContent(json.home);}}});req.send();}
function forgotPass(form,champs)
{var chaine=getValues(form,champs);if(chaine!=false)
{var req=new Request.JSON({url:'moteur/connexion.php?type=newpass',method:'post',data:chaine,onSuccess:function(json){if(json.success!=1)
alertWindow(json.retour,lang.windows.error);else
{alert(json.retour);closeWindow('forgotPassWindow');}}});req.send();}
return false;}
var sendRequest;function doImport()
{sendRequest=new Request.JSON({url:'moteur/doImport.php',method:'get',data:'',onSuccess:function(json){if(json.success!=1)
alertWindow(json.retour,lang.windows.error);else
{closeWindow('importWindow');MochaUI.notification(json.retour);$(document.body).fireEvent("refresh");}}});sendRequest.send();return false;}
function systemAction(action)
{sendRequest=new Request.JSON({url:'moteur/admin/system.php',method:'get',data:'action='+action,onSuccess:function(json){if(json.success!=1)
alertWindow(json.retour,lang.windows.error);else
{MochaUI.notification(json.retour);MochaUI.updateContent({'element':$('administrationWindow'),'url':'template/admin/gestSystem.php'});}}});sendRequest.send();return false;}
function user(form,champs,chaine,isCurrent)
{if(!chaine)
var chaine=getValues(form,champs);else
if(!confirm(lang.windows.utilisateurs.del))
return false;if(isCurrent&&!confirm(lang.windows.utilisateurs.delHimSelf))
return false;if(chaine!=false)
{var req=new Request.JSON({url:'moteur/admin/user.php',method:'post',data:chaine,onSuccess:function(json){if(json.success!=1)
alertWindow(json.retour,lang.windows.error);else
{MochaUI.notification(json.retour);MochaUI.updateContent({'element':$('administrationWindow'),'url':'template/admin/gestUsers.php'});closeWindow('userWindow');if(isCurrent)
deconnexion();}}});req.send();}
return false;}
function userOption(form,champs)
{var chaine=getValues(form,champs);if(chaine!=false)
{var req=new Request.JSON({url:'moteur/user/options.php',method:'post',data:chaine,onSuccess:function(json){if(json.success!=1&&json.success!=2)
alertWindow(json.retour,lang.windows.error);else
{MochaUI.notification(json.retour);closeWindow('userOptionWindow');if(json.success==2)
if(confirm(lang.windows.utilisateursOptions.confirmNewLang))
window.location.reload();}}});req.send();}
return false;}
function groupe(form,champs,chaine)
{if(!chaine)
var chaine=getValues(form,champs);else
if(!confirm(lang.windows.groupes.del))
return false;if(chaine!=false)
{var req=new Request.JSON({url:'moteur/admin/groupe.php',method:'post',data:chaine,onSuccess:function(json){if(json.success!=1)
alertWindow(json.retour,lang.windows.error);else
{MochaUI.notification(json.retour);MochaUI.updateContent({'element':$('administrationWindow'),'url':'template/admin/gestGroupes.php'});closeWindow('groupWindow');}}});req.send();}
return false;}
function share(chaine,idDossier,noNotify)
{if(chaine=='')
var chaine=getValues($('formShare'+idDossier),'');else
{if(!confirm(lang.windows.properties.share.del))
return false;if($('recurShare').checked)
chaine+="&recursive=1";}
if(chaine!=false)
{var req=new Request.JSON({url:'moteur/admin/share.php?idDossier='+idDossier,method:'post',data:chaine,onSuccess:function(json){if(json.success!=1)
alertWindow(json.retour,lang.windows.error);else
{if(!noNotify)
MochaUI.notification(json.retour);MochaUI.updateContent({'element':$('propertieWindow'+idDossier),'url':'template/properties/shareWindow.php?id='+idDossier});}}});req.send();}
return false;}
function addUserShare(idDossier)
{var chaine=getValues($('shareUsersAndGroups'),'');if(chaine!=false)
{var req=new Request.JSON({url:'moteur/admin/addUserShare.php',method:'post',data:"idDossier="+idDossier+"&"+chaine,onSuccess:function(json){if(json.success!=1)
alertWindow(json.retour,lang.windows.error);else
{if($('formShare'+idDossier))
share('',idDossier,true);else
MochaUI.updateContent({'element':$('propertieWindow'+idDossier),'url':'template/properties/shareWindow.php?id='+idDossier});MochaUI.notification(json.retour);closeWindow('addUserShareWindow');}}});req.send();}
return false;}
function email(chaine,idDossier,noNotify)
{if(chaine=='')
var chaine=getValues($('formEmail'+idDossier),'');else
{if(!confirm(lang.windows.properties.email.del))
return false;if($('recurEmail').checked)
chaine+="&recursive=1";}
if(chaine!=false)
{var req=new Request.JSON({url:'moteur/admin/email.php?idDossier='+idDossier,method:'post',data:chaine,onSuccess:function(json){if(json.success!=1)
alertWindow(json.retour,lang.windows.error);else
{if(!noNotify)
MochaUI.notification(json.retour);MochaUI.updateContent({'element':$('propertieWindow'+idDossier),'url':'template/properties/emailWindow.php?id='+idDossier});}}});req.send();}
return false;}
function addEmail(idDossier)
{var req=new Request.JSON({url:'moteur/admin/addEmail.php',method:'post',data:"idDossier="+idDossier,onSuccess:function(json){if(json.success!=1)
alertWindow(json.retour,lang.windows.error);else
{if($('formEmail'+idDossier))
email('',idDossier,true);else
MochaUI.updateContent({'element':$('propertieWindow'+idDossier),'url':'template/properties/emailWindow.php?id='+idDossier});MochaUI.notification(json.retour);}}});req.send();}
function saveEmail()
{var chaine=getValues($('formEditEmail'),'');if(chaine!=false)
{var req=new Request.JSON({url:'moteur/admin/saveEmail.php',method:'post',data:chaine,onSuccess:function(json){if(json.success!=1)
alertWindow(json.retour,lang.windows.error);else
{MochaUI.notification(json.retour);closeWindow("editEmailWindow");}}});req.send();}
return false;}
function saveConfig(div)
{var chaine=getValues($(div),'rep_sync,rep_syncw,user,password');if(chaine!=false)
{var req=new Request.JSON({url:'moteur/admin/saveConfig.php',method:'post',data:chaine,onSuccess:function(json){if(json.success!=1)
alertWindow(json.retour,lang.windows.error);else
{MochaUI.notification(json.retour);}}});req.send();}
return false;}
function saveLicence(div)
{var chaine=getValues($(div),'');if(chaine!=false)
{var req=new Request.JSON({url:'moteur/admin/saveLicence.php',method:'post',data:chaine,onSuccess:function(json){if(json.success!=1)
alertWindow(json.retour,lang.windows.error);else
{MochaUI.notification(json.retour);MochaUI.updateContent({'element':$('administrationWindow'),'url':'template/admin/gestLicence.php'});}}});req.send();}
return false;}
function checkEmail(el)
{if(el.checked)
$('textAreaEmail').disabled="disabled";else
$('textAreaEmail').disabled=false;}
function setPath(el)
{$('fieldHomeTxt').value=el.value;}
function setUserName(el)
{login=el.value.split('@');$('loginField').value=login[0];setPath($('loginField'));}
function userSelectedFolder(id,txt)
{$('fieldHome').value=id;$('fieldHomeTxt').value=txt;}
function checkOther(id)
{if($('checkboxWrite'+id).checked||$('checkboxEdit'+id).checked)
{$('checkboxRead'+id).checked="checked";$('checkboxRead'+id).disabled="disabled";}
else
$('checkboxRead'+id).disabled=false;}
function saveDroits(form)
{var chaine=getValues($(form),'');if(chaine!=false)
{var req=new Request.JSON({url:'moteur/admin/droits.php',method:'post',data:chaine,onSuccess:function(json){if(json.success!=1)
alertWindow(json.retour,lang.windows.error);else
{MochaUI.notification(json.retour);}}});req.send();}
return false;}
function saveQuota(form)
{var chaine=getValues($(form),'');if(chaine!=false)
{var req=new Request.JSON({url:'moteur/admin/quota.php',method:'post',data:chaine,onSuccess:function(json){if(json.success!=1)
alertWindow(json.retour,lang.windows.error);else
{MochaUI.notification(json.retour);}}});req.send();}
return false;}
function info(txt)
{$('panelInfo_pad').innerHTML="";$('panelInfo').style.backgroundColor='#f8f8f8';if(txt==undefined)
return;$('panelInfo').style.backgroundColor='#99cfeb';$('panelInfo_pad').innerHTML=txt;}
function hideBackground(id)
{$(id).setStyle("background-image","none");}
var isUploading=false;var currentRep="";function handleStartUpload(number)
{isUploading=true;}
function handleCurrentUpload(filename)
{msg="Uploading "+filename+" ("+(window._index++)+"/"+window._number+")...";}
function handleEndUpload()
{$("mainPanel").fireEvent("endUpload");MochaUI.notification(lang.panelUpload.info1);isUploading=false;}
function handleError(message)
{MochaUI.notification(message,lang.windows.error);}
var Pagination=new Class({options:{currentPage:0,lines:15},initialize:function(table,options){this.table=table;this.setOptions(options);$('pPrev').addEvent('click',function(e){e.stop();this.previousPage();}.bind(this));$('pNext').addEvent('click',function(e){e.stop();this.nextPage();}.bind(this));$('pFirst').addEvent('click',function(e){e.stop();this.firstPage();}.bind(this));$('pLast').addEvent('click',function(e){e.stop();this.lastPage();}.bind(this));this._init();this.goToPage(this.options.currentPage);},_init:function(){this.rows=$(this.table).getElements('tbody tr');if(this.rows.length<=this.options.lines)
{$('tablePagination').setStyle('display','none');return;}
this.countPages=Math.ceil(this.rows.length/this.options.lines);},_display:function(){this.rows.each(function(row,index){if(index<this.options.lines*this.options.currentPage){row.setStyle('display','none');}else if(index>this.options.lines*(this.options.currentPage+1)-1){row.setStyle('display','none');}else{row.setStyle('display','table-row');}}.bind(this));},goToPage:function(page){if(page<0||page>this.countPages-1)return;this.options.currentPage=page;if(page==0)
{$('blockPrev').setStyle('display','none');}
else
{$('blockPrev').setStyle('display','inline');}
if(page==this.countPages-1)
{$('blockNext').setStyle('display','none');}
else
{$('blockNext').setStyle('display','inline');}
this._display();},previousPage:function(){this.goToPage(this.options.currentPage-1);},nextPage:function(){this.goToPage(this.options.currentPage+1);},firstPage:function(){this.goToPage(0);},lastPage:function(){this.goToPage(this.countPages-1);}});Pagination.implement(new Options);Element.Events.resetclick={base:'click',condition:function(event){return true;}};if(Browser.Engine.presto){Element.Events.extend({contextmenu:{base:'click',condition:function(event){if(event.control||event.shift||event.alt)
{return true;}}}});}
Request.PERIODICAL=new Class({Extends:Request.JSON});Request.PERIODICAL.implement({options:{initialDelay:5000,delay:5000,limit:60000},startTimer:function(data){var fn=(function(){if(!this.running)this.send({data:data});});this.timer=fn.delay(this.options.initialDelay,this);this.lastDelay=this.options.initialDelay;this.completeCheck=function(j){$clear(this.timer);if(j)this.lastDelay=this.options.delay;else this.lastDelay=(this.lastDelay+this.options.delay).min(this.options.limit);this.timer=fn.delay(this.lastDelay,this);};this.addEvent('complete',this.completeCheck);return this;},stopTimer:function(){$clear(this.timer);this.removeEvent('complete',this.completeCheck);return this;}});