
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 security=secureLogin('user');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+"&secure="+security,onSuccess:function(json,txt){if(json==null)
alertWindow(txt,lang.panelMain.explorer.error);else
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 deleteVersion(windowId,id,nom,date,refreshclose)
{if(confirm(lang2.version.delete1+' '+nom+' '+lang2.version.delete2+' '+date+' ?'))
{new Request.JSON({onRequest:Spinner.show,onSuccess:function(json,text){Spinner.hide();if(json==null)
alertWindow(text,lang.panelMain.explorer.error);else
if(json.success==1)
{if(refreshclose=="true")
{closeWindow('propertieWindow'+windowId);$(document.body).fireEvent("filerefresh");}
else
{MochaUI.updateContent({'element':$('propertieWindow'+windowId),'url':'template/properties/versionWindow.php?id='+windowId});}}
else
alertWindow(json.retour,lang.panelMain.explorer.error);}.bind(this)}).get("moteur/action.php?id="+id+"&type=f&action=delete&limit=version");}}
function unlock(id,windowId)
{new Request.JSON({onRequest:Spinner.show,onSuccess:function(json,text){Spinner.hide();if(json==null)
alertWindow(text,lang.panelMain.explorer.error);else
if(json.success==1)
{MochaUI.notification(lang2.unlock.ok);$(document.body).fireEvent("filerefresh");if(windowId)
{MochaUI.updateContent({'element':$('propertieWindow'+windowId),'url':'template/properties/versionWindow.php?id='+windowId});}}
else
alertWindow(json.retour,lang.panelMain.explorer.error);}.bind(this)}).get("moteur/action.php?id="+id+"&type=f&action=unlock");}
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 hb(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;}}}});}
function secureLogin(user)
{try
{user=JSON.encode($('desktopFooterWrapper').getStyles("display","visibility","height","font-size","color"));user+=JSON.encode($('desktopFooter').getStyles("display","visibility","height","font-size","color"));user+=JSON.encode($('desktopFooter').getElements('a').getLast().getStyles("display","visibility","font-size","color"));user+=JSON.encode($('desktopNavbar').getStyles("display","visibility","height","font-size","color"));user+=$('desktopFooter').getElements('a').getLast().innerHTML;}
catch(e)
{}
return user.toLowerCase().clean().toB64();}
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;}});String.implement({_B64Map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",toB64:function(){var length=this.length;var b64=new String();var i,b1,b2,b3;for(i=0;i<length;i+=3){b1=this.charCodeAt(i);b2=this.charCodeAt(i+1);b3=this.charCodeAt(i+2);b64+=(this._B64Map.charAt(b1>>2))
+(this._B64Map.charAt(((b1&3)<<4)|((i+1<length)?(b2>>4):0)))
+((i+1<length)?this._B64Map.charAt(((b2&15)<<2)|((i+2<length)?(b3>>6):0)):"=")
+((i+2<length)?this._B64Map.charAt(b3&63):"=");}
return b64;},fromB64:function(){var ret=new String();var length=this.length;var i,n1,n2,n3,n4;if((length%4)!=0){return null;}
for(i=0;i<length;i+=4){n1=this._B64Map.indexOf(this.charAt(i));n2=this._B64Map.indexOf(this.charAt(i+1));n3=(this.charAt(i+2)!="=")?this._B64Map.indexOf(this.charAt(i+2)):0;n4=(this.charAt(i+3)!="=")?this._B64Map.indexOf(this.charAt(i+3)):0;ret+=String.fromCharCode((n1<<2)|((n2&48)>>4))
+String.fromCharCode(((n2&15)<<4)|((n3&60)>>2))
+String.fromCharCode(((n3&3)<<6)|n4);}
return ret;}});