var dragstarted=false;var currentX=0;var currentY=0;var writing=false;var zindexcount=1;var activeMenu;clipboard=new Object;clipboard.from=false;clipboard.to=false;clipboard.items=new Array;var clipboardAction='copy';var upload2share=false;clipboard.fromuid=false;preloaded=new Array;var dragListBuilded=false;function getById(id){
obj=document.getElementById(id);if(!obj){
return false;
}else{
return obj;
}
}
function BrowserCheck(){
var ua=navigator.userAgent.toLowerCase();this.Opera=ua.indexOf("opera")!=-1;this.IE=(!this.Opera && (ua.indexOf("msie")!=-1));this.NS=(!this.Opera && (ua.indexOf("mozilla")!=-1) && (ua.indexOf("compatible")==-1));if(this.Opera){
this.what='Opera';
} else if(this.IE){
this.what='IE';
} else if(this.NS){
this.what='NS';
} 
}
is=new BrowserCheck();function preloadImg(src){
index=preloaded.length;preloaded[index]=new Image();preloaded[index].src=src;
}
function imageReloadSrc(){
this.src=this.src;
}
if(is.NS){
document.captureEvents(Event.MOUSEMOVE);
}
function cancelBubble(e){
if(is.IE){
eveniment=window.event;e.returnValue=false;event.cancelBubble=true;
}else{
e.stopPropagation();
}
}
function getScrollLeft(){
if(window.pageXOffset!=null){
scroll_left=window.pageXOffset;
}
if(document.body.scrollHeight!=null){
scroll_left=document.body.scrollLeft;
}
return scroll_left;
}
function getScrollTop(){
if(window.pageYOffset!=null){
scroll_top=window.pageYOffset;
}
if(document.body.scrollWidth!=null){
scroll_top=document.body.scrollTop;
}
return scroll_top;
}
function getX(event){
return event.clientX+getScrollLeft();
}
function getY(event){
return event.clientY+getScrollTop();
}
function getBodyH(){
return ((is.NS)?document.body.clientHeight:document.body.offsetHeight);
}
function getBodyW(){
return ((is.NS)?document.body.clientWidth:document.body.offsetWidth);
}
function newHiddenIframe(id){
el=document.createElement('IFRAME');el.name=id;el.id=id;el.src='blank.html';AfianHandler.iframesContainer.appendChild(el);return el;
}
function formatFileSize(filesize){
if(filesize >= 1024 && filesize < 1048576){
filesize=filesize/1024;dotpos=filesize.toString().indexOf(".");if(dotpos==-1){
dotpos=filesize.toString().length;
}
filesize=filesize.toString().substring(0,dotpos+2);filesize += " KB";
} else if(filesize >= 1048576){
filesize=(filesize/1024)/1024;dotpos=filesize.toString().indexOf(".");if(dotpos==-1){
dotpos=filesize.toString().length;
}
filesize=filesize.toString().substring(0,dotpos+2);filesize += " MB";
} else if(filesize > 0){
filesize=filesize;filesize += " Bytes";
}else{
filesize="0 Bytes";
}
return filesize;
}
Array.prototype.has4ValidElms=function(){
count=0;for (var i=0 ;i < this.length;i++){
if(this[i]!=undefined){
count++;
}
}
if(count > 3){
return true;
}else{
return false;
}
};function gluePath(pieces){
path='';for (var i=0 ;i < pieces.length;i++){
pieces[i]=addSingleSlashess(pieces[i]);if(path.substring(path.length-1, path.length)=='/'){
if(pieces[i].substring(0, 1)=='/'){
path += pieces[i].substring(1, pieces[i].length);
}else{
path += pieces[i];
}
}else{
if(pieces[i].substring(0, 1)!='/'){
if(pieces[i].length > 0){
path += '/'+pieces[i];
}else{
path += pieces[i];
}
}else{
path += pieces[i];
}
}
}
return path;
}
function addSingleSlashess(str){
return str.replace("\\","").replace("\'","\\\'");
}
function insertHTMLBeforeEnd (el, sHTML){
if(el.insertAdjacentHTML!=null){
el.insertAdjacentHTML("BeforeEnd", sHTML)
return;
}
var r=el.ownerDocument.createRange();r.selectNodeContents(el);r.collapse(false);df=r.createContextualFragment(sHTML);el.appendChild(df);
}
function isLegalFilename(filename){
bad=new Array;bad[0]="\\";bad[1]="/";bad[2]=":";bad[3]="*";bad[4]="?";bad[5]="<";bad[6]=">";bad[7]="|";bad[7]="\"";for (var i=0;i < bad.length ;i++){
if(filename.indexOf(bad[i])!=-1){
return false;
}
}
return true;
}
function debugLog(str){
debugWindow.document.write(str);debugWindow.document.write('<br>');
}
function popup(url, name, height, width, scrollbars){
var popwin;var opts="toolbar=no,status=yes,location=no,menubar=no,resizable=yes";opts += ",height=" + height + ",width=" + width + ",top="+(((screen.height/2)-height/2)-20)+",left=" + ((screen.width/2)-width/2) + ",scrollbars=" + scrollbars;popwin=window.open("", ''+name+'', opts);if(popwin){
popwin.location.replace(url);popwin.focus();
}
return popwin;
}
selectableTags=["input", "textarea", "select"];function disableselect(e){
if(is.IE){
target=event.srcElement;
}else{
target=e.target;
}
if(target.getAttribute('selectable')){
return true;
}else{
if(inArray(selectableTags, target.tagName.toLowerCase())){
return true;
}else{
return false;
}
}
}
function inArray(arr, needle){
for (var i=0 ;i < arr.length;i++){
if(arr[i]==needle){
return true;
}
}
return false;
}
if(window.name=='AfianMainWindow'){
if(typeof document.onselectstart!="undefined"){
document.onselectstart=disableselect;
}else{
document.onmousedown=disableselect;document.onmouseup=function(){return true;};
}
}
/* COOKIES */
function setCookie(key, value){
document.cookie=key + "=" + escape(value);
}
function getCookie(key){
if(document.cookie){
var start=document.cookie.indexOf(' ' + key + '=');if(start==-1){
return null;
}
var end=document.cookie.indexOf(";", start);if(end==-1){
end=document.cookie.length;
}
end -= start;var cookie=document.cookie.substr(start,end);return unescape(cookie.substr(cookie.indexOf('=') + 1, cookie.length - cookie.indexOf('=') + 1));
}else{
return null;
}
}
/* END COOKIES */
function insertJavaApplet(placeHolder, postURL){
app=document.createElement('APPLET');placeHolder.appendChild(app);app.setAttribute('archive', 'jupload.jar');app.setAttribute('code', 'wjhk.jupload.JUploadApplet.class');app.setAttribute('height', '200');app.setAttribute('width', '200');app.setAttribute('mayscript', '1');par=document.createElement('PARAM');par.setAttribute('name', 'postURL');par.setAttribute('value', postURL);app.appendChild(par);par=document.createElement('PARAM');par.setAttribute('name', 'text_labels[drag]');par.setAttribute('value', jlabels[0]);app.appendChild(par);par=document.createElement('PARAM');par.setAttribute('name', 'text_labels[uploading]');par.setAttribute('value', jlabels[1]);app.appendChild(par);par=document.createElement('PARAM');par.setAttribute('name', 'text_labels[of]');par.setAttribute('value', jlabels[2]);app.appendChild(par);par=document.createElement('PARAM');par.setAttribute('name', 'text_labels[files]');par.setAttribute('value', jlabels[3]);app.appendChild(par);
}
/* JAVA Upload */
var filearr=new Array();var JAVAUploadSettings=new Array();function onJavaUploadBeforeUpload(){
b='';for (var i=0 ;i < filearr.length ;i++){
b += filearr[i]['filename']+'\r\n';
}
//alert(b);
}
function onJavaUploadStart(){
JAVAUploadSettings['tb']=AfianHandler.allTabs[JAVAUploadSettings['tabId']];JAVAUploadSettings['tb'].showHourGlass();getById('cancelButton').style.display='block';
}
function onJavaUploadFinish(){
JAVAUploadSettings['tb'].hideHourGlass();cd(JAVAUploadSettings['tb'].basepath, false, JAVAUploadSettings['tb'].title);getById('cancelButton').style.display='none';
}
function cancelJavaUpload(){
document.applets[0].stopUpload();document.applets[0].reset();getById('cancelButton').style.display='none';JAVAUploadSettings['tb'].hideHourGlass();cd(JAVAUploadSettings['tb'].basepath, false, JAVAUploadSettings['tb'].title);var div=getById('juploadHTMLCode');var html=getById('juploadHTMLCodeTextarea').value;div.innerHTML=html;
}
function onJavaUploadReply(replytext){
console.log(replytext);boundarStart='---REPLY START---';var boundaryStartPos=replytext.indexOf(boundarStart);pos=boundaryStartPos+boundarStart.length;var withoutHeader=replytext.substring(pos);var reply=withoutHeader.substring(0, withoutHeader.length-15);replyParts=reply.split("|");replyAction=replyParts[0];replyMsg=replyParts[1];if(replyAction=='CANCEL'){
cancelJavaUpload();
}
if(replyMsg!=undefined){
AfianAlert(replyMsg);
}
}
function addFile(filename, fullpath, filesize, uploaded){
var nFile=new Array();nFile['filename']=filename;nFile['fullpath']=fullpath;nFile['filesize']=filesize;nFile['uploaded']=uploaded;filearr.push(nFile);
}
function clearFiles(){
fileArr=new Array();
}
var popMenuTemplate='<table cellspacing="0" cellpadding="0" border="0"><tr id="POPM_ID"> <td width="9" height="21"><img src="images/interface/popmenu/sp-titlebar-top-left.gif" width="9" height="21" alt="" border="0"></td> <td background="images/interface/popmenu/sp-titlebar-top-bg.gif" style="background-repeat:repeat-x;font-weight:bold;background-color:silver" align="center">POPM_TOP</td> <td width="11" height="21"><img src="images/interface/popmenu/sp-titlebar-top-right.gif" width="11" height="21" alt="" border="0"></td></tr><tr> <td width="9" height="5"><img src="images/interface/popmenu/sp-titlebar2-top-left.gif" width="9" height="5" alt="" border="0"></td> <td height="5" background="images/interface/popmenu/sp-titlebar2-top-bg.gif" style="background-repeat:repeat-x"><img src="images/interface/pixel.gif" width="1" height="5" border="0" alt=""></td> <td width="11" height="5"><img src="images/interface/popmenu/sp-titlebar2-top-right.gif" width="11" height="5" alt="" border="0"></td></tr><tr> <td width="9" background="images/interface/popmenu/sp-left.gif" style="background-repeat:repeat-y"><img src="images/interface/pixel.gif" width="9" height="1" border="0" alt=""></td> <td style="background-color:#E4E4E4;padding-left:20px;padding-right:20px;padding-top:10px" align="center">POPM_MIDDLE</td> <td width="11" background="images/interface/popmenu/sp-right.gif" style="background-repeat:repeat-y"><img src="images/interface/pixel.gif" width="9" height="1" border="0" alt=""></td></tr><tr> <td width="9" height="44"><img src="images/interface/popmenu/sp-bottom-left.gif" width="9" height="44" alt="" border="0"></td> <td height="44" background="images/interface/popmenu/sp-bottom-bg.gif" style="background-repeat:repeat-x;background-color:whitesmoke" align="center">POPM_BOTTOM</td> <td width="11" height="44"><img src="images/interface/popmenu/sp-bottom-right.gif" width="11" height="44" alt="" border="0"></td></tr></table>';function preloadAllImages(){
var imgdir='images/interface/';preloadImg(imgdir+'popmenu/sp-bottom-bg.gif');preloadImg(imgdir+'popmenu/sp-bottom-left.gif');preloadImg(imgdir+'popmenu/sp-bottom-right.gif');preloadImg(imgdir+'popmenu/sp-left.gif');preloadImg(imgdir+'popmenu/sp-right.gif');preloadImg(imgdir+'popmenu/sp-titlebar2-top-bg.gif');preloadImg(imgdir+'popmenu/sp-titlebar2-top-left.gif');preloadImg(imgdir+'popmenu/sp-titlebar2-top-right.gif');preloadImg(imgdir+'popmenu/sp-titlebar-top-bg.gif');preloadImg(imgdir+'popmenu/sp-titlebar-top-left.gif');preloadImg(imgdir+'popmenu/sp-titlebar-top-right.gif');preloadImg(imgdir+'hourglass.gif');preloadImg(imgdir+'dropdown-dot.gif');preloadImg(imgdir+'iconbg.gif');
};function clipSelected(){
clipboard.items.length=0;clipboard.fromtabid=AfianHandler.activeTab.id;clipboard.fromtabbasepath=AfianHandler.activeTab.basepath;if(AfianHandler.activeTab.uid){
clipboard.fromuid=AfianHandler.activeTab.uid;
}
for (var i=0 ;i < AfianHandler.activeTab.items.length;i++){
if(AfianHandler.activeTab.items[i]!=undefined){
if(AfianHandler.activeTab.items[i].selected){
clipboard.items[clipboard.items.length]=AfianHandler.activeTab.items[i].input_value;
}
}
}
if(AfianHandler.activeTab.section!='browseshare'){
getById('MyFilesPasteButton').style.visibility='visible';
}else{
getById('BSharePasteButton').style.visibility='visible';
}
AfianHandler.activeTab.unselectAll();
}
function resetClipboard(){
clipboard.from=false;clipboard.to=false;clipboard.items=new Array;clipboard.length=0;clipboardAction='copy';clipboard.fromuid=false;
}
function fillHiddenFormItemList(){
document.hiddenForm.itemlist.value='';for (var i=0 ;i < AfianHandler.activeTab.items.length;i++){
if(AfianHandler.activeTab.items[i]!=undefined){
if(AfianHandler.activeTab.items[i].selected){
document.hiddenForm.itemlist.value += '|'+encodeURIComponent(AfianHandler.activeTab.items[i].input_value);
}
}
}
}
function showMenu(menuId){
if(activeMenu){
hideMenu(activeMenu);
}
meniu=getById(menuId);scroll_left=getScrollLeft();scroll_top=getScrollTop();if(meniu){
var leftPos=parseInt(currentX+20);var topPos=parseInt(currentY+15);if(leftPos+meniu.offsetWidth > getBodyW()+scroll_left-25){
leftPos=leftPos+((getBodyW()+scroll_left)-(leftPos+meniu.offsetWidth+25));
}
if(topPos+meniu.offsetHeight > getBodyH()+scroll_top-10){
topPos=topPos+((getBodyH()+scroll_top)-(topPos+meniu.offsetHeight)-10);
}
meniu.style.visibility='visible';meniu.style.left=leftPos;meniu.style.top=topPos;zindexcount=zindexcount++;meniu.style.zIndex=zindexcount;hideStupidMSIEElements(meniu);if(menuId!='popmenu-alert' && menuId!='popmenu-prompt' && menuId.indexOf('context')==-1){
activeMenu=menuId;
}
}
}
function hideMenu(menuId){
getById(menuId).style.visibility='hidden';showStupidMSIEElements();
}
function centeredMenu(menuId){
if(activeMenu){
hideMenu(activeMenu);
}
scroll_left=getScrollLeft();scroll_top=getScrollTop();meniu=getById(menuId);leftPos=(getBodyW()/2)-(meniu.offsetWidth/2);topPos=(getBodyH()/2)-(meniu.offsetHeight/2);if(meniu.offsetHeight > getBodyH()){
topPos=20;
}
meniu.style.left=leftPos;meniu.style.top=topPos+scroll_top;meniu.style.visibility='visible';zindexcount=zindexcount++;meniu.style.zIndex=zindexcount;hideStupidMSIEElements(meniu);if(menuId!='popmenu-alert' && menuId!='popmenu-prompt'){
activeMenu=menuId;
}
}
function getBreadCrumbs(startHTML, path, endHTML){
str='';splited=path.split('/');pt='';if(splited.length==1){
return path;
}else{
for (var i=0 ;i < splited.length;i++){
pt=gluePath([pt, splited[i]]);str += startHTML+splited[i]+endHTML;str=str.replace(/PATH/g, pt);if(splited[i+1]!=undefined){
if(splited[i+1].substring(0, 1)!='/'){
str += '/';
}
}
}
return str;
}
}
function btnOnMUp(){this.className='button';}
function btnOnMDown(){this.className='pushedbutton';}
function btnOnMOut(){this.className='button';}
function buttonize(){
buttons=document.getElementsByTagName('TABLE');for (var i=0 ;i < buttons.length;i++){
if(buttons[i].className=='button'){
histd=buttons[i];histd.onmouseup=btnOnMUp;histd.onmousedown=btnOnMDown;histd.onmouseout=btnOnMOut;
}
}
}
function styleDisableButton(id){
if(!AfianUserPermissions['ui_has_tree']){
return true;
}
btn=getById(id);if(is.IE){
btn.disabled=true;
}else{
btn.style.color='gray';
}
}
function styleEnableButton(id){
if(!AfianUserPermissions['ui_has_tree']){
return true;
}
btn=getById(id);if(is.IE){
btn.disabled=false;
}else{
btn.style.color='black';
}
}
function toggleView(how){
if(AfianHandler.activeTab.section=='browseshare'){
postfix='-bshare';
}else{
postfix='';
}
iBtn=getById('iconBtn'+postfix);lBtn=getById('listBtn'+postfix);tBtn=getById('thumbBtn'+postfix);if(how=='icons'){
iBtn.className='viewModeSelected';lBtn.className='viewMode';tBtn.className='viewMode';
} else if(how=='list'){
iBtn.className='viewMode';lBtn.className='viewModeSelected';tBtn.className='viewMode';
}else{
iBtn.className='viewMode';lBtn.className='viewMode';tBtn.className='viewModeSelected';
}
}
function changeView(how){
tb=AfianHandler.activeTab;tb.viewMode=how;tb.destroyItems();tb.buildItems();tb.showItems();setCookie('AfianViewMode', how);
}
afian_submenus=new Array;function Afian_SubMenu(menuid, left, top){
this.obj=getById(menuid);afian_submenus[menuid]=this;this.obj.onmouseover= new Function('Afian_SubMenu.Pause(\''+menuid+'\')');this.obj.onmouseout= new Function('Afian_SubMenu.Out(\''+menuid+'\')');this.obj.onclick= new Function('Afian_SubMenu.Out(\''+menuid+'\')');this.obj.onfocus=new Function('blur()');
}
Afian_SubMenu.Over=function(menuid, left, top){
if(!afian_submenus[menuid].draw){
clearTimeout(afian_submenus[menuid].stopTimer);afian_submenus[menuid].startTimer=setTimeout('Afian_SubMenu.Draw(\''+menuid+'\', \''+left+'\', \''+top+'\')', '0');
}else{
Afian_SubMenu.Pause(menuid);
}
if(Afian_SubMenu.activeMenuId!=menuid && Afian_SubMenu.activeMenuId!=undefined){
Afian_SubMenu.Hide(Afian_SubMenu.activeMenuId);
}
}
Afian_SubMenu.Draw=function(menuid, left, top){
afian_submenus[menuid].draw=true;menu=afian_submenus[menuid].obj;menu.style.left=left;menu.style.top=top;menu.style.display='block';zindexcount++;getById('afian_hmenu').style.zIndex=zindexcount;Afian_SubMenu.activeMenuId=menuid;
}
Afian_SubMenu.Out=function(menuid){
clearTimeout(afian_submenus[menuid].startTimer);afian_submenus[menuid].stopTimer=setTimeout('Afian_SubMenu.Hide(\''+menuid+'\')', 100);
}
Afian_SubMenu.Hide=function(menuid){
menu=afian_submenus[menuid].obj;menu.style.display='none';afian_submenus[menuid].draw=false;
}
Afian_SubMenu.Pause=function(menuid){
clearTimeout(afian_submenus[menuid].stopTimer);
}
function fileNameExists(name){
for (var i=0;i < AfianHandler.activeTab.items.length;i++){
if(AfianHandler.activeTab.items[i]!=undefined){
if(AfianHandler.activeTab.items[i].icon_title==name){
return true;
}
}
}
return false;
}
function makeDragable(objid){
Drag.init(getById(objid),null);
}
function titleDrag(objid){
Drag.init(getById('popmenu-titlebar-'+objid), getById('popmenu-'+objid));
}
function makePopMenu(id){
tp=getById('popmenu-top-'+id);mid=getById('popmenu-middle-'+id);bot=getById('popmenu-bottom-'+id);content=popMenuTemplate.replace('POPM_TOP', tp.innerHTML);content=content.replace('POPM_MIDDLE', mid.innerHTML);content=content.replace('POPM_BOTTOM', bot.innerHTML);content=content.replace('POPM_ID', 'popmenu-titlebar-'+id);tp.innerHTML='';mid.innerHTML='';bot.innerHTML='';getById('popmenu-'+id).innerHTML=content;
}
function AfianAlert(str){
getById('popmenu-alert-message').innerHTML=str;centeredMenu('popmenu-alert');
}
function AfianPrompt(str, buttons){
getById('popmenu-prompt-message').innerHTML=str;str='';for (var i=0 ;i < buttons.length;i++){
str += '<td><table cellspacing="0" cellpadding="0" class="button" onclick="javascript:'+buttons[i]['onclick']+'"><tr><td align="center">'+buttons[i]['title']+'</td></tr></table></td>';
}
getById('popmenu-prompt-buttons').innerHTML='<table border="0" cellpadding="1" cellspacing="0"><tr>'+str+'</tr></table>';buttonize();centeredMenu('popmenu-prompt');
}
function addUploadFields(){
if(is.Opera){
AfianAlert('Opera browser does not support this feature.');
}else{
tr=document.createElement('TR');td=document.createElement('TD');td.align='right';td.innerHTML='<input type="file" name="uploadfiles[]" class="inputfile" onFocus="javascript:writing=true;" onBlur="javascript:writing=false;" name="upload_extra_fileds[]">';tr.appendChild(td);getById('afian_upload_fields').appendChild(tr);
}
}
function msg(type, simplealert){
if(simplealert){
fnc=alert;
}else{
fnc=AfianAlert;
}
if(type=='noperm'){
fnc(AfianMessages['You are not allowed to perform this operation']);
} else if(type=='nospace'){
fnc(AfianMessages['Not enough space']);
} else if(type=='notraffic'){
fnc(AfianMessages['Traffic quota exceeded']);
}else{
fnc(AfianMessages['Option unavailable']);
}
}
function setQuotaIndicators (wich, curr, quota){
prefix=(wich=='space')?'space':'traffic';proc=Math.round((curr*100)/quota);getById(prefix+'_curr').style.width=proc+'%';getById(prefix+'_curr_num').innerHTML=formatFileSize(curr);getById(prefix+'_quota_num').innerHTML=formatFileSize(quota);getById(prefix+'_txt').style.color= (curr >= quota)?'red':'dimgray';
}
function AdminLoadCalendar(uid){
cali=getById('califrame');cali.setAttribute('src', 'javascript:document.write(\'<body style="border:1px solid silver;padding:5px;font-size:11px;font-family: verdana, tahoma, arial, sans-serif;color:#363636;" bgcolor="#E4E4E4">'+AfianMessages['Loading, please wait...']+'</body>\')');window.setTimeout('loadCalendarUID('+uid+')', 500);
}
function loadCalendarUID(uid){
cali.setAttribute('src', '?file=calendar'+((uid)?'&uid='+uid:'')+'');
}
var hideinterval;function AfianBubbleMessage(str, delay){
if(str.length==0){
hidePopupMessage();
}
if(!delay){
delay=2100;
}
if(hideinterval){
window.clearInterval(hideinterval);
}
container=getById('bubbleMessage');container.innerHTML=str;container.style.visibility='visible';hideinterval=window.setInterval('hidePopupMessage()',delay);
}
function hidePopupMessage(){
getById('bubbleMessage').style.visibility='hidden';if(hideinterval){
window.clearInterval(hideinterval);
}
}
function debugMode(how){
ic=document.getElementById('iframesContainer');if(how==false){
ic.style.display='none';
}else{
ic.style.display='block';
}
}
var showTabCloseBtnTimer=new Array;AfianHandler={
debug : false,
allTabs : new Array,
allItems : new Array,
iframesContainer : false,
tray : false,
baseMenuContainer : false,
taskBar : false,
components : new Array,
shiftpressed : false,
uploadType : 'clasic',
currentUserId : false,
itemonclick : function(){
AfianHandler.allItems[this.id].onclick();
},
itemondblclick : function(){
AfianHandler.allItems[this.id].ondblclick();
},
itemonmouseup : function(){
AfianHandler.allItems[this.id].onmouseup();
},
itemonmouseover : function(){
AfianHandler.allItems[this.id].onmouseover();
},
itemonmouseout : function(){
AfianHandler.allItems[this.id].onmouseout();
},
loadtab : function(tid){
tabid=(tid)?tid:this.id;AfianHandler.allTabs[tabid].load();
},
closetab : function(tid){
if(AfianHandler.allTabs.has4ValidElms()){
tid=tid ? tid : this.id;AfianHandler.allTabs[tid].close(true);
}else{
AfianBubbleMessage('You must have at least one tab opened.');
}
},
deleteTab : function(tab){
for (var i=0 ;i < AfianHandler.allTabs.length;i++){
if(AfianHandler.allTabs[i]!=undefined){
if(AfianHandler.allTabs[i].id==tab.id){
delete AfianHandler.allTabs[i];delete AfianHandler.allTabs[tab.id];
}
}
}
},
showTabCloseBtn : function(tid){
if(showTabCloseBtnTimer[tid]){
window.clearTimeout(showTabCloseBtnTimer[tid]);
}
document.getElementById('tabclosebtn_'+tid).style.visibility='visible';
},
hideTabCloseBtn : function(tid){
showTabCloseBtnTimer[tid]=window.setTimeout( function(){
document.getElementById('tabclosebtn_'+tid).style.visibility='hidden';
}, 100);
}
};var firstActive=true;AfianHandler.addComponent=function (componentName, componentType){
AfianHandler.components[componentName]=new Array;AfianHandler.components[componentName]['loaded']=false;o=document.createElement('DIV');o.id=componentName;io=document.createElement('DIV');if(componentType=='basemenu'){
if(firstActive){
o.className='activeBaseMenu';firstActive=false;
}else{
o.className='hiddenBaseMenu';
}
io.className ='baseMenuContainer';io.innerHTML=AfianMessages['Building menu..'];
}
o.appendChild(io);if(componentType=='basemenu'){
getById('baseMenuContainer').appendChild(o);
}else{
getById('HTMLComponentContainer').appendChild(o);
}
AfianHandler.components[componentName]['obj']=o;
}
function Afian_Init(){
if(AfianHandler.debug){
debugWindow=popup('javascript:;', 'debugWindow', 60, 100, 'yes');
}
AfianHandler.iframesContainer=getById('iframesContainer');AfianHandler.tray=getById('afian_file_list');AfianHandler.taskBar=getById('taskBar');AfianHandler.baseMenuContainer=getById('baseMenuContainer');AfianHandler.statusBar=getById('afian_status_bar');AfianHandler.titleBar=getById('titleBar');AfianHandler.dragListContainer=getById('dragcontainer');AfianHandler.dragList=getById('draglist');
/* aici ai ramas */
allComponents=new Array(
new Array('MyFilesBaseMenu', 'basemenu'), 
new Array('MyFilesContextMenus', 'contextmenus'), 
new Array('TrashBaseMenu', 'basemenu'), 
new Array('TrashContextMenus', 'contextmenus'), 
new Array('MySharesBaseMenu', 'basemenu'), 
new Array('MySharesContextMenus', 'contextmenus'), 
new Array('BShareBaseMenu', 'basemenu'), 
new Array('BShareContextMenus', 'contextmenus'), 
new Array('SearchBaseMenu', 'basemenu'), 
new Array('SearchContextMenus', 'contextmenus'), 
new Array('BrowseZipBaseMenu', 'basemenu'), 
new Array('BrowseZipBaseMenu', 'basemenu'), 
new Array('BrowseZipContextMenus', 'contextmenus'), 
new Array('AdmGroupsBaseMenu', 'basemenu'), 
new Array('AdmGroupsContextMenus', 'contextmenus'), 
new Array('AdmUsersBaseMenu', 'basemenu'), 
new Array('AdmUsersContextMenus', 'contextmenus'), 
new Array('AdmLogsBaseMenu', 'basemenu'),
/*'AdmLogsContextMenus',*/
new Array('AdmUsersMenus', 'menus')
);for (var i=0 ;i < allComponents.length;i++){
AfianHandler.addComponent(allComponents[i][0], allComponents[i][1]);
}
AfianHandler.MyFilesDetailsTemplate='<table width="350" border="0" cellpadding="0" cellspacing="0"><tr><td width="70" align="right" nowrap>FORMATEDSIZE</td><td align="right">FTYPEDESCR</td><td width="90" align="right">EXTRA</td></tr></table>';AfianHandler.SearchDetailsTemplate='<table width="350" border="0" cellpadding="0" cellspacing="0"><tr><td><div style="white-space:nowrap;overflow:hidden;width:350px;">FTYPEDESCR</div></td></tr></table>';AfianHandler.TrashDetailsTemplate='<table width="350" border="0" cellpadding="0" cellspacing="0"><tr><td><div style="white-space:nowrap;overflow:hidden;width:210px;">FTYPEDESCR</div></td><td width="140" align="right">EXTRA</td></tr></table>';AfianHandler.MySharesDetailsTemplate='<table width="350" border="0" cellpadding="0" cellspacing="0"><tr><td><div style="white-space:nowrap;overflow:hidden;width:350px;" selectable="1">FTYPEDESCR</div></td></tr></table>';AfianHandler.BShareDetailsTemplate='<table width="350" border="0" cellpadding="0" cellspacing="0"><tr><td width="70" align="right" nowrap>FORMATEDSIZE</td><td align="right">FTYPEDESCR</td><td width="140" align="right">EXTRA</td></tr></table>';AfianHandler.BrowseZipDetailsTemplate='<table width="350" border="0" cellpadding="0" cellspacing="0"><tr><td><div style="white-space:nowrap;overflow:hidden;width:350px;">FTYPEDESCR</div></td></tr></table>';
/* admin stuff */
AfianHandler.AdmGroupsTemplate='<table width="350" border="0" cellpadding="0" cellspacing="0"><tr><td><div style="white-space:nowrap;overflow:hidden;width:350px;">FTYPEDESCR</div></td></tr></table>';AfianHandler.AdmUsersTemplate='<table width="350" border="0" cellpadding="0" cellspacing="0"><tr><td><div style="white-space:nowrap;overflow:hidden;width:350px;">FTYPEDESCR</div></td></tr></table>';
}
/*creates a new tab*/
function Afian_Tab(title, basepath, taskBarIcon){
this.title=title;this.basepath=basepath;this.countSelected=0;this.items=new Array;this.countAll=0;cookieViewMode=getCookie('AfianViewMode');this.viewMode=cookieViewMode?cookieViewMode:'icons';this.sortBy='name';this.active=false;this.busy=false;this.showHG=false;this.sortBy=false;this.sortDirection=false;this.onselect=function(){};this.onload=function(){};this.baseMenu=false;this.selSize=0;this.totalSize=0;this.browsed=false;AfianHandler['allTabs'][AfianHandler['allTabs'].length]=this;this.id=AfianHandler['allTabs'].length;AfianHandler['allTabs'][this.id]=this;this.ifram=createTabsHIframe(this.id);if(taskBarIcon){
this.taskBarIcon=taskBarIcon;
}
this.taskBarOption();return this;
}
function createTabsHIframe(tid){
/*
this.ifram=document.createElement('IFRAME');this.ifram.name='hifrm_'+this.id;this.ifram.id='hifrm_'+this.id;AfianHandler.iframesContainer.appendChild(this.ifram);
*/
insertHTMLBeforeEnd(AfianHandler.iframesContainer, '<iframe src="blank.html" id="hifrm_'+tid+'" name="hifrm_'+tid+'"></iframe>');return getById('hifrm_'+tid+'');
}
/*add an item to the tab, no dom changes*/
Afian_Tab.prototype.addItem=function (item){
index=this.items.length;this.items[index]=item;this.items[index].tab=this;this.countAll++;this.totalSize=this.totalSize+item.fsize;preloadImg(item.icon_img_src);preloadImg(item.list_img_src);preloadImg(item.thumb_img_src);
}
/*remove an item from the tab*/
Afian_Tab.prototype.removeItem=function (inputValue){
for (var i=0;i < this.items.length;i++){
if(this.items[i]!=undefined){
if(this.items[i].input_value==inputValue){
this.totalSize=this.totalSize-this.items[i].fsize;this.items[i].unbuild();delete this.items[i];this.countAll--;
}
}
}
}
Afian_Tab.prototype.focusItem=function (inputValue){
return false;for (var i=0;i < this.items.length;i++){
if(this.items[i]!=undefined){
if(this.items[i].input_value==inputValue){
/*alert(this.items[i].id);*/
document.location.hash='#'+this.items[i].id;
}
}
}
}
/*remove an item from the tab*/
Afian_Tab.prototype.removeItemArray=function (inputValue){
for (var i=0;i < this.items.length;i++){
if(this.items[i]!=undefined){
if(this.items[i].input_value==inputValue){
this.totalSize=this.totalSize-this.items[i].fsize;delete this.items[i];this.countAll--;
}
}
}
}
/*remove all items from the tab*/
Afian_Tab.prototype.removeAll=function (){
for (var i=0;i < this.items.length;i++){
if(this.items[i]!=undefined){
this.items[i].unbuild();delete this.items[i];
}
}
this.selSize=0;this.totalSize=0;this.countAll=0;this.countSelected=0;
}
/* custom selection */
Afian_Tab.prototype.customSel=function(attr, val, substr){
for (var i=0;i < this.items.length;i++){
if(this.items[i]!=undefined){
if(substr){
if(this.items[i][attr].toLowerCase().indexOf(val.toLowerCase())!=-1){
if(!this.items[i].selected){
this.items[i].select();
}
}else{
if(this.items[i].selected){
this.items[i].unselect();
}
}
}else{
if(this.items[i][attr]==val){
if(!this.items[i].selected){
this.items[i].select();
}
}else{
if(this.items[i].selected){
this.items[i].unselect();
}
}
}
}
}
}
/*unselect item*/
Afian_Tab.prototype.unselectAll=function(){
for (var i=0;i < this.items.length;i++){
if(this.items[i]!=undefined){
if(this.items[i].selected){
this.items[i].unselect();
}
}
}
this.onselect();
}
/*select item*/
Afian_Tab.prototype.selectAll=function(){
for (var i=0;i < this.items.length;i++){
if(this.items[i]!=undefined){
if(!this.items[i].selected){
this.items[i].select();
}
}
}
this.onselect();
}
Afian_Tab.prototype.debugItems=function(){
w=window.open();debugtxt='';for (var i=0 ;i < this.items.length;i++){
if(this.items[i]!=undefined){
debugtxt += i+' => '+this.items[i].title+'<br>';
}else{
debugtxt += i+' => undefined'+'<br>';
}
}
w.document.write(debugtxt);
}
Afian_Tab.prototype.buildItems=function(){
for (var i=0 ;i < this.items.length;i++){
if(this.items[i]!=undefined){
this.items[i].build();
}
}
}
Afian_Tab.prototype.destroyItems=function(){
for (var i=0 ;i < this.items.length;i++){
if(this.items[i]!=undefined){
this.items[i].unbuild();
}
}
}
Afian_Tab.prototype.showItems=function(){
for (var i=0 ;i < this.items.length;i++){
if(this.items[i]!=undefined){
this.items[i].show();
}
}
}
Afian_Tab.prototype.hideItems=function(){
for (var i=0 ;i < this.items.length;i++){
if(this.items[i]!=undefined){
this.items[i].hide();
}
}
}
Afian_Tab.prototype.selHasOnlyDirs=function(){
var temp1=0;var temp2=0;for (var i=0;i < this.items.length;i++){
if(this.items[i]!=undefined){
if(this.items[i].selected){
if(this.items[i].isdir){
temp1++;
}
temp2++;
}
}
}
if(temp1==temp2){
return true;
}else{
return false;
}
}
/*create a basemenu - not used yet*/
AfianHandler.createBaseMenu=function(){
b=document.createElement('div');b['td'].className='hiddenBaseMenu';AfianHandler.baseMenuContainer.insertBefore(b, Afian.bm.lastChild);this.baseMenu=b;
}
/**/
AfianHandler.insertBaseMenuHTML=function(componentName, content){
AfianHandler.components[componentName]['obj'].innerHTML=content;
}
AfianHandler.loadHTMLComponent=function(componentName, content){
getById('HTMLComponentContainer').innerHTML += content;
}
AfianHandler.showBaseMenu=function(componentName){
AfianHandler.components[componentName]['obj'].className='activeBaseMenu';
}
AfianHandler.hideBaseMenu=function(componentName){
AfianHandler.components[componentName]['obj'].className='hiddenBaseMenu';
}
/*create taskbar option (button) for this tab*/
Afian_Tab.prototype.taskBarOption=function(){
if(!this.taskBarIcon){
this.taskBarIcon='images/icons/taskbar/folder.gif';
}
/*width="16" height="13"*/
html='<div id="tabdiv_'+this.id+'" class="tab" onclick="AfianHandler.loadtab('+this.id+')" onmouseup="AfianHandler.check4drop('+this.id+');AfianHandler.check4dragout('+this.id+')" onmouseover="AfianHandler.check4dragover('+this.id+');AfianHandler.showTabCloseBtn('+this.id+')" onmouseout="AfianHandler.check4dragout('+this.id+');AfianHandler.hideTabCloseBtn('+this.id+')"><table border="0" cellspacing="0" cellpadding="3" width="100%"><tr><td width="18"><img src="'+this.taskBarIcon+'" border="0" alt="" height="16" width="16" id="tabimg_'+this.id+'"></td><td><div id="tabtxt_'+this.id+'">'+this.title+'</div></td><td id="tabclosebtn_'+this.id+'" style="visibility:hidden"><a href="javascript:;" onclick="AfianHandler.closetab('+this.id+')"><img src="images/interface/tab_close_button.gif" width="8" height="8" alt="" border="0"></a></td></tr></table></div>';insertHTMLBeforeEnd(AfianHandler.taskBar, html);this.taskBarOpt=new Object;this.taskBarOpt.img=getById('tabimg_'+this.id);this.taskBarOpt.div=getById('tabdiv_'+this.id);this.taskBarOpt.txt=getById('tabtxt_'+this.id);
}
/*load tab, display its icons, etc...*/
Afian_Tab.prototype.load=function(){
if(AfianHandler.activeTab==this){
return;
}
if(this.showHG){
this.showHourGlass();
}else{
this.hideHourGlass();
}
this.select();if(AfianHandler.activeTab!=undefined){
AfianHandler.activeTab.unselect();AfianHandler.activeTab.hideItems();AfianHandler.activeTab.unselectAll();AfianHandler.activeTab.active=false;hideMenu('popmenu-prompt');
}
this.showItems();this.active=true;AfianHandler.activeTab=this;if(this.onload){
/* user may switch the tabs before loading */
this.onload();
}
if(this.section=='myfiles'){
styleEnableButton('newtabbtn')
}else{
styleDisableButton('newtabbtn');
}
}
/* close/delete tab */
Afian_Tab.prototype.close=function(loadanother){
if(!this.isBusy(true)){
AfianHandler.iframesContainer.removeChild(this.ifram);if(this.timer){
window.clearTimeout(this.timer);
}
this.removeTaskBarOpt();this.destroyItems();AfianHandler.deleteTab(this);if(loadanother){
for (var i=AfianHandler.allTabs.length ;i > 0;i--){
if(AfianHandler.allTabs[i]!=undefined){
AfianHandler.allTabs[i].load();return true;
}
}
}
}
}
/* force close/delete tab */
Afian_Tab.prototype.forceClose=function(loadanother){
this.busy=false;this.close(loadanother);
}
Afian_Tab.prototype.isBusy=function(closeAction){
if(this.busy){
if(closeAction){
b=new Array;b[0]=new Array;b[0]['title']=AfianMessages['Close anyway'];b[0]['onclick']='AfianHandler.allTabs[\''+this.id+'\'].forceClose(true);hideMenu(\'popmenu-prompt\')';b[1]=new Array;b[1]['title']=AfianMessages['Cancel'];b[1]['onclick']='hideMenu(\'popmenu-prompt\')';AfianPrompt(AfianMessages['This tab has tasks in progress.'], b);
}else{
AfianAlert(AfianMessages['This tab has tasks in progress.']);
}
return true;
}else{
return false;
}
}
deleteTabFromHandler=function(){
AfianHandler.iframesContainer.removeChild(this.ifram);this.removeTaskBarOpt();this.destroyItems();for (var i=0 ;i < AfianHandler.allTabs.length;i++){
if(AfianHandler.allTabs[i]!=undefined){
AfianHandler.allTabs[i].load();return true;
}
}
}
/*get first selected item */
Afian_Tab.prototype.selectedItem=function(){
for (var i=0 ;i < this.items.length;i++){
if(this.items[i]!=undefined){
if(this.items[i].selected){
return this.items[i];
}
}
}
}
/*select taskbar option*/
Afian_Tab.prototype.select=function(){
this.taskBarOpt.div.className='selectedtab';
}
/*unselect taskbar option*/
Afian_Tab.prototype.unselect=function(){
this.taskBarOpt.div.className='tab';
}
/*remove tab from taskbar*/
Afian_Tab.prototype.removeTaskBarOpt=function(){
AfianHandler.taskBar.removeChild(this.taskBarOpt.div);
}
/*adds the tab to the taskBar*/
Afian_Tab.prototype.changeTaskBarOptTitle=function(title){
this.taskBarOpt.txt.innerHTML=title;
}
/*create a new item*/
function Afian_Item(data){
this.selected=false;this.isdir=data.isdir;this.txt=data.txt;this.cnr=false;this.fsize=data.fsize;this.formatedSize=formatFileSize(data.fsize);this.iszip=(data.iszip)?true:false;this.ondblclk=data.ondblclk;this.input_value=data.input_value;this.icon_img_src=data.icon_img_src;this.list_img_src=data.list_img_src;this.thumb_img_src=data.thumb_img_src;this.img_title=data.input_value;this.icon_title=data.icon_title;this.filetype_descr=data.filetype_descr;this.builded=false;this.inserted=false;this.ext=data.ext;this.extra=data.extra;this.id=AfianHandler['allItems'].length;this.bigthumb=data.bigthumb;AfianHandler['allItems'][this.id]=this;AfianHandler['allItems'][AfianHandler['allItems'].length]=this;
}
/*item onclick*/
Afian_Item.prototype.onclick=function(){
if(!this.selected){
this.select(true);
}else{
this.unselect(true);
}
}
/*item ondblclick*/
Afian_Item.prototype.ondblclick=function(){
eval(this.ondblclk);
}
Afian_Item.prototype.onmouseup=function(){
if(dragstarted){
if(this.isdir){
MyFilesDropDrag(gluePath([this.tab.basepath,this.input_value]));if(this.dragOverHilight){
this.onmouseout();
}
}
}
}
Afian_Item.prototype.onmouseover=function(){
if(dragstarted && this.isdir){
this.origClassName=this.obj.table.className;if(this.tab.viewMode=='icons'){
postfix="";
} else if(this.tab.viewMode=='thumbs'){
postfix="_thumbs";
}else{
postfix="_list";
}
this.obj.table.className='dragOverIcon'+postfix;this.dragOverHilight=true;
}
}
Afian_Item.prototype.onmouseout=function(){
if(dragstarted && this.isdir){
if(this.origClassName!=undefined){
this.obj.table.className=this.origClassName;this.dragOverHilight=false;delete this.origClassName;
}
}
}
/*select item*/
Afian_Item.prototype.select=function(onsel){
if(this.tab.singleSelection){
this.tab.unselectAll();
}
this.tab.countSelected++;this.tab.selSize=this.tab.selSize+this.fsize;this.selected=true;this.check();this.highlight('on');if(onsel){
this.tab.onselect(this);
}
AfianHandler.lastSelectedItem=this;
}
/*unselect item*/
Afian_Item.prototype.unselect=function(onsel){
this.tab.countSelected--;this.tab.selSize=this.tab.selSize-this.fsize;this.selected=false;this.uncheck();this.highlight('off');if(onsel){
this.tab.onselect(this);
}
}
/*build html item*/
Afian_Item.prototype.build=function(){
if(this.tab.viewMode=='icons'){
this.buildDOMobject_icon();
} else if(this.tab.viewMode=='thumbs'){
this.buildDOMobject_thumb();
}else{
this.buildDOMobject_list();
}
if(this.selected){
this.highlight('on');
}
AfianHandler.tray.appendChild(this.obj.table);
/* drag & drop */
if(this.tab.section=='myfiles'){
if(!AfianUserPermissions['readonly']){
Drag.init(this.obj.table, AfianHandler.dragListContainer);
}
}
AfianHandler.dragListContainer.onDragStart=function(x,y){
movementCounter=0;
}
AfianHandler.dragListContainer.onDrag=function(x, y){
movementCounter++;if(movementCounter > 4){
if(AfianHandler.activeTab.countSelected > 0){
/* allow dragging 1 unselected item */
if(AfianHandler.activeTab.countSelected==1){
if(Drag.obj.id!=AfianHandler.lastSelectedItem.id){
AfianHandler.lastSelectedItem.unselect();AfianHandler.allItems[Drag.obj.id].select();return;
}
}
if(!dragstarted){
BuildDragList();this.style.top=currentY+10;this.style.left=currentX+10;
}
dragstarted=true;
}else{
/* allow dragging 1 unselected item */
/*AfianBubbleMessage('You must first select the items you want to drag.');*/
AfianHandler.allItems[Drag.obj.id].select();
}
}
}
AfianHandler.dragListContainer.onDragEnd=function(x, y){
if(dragstarted){
AfianHandler.dragListContainer.style.display='none';movementCounter=0;dragListBuilded=false;AfianHandler.HideShowSelected('show');if(AfianHandler.activeTab.countSelected==1){
AfianHandler.lastSelectedItem.unselect();
}
AfianHandler.activeTab.onselect();dragstarted=false;
}
}
this.obj.table.onmouseup=AfianHandler.itemonmouseup;
/* ca sa compenseze faptul ca am scos return-ul din dom-drag cand tragi imagini */
this.obj.img.ondrag=new Function('return false;');this.obj.table.onmouseover=AfianHandler.itemonmouseover;this.obj.table.onmouseout=AfianHandler.itemonmouseout;
}
function BuildDragList(){
if(!dragListBuilded){
dc=AfianHandler.dragListContainer;dl=AfianHandler.dragList;dl.innerHTML='';if(AfianHandler.activeTab.countSelected > 10){
dl.innerHTML += '<table border="0" cellpadding="0" cellspacing="0" style="border: 1px solid #87ceeb;height:22px;background-color:#B3E8FE;clear:both;margin-bottom:2px"><tr><td nowrap style="padding:3px;">'+AfianHandler.activeTab.countSelected+' items</td></tr></table>';
}else{
for (var i=0 ;i < AfianHandler.activeTab.items.length;i++){
if(AfianHandler.activeTab.items[i]!=undefined){
if(AfianHandler.activeTab.items[i].selected){
dl.innerHTML += '<table border="0" cellpadding="1" cellspacing="0" class="dragListItem"><tr><td width="17"><img src="'+AfianHandler.activeTab.items[i].list_img_src+'" width="16" height="16"></td><td><div style="white-space:nowrap;overflow:hidden;width:110px;"> '+AfianHandler.activeTab.items[i].icon_title+'</div></td></tr></table>';
}
}
}
}
AfianHandler.HideShowSelected('hide');dc.style.display='block';hideMenu('afian_context_dir');hideMenu('afian_context_file');hideMenu('afian_context_multiple');dragListBuilded=true;
}
}
AfianHandler.HideShowSelected=function(how){
for (var i=0 ;i < AfianHandler.activeTab.items.length;i++){
if(AfianHandler.activeTab.items[i]!=undefined){
if(AfianHandler.activeTab.items[i].selected){
if(how=='show'){
AfianHandler.activeTab.items[i].show(true);
}else{
AfianHandler.activeTab.items[i].hide(true);
}
}
}
}
}
AfianHandler.check4drop=function(tid){
if(dragstarted){
/*AfianHandler.loadtab(tid);*/
if(AfianHandler.allTabs[tid].section=='myfiles'){
MyFilesDropDrag(AfianHandler.allTabs[tid].basepath);
} else if(AfianHandler.allTabs[tid].section=='trash'){
MyFilesDel();
}
}
}
AfianHandler.check4dragover=function(tid){
tb=AfianHandler.allTabs[tid];if(tb!=AfianHandler.activeTab){
if(dragstarted){
if(tb.section=='myfiles' || tb.section=='trash'){
tb.taskBarOpt.div.style.backgroundColor='#d7d7d7';
}
}
}
}
AfianHandler.check4dragout=function(tid){
tb=AfianHandler.allTabs[tid];if(tb!=AfianHandler.activeTab){
if(dragstarted){
if(tb.section=='myfiles' || tb.section=='trash'){
if(AfianHandler.activeTab==tb){
tb.taskBarOpt.div.style.backgroundColor='whitesmoke';
}else{
tb.taskBarOpt.div.style.backgroundColor='';
}
}
}
}
}
Afian_Item.prototype.unbuild=function(){
AfianHandler.tray.removeChild(this.obj.table);
}
Afian_Item.prototype.show=function(vis){
if(vis){
this.obj.table.style.visibility='visible';return true;
}
this.obj.table.style.display='block';
}
Afian_Item.prototype.hide=function(vis){
if(vis){
this.obj.table.style.visibility='hidden';return true;
}
this.obj.table.style.display='none';
}
Afian_Item.prototype.check=function (){
this.obj.chkbox.checked=true;
}
Afian_Item.prototype.uncheck=function (){
this.obj.chkbox.checked=false;
}
Afian_Item.prototype.highlight=function (how){
var postfix='';if(this.tab.viewMode=='list'){
postfix='_list';
} else if(this.tab.viewMode=='thumbs'){
postfix='_thumbs';
}
if(how=='on'){
this.obj.table.className='selIcon'+postfix;this.obj.tr1_td.className='selthumb'+postfix;
}else{
this.obj.table.className='icon'+postfix;this.obj.tr1_td.className='thumb'+postfix;
}
}
Afian_Tab.prototype.MyFiles_Browse=function (path){
path=(path!=null)?path:this.basepath;this.showHourGlass();this.ifram.src='?file=listing&tabid='+this.id+'&path='+path;tabStartTimer(this);
}
Afian_Tab.prototype.Trash_Browse=function (){
this.showHourGlass();this.ifram.src='?trash=1&sub=listing&tabid='+this.id;tabStartTimer(this);
}
Afian_Tab.prototype.MyShares_Browse=function (){
this.showHourGlass();this.ifram.src='?myshares=1&sub=listing&tabid='+this.id;tabStartTimer(this);
}
Afian_Tab.prototype.BShare_Browse=function (){
this.showHourGlass();this.ifram.src='?browseshare=1&sub=listing&tabid='+this.id+'&path='+encodeURIComponent(this.basepath)+'&uid='+this.uid;tabStartTimer(this);
}
Afian_Tab.prototype.AdmGroups_Browse=function (){
this.showHourGlass();this.ifram.src='?admin=1&section=groups&sub=listing&tabid='+this.id;tabStartTimer(this);
}
Afian_Tab.prototype.AdmUsers_Browse=function (gid, gname){
this.showHourGlass();this.ifram.src='?admin=1&section=users&sub=listing&tabid='+this.id+'&gid='+gid;tabStartTimer(this);
}
Afian_Tab.prototype.sortItems=function (by, direction){
dirs=new Array;files=new Array;for (var i=0 ;i < this.items.length;i++){
if(this.items[i]!=undefined){
if(this.items[i].isdir){
dirs[dirs.length]=this.items[i];
}else{
files[files.length]=this.items[i];
}
}
}
function byName(a, b){
 var anew=a.input_value.toLowerCase();
 var bnew=b.input_value.toLowerCase();
 if(anew < bnew) return -1;
 if(anew > bnew) return 1;
 return 0;
}
function bySize(a, b){
 if(a.fsize > b.fsize) return -1;
 if(a.fsize < b.fsize) return 1;
 return 0;
}
function byType(a, b){
 if(a.ext < b.ext) return -1;
 if(a.ext > b.ext) return 1;
 return 0;
}
if(by=='name'){
func=byName;
} else if(by=='size'){
func=bySize;
} else if(by=='type'){
func=byType;
}else{
func=byName;
}
dirs.sort(func);files.sort(func);if(direction=='desc'){
this.items.reverse();
}
this.items=dirs.concat(files);this.sortBy=by;this.sortDirection=direction;
}
function closeTabByPath(path){
for (var i=0 ;i < AfianHandler.allTabs.length;i++){
if(AfianHandler.allTabs[i]!=undefined){
if(AfianHandler.allTabs[i].basepath==path){
AfianHandler.allTabs[i].close(false);
}
}
}
}
Afian_Tab.prototype.showHourGlass=function(msg){
this.showHG=true;this.busy=true;if(this.active){
AfianHandler.statusBar.innerHTML='<img src="images/interface/hourglass.gif" width="16" height="15" border="0" alt="">';
}
this.taskBarOpt.img.src='images/interface/hourglass.gif';if(msg){
AfianHandler.statusBar.innerHTML += msg;
}
}
Afian_Tab.prototype.hideHourGlass=function(){
this.showHG=false;this.busy=false;if(this.active){
AfianHandler.statusBar.innerHTML='';this.onselect();
}
this.taskBarOpt.img.src=this.taskBarIcon;
}
function loadComponentData(component, extra){
tmpiframe=newHiddenIframe('');tmpiframe.src='components_loader/'+component+'.php'+(extra?'?'+extra:'');
}
function tabStartTimer(tb){
tb.timer=window.setTimeout('tabHasTimedOut(\''+tb.id+'\')', 30000);
}
function cancelTimeOut(tabid){
window.clearTimeout(AfianHandler.allTabs[tabid].timer);
}
function tabHasTimedOut(tabid){
/*
if(AfianHandler.allTabs[tabid]){
AfianHandler.allTabs[tabid].load();b=new Array;b[0]=new Array;b[0]['title']='Wait for server response';b[0]['onclick']='continueWaiting(\''+tabid+'\')';b[1]=new Array;b[1]['title']='Cancel action';b[1]['onclick']='cancelAction(\''+tabid+'\')';AfianPrompt('This tab has timed out.', b);
}
*/
}
function continueWaiting(tabid){
tabStartTimer(AfianHandler.allTabs[tabid]);hideMenu('popmenu-prompt');
}
function cancelAction(tabid){
tb=AfianHandler.allTabs[tabid];if(tb.section=='myfiles'){
MyFilesEndAction(tb);
}else{
tb.hideHourGlass();cancelTimeOut(tb.id);
}
stopIframe(tabid);hideMenu('popmenu-prompt');
}
function stopIframe(tabid){
tb=AfianHandler.allTabs[tabid];ifram=tb.ifram;if(is.IE){
window.frames[ifram.name].location.replace('javascript:;');
} else if(is.Opera){
AfianHandler.iframesContainer.removeChild(ifram);tb.ifram=createTabsHIframe(tb.id);
}else{
ifram.contentDocument.location.replace('javascript:;');
}
}
Afian_Item.prototype.buildDOMobject_icon=function (){
o=new Array;
/* creating the table */
o.table=document.createElement('TABLE');o.table.id=this.id;o.table.className='icon';o.table.name=this.id;o.table.style.display='none';o.tbody=document.createElement('TBODY');o.table.appendChild(o.tbody);
/* adding a row */
o.tr1=o.tbody.insertRow(0);
/* adding a cell*/
o.tr1_td=o.tr1.insertCell(0);o.tr1_td.className='thumb';o.tr1.appendChild(o.tr1_td);o.chkbox=document.createElement('INPUT');o.chkbox.type='checkbox';o.chkbox.className='iconCheckbox';o.tr1_td.appendChild(o.chkbox);if(is.IE){
o.img=new Image();
}else{
o.img=document.createElement('IMG');
}
o.tr1_td.appendChild(o.img);o.img.src=this.icon_img_src;o.table.title=this.icon_title;
/* MSIE workaround*/
o.img.onabort=imageReloadSrc;
/*window.event.cancelBubble=true;*/
/*AfianHandler.allItems[\''+this.id+'\'].obj.table.fireEvent(\'onmouseup\');*/
/* adding the second row*/
o.tr2=o.tbody.insertRow(1);
/* adding a cell to the second row */
o.tr2_td=o.tr2.insertCell(0);o.tr2_td.className='iconTitle';o.table.onclick=AfianHandler.itemonclick;if(this.ondblclk){
o.table.ondblclick=AfianHandler.itemondblclick;
}
o.tr2_td_div=document.createElement('div');o.tr2_td.appendChild(o.tr2_td_div);o.tr2_td_div.innerHTML=this.icon_title;o.tr2_td_div.setAttribute('selectable', '1');this.obj=o;
}
Afian_Item.prototype.buildDOMobject_list=function (){
o=new Array();
/* creating the table */
o.table=document.createElement('TABLE');o.table.className='icon_list';
/*o.table.border='1';*/
o.table.id=this.id;o.table.style.display='none';o.tbody=document.createElement('TBODY');o.table.appendChild(o.tbody);
/* adding a row */
o.tr1=o.tbody.insertRow(0);
/* adding a cell*/
o.tr1_td=o.tr1.insertCell(0);o.tr1_td.className='thumb_list';o.chkbox=document.createElement('INPUT');o.chkbox.type='checkbox';o.chkbox.className='iconCheckbox';o.tr1_td.appendChild(o.chkbox);if(is.IE){
o.img=new Image();
}else{
o.img=document.createElement('IMG');
}
o.img.style.height='16px';o.img.style.width='16px';o.table.title=this.icon_title;o.img.align='middle';o.tr1_td.appendChild(o.img);o.img.src=this.list_img_src;
/* MSIE workaround*/
o.img.onabort=imageReloadSrc;
/* adding a second cell to the row */
o.tr1_td2=o.tr1.insertCell(1);o.tr1_td2.className='iconTitle_list';
/* adding a third cell to the row */
o.tr1_td3=o.tr1.insertCell(2)
o.tr1_td3.className='description_list';o.table.onclick=AfianHandler.itemonclick;if(this.ondblclk){
o.table.ondblclick=AfianHandler.itemondblclick;
}
o.tr1_td2_div=document.createElement('div');o.tr1_td2.appendChild(o.tr1_td2_div);o.tr1_td2_div.innerHTML=this.icon_title;o.tr1_td2_div.setAttribute('selectable', '1');details=this.tab.detailHTML;details=details.replace('FORMATEDSIZE', this.formatedSize);details=details.replace('FSIZE', this.fsize);details=details.replace('FTYPEDESCR', this.filetype_descr);details=details.replace('EXTRA', ((this.extra==0)?'&nbsp;':this.extra));o.tr1_td3.innerHTML=details;this.obj=o;
}
Afian_Item.prototype.buildDOMobject_thumb=function (){
o=new Array();
/* creating the table */
o.table=document.createElement('TABLE');o.table.className='icon_thumbs';o.table.style.display='none';o.table.id=this.id;
/*o.table.border=1;*/
o.tbody=document.createElement('TBODY');o.table.appendChild(o.tbody);
/* adding a row */
o.tr1=o.tbody.insertRow(0);
/* adding a cell*/
o.tr1_td=o.tr1.insertCell(0);o.tr1_td.className='thumb_thumbs';o.chkbox=document.createElement('INPUT');o.chkbox.type='checkbox';o.chkbox.className='iconCheckbox';o.tr1_td.appendChild(o.chkbox);if(is.IE){
if(this.bigthumb){
o.img=new Image(90,66);
}else{
o.img=new Image(32,32);
}
}else{
o.img=document.createElement('IMG');
}
o.img.src=this.thumb_img_src;o.tr1_td.appendChild(o.img);
/* MSIE workaround(s)*/
o.img.onabort=imageReloadSrc;o.table.title=this.icon_title;
/* adding the second row*/
o.tr2=o.tbody.insertRow(1);
/* adding a cell to the second row */
o.tr2_td=o.tr2.insertCell(0);o.tr2_td.className='iconTitle_thumbs';o.table.onclick=AfianHandler.itemonclick;if(this.ondblclk){
o.table.ondblclick=AfianHandler.itemondblclick;
}
o.tr2_td_div=document.createElement('div');o.tr2_td.appendChild(o.tr2_td_div);o.tr2_td_div.innerHTML=this.icon_title;o.tr2_td_div.title=this.icon_title;o.tr2_td_div.setAttribute('selectable', '1');this.obj=o;
}
/*change directory or open new tab*/
function cd(path, newtab, title){
tb=AfianHandler.activeTab;path=path?path:gluePath([tb.basepath, tb.selectedItem().input_value]);if(AfianHandler.shiftpressed){
newtab=true;
}
if(newtab){
title=title?title:tb.selectedItem().icon_title;newTab=new Afian_Tab(title, path);newTab.section='myfiles';newTab.viewMode=tb.viewMode;newTab.onload=MyFilesOnLoad;newTab.detailHTML=AfianHandler.MyFilesDetailsTemplate;if(!AfianHandler.shiftpressed){
newTab.load();
}
newTab.MyFiles_Browse(encodeURIComponent(path));newTab.onselect=MyFilesOnSelect;
}else{
if(!tb.isBusy()){
tb.MyFiles_Browse(encodeURIComponent(path));
/*tabStartTimer(tb);????*/
}
}
}
function MyFilesFolderNA(tab, path){
AfianAlert(AfianMessages['Folder \'%1\' does not exist any more'].replace('%1', path));if(tab.basepath!='/'){
if(AfianUserPermissions['ui_has_tree']){
reloadTreeByPath('/');
}
tab.MyFiles_Browse('/');
}
}
function MyFilesOnLoad(){
if(AfianHandler.activeTab==this){
/* show the menu */
AfianHandler.showBaseMenu('MyFilesBaseMenu');AfianHandler.hideBaseMenu('TrashBaseMenu');AfianHandler.hideBaseMenu('SearchBaseMenu');AfianHandler.hideBaseMenu('MySharesBaseMenu');AfianHandler.hideBaseMenu('BShareBaseMenu');AfianHandler.hideBaseMenu('BrowseZipBaseMenu');
/*admin stuff*/
AfianHandler.hideBaseMenu('AdmGroupsBaseMenu');AfianHandler.hideBaseMenu('AdmUsersBaseMenu');AfianHandler.hideBaseMenu('AdmLogsBaseMenu');if(activeMenu){
hideMenu(activeMenu);
}
if(AfianHandler.components['MyFilesBaseMenu']['loaded']){
getById('MyFilesBreadcrumbs').innerHTML=getBreadCrumbs('<a href="javascript:;" onclick="cd(\'PATH\')" title="Click to browse \'PATH\'">', AfianHandler.activeTab.basepath, '</a>');
/* highlight the toggle */
toggleView(this.viewMode);if(clipboard.items.length > 0){
getById('MyFilesPasteButton').style.visibility='visible';
}else{
getById('MyFilesPasteButton').style.visibility='hidden';
}
}
/* toggle the tree */
if(AfianUserPermissions['ui_has_tree']){
toggleTreeByPath(this.basepath);
}
setCookie('AfianLastFolder', this.basepath);
/* change the title */
AfianHandler.titleBar.innerHTML=this.title;if(!this.showHG){
MyFilesStatusBar();
}else{
this.showHourGlass();
}
}
}
function MyFilesStatusBar(){
tb=AfianHandler.activeTab;if(tb.countSelected==0){
if(tb.countAll==0){
if(tb.browsed){
AfianHandler.statusBar.innerHTML=AfianMessages['Folder empty'];
}else{
AfianHandler.statusBar.innerHTML=AfianMessages['Accessing folder...'];
}
}else{
if(tb.countAll==1){
AfianHandler.statusBar.innerHTML=AfianMessages['One object (%1)'].replace('%1', formatFileSize(AfianHandler.activeTab.totalSize));
}else{
AfianHandler.statusBar.innerHTML=AfianMessages['%1 objects (%2)'].replace('%1', tb.countAll).replace('%2', formatFileSize(AfianHandler.activeTab.totalSize));
}
}
} else if(tb.countSelected==1){
AfianHandler.statusBar.innerHTML=AfianMessages['One object selected (%1)'].replace('%1', formatFileSize(tb.selSize));
}else{
AfianHandler.statusBar.innerHTML=AfianMessages['%1 objects selected (%2)'].replace('%1', tb.countSelected).replace('%2', formatFileSize(tb.selSize));
}
}
function MyFilesOnSelect(){
showfuncname=showMenu;hidefuncname=hideMenu;if(this.countSelected==0){
if(AfianHandler.components['MyFilesContextMenus'].loaded){
hidefuncname('afian_context_dir');hidefuncname('afian_context_file');hidefuncname('afian_context_multiple');
}
} else if(this.countSelected==1){
sel=this.selectedItem();if(AfianHandler.components['MyFilesContextMenus'].loaded){
if(sel.isdir){
showfuncname('afian_context_dir');hidefuncname('afian_context_file');hidefuncname('afian_context_multiple');
}else{
unzipcontextoption=getById('MyFilesContextUnzipOption');zipcontextoption=getById('MyFilesContextZipOption');if(sel.iszip){
unzipcontextoption.style.display='inline';zipcontextoption.style.display='none';
}else{
unzipcontextoption.style.display='none';zipcontextoption.style.display='inline';
}
showfuncname('afian_context_file');hidefuncname('afian_context_dir');hidefuncname('afian_context_multiple');
}
}
}else{
if(AfianHandler.components['MyFilesContextMenus'].loaded){
showfuncname('afian_context_multiple');hidefuncname('afian_context_dir');hidefuncname('afian_context_file');
}
}
MyFilesStatusBar();
}
/*download*/
function get(filename){
if(!AfianUserPermissions['download']){
AfianAlert(AfianMessages['You are not allowed to download files.']);return false;
}
filename=(filename)?filename:tb.selectedItem().input_value;tb=AfianHandler.activeTab;document.hiddenForm.action='?file=myfilesacting';document.hiddenForm.action += '&act=download';document.hiddenForm.action += '&fromfolder='+encodeURIComponent(tb.basepath);document.hiddenForm.action += '&filename='+encodeURIComponent(filename);document.hiddenForm.target='hifrm_'+tb.id;document.hiddenForm.submit();tb.unselectAll();
}
function multiget(){
if(!AfianUserPermissions['download']){
AfianAlert(AfianMessages['You are not allowed to download files.']);return false;
}
tb=AfianHandler.activeTab;if(!tb.isBusy()){
document.hiddenForm.action='?file=myfilesacting';document.hiddenForm.action += '&act=multidownload';document.hiddenForm.action += '&fromfolder='+encodeURIComponent(tb.basepath);document.hiddenForm.action += '&fromtabid='+tb.id;fillHiddenFormItemList();document.hiddenForm.target='hifrm_'+tb.id;tb.unselectAll();if(document.hiddenForm.itemlist.value.length > 1){
document.hiddenForm.submit();
}
}
}
/*upload*/
function Mput(){
tb=AfianHandler.activeTab;if(!tb.isBusy()){
document.afian_upload_form.action='?file=myfilesacting&act=upload&tofolder='+encodeURIComponent(tb.basepath)+'&totabid='+tb.id;
/*
hiframeid='action_hifrm_upload_'+new Date().getTime();newHiddenIframe(hiframeid);document.afian_upload_form.target=hiframeid;alert('se trimite catre frame-ul:'+hiframeid);
*/
document.afian_upload_form.target='hifrm_'+tb.id;document.afian_upload_form.submit();hideMenu('popmenu-afian_upload');
/*document.afian_upload_form.reset();//MSIE sux bigtime*/
tb.showHourGlass();
/* timers */
tabStartTimer(tb);
}
}
function MyFilesShowUpload(){
upload2share=false;centeredMenu('popmenu-afian_upload');JAVAUploadSettings['tabId']=AfianHandler.activeTab.id;if(AfianHandler.uploadType){
initJUploadApplet();
}
}
function switchUploadType(type){
if(upload2share){
AfianBubbleMessage('You cannot use drag&drop mode in a shared folder.');return false;
}
setCookie('upload_type', type);if(type=='java'){
getById('clasic_upload_btn').style.display='none';getById('afian_jupload').style.display='block';getById('afian_upload_clasic').style.display='none';initJUploadApplet();AfianHandler.uploadType='java';
}else{
getById('clasic_upload_btn').style.display='block';getById('afian_jupload').style.display='none';getById('afian_upload_clasic').style.display='block';AfianHandler.uploadType='clasic';
}
}
function initJUploadApplet(){
var tb=AfianHandler.activeTab;postURL=jUploadURL+'&path='+encodeURIComponent(tb.basepath);getById('juploadHTMLCode').innerHTML='';insertJavaApplet(getById('juploadHTMLCode'), postURL)
}
function MyFilesNewFolder(){
tb=AfianHandler.activeTab;if(!tb.isBusy()){
document.mkdirForm.action='?file=myfilesacting';document.mkdirForm.action += '&act=newfolder';document.mkdirForm.action += '&totabid='+tb.id;document.mkdirForm.action += '&path='+encodeURIComponent(tb.basepath);document.mkdirForm.target='hifrm_'+tb.id;document.mkdirForm.submit();hideMenu('popmenu-afian_mkdir');document.mkdirForm.dirName.value='Folder Name';tb.showHourGlass();
/* timers */
tabStartTimer(tb);
}
}
function MyFilesDel(){
if(AfianUserPermissions['readonly']){
AfianAlert(AfianMessages['You are not allowed to delete files.']);return false;
}
tb=AfianHandler.activeTab;if(!tb.isBusy()){
document.hiddenForm.action='?file=myfilesacting';document.hiddenForm.action += '&act=delete';document.hiddenForm.action += '&fromfolder='+encodeURIComponent(tb.basepath);document.hiddenForm.action += '&fromtabid='+tb.id;fillHiddenFormItemList();document.hiddenForm.target='hifrm_'+tb.id;tb.unselectAll();if(document.hiddenForm.itemlist.value.length > 1){
document.hiddenForm.submit();tb.showHourGlass();
/* timers */
tabStartTimer(tb);
}
}
}
function MyFilesPaste(){
getById('MyFilesPasteButton').style.visibility='hidden';if(AfianUserPermissions['readonly']){
AfianAlert(AfianMessages['You are not allowed to move or copy files.']);return false;
}
tb=AfianHandler.activeTab;if(!tb.isBusy()){
clipboard.totabid=tb.id;clipboard.totabbasepath=tb.basepath;document.hiddenForm.action='?file=myfilesacting';document.hiddenForm.action += '&act='+clipboardAction;document.hiddenForm.action += '&fromfolder='+encodeURIComponent(clipboard.fromtabbasepath);document.hiddenForm.action += '&tofolder='+encodeURIComponent(clipboard.totabbasepath);document.hiddenForm.action += '&fromtabid='+clipboard.fromtabid;document.hiddenForm.action += '&totabid='+clipboard.totabid;if(clipboard.fromuid){
document.hiddenForm.action += '&fromuid='+clipboard.fromuid;
}
document.hiddenForm.itemlist.value='';for (var i=0 ;i < clipboard.items.length;i++){
if((clipboard.fromtabbasepath!=clipboard.totabbasepath) || clipboard.fromuid!=false){
src=gluePath([clipboard.fromtabbasepath,'/',clipboard.items[i]]);if(clipboard.totabbasepath.substring(0,src.length)!=src){
document.hiddenForm.itemlist.value += '|'+encodeURIComponent(clipboard.items[i]);
}else{
AfianAlert(AfianMessages['You cannot move or copy a folder under itself']);
}
}
}
document.hiddenForm.target='hifrm_'+clipboard.totabid;if(document.hiddenForm.itemlist.value.length > 1){
document.hiddenForm.submit();tb.showHourGlass();
/* timers */
tabStartTimer(tb);
}
resetClipboard();
/*
if(AfianHandler.allTabs[clipboard.fromtabid]!=undefined){
AfianHandler.allTabs[clipboard.fromtabid].showHourGlass();
}
*/
}
}
/*
//use this to see what's in the clipboard
function clipboardTip(){
if(clipboardAction=='copy'){
} else if(clipboardAction=='cut'){
}else{
}
for (var i=0 ;i < clipboard.items.length;i++){
gluePath([clipboard.fromtabbasepath,clipboard.items[i]])
}
return str;
}
*/
function MyFilesSync(tab){
if(!tab.isBusy()){
tab.showHG=true;tab.showHourGlass();document.hiddenForm.itemlist.value='';document.hiddenForm.action='?file=myfilesacting&act=sync&tabid='+tab.id+'&path='+encodeURIComponent(tab.basepath);for (var i=0 ;i < tab.items.length;i++){
if(tab.items[i]!=undefined){
document.hiddenForm.itemlist.value += '|'+encodeURIComponent(tab.items[i].input_value);
}
}
document.hiddenForm.target='hifrm_'+tab.id;document.hiddenForm.submit();
/* timers */
tabStartTimer(tb);
/*reloadTreeByPath(tab.basepath);*/
}
}
function MyFilesRename(){
if(AfianUserPermissions['readonly']){
AfianAlert(AfianMessages['You are not allowed to rename files.']);return false;
}
tb=AfianHandler.activeTab;var newform='';for (var i=0;i < tb.items.length;i++){
if(tb.items[i]!=undefined){
if(tb.items[i].selected){
newform += '<input type="text" name="newName[]" value="'+tb.items[i].icon_title+'"><input type="hidden" value="'+encodeURIComponent(tb.items[i].input_value)+'" name="oldName[]"><br><br>';
}
}
}
getById('renameCust').innerHTML=newform;centeredMenu('popmenu-afian_rename');
/*tb.unselectAll();*/
hideMenu('afian_context_file');hideMenu('afian_context_dir');hideMenu('afian_context_multiple');
}
function MyFilesRenameSubmit(){
tb=AfianHandler.activeTab;if(!tb.isBusy()){
tb.unselectAll();document.renameForm.action='?file=myfilesacting';document.renameForm.action += '&act=rename';document.renameForm.action += '&fromtabid='+tb.id;document.renameForm.action += '&fromfolder='+encodeURIComponent(tb.basepath);document.renameForm.target='hifrm_'+tb.id;document.renameForm.submit();hideMenu('popmenu-afian_rename');document.renameForm.reset();tb.showHourGlass();
/* timers */
tabStartTimer(tb);
}
}
function MyFilesZip(){
if(AfianUserPermissions['readonly']){
AfianAlert(AfianMessages['You are not allowed to zip files.']);return false;
}
hideMenu('afian_context_file');hideMenu('afian_context_dir');hideMenu('afian_context_multiple');centeredMenu('popmenu-afian_zip');
}
function MyFilesUnZip(){
if(AfianUserPermissions['readonly']){
AfianAlert(AfianMessages['You are not allowed to unzip files.']);return false;
}
hideMenu('afian_context_file');hideMenu('afian_context_dir');hideMenu('afian_context_multiple');centeredMenu('popmenu-afian_unzip');
}
function MyFilesUnZipSubmit(){
tb=AfianHandler.activeTab;if(!tb.isBusy()){
selected=tb.selectedItem();fromtabid=tb.id;document.hiddenForm.action='?file=myfilesacting';document.hiddenForm.action += '&act=unzip';document.hiddenForm.action += '&fromfolder='+encodeURIComponent(tb.basepath);document.hiddenForm.action += '&fromtabid='+fromtabid;document.hiddenForm.action += '&filename='+encodeURIComponent(selected.input_value);document.hiddenForm.action += '&foldername='+encodeURIComponent(document.unzipForm.foldername.value);document.hiddenForm.target='hifrm_'+fromtabid;tb.unselectAll();document.hiddenForm.submit();tb.showHourGlass();hideMenu('popmenu-afian_unzip');document.unzipForm.reset();
/* timers */
tabStartTimer(tb);
}
}
function MyFilesZipSubmit(){
tb=AfianHandler.activeTab;if(!tb.isBusy()){
fromtabid=tb.id;document.hiddenForm.action='?file=myfilesacting';document.hiddenForm.action += '&act=zip';document.hiddenForm.action += '&fromfolder='+encodeURIComponent(tb.basepath);document.hiddenForm.action += '&fromtabid='+fromtabid;document.hiddenForm.action += '&zipname='+encodeURIComponent(document.zipForm.zipname.value);fillHiddenFormItemList();document.hiddenForm.target='hifrm_'+fromtabid;hideMenu('popmenu-afian_zip');tb.unselectAll();if(document.hiddenForm.itemlist.value.length > 1){
document.hiddenForm.submit();tb.showHourGlass();
/* timers */
tabStartTimer(tb);document.zipForm.reset();
}
}
}
function MyFilesEditText(newfile, confirm){
hideMenu('afian_context_file');hideMenu('afian_context_dir');hideMenu('afian_context_multiple');tb=AfianHandler.activeTab;if(newfile=="1"){
popup(baseURL+'?file=edittext&tabid='+tb.id+'&path='+encodeURIComponent(tb.basepath)+'&filename=newfile.txt&new=1', 'editastext'+Math.round(Math.random()), '460', '650', 'yes');
}else{
if(tb.countSelected==0){
AfianAlert(AfianMessages['Please select a file to edit.']);return false;
}
selected=tb.selectedItem();istext=selected.txt;if(istext==false){
if(!confirm){
b=new Array;b[0]=new Array;b[0]['title']='Yes';b[0]['onclick']='MyFilesEditText(\''+((newfile)?'true':'false')+'\', true);hideMenu(\'popmenu-prompt\')';b[1]=new Array;b[1]['title']='Cancel';b[1]['onclick']='hideMenu(\'popmenu-prompt\');AfianHandler.activeTab.onselect()';AfianPrompt(AfianMessages['This doesn\'t seem to be a text file.<br>Edit anyway?'], b);return false;
}
}
popup(baseURL+'?file=edittext&tabid='+tb.id+'&path='+encodeURIComponent(tb.basepath)+'&filename='+encodeURIComponent(selected.input_value), 'editastext'+Math.round(Math.random()), '460', '650', 'yes');tb.unselectAll();
}
}
function MyFilesByMail(){
if(AfianUserPermissions['byemail']==false){
AfianAlert(AfianMessages['You are not allowed to send files by email.']);return false;
}
tb=AfianHandler.activeTab;if(tb.selHasOnlyDirs()){
AfianAlert(AfianMessages['Please select at least one file.']);
}else{
document.hiddenForm.action='?file=byemail';document.hiddenForm.action += '&path='+encodeURIComponent(tb.basepath);document.hiddenForm.action += '&tabid='+tb.id;document.hiddenForm.itemlist.value='';fillHiddenFormItemList();pop=popup('javascript:;', 'bymail', '400', '454', 'no');document.hiddenForm.target='bymail';if(document.hiddenForm.itemlist.value.length > 1){
if(pop){
document.hiddenForm.submit();
}
}
}
}
function MyFilesComment(){
/*
if(AfianUserPermissions['readonly']){
AfianAlert(AfianMessages['You are not allowed to add comments to files.']);return false;
}
*/
tb=AfianHandler.activeTab;popup(baseURL+'?file=comments&path='+encodeURIComponent(tb.basepath)+'&object='+encodeURIComponent(tb.selectedItem().input_value), 'comments', '250', '544', 'yes');
}
function MyFilesShare(){
if(AfianUserPermissions['share']==false){
AfianAlert('You are not allowed to share folders.');return false;
}
tb=AfianHandler.activeTab;popup(baseURL+'?file=share&path='+encodeURIComponent(tb.basepath)+'&object='+encodeURIComponent(tb.selectedItem().input_value), 'share', '360', '514', 'no');
}
function MyFilesEndAction(tb){
if(tb!=undefined){
if(tb.active){
MyFilesStatusBar();
}
tb.hideHourGlass();cancelTimeOut(tb.id);
}
}
function QuickSelectStatus(){
count=AfianHandler.activeTab.countSelected;if(count > 0){
getById('quickselcount').innerHTML=AfianMessages['%1 matches'].replace('%1', count);
}else{
getById('quickselcount').innerHTML=AfianMessages['No matches'];
}
}
function MyFilesDropDrag(toPath){
if(AfianUserPermissions['readonly']){
AfianAlert(AfianMessages['You are not allowed to move files.']);return false;
}
toPath=addSingleSlashess(toPath);tb=AfianHandler.activeTab;if(!tb.isBusy()){
document.hiddenForm.action='?file=myfilesacting';document.hiddenForm.action += '&act=dropdrag';document.hiddenForm.action += '&fromfolder='+encodeURIComponent(tb.basepath);document.hiddenForm.action += '&tofolder='+encodeURIComponent(toPath);document.hiddenForm.action += '&fromtabid='+tb.id;document.hiddenForm.action += '&totabid='+tb.id;
/*
if(clipboard.fromuid){
document.hiddenForm.action += '&fromuid='+clipboard.fromuid;
}
*/
document.hiddenForm.itemlist.value='';for (var i=0 ;i < tb.items.length;i++){
if(tb.items[i]!=undefined){
if(tb.items[i].selected){
src=gluePath([tb.basepath,'/',tb.items[i].input_value]);if(toPath.substring(0,src.length)==src){
AfianBubbleMessage(AfianMessages['You cannot move or copy a folder under itself.']);
} else if(tb.basepath==toPath){
/*AfianBubbleMessage('The folder you want to move is already there.');*/
}else{
document.hiddenForm.itemlist.value += '|'+encodeURIComponent(tb.items[i].input_value);
}
}
}
}
document.hiddenForm.target='hifrm_'+tb.id;if(document.hiddenForm.itemlist.value.length > 1){
document.hiddenForm.submit();tb.showHourGlass();
/* timers */
tabStartTimer(tb);tb.unselectAll();
}
}
}
function MyFilesStartSlideShow(){
tb=AfianHandler.activeTab;popup(baseURL+'?slideshow=1&path='+encodeURIComponent(tb.basepath), 'slideshow', '550', '700', 'no');
}
function loadTrashComponents(){
if(!AfianHandler.components['TrashBaseMenu'].loaded){
loadComponentData('TrashBaseMenu');
}
if(!AfianHandler.components['TrashContextMenus'].loaded){
loadComponentData('TrashContextMenus');
}
}
function openTrash(){
loadTrashComponents();focusOpened=false;for (var i=0 ;i < AfianHandler.allTabs.length;i++){
if(AfianHandler.allTabs[i]!=undefined){
if(AfianHandler.allTabs[i].section=='trash'){
AfianHandler.allTabs[i].load();focusOpened=true;break;
}
}
}
if(!focusOpened){
trash=new Afian_Tab(AfianMessages['Trash'], 'trash@afian', 'images/tree/trash.gif');trash.viewMode='list';trash.section='trash';trash.onload=TrashOnLoad;trash.onselect=TrashOnSelect;trash.baseMenu='TrashBaseMenu';trash.detailHTML=AfianHandler.TrashDetailsTemplate;trash.load();trash.Trash_Browse();
}
}
function TrashOnLoad(){
loadTrashComponents();if(AfianHandler.activeTab==this){
AfianHandler.showBaseMenu('TrashBaseMenu');AfianHandler.hideBaseMenu('MyFilesBaseMenu');AfianHandler.hideBaseMenu('SearchBaseMenu');AfianHandler.hideBaseMenu('MySharesBaseMenu');AfianHandler.hideBaseMenu('BShareBaseMenu');AfianHandler.hideBaseMenu('BrowseZipBaseMenu')
/*admin stuff*/
AfianHandler.hideBaseMenu('AdmGroupsBaseMenu');AfianHandler.hideBaseMenu('AdmUsersBaseMenu');AfianHandler.hideBaseMenu('AdmLogsBaseMenu');if(activeMenu){
hideMenu(activeMenu);
}
toggleTreeByPath('trash@afian');AfianHandler.titleBar.innerHTML=AfianHandler.activeTab.title;TrashStatusBar();
}
}
function TrashStatusBar(){
if(AfianHandler.activeTab.countSelected==0){
if(AfianHandler.activeTab.countAll==0){
if(AfianHandler.activeTab.browsed){
AfianHandler.statusBar.innerHTML=AfianMessages['Trash empty'];
}else{
AfianHandler.statusBar.innerHTML=AfianMessages['Accessing Trash...'];
}
}else{
AfianHandler.statusBar.innerHTML=AfianMessages['%1 deleted objects (%2)'].replace('%1', AfianHandler.activeTab.countAll).replace('%2', formatFileSize(AfianHandler.activeTab.totalSize));
}
} else if(AfianHandler.activeTab.countSelected==1){
AfianHandler.statusBar.innerHTML=AfianMessages['One object selected (%1)'].replace('%1', formatFileSize(AfianHandler.activeTab.selSize));
}else{
AfianHandler.statusBar.innerHTML=AfianMessages['%1 objects selected (%2)'].replace('%1', AfianHandler.activeTab.countSelected).replace('%2', formatFileSize(AfianHandler.activeTab.selSize));
}
}
function TrashOnSelect(){
showfuncname=showMenu;hidefuncname=hideMenu;if(AfianHandler.components['TrashContextMenus'].loaded){
if(this.countSelected==0){
hidefuncname('afian_trash_context_dir');hidefuncname('afian_trash_context_file');hidefuncname('afian_trash_context_multiple');
} else if(this.countSelected==1){
sel=this.selectedItem();if(sel.isdir){
showfuncname('afian_trash_context_dir');hidefuncname('afian_trash_context_file');hidefuncname('afian_trash_context_multiple');
}else{
showfuncname('afian_trash_context_file');hidefuncname('afian_trash_context_dir');hidefuncname('afian_trash_context_multiple');
}
}else{
showfuncname('afian_trash_context_multiple');hidefuncname('afian_trash_context_dir');hidefuncname('afian_trash_context_file');
}
}
TrashStatusBar();
}
function TrashRestore(){
tb=AfianHandler.activeTab;fromtabid=tb.id;document.hiddenForm.action='?file=trashacting';document.hiddenForm.action += '&act=restore';document.hiddenForm.action += '&fromtabid='+fromtabid;fillHiddenFormItemList();document.hiddenForm.target='hifrm_'+fromtabid;if(document.hiddenForm.itemlist.value.length > 1){
tb.unselectAll();tb.showHourGlass();document.hiddenForm.submit();
}
}
function TrashDelete(){
tb=AfianHandler.activeTab;fromtabid=tb.id;document.hiddenForm.action='?file=trashacting';document.hiddenForm.action += '&act=delete';document.hiddenForm.action += '&fromtabid='+fromtabid;fillHiddenFormItemList();document.hiddenForm.target='hifrm_'+fromtabid;if(document.hiddenForm.itemlist.value.length > 1){
tb.unselectAll();tb.showHourGlass();document.hiddenForm.submit();
}
}
function EmptyTrash(){
tb=AfianHandler.activeTab;document.hiddenForm.action='?file=trashacting';document.hiddenForm.action += '&act=empty';document.hiddenForm.action += '&fromtabid='+tb.id;document.hiddenForm.target='hifrm_'+tb.id;document.hiddenForm.submit();tb.showHourGlass();
}
function loadSearchComponents(){
if(!AfianHandler.components['SearchBaseMenu'].loaded){
window.setTimeout('loadComponentData(\'SearchBaseMenu\')',300);
}
if(!AfianHandler.components['SearchContextMenus'].loaded){
window.setTimeout('loadComponentData(\'SearchContextMenus\')',300);
}
}
function MyFilesSearch(){
loadSearchComponents();search=new Afian_Tab(AfianMessages['Search'], '', 'images/icons/taskbar/search.gif');search.viewMode='list';search.section='search';search.singleSelection=true;search.q='';search.frompath=AfianHandler.activeTab.basepath;search.detailHTML=AfianHandler.SearchDetailsTemplate;search.onload=MyFilesSearchOnLoad;search.onselect=SearchOnSelect;search.baseMenu='SearchBaseMenu';search.load();
}
function MyFilesSearchOnLoad(){
loadSearchComponents();if(AfianHandler.activeTab==this){
AfianHandler.showBaseMenu('SearchBaseMenu');AfianHandler.hideBaseMenu('MyFilesBaseMenu');AfianHandler.hideBaseMenu('TrashBaseMenu');AfianHandler.hideBaseMenu('MySharesBaseMenu');AfianHandler.hideBaseMenu('BShareBaseMenu');AfianHandler.hideBaseMenu('BrowseZipBaseMenu');
/*admin stuff*/
AfianHandler.hideBaseMenu('AdmGroupsBaseMenu');AfianHandler.hideBaseMenu('AdmUsersBaseMenu');AfianHandler.hideBaseMenu('AdmLogsBaseMenu');if(activeMenu){
hideMenu(activeMenu);
}
AfianHandler.titleBar.innerHTML=AfianMessages['Search'];if(AfianHandler.components['SearchBaseMenu'].loaded){
searchFromDisplay=document.getElementById('searchFrom');searchFromDisplay.innerHTML=AfianHandler.activeTab.frompath;searchFromDisplay.title=AfianHandler.activeTab.frompath;
}
SearchStatusBar();
}
}
function SearchOnSelect(){
if(AfianHandler.components['SearchContextMenus'].loaded){
showfuncname=showMenu;hidefuncname=hideMenu;if(this.countSelected==0){
hidefuncname('afian_search_context_dir');hidefuncname('afian_search_context_file');
}else{
sel=AfianHandler.activeTab.selectedItem();if(sel.isdir){
showfuncname('afian_search_context_dir');hidefuncname('afian_search_context_file');
}else{
showfuncname('afian_search_context_file');hidefuncname('afian_search_context_dir');
}
}
}
SearchStatusBar();
}
function MyFilesGoSearch(q){
AfianHandler.activeTab.ifram.src='?search=1&sub=listing&tabid='+AfianHandler.activeTab.id+'&path='+AfianHandler.activeTab.frompath+'&q='+q;AfianHandler.activeTab.showHourGlass();
}
function SearchStatusBar(){
if(AfianHandler.activeTab.countAll==0){
if(AfianHandler.activeTab.browsed){
AfianHandler.statusBar.innerHTML=AfianMessages['No search results'];
}else{
AfianHandler.statusBar.innerHTML='';
}
}else{
AfianHandler.statusBar.innerHTML=AfianMessages['%1 objects'].replace('%1', AfianHandler.activeTab.countAll);
}
}
function SearchGet(){
tb=AfianHandler.activeTab;selected=tb.selectedItem();document.hiddenForm.action='?file=myfilesacting';document.hiddenForm.action += '&act=download';document.hiddenForm.action += '&path='+gluePath([tb.frompath, selected.input_value]);document.hiddenForm.target='hifrm_'+tb.id;document.hiddenForm.submit();tb.unselectAll();
}
function SearchGoTo(){
selected=AfianHandler.activeTab.selectedItem();path=selected.filetype_descr;if(selected.isdir){
title=AfianMessages['Locating folder...'];
}else{
title=AfianMessages['Locating file...'];
}
newTab=new Afian_Tab(title, path);newTab.section='myfiles';newTab.viewMode='icons';newTab.onload=MyFilesOnLoad;newTab.detailHTML=AfianHandler.MyFilesDetailsTemplate;newTab.load();newTab.MyFiles_Browse(encodeURIComponent(path));newTab.onselect=MyFilesOnSelect;newTab.showHourGlass();
}
function SearchSortName(){
if(tb.sortBy!='name'){
tb=AfianHandler.activeTab;tb.destroyItems();tb.sortItems('name', 'desc');tb.buildItems();tb.showItems();
}
}
function SearchSortSize(){
tb=AfianHandler.activeTab;if(tb.sortBy!='size'){
tb.destroyItems();tb.sortItems('size', 'desc');tb.buildItems();tb.showItems();
}
}
function SearchSortType(){
tb=AfianHandler.activeTab;if(tb.sortBy!='type'){
tb.destroyItems();tb.sortItems('type', 'desc');tb.buildItems();tb.showItems();
}
}
var dragstarted;var AfianTreeConfig={
rootIcon : 'images/tree/foldericon.gif',
openRootIcon : 'images/tree/openfoldericon.gif',
folderIcon : 'images/tree/foldericon.gif',
openFolderIcon : 'images/tree/openfoldericon.gif',
fileIcon : 'images/tree/file.gif',
iIcon : 'images/tree/i.gif',
lIcon : 'images/tree/l.gif',
lMinusIcon : 'images/tree/lminus.gif',
lPlusIcon : 'images/tree/lplus.gif',
tIcon : 'images/tree/t.gif',
tMinusIcon : 'images/tree/tminus.gif',
tPlusIcon : 'images/tree/tplus.gif',
blankIcon : 'images/tree/blank.gif',
defaultText : 'Tree Item',
defaultAction : 'javascript:void(0);',
defaultBehavior : 'explorer',
loadingText: AfianMessages['Loading...'],
reloadingText: AfianMessages['Reloading...']
};var selectedPath;var AfianTreeHandler={
idCounter : 0,
idPrefix : "afian_tree_",
all : new Array,
all2 : new Array,
behavior : null,
selected : null,
onSelect : null,
getId : function(){ return this.idPrefix + this.idCounter++;},
toggle : function (oItem){ this.all[oItem.id.replace('-plus','')].toggle();},
idtoggle : function (id){ this.all[id].toggle();},
reload : function (oItem){
this.all[oItem.id.replace('-icon','')].reload();
},
dropdrag: function (oItem){
this.all[oItem.id.replace('-anchor','')].dropdrag();
},
mouseover: function (oItem){
this.all[oItem.id.replace('-anchor','')].mouseover();
},
mouseout: function (oItem){
this.all[oItem.id.replace('-anchor','')].mouseout();
},
select : function (oItem){ this.all[oItem.id.replace('-anchor','')].select();},
blur : function (oItem){ this.all[oItem.id.replace('-anchor','')].blur();},
rootOnClick: function(){},
insertHTMLBeforeEnd:function (oElement, sHTML){
if(oElement.insertAdjacentHTML!=null){
oElement.insertAdjacentHTML("BeforeEnd", sHTML)
return;
}
var df;var r=oElement.ownerDocument.createRange();r.selectNodeContents(oElement);r.collapse(false);df=r.createContextualFragment(sHTML);oElement.appendChild(df);
}
};function AfianTreeAbstractNode(sText, sAction){
this.childNodes=[];this.id=AfianTreeHandler.getId();this.text=sText || AfianTreeConfig.defaultText;this.action=sAction || AfianTreeConfig.defaultAction;this._last=false;this.all2index=AfianTreeHandler.all2.length;AfianTreeHandler.all[this.id]=this;AfianTreeHandler.all2[this.all2index]=this;
}
AfianTreeAbstractNode.prototype.add=function (node, bNoIdent){
node.parentNode=this;this.childNodes[this.childNodes.length]=node;var root=this;if(this.childNodes.length >= 2){
this.childNodes[this.childNodes.length - 2]._last=false;
}
while (root.parentNode){ root=root.parentNode;}
if(root.rendered){
if(this.childNodes.length >= 2){
getById(this.childNodes[this.childNodes.length - 2].id + '-plus').src=((this.childNodes[this.childNodes.length -2].folder)?((this.childNodes[this.childNodes.length -2].open)?AfianTreeConfig.tMinusIcon:AfianTreeConfig.tPlusIcon):AfianTreeConfig.tIcon);this.childNodes[this.childNodes.length - 2].plusIcon=AfianTreeConfig.tPlusIcon;this.childNodes[this.childNodes.length - 2].minusIcon=AfianTreeConfig.tMinusIcon;this.childNodes[this.childNodes.length - 2]._last=false;
}
this._last=true;var foo=this;while (foo.parentNode){
for (var i=0;i < foo.parentNode.childNodes.length;i++){
if(foo.id==foo.parentNode.childNodes[i].id){ break;}
}
if(i==foo.parentNode.childNodes.length - 1){ foo.parentNode._last=true;}
else { foo.parentNode._last=false;}
foo=foo.parentNode;
}
AfianTreeHandler.insertHTMLBeforeEnd(getById(this.id + '-cont'), node.toString());if((!this.folder) && (!this.openIcon)){
this.icon=AfianTreeConfig.folderIcon;this.openIcon=AfianTreeConfig.openFolderIcon;
}
if(!this.folder){ this.folder=true;this.collapse(true);}
if(!bNoIdent){ this.indent();}
}
return node;
}
AfianTreeAbstractNode.prototype.toggle=function(){
if(this.folder){
if(this.open){ this.collapse();}
else { this.expand();}
}}
AfianTreeAbstractNode.prototype.select=function(){
if((AfianTreeHandler.selected) && (AfianTreeHandler.selected!=this) && (AfianTreeHandler.all[AfianTreeHandler.selected.id]!=undefined)){ AfianTreeHandler.selected.deSelect();
}
AfianTreeHandler.selected=this;if((this.openIcon)){
getById(this.id + '-icon').src=this.openIcon;
}
getById(this.id + '-anchor').className='tree-item-fulltitle-selected';if(AfianTreeHandler.onSelect){ AfianTreeHandler.onSelect(this);}
}
AfianTreeAbstractNode.prototype.deSelect=function(){
getById(this.id + '-anchor').className='tree-item-fulltitle';if((this.openIcon)){
getById(this.id + '-icon').src=this.icon;
}
AfianTreeHandler.selected=null;
}
AfianTreeAbstractNode.prototype.doExpand=function(){
/*if(AfianTreeHandler.behavior=='classic'){ getById(this.id + '-icon').src=this.openIcon;}*/
if(this.childNodes.length){ getById(this.id + '-cont').style.display='block';}
this.open=true;
}
AfianTreeAbstractNode.prototype.doCollapse=function(){
/*if(AfianTreeHandler.behavior=='classic'){ getById(this.id + '-icon').src=this.icon;}*/
if(this.childNodes.length){ getById(this.id + '-cont').style.display='none';}
this.open=false;
}
AfianTreeAbstractNode.prototype.expandAll=function(){
this.expandChildren();if((this.folder) && (!this.open)){ this.expand();}
}
AfianTreeAbstractNode.prototype.expandChildren=function(){
for (var i=0;i < this.childNodes.length;i++){
this.childNodes[i].expandAll();
} }
AfianTreeAbstractNode.prototype.collapseAll=function(){
this.collapseChildren();if((this.folder) && (this.open)){ this.collapse(true);}
}
AfianTreeAbstractNode.prototype.collapseChildren=function(){
for (var i=0;i < this.childNodes.length;i++){
this.childNodes[i].collapseAll();
} }
AfianTreeAbstractNode.prototype.indent=function(lvl, del, last, level, nodesLeft){
if(lvl==null){ lvl=-2;}
var state=0;for (var i=this.childNodes.length - 1;i >= 0 ;i--){
state=this.childNodes[i].indent(lvl + 1, del, last, level);if(state){ return;}
}
if(del){
if((level >= this._level) && (getById(this.id + '-plus'))){
if(this.folder){
getById(this.id + '-plus').src=(this.open)?AfianTreeConfig.lMinusIcon:AfianTreeConfig.lPlusIcon;this.plusIcon=AfianTreeConfig.lPlusIcon;this.minusIcon=AfianTreeConfig.lMinusIcon;
}
else if(nodesLeft){ getById(this.id + '-plus').src=AfianTreeConfig.lIcon;}
return 1;
}}
var foo=getById(this.id + '-indent-' + lvl);if(foo){
if((foo._last) || ((del) && (last))){ foo.src=AfianTreeConfig.blankIcon;}
else { foo.src=AfianTreeConfig.iIcon;}
}
return 0;
}
function AfianTree(sText, sAction, sBehavior, sIcon, sOpenIcon){
this.base=AfianTreeAbstractNode;this.base(sText, sAction);this.icon=sIcon || AfianTreeConfig.rootIcon;this.openIcon=sOpenIcon || AfianTreeConfig.openRootIcon;this.open=true;this.folder=true;this.rendered=false;this.onSelect=null;if(!AfianTreeHandler.behavior){ AfianTreeHandler.behavior=sBehavior || AfianTreeConfig.defaultBehavior;}
}
AfianTree.prototype=new AfianTreeAbstractNode;AfianTree.prototype.setBehavior=function (sBehavior){
AfianTreeHandler.behavior=sBehavior;
};AfianTree.prototype.getBehavior=function (sBehavior){
return AfianTreeHandler.behavior;
};AfianTree.prototype.getSelected=function(){
if(AfianTreeHandler.selected){ return AfianTreeHandler.selected;}
else { return null;}
}
AfianTree.prototype.remove=function(){ }
AfianTree.prototype.expand=function(){
this.doExpand();
}
AfianTree.prototype.collapse=function(b){
this.doCollapse();
}
AfianTree.prototype.getFirst=function(){
return null;
}
AfianTree.prototype.getLast=function(){
return null;
}
AfianTree.prototype.getNextSibling=function(){
return null;
}
AfianTree.prototype.getPreviousSibling=function(){
return null;
}
AfianTree.prototype.toString=function(){
var str="<div id=\"" + this.id + "\" class=\"afian-tree-item\">" +
"<span class=\"tree-item-fulltitle\" onclick=\"" + this.action + "\"><img id=\"" + this.id + "-icon\" class=\"afian-tree-icon\" src=\"" + ((AfianTreeHandler.behavior=='classic' && this.open)?this.openIcon:this.icon) + "\" onclick=\"AfianTreeHandler.rootOnClick();\">" +
"<span class=\"tree-item-title\">" + this.text + "</span></span></div>" +
"<div id=\"" + this.id + "-cont\" class=\"afian-tree-container\" style=\"display: " + ((this.open)?'block':'none') + ";\">";var sb=[];for (var i=0;i < this.childNodes.length;i++){
sb[i]=this.childNodes[i].toString(i, this.childNodes.length);
}
this.rendered=true;return str + sb.join("") + "</div>";
};function AfianTreeItem(sText, sAction, eParent, sIcon, sOpenIcon, dynamic){
this.base=AfianTreeAbstractNode;this.base(sText, sAction);this.dynamic=dynamic;if(AfianTreeConfig.usePersistence){
this.open=(AfianTreeHandler.cookies.getCookie(this.id.substr(18,this.id.length - 18))=='1')?true:false;
}else{ this.open=false;}
if(sIcon){ this.icon=sIcon;}
if(sOpenIcon){ this.openIcon=sOpenIcon;}
if(eParent){ eParent.add(this);}
}
AfianTreeItem.prototype=new AfianTreeAbstractNode;AfianTreeItem.prototype.remove=function(){
var iconSrc=getById(this.id + '-plus').src;var parentNode=this.parentNode;var prevSibling=this.getPreviousSibling(true);var nextSibling=this.getNextSibling(true);var folder=this.parentNode.folder;var last=((nextSibling) && (nextSibling.parentNode) && (nextSibling.parentNode.id==parentNode.id))?false:true;this._remove();if(parentNode.childNodes.length==0){
getById(parentNode.id + '-cont').style.display='none';parentNode.doCollapse();parentNode.folder=false;parentNode.open=false;
}
if(!nextSibling || last){ parentNode.indent(null, true, last, this._level, parentNode.childNodes.length);}
if((prevSibling==parentNode) && !(parentNode.childNodes.length)){
prevSibling.folder=false;prevSibling.open=false;iconSrc=getById(prevSibling.id + '-plus').src;iconSrc=iconSrc.replace('minus', '').replace('plus', '');getById(prevSibling.id + '-plus').src=iconSrc;getById(prevSibling.id + '-icon').src=prevSibling.icon;
}
if(getById(prevSibling.id + '-plus')){
if(parentNode==prevSibling.parentNode){
iconSrc=iconSrc.replace('minus', '').replace('plus', '');getById(prevSibling.id + '-plus').src=iconSrc;
}}}
AfianTreeItem.prototype._remove=function(){
for (var i=this.childNodes.length - 1;i >= 0;i--){
this.childNodes[i]._remove();
 }
for (var i=0;i < this.parentNode.childNodes.length;i++){
if(this==this.parentNode.childNodes[i]){
for (var j=i;j < this.parentNode.childNodes.length;j++){
this.parentNode.childNodes[j]=this.parentNode.childNodes[j+1];
}
this.parentNode.childNodes.length -= 1;if(i + 1==this.parentNode.childNodes.length){ this.parentNode._last=true;}
break;
}}
AfianTreeHandler.all[this.id]=null;delete AfianTreeHandler.all2[this.all2index];var tmp=getById(this.id);if(tmp){ tmp.parentNode.removeChild(tmp);}
tmp=getById(this.id + '-cont');if(tmp){ tmp.parentNode.removeChild(tmp);}
}
AfianTreeItem.prototype.expand=function(){
this.doExpand();getById(this.id + '-plus').src=this.minusIcon;
}
AfianTreeItem.prototype.collapse=function(b){
this.doCollapse();getById(this.id + '-plus').src=this.plusIcon;
}
AfianTreeItem.prototype.getFirst=function(){
return this.childNodes[0];
}
AfianTreeItem.prototype.getLast=function(){
if(this.childNodes[this.childNodes.length - 1].open){ return this.childNodes[this.childNodes.length - 1].getLast();}
else { return this.childNodes[this.childNodes.length - 1];}
}
AfianTreeItem.prototype.getNextSibling=function(){
for (var i=0;i < this.parentNode.childNodes.length;i++){
if(this==this.parentNode.childNodes[i]){ break;}
}
if(++i==this.parentNode.childNodes.length){ return this.parentNode.getNextSibling();}
else { return this.parentNode.childNodes[i];}
}
AfianTreeItem.prototype.getPreviousSibling=function(b){
for (var i=0;i < this.parentNode.childNodes.length;i++){
if(this==this.parentNode.childNodes[i]){ break;}
}
if(i==0){ return this.parentNode;}
else {
if((this.parentNode.childNodes[--i].open) || (b && this.parentNode.childNodes[i].folder)){ return this.parentNode.childNodes[i].getLast();}
else { return this.parentNode.childNodes[i];}
} }
AfianTreeItem.prototype.toString=function (nItem, nItemCount){
var foo=this.parentNode;var indent='';if(nItem + 1==nItemCount){ this.parentNode._last=true;}
var i=0;while (foo.parentNode){
foo=foo.parentNode;indent="<img id=\"" + this.id + "-indent-" + i + "\" src=\"" + ((foo._last)?AfianTreeConfig.blankIcon:AfianTreeConfig.iIcon) + "\" alt=\"\" width=\"19\" height=\"16\">" + indent;i++;
}
this._level=i;if(this.childNodes.length){ this.folder=1;}
else { this.open=false;}
if((this.folder) || (AfianTreeHandler.behavior!='classic')){
if(!this.icon){ this.icon=AfianTreeConfig.folderIcon;}
if(!this.openIcon){ this.openIcon=AfianTreeConfig.openFolderIcon;}
}
else if(!this.icon){ this.icon=AfianTreeConfig.fileIcon;}
var label=this.text.replace(/</g, '&lt;').replace(/>/g, '&gt;');var str="<div id=\"" + this.id + "\" class=\"afian-tree-item\" >" +
indent +
"<img id=\"" + this.id + "-plus\" src=\"" + ((this.folder)?((this.open)?((this.parentNode._last)?AfianTreeConfig.lMinusIcon:AfianTreeConfig.tMinusIcon):((this.parentNode._last)?AfianTreeConfig.lPlusIcon:AfianTreeConfig.tPlusIcon)):((this.parentNode._last)?AfianTreeConfig.lIcon:AfianTreeConfig.tIcon)) + "\" onclick=\"AfianTreeHandler.toggle(this);\" width=\"19\" height=\"16\" alt=\"\" onmouseover=\"check4dragTreePlus(this)\" onmouseout=\"cancelCheck4dragTreePlus(this)\">" +
"<span class=\"tree-item-fulltitle\" onclick=\"" + ((this.action!='X')?this.action:'javascript:AfianTreeHandler.idtoggle(\''+this.id+'\')') + "\" id=\"" + this.id + "-anchor\" " +
(this.target ? " target=\"" + this.target + "\"" : "") +
" onmouseup=\"AfianTreeHandler.dropdrag(this)\" onmouseover=\"AfianTreeHandler.mouseover(this)\" onmouseout=\"AfianTreeHandler.mouseout(this)\"><img id=\"" + this.id + "-icon\" class=\"afian-tree-icon\" src=\"" + ((this.open)?this.openIcon:this.icon) + "\" width=\"16\" height=\"16\">" +
"<span class=\"tree-item-title\">" + label + "</span></span></div>" +
"<div id=\"" + this.id + "-cont\" class=\"afian-tree-container\" style=\"display: " + ((this.open)?'block':'none') + ";\">";
/*"+((this.MyFilesItem)?"title=\"Click to browse '"+this.path+"'\"":"")+"*/
var sb=[];for (var i=0;i < this.childNodes.length;i++){
sb[i]=this.childNodes[i].toString(i,this.childNodes.length);
}
this.plusIcon=((this.parentNode._last)?AfianTreeConfig.lPlusIcon:AfianTreeConfig.tPlusIcon);this.minusIcon=((this.parentNode._last)?AfianTreeConfig.lMinusIcon:AfianTreeConfig.tMinusIcon);return str + sb.join("") + "</div>";
}
function check4dragTreePlus(item){
if(dragstarted){
item=AfianTreeHandler.all[item.id.replace('-plus','')];if(item.MyFilesItem){
if(!item.open){
item.toggleTimeOut=window.setTimeout('AfianTreeHandler.idtoggle(\''+item.id+'\')', 500);
}
}
}
}
function cancelCheck4dragTreePlus(item){
if(dragstarted){
item=AfianTreeHandler.all[item.id.replace('-plus','')];if(item.toggleTimeOut){
window.clearTimeout(item.toggleTimeOut);
}
}
}
function AfianDynTree(sText, sXmlSrc, sAction, sBehavior, sIcon, sOpenIcon){
this.AfianTree=AfianTree;this.AfianTree(sText, sAction, sBehavior, sIcon, sOpenIcon);this.src=sXmlSrc;this.loading=false;this.loaded=false;this.errorText="";if(this.open)
AfianTreeLoadData(this.src, this);else {
this._loadingItem=new AfianTreeItem(AfianTreeConfig.loadingText);this.add(this._loadingItem);
}
}
AfianDynTree.prototype=new AfianTree;AfianDynTree.prototype._AfianTree_expand=AfianTree.prototype.expand;AfianDynTree.prototype.expand=function(){
if(!this.loaded && !this.loading){
AfianTreeLoadData(this.src, this);
}
this._AfianTree_expand();
};function AfianDynTreeItem(sText, sXmlSrc, sAction, eParent, sIcon, sOpenIcon){
this.AfianTreeItem=AfianTreeItem;this.AfianTreeItem(sText, sAction, eParent, sIcon, sOpenIcon, true);this.src=sXmlSrc;this.loading=false;this.loaded=false;this.errorText="";if(this.open)
AfianTreeLoadData(this.src, this);else {
this._loadingItem=new AfianTreeItem(AfianTreeConfig.loadingText);this.add(this._loadingItem);
}
}
AfianDynTreeItem.prototype=new AfianTreeItem;AfianDynTreeItem.prototype._AfianTreeitem_expand=AfianTreeItem.prototype.expand;AfianDynTreeItem.prototype.expand=function(){
if(!this.loaded && !this.loading){
AfianTreeLoadData(this.src, this);
}
this._AfianTreeitem_expand();
};AfianDynTree.prototype.reload =
AfianDynTreeItem.prototype.reload=function (){
if(this.loaded){
var open=this.open;while (this.childNodes.length > 0)
this.childNodes[this.childNodes.length - 1].remove();this.loaded=false;this._loadingItem=new AfianTreeItem(AfianTreeConfig.reloadingText);this.add(this._loadingItem);
 this.expand();
 
 
 if(AfianTreeHandler.selected){
selectedPath=AfianTreeHandler.selected.path;
}
if(selectedPath){
this.onreload=new Function('onreload(\''+addSingleSlashess(selectedPath)+'\')');
}
 
 
}
else if(this.open && !this.loading)
AfianTreeLoadData(this.src, this);
};function AfianTreeLoadData(sSrc, jsNode){
if(jsNode.loading || jsNode.loaded)
return;jsNode.loading=true;ifrm=newHiddenIframe(jsNode.id+'-tree-iframe')
ifrm.src=sSrc+'&id='+jsNode.id;jsNode.iframe=ifrm;
}
function FolderBrowserLoadTreeItem(oNode){
var text=oNode["text"];var parent=null;var icon=oNode["icon"];var openIcon=AfianTreeConfig.openFolderIcon;var target=oNode["target"];var path=oNode['path'];var dynamic=true;var action='javascript:writePath(\''+addSingleSlashess(path)+'\', \''+addSingleSlashess(text)+'\')';var src='index.php?folder_browser_data_feeder=1&path='+encodeURIComponent(path);var jsNode=new AfianDynTreeItem(text, src, action, parent, icon, openIcon, dynamic);jsNode.path=path;return jsNode;
}
function MyFilesLoadTreeItem(oNode){
var text=oNode["text"];var parent=null;var icon=oNode["icon"];var openIcon=AfianTreeConfig.openFolderIcon;var target=oNode["target"];var path=oNode['path'];var dynamic=true;action='javascript:OpenTreeFolder(\''+addSingleSlashess(path)+'\', \''+addSingleSlashess(text)+'\')';var src='?file=tree_listing&path='+encodeURIComponent(path);var jsNode;if(src!=null && src!="")
jsNode=new AfianDynTreeItem(text, src, action, parent, icon, openIcon, dynamic);else
jsNode=new AfianTreeItem(text, action, parent, icon, openIcon);if(target!="")
jsNode.target=target;jsNode.path=path;jsNode.MyFilesItem=true;return jsNode;
}
function ListUser(oNode){
var text=oNode["text"];var parent=null;var icon="images/tree/afn.gif";var src='?listusers=1&sub=treelisting&uid='+oNode['uid'];var dynamic=true;var action='X';var jsNode;jsNode=new AfianDynTreeItem(text, src, action, parent, icon, icon, dynamic);jsNode.path=path;return jsNode;
}
function ListSharedFolder(oNode){
var text=oNode["text"];var parent=null;var icon=oNode["icon"];var openIcon=oNode["openIcon"];var target=oNode["target"];if(oNode['path']){
var path=oNode['path'];
}else{
var path='/'+text;
}
var src='?listusers=1&sub=treelisting&uid='+oNode['uid']+'&path='+oNode['uid']+'::'+encodeURIComponent(path);var action='javascript:openShare(\''+oNode['user']+'\', \''+oNode['uid']+'\', \''+path+'\')';var jsNode;jsNode=new AfianDynTreeItem(text, src, action, parent, icon, openIcon, true);jsNode.path=oNode['user']+'::'+path;return jsNode;
}
function AfianTreeDataLoaded(newIcons, jsParentNode, fnc){
if(jsParentNode.loaded)
return;if(!fnc){
fnc=MyFilesLoadTreeItem;
}
var bIndent=false;var bAnyChildren=false;jsParentNode.loaded=true;jsParentNode.loading=false;cs=newIcons
var l=cs.length;for (var i=0;i < l;i++){
bAnyChildren=true;bIndent=true;jsParentNode.add(fnc(cs[i]), true);
}
if(jsParentNode._loadingItem!=null){
jsParentNode._loadingItem.remove();bIndent=true;
}
AfianHandler.iframesContainer.removeChild(jsParentNode.iframe);if(bIndent){
jsParentNode.indent();
}
if(jsParentNode.errorText!="")
window.status=jsParentNode.errorText;if(jsParentNode.onreload){
jsParentNode.onreload();
}
}
function reloadTreeByPath(path){
for (var i=0 ;i < AfianTreeHandler.all2.length;i++){
if(AfianTreeHandler.all2[i]!=undefined && AfianTreeHandler.all2[i].path==path){
AfianTreeHandler.all2[i].reload();return;
}
}
}
function onreload(path){
toggleTreeByPath(path);
}
function toggleTreeByPath(path){
for (var i=0 ;i < AfianTreeHandler.all2.length;i++){
if((AfianTreeHandler.all2[i]!=undefined) && (AfianTreeHandler.all2[i].path==path)){
if(AfianTreeHandler.all2[i].folder){
if(!AfianTreeHandler.all2[i].open){
AfianTreeHandler.all2[i].expand();
}
}
AfianTreeHandler.all2[i].select();return;
}
}
}
function parseTree(treeitem, str){
for (var i=0 ;i < AfianTreeHandler.all2.length;i++){
if(AfianTreeHandler.all2[i]!=undefined){
str += AfianTreeHandler.all2[i].text;str += '\r\n';
}
}
return str;
}
function OpenTreeFolder(path, text){
bp=AfianHandler.activeTab.section;
//cd(path, (bp!='myfiles')?true:false, text);//opens in same tab
cd(path, true, text);
}
/* drag and drop */
AfianTreeAbstractNode.prototype.dropdrag=function (){
if(dragstarted){
if(this.MyFilesItem){
MyFilesDropDrag(this.path);
}else{
if(this.path=='trash@afian'){
MyFilesDel();
}
}
if(this.dragOverHilight){
this.mouseout();
}
}
};AfianTreeAbstractNode.prototype.mouseover=function (){
thea=getById(this.id+'-anchor');if(dragstarted){
if(this.MyFilesItem || this.path=='trash@afian'){
this.origBgColor=thea.style.backgroundColor;thea.style.backgroundColor='#d7d7d7';/*#B3E8FE*/
thea.style.textDecoration='none';this.dragOverHilight=true;
/*
getById('dragcontainer').style.border='1px solid gray';if(this.MyFilesItem){
AfianBubbleMessage('Move dragged items to \''+this.path+'\'', 10000);
}else{
AfianBubbleMessage('Move dragged items to Trash', 10000);
}
*/
}
}else{
thea.style.textDecoration='underline';thea.style.color='navy';
}
};AfianTreeAbstractNode.prototype.mouseout=function (){
thea=getById(this.id+'-anchor');if(dragstarted){
if(this.MyFilesItem || this.path=='trash@afian'){
if(this.origBgColor!=undefined){
thea.style.backgroundColor=this.origBgColor;thea.style.textDecoration='';this.dragOverHilight=false;delete this.origBgColor;
/*
getById('dragcontainer').style.border='none';AfianBubbleMessage('', 0);
*/
}
}
}else{
thea.style.textDecoration='none';thea.style.color='black';
}
};
/**************************************************
 * dom-drag.js
 * 09.25.2001
 * www.youngpup.net
 **************************************************/
var Drag={
obj : null,
init : function(o, oRoot, minX, maxX, minY, maxY, bSwapHorzRef, bSwapVertRef, fXMapper, fYMapper)
{
o.onmousedown= Drag.start;o.hmode= bSwapHorzRef ? false : true ;o.vmode= bSwapVertRef ? false : true ;o.root=oRoot && oRoot!=null ? oRoot : o ;if(o.hmode && isNaN(parseInt(o.root.style.left ))) o.root.style.left="0px";if(o.vmode && isNaN(parseInt(o.root.style.top ))) o.root.style.top="0px";if(!o.hmode && isNaN(parseInt(o.root.style.right ))) o.root.style.right="0px";if(!o.vmode && isNaN(parseInt(o.root.style.bottom))) o.root.style.bottom="0px";o.minX= typeof minX!='undefined' ? minX : null;o.minY= typeof minY!='undefined' ? minY : null;o.maxX= typeof maxX!='undefined' ? maxX : null;o.maxY= typeof maxY!='undefined' ? maxY : null;o.xMapper=fXMapper ? fXMapper : null;o.yMapper=fYMapper ? fYMapper : null;o.root.onDragStart= new Function();o.root.onDragEnd= new Function();o.root.onDrag= new Function();o.root.onmouseover=function(){
zindexcount=zindexcount+100;this.style.zIndex=zindexcount;
}
},
start : function(e)
{
if(is.IE){
eveniment=window.event;
}else{
eveniment=e;
}
if(is.IE){
elementul=eveniment.srcElement;
}else{
elementul=eveniment.target;
}
if(elementul.tagName=='A' || elementul.tagName=='INPUT'){
document.onmousemove= null;document.onmouseup= null;return false;
}
var o=Drag.obj=this;e=Drag.fixE(e);var y=parseInt(o.vmode ? o.root.style.top : o.root.style.bottom);var x=parseInt(o.hmode ? o.root.style.left : o.root.style.right );o.root.onDragStart(x, y);o.lastMouseX= e.clientX;o.lastMouseY= e.clientY;if(o.hmode){
if(o.minX!=null)o.minMouseX= e.clientX - x + o.minX;if(o.maxX!=null)o.maxMouseX= o.minMouseX + o.maxX - o.minX;
}else{
if(o.minX!=null) o.maxMouseX=-o.minX + e.clientX + x;if(o.maxX!=null) o.minMouseX=-o.maxX + e.clientX + x;
}
if(o.vmode){
if(o.minY!=null)o.minMouseY= e.clientY - y + o.minY;if(o.maxY!=null)o.maxMouseY= o.minMouseY + o.maxY - o.minY;
}else{
if(o.minY!=null) o.maxMouseY=-o.minY + e.clientY + y;if(o.maxY!=null) o.minMouseY=-o.maxY + e.clientY + y;
}
document.onmousemove= Drag.drag;document.onmouseup= Drag.end;return false;
},
drag : function(e){
e=Drag.fixE(e);var o=Drag.obj;hideStupidMSIEElements(Drag.obj.root);var ey= e.clientY;var ex= e.clientX;var y=parseInt(o.vmode ? o.root.style.top : o.root.style.bottom);var x=parseInt(o.hmode ? o.root.style.left : o.root.style.right );var nx, ny;if(o.minX!=null) ex=o.hmode ? Math.max(ex, o.minMouseX) : Math.min(ex, o.maxMouseX);if(o.maxX!=null) ex=o.hmode ? Math.min(ex, o.maxMouseX) : Math.max(ex, o.minMouseX);if(o.minY!=null) ey=o.vmode ? Math.max(ey, o.minMouseY) : Math.min(ey, o.maxMouseY);if(o.maxY!=null) ey=o.vmode ? Math.min(ey, o.maxMouseY) : Math.max(ey, o.minMouseY);nx=x + ((ex - o.lastMouseX) * (o.hmode ? 1 : -1));ny=y + ((ey - o.lastMouseY) * (o.vmode ? 1 : -1));if(o.xMapper)nx=o.xMapper(y)
else if(o.yMapper)ny=o.yMapper(x)
Drag.obj.root.style[o.hmode ? "left" : "right"]=nx + "px";Drag.obj.root.style[o.vmode ? "top" : "bottom"]=ny + "px";Drag.obj.lastMouseX= ex;Drag.obj.lastMouseY= ey;Drag.obj.root.onDrag(nx, ny, Drag.obj);if(elementul.tagName!="IMG"){ /*MSIE image dragging workaround*/
return false;
}
},
end : function()
{
document.onmousemove=null;document.onmouseup=null;Drag.obj.root.onDragEnd(parseInt(Drag.obj.root.style[Drag.obj.hmode ? "left" : "right"]), 
parseInt(Drag.obj.root.style[Drag.obj.vmode ? "top" : "bottom"]), Drag.obj);Drag.obj=null;
},
fixE : function(e)
{
if(typeof e=='undefined') e=window.event;if(typeof e.layerX=='undefined') e.layerX=e.offsetX;if(typeof e.layerY=='undefined') e.layerY=e.offsetY;return e;
}
};var allDropDownMenus=false;function preloadStupidMSIEElementsPosition(){
allDropDownMenus=document.getElementsByTagName('select');preloadedPositions=new Array;for (var i=0;i < allDropDownMenus.length;i++){
index=preloadedPositions.length;p=getAbsolutePos(allDropDownMenus[i]);preloadedPositions[index]=new Array;preloadedPositions[index]['object']=allDropDownMenus[i];preloadedPositions[index]['x']=p.x;preloadedPositions[index]['y']=p.y;preloadedPositions[index]['h']=allDropDownMenus[i].offsetHeight;preloadedPositions[index]['w']=allDropDownMenus[i].offsetWidth;preloadedPositions[index]['nohide']=allDropDownMenus[i].getAttribute('nohide');
}
}
function prelIsOver(dragElX, dragElY, dragElH, dragElW, i){
targetEl=preloadedPositions[i];if((dragElX > targetEl['x']+targetEl['w']) || (dragElX+dragElW < targetEl['x']) || (dragElY > targetEl['y']+targetEl['h']) || (dragElY+dragElH < targetEl['y'])){
return false;
}else{
if(targetEl['nohide']=="1"){
return false;
}else{
return true;
}
}
}
function getAbsolutePos(el){
var r={ x: el.offsetLeft, y: el.offsetTop };if(el.offsetParent){
var tmp=getAbsolutePos(el.offsetParent);r.x += tmp.x;r.y += tmp.y;
}
return r;
}
var tempDiv=Array;function hideStupidMSIEElements(dragEl){
dragElX=dragEl.offsetLeft;dragElY=dragEl.offsetTop;dragElH=dragEl.offsetHeight;dragElW=dragEl.offsetWidth;for (var i=0;i<allDropDownMenus.length;i++){
if(prelIsOver(dragElX,dragElY,dragElH,dragElW,i)){
/*
if(!tempDiv[i]){
tempDiv[i]=document.createElement("div");tempDiv[i].style.border='1px solid silver';tempDiv[i].style.backgroundColor='white';tempDiv[i].style.overflow='hidden';tempDiv[i].style.height=preloadedPositions[i]['h']+'px';tempDiv[i].style.width=preloadedPositions[i]['w']+'px';allDropDownMenus[i].parentNode.appendChild(tempDiv[i]);tempDiv[i].appendChild(allDropDownMenus[i]);
}
*/
allDropDownMenus[i].style.visibility='hidden';
}else{
/*
if(tempDiv[i]){
if(tempDiv[i].firstChild){
tempDiv[i].parentNode.appendChild(tempDiv[i].firstChild);
}
allDropDownMenus[i].parentNode.removeChild(tempDiv[i]);tempDiv[i]=false;
}*/
allDropDownMenus[i].style.width=preloadedPositions[i]['w']+1;allDropDownMenus[i].style.height=preloadedPositions[i]['h']+1;allDropDownMenus[i].style.visibility='inherit';
}
}
}
function showStupidMSIEElements(){
for (var i=0;i < allDropDownMenus.length;i ++){
allDropDownMenus[i].style.visibility='inherit';
}
}
function loadMySharesComponents(){
if(!AfianHandler.components['MySharesBaseMenu'].loaded){
loadComponentData('MySharesBaseMenu');
}
if(!AfianHandler.components['MySharesContextMenus'].loaded){
loadComponentData('MySharesContextMenus');
}
}
function openMyShares(){
loadMySharesComponents();focusOpened=false;for (var i=0 ;i < AfianHandler.allTabs.length;i++){
if(AfianHandler.allTabs[i]!=undefined){
if(AfianHandler.allTabs[i].section=='myshares'){
AfianHandler.allTabs[i].load();focusOpened=true;break;
}
}
}
if(!focusOpened){
MyShares=new Afian_Tab(AfianMessages['My Shares'], 'myshares@afian', 'images/icons/filetypes/small/folder-shared.gif');MyShares.viewMode='list';MyShares.section='myshares';MyShares.onload=MySharesOnLoad;MyShares.onselect=MySharesOnSelect;MyShares.baseMenu='MySharesBaseMenu';MyShares.detailHTML=AfianHandler.MySharesDetailsTemplate;MyShares.load();MyShares.MyShares_Browse();
}
}
function MySharesOnSelect(){
showfuncname=showMenu;hidefuncname=hideMenu;if(AfianHandler.components['MySharesContextMenus'].loaded){
if(this.countSelected==0){
hidefuncname('afian_myshares_context_dir');hidefuncname('afian_myshares_context_multiple');
} else if(this.countSelected==1){
showfuncname('afian_myshares_context_dir');hidefuncname('afian_myshares_context_multiple');
}else{
showfuncname('afian_myshares_context_multiple');hidefuncname('afian_myshares_context_dir');
}
}
MySharesStatusBar();
}
function MySharesOnLoad(){
loadMySharesComponents();if(AfianHandler.activeTab==this){
AfianHandler.showBaseMenu('MySharesBaseMenu');AfianHandler.hideBaseMenu('MyFilesBaseMenu');AfianHandler.hideBaseMenu('TrashBaseMenu');AfianHandler.hideBaseMenu('SearchBaseMenu');AfianHandler.hideBaseMenu('BShareBaseMenu');AfianHandler.hideBaseMenu('BrowseZipBaseMenu');
/*admin stuff*/
AfianHandler.hideBaseMenu('AdmGroupsBaseMenu');AfianHandler.hideBaseMenu('AdmUsersBaseMenu');AfianHandler.hideBaseMenu('AdmLogsBaseMenu');if(activeMenu){
hideMenu(activeMenu);
}
AfianHandler.titleBar.innerHTML=this.title;MySharesStatusBar();toggleTreeByPath(this.basepath);
}
}
function MySharesStatusBar(){
tb=AfianHandler.activeTab;if(tb.countSelected==0){
if(tb.countAll==0){
if(tb.browsed){
AfianHandler.statusBar.innerHTML=AfianMessages['No shared folder'];
}else{
AfianHandler.statusBar.innerHTML=AfianMessages['Searching for shared folders...'];
}
}else{
if(tb.countAll==1){
AfianHandler.statusBar.innerHTML=AfianMessages['One shared folder (%1)'].replace('%1', formatFileSize(tb.totalSize));
}else{
AfianHandler.statusBar.innerHTML=AfianMessages['%1 shared folders (%2)'].replace('%1', tb.countAll).replace('%2', formatFileSize(tb.totalSize));
}
}
} else if(tb.countSelected==1){
AfianHandler.statusBar.innerHTML=AfianMessages['One shared folder selected (%1)'].replace('%1', formatFileSize(tb.selSize));
}else{
AfianHandler.statusBar.innerHTML=AfianMessages['%1 shared folders selected (%2)'].replace('%1', tb.countSelected).replace('%2', formatFileSize(tb.selSize));
}
}
function MySharesOptions(){
selected=AfianHandler.activeTab.selectedItem();popup(baseURL+'?file=share&path='+selected.extra+'&object='+selected.icon_title, 'share', '360', '514', 'no');
}
function MySharesUnshare(){
tb=AfianHandler.activeTab;document.hiddenForm.action='?file=mysharesacting&act=unshare';document.hiddenForm.action += '&path='+tb.basepath;document.hiddenForm.action += '&tabid='+tb.id;document.hiddenForm.itemlist.value='';fillHiddenFormItemList();document.hiddenForm.target='hifrm_'+tb.id;if(document.hiddenForm.itemlist.value.length > 1){
document.hiddenForm.submit();tb.unselectAll();tb.showHourGlass();
}
}
function MySharesGoTo(){
tb=AfianHandler.activeTab;selected=tb.selectedItem();path=selected.extra;title=AfianMessages['Locating folder..'];newTab=new Afian_Tab(title, path);newTab.section='myfiles';newTab.viewMode='icons';newTab.onload=MyFilesOnLoad;newTab.detailHTML=AfianHandler.MyFilesDetailsTemplate;newTab.load();newTab.MyFiles_Browse(encodeURIComponent(path));newTab.onselect=MyFilesOnSelect;tb.showHourGlass();
}
function openShare(username, uid, path){
if(!AfianHandler.components['BShareBaseMenu'].loaded){
loadComponentData('BShareBaseMenu');
}
if(!AfianHandler.components['BShareContextMenus'].loaded){
loadComponentData('BShareContextMenus');
}
if(AfianHandler.activeTab.section=='browseshare'){
AfianHandler.activeTab.uid = uid;
BShareCD(path);
}else{
bshare=new Afian_Tab(username+': '+path, path);bshare.section='browseshare';bshare.onload=BShareOnLoad;bshare.username=username;bshare.uid=uid;bshare.canwrite=false;bshare.onselect=BShareOnSelect;bshare.baseMenu='BShareBaseMenu';bshare.detailHTML=AfianHandler.BShareDetailsTemplate;bshare.load();bshare.BShare_Browse();
}
}
function BShareOnLoad(){
if(AfianHandler.activeTab==this){
AfianHandler.showBaseMenu('BShareBaseMenu');AfianHandler.hideBaseMenu('MySharesBaseMenu');AfianHandler.hideBaseMenu('MyFilesBaseMenu');AfianHandler.hideBaseMenu('TrashBaseMenu');AfianHandler.hideBaseMenu('SearchBaseMenu');AfianHandler.hideBaseMenu('BrowseZipBaseMenu');
/*admin stuff*/
AfianHandler.hideBaseMenu('AdmGroupsBaseMenu');AfianHandler.hideBaseMenu('AdmUsersBaseMenu');AfianHandler.hideBaseMenu('AdmLogsBaseMenu');if(activeMenu){
hideMenu(activeMenu);
}
if(AfianHandler.components['BShareBaseMenu']['loaded']){
document.getElementById('BShareBreadcrumbs').innerHTML=this.username+': '+ getBreadCrumbs('<a href="#" onclick="BShareCD(\'PATH\')">',this.basepath,'</a>');
/* highlight the toggle */
toggleView(this.viewMode);if(clipboard.items.length > 0){
if(this.canwrite){
document.getElementById('BSharePasteButton').style.visibility='visible';
}else{
document.getElementById('BSharePasteButton').style.visibility='hidden';
}
}else{
document.getElementById('BSharePasteButton').style.visibility='hidden';
}
}
toggleTreeByPath(this.username+'::'+this.basepath);AfianHandler.titleBar.innerHTML=this.title;if(!AfianHandler.activeTab.showHG){
BShareStatusBar();
}else{
this.showHourGlass();
}
}
}
function BShareStatusBar(){
tb=AfianHandler.activeTab;if(tb.countSelected==0){
if(tb.countAll==0){
if(tb.browsed){
AfianHandler.statusBar.innerHTML=AfianMessages['Folder empty'];
}else{
AfianHandler.statusBar.innerHTML=AfianMessages['Accessing folder...'];
}
}else{
AfianHandler.statusBar.innerHTML=AfianMessages['%1 objects (%2)'].replace('%1', tb.countAll).replace('%2',formatFileSize(tb.totalSize));
}
} else if(tb.countSelected==1){
AfianHandler.statusBar.innerHTML=AfianMessages['One object selected (%1)'].replace('%1', formatFileSize(tb.selSize));
}else{
AfianHandler.statusBar.innerHTML=AfianMessages['%1 objects selected (%2)'].replace('%1', tb.countSelected).replace('%2', formatFileSize(tb.selSize));
}
}
function BShareOnSelect(){
showfuncname=showMenu;hidefuncname=hideMenu;if(this.countSelected==0){
if(AfianHandler.components['BShareContextMenus'].loaded){
hidefuncname('afian_bshare_context_dir');hidefuncname('afian_bshare_context_file');hidefuncname('afian_bshare_context_multiple');
}
} else if(this.countSelected==1){
sel=this.selectedItem();if(AfianHandler.components['BShareContextMenus'].loaded){
if(sel.isdir){
showfuncname('afian_bshare_context_dir');hidefuncname('afian_bshare_context_file');hidefuncname('afian_bshare_context_multiple');
}else{
showfuncname('afian_bshare_context_file');hidefuncname('afian_bshare_context_dir');hidefuncname('afian_bshare_context_multiple');
}
}
}else{
if(AfianHandler.components['BShareContextMenus'].loaded){
showfuncname('afian_bshare_context_multiple');hidefuncname('afian_bshare_context_dir');hidefuncname('afian_bshare_context_file');
}
}
BShareStatusBar();
}
function BShareSync(tab){
document.hiddenForm.itemlist.value='';document.hiddenForm.action='?file=bshareacting&act=sync&tabid='+tab.id+'&path='+encodeURIComponent(tab.basepath);for (var i=0 ;i < tab.items.length;i++){
if(tab.items[i]!=undefined){
document.hiddenForm.itemlist.value += '|'+tab.items[i].input_value;
}
}
document.hiddenForm.target='hifrm_'+tab.id;document.hiddenForm.submit();tab.showHourGlass();
}
function BShareCD(path, newtab, title){
tb=AfianHandler.activeTab;selected=tb.selectedItem();if(path=='/'){
/*AfianAlert('You are browsing the top folder.<br>You can select another shared folder (if aplicable) from the tree menu.');*/
return true;
}
path=path?path:gluePath([tb.basepath, selected.input_value]);if(newtab){
title=title?title:selected.icon_title;newTab=new Afian_Tab(title, path);newTab.section='myfiles';newTab.viewMode=tb.viewMode;newTab.onload=BShareOnLoad;newTab.detailHTML=AfianHandler.MyFilesDetailsTemplate;newTab.load();newTa.basepath=path;newTab.BShare_Browse();newTab.onselect=BShareOnSelect;
}else{
if(!tb.isBusy()){
tb.basepath=path;tb.BShare_Browse();
}
}
tb.showHourGlass();
}
function BShareGet(filename){
tb=AfianHandler.activeTab;filename=(filename)?filename:tb.selectedItem().input_value;document.hiddenForm.action='?file=bshareacting';document.hiddenForm.action += '&act=download';document.hiddenForm.action += '&path='+tb.basepath;document.hiddenForm.action += '&uid='+tb.uid;document.hiddenForm.action += '&filename='+filename;document.hiddenForm.target='hifrm_'+tb.id;document.hiddenForm.submit();AfianHandler.activeTab.unselectAll();
}
function BSharePut(){
tb=AfianHandler.activeTab;if(!tb.isBusy()){
document.afian_upload_form.action='?file=bshareacting';document.afian_upload_form.action += '&act=upload';document.afian_upload_form.action += '&path='+tb.basepath;document.afian_upload_form.action += '&uid='+tb.uid;document.afian_upload_form.action += '&totabid='+tb.id;document.afian_upload_form.target='hifrm_'+tb.id;document.afian_upload_form.submit();hideMenu('popmenu-afian_upload');document.afian_upload_form.reset();tb.showHourGlass();
}
}
function BShareEndAction(tb){
if(tb!=undefined){
tb.showHG=false;if(tb.active){
BShareStatusBar();
}
tb.hideHourGlass();cancelTimeOut(tb.id);
}
}
function BShareShowUpload(){
if(AfianHandler.activeTab.canwrite){
switchUploadType('clasic');upload2share=true;centeredMenu('popmenu-afian_upload');
}else{
AfianAlert(AfianMessages['This shared folder has "read-only" access']);
}
}
function BSharePaste(){
tb=AfianHandler.activeTab;if(clipboard.fromuid==tb.uid){
AfianAlert(AfianMessages['You cannot copy files or folders from and to the same user.']);return true;
}
if(!tb.isBusy()){
document.hiddenForm.action='?file=bshareacting';document.hiddenForm.action += '&act=copy';document.hiddenForm.action += '&fromfolder='+clipboard.fromtabbasepath;document.hiddenForm.action += '&tofolder='+tb.basepath;document.hiddenForm.action += '&uid='+tb.uid;document.hiddenForm.action += '&fromtabid='+clipboard.fromtabid;document.hiddenForm.action += '&totabid='+tb.id;document.hiddenForm.itemlist.value='';for (var i=0 ;i < clipboard.items.length;i++){
document.hiddenForm.itemlist.value += '|'+clipboard.items[i];
}
document.hiddenForm.target='hifrm_'+tb.id;if(document.hiddenForm.itemlist.value.length > 1){
document.hiddenForm.submit();tb.showHourGlass();
/* timers */
tabStartTimer(tb);
}
document.getElementById('BSharePasteButton').style.visibility='hidden';resetClipboard();
}
}
function BShareComment(){
tb=AfianHandler.activeTab;popup(baseURL+'?file=comments&path='+encodeURIComponent(tb.basepath)+'&object='+encodeURIComponent(tb.selectedItem().input_value)+'&uid='+tb.uid, 'comments', '250', '544', 'yes');
}
function openAdmGroups(){
if(!AfianHandler.components['AdmGroupsBaseMenu'].loaded){
loadComponentData('AdmGroupsBaseMenu');
}
if(!AfianHandler.components['AdmGroupsContextMenus'].loaded){
loadComponentData('AdmGroupsContextMenus');
}
focusOpened=false;for (var i=0 ;i < AfianHandler.allTabs.length;i++){
if(AfianHandler.allTabs[i]!=undefined){
if(AfianHandler.allTabs[i].section=='admin-groups'){
AfianHandler.allTabs[i].load();focusOpened=true;break;
}
}
}
if(!focusOpened){
groups=new Afian_Tab(AfianMessages['Admin: Groups'], 'admin_groups@afian', 'images/tree/admin.gif');groups.viewMode='list';groups.singleSelection=true;groups.section='admin-groups';groups.onload=AdmGroupsOnLoad;groups.onselect=AdmGroupsOnSelect;groups.baseMenu='AdmGroupsBaseMenu';groups.detailHTML=AfianHandler.AdmGroupsTemplate;groups.load();groups.AdmGroups_Browse();
}
}
function AdmGroupsOnLoad(){
tb=AfianHandler.activeTab;if(tb==this){
/* show the menu */
AfianHandler.showBaseMenu('AdmGroupsBaseMenu');AfianHandler.hideBaseMenu('AdmUsersBaseMenu');AfianHandler.hideBaseMenu('MyFilesBaseMenu');AfianHandler.hideBaseMenu('TrashBaseMenu');AfianHandler.hideBaseMenu('SearchBaseMenu');AfianHandler.hideBaseMenu('MySharesBaseMenu');AfianHandler.hideBaseMenu('BShareBaseMenu');AfianHandler.hideBaseMenu('BrowseZipBaseMenu');if(activeMenu){
hideMenu(activeMenu);
}
/* toggle the tree */
toggleTreeByPath(this.basepath);
/* change the title */
AfianHandler.titleBar.innerHTML=this.title;if(!this.showHG){
AdmGroupsStatusBar();
}else{
this.showHourGlass();
}
}
}
function AdmGroupsStatusBar(){
tb=AfianHandler.activeTab;if(tb.countSelected==0){
if(tb.countAll==0){
if(tb.browsed){
AfianHandler.statusBar.innerHTML=AfianMessages['server problem'];
}else{
AfianHandler.statusBar.innerHTML=AfianMessages['listing groups'];
}
}else{
if(tb.countAll==1){
AfianHandler.statusBar.innerHTML=AfianMessages['one group'];
}else{
AfianHandler.statusBar.innerHTML=AfianMessages['%1 groups'].replace('%1', tb.countAll);
}
}
} else if(tb.countSelected==1){
AfianHandler.statusBar.innerHTML=AfianMessages['Group %1 selected'].replace('%1', tb.selectedItem().icon_title);
}
}
function AdmGroupsOnSelect(){
showfuncname=showMenu;hidefuncname=hideMenu;if(AfianHandler.components['AdmGroupsContextMenus'].loaded){
if(this.countSelected==0){
hidefuncname('afian_admgroups_contextmenu');
}else{
showfuncname('afian_admgroups_contextmenu');
}
}
AdmGroupsStatusBar();
}
function AdmGroupsAddUser(gid){
gid=gid?gid:AfianHandler.activeTab.selectedItem().input_value;popup(baseURL+'?admin=1&sub=adduser&tabid='+AfianHandler.activeTab.id+'&gid='+gid, 'add_user', '600', '700', 'yes');
}
function AdmGroupsAdd(){
popup(baseURL+'?admin=1&sub=addgroup&tabid='+AfianHandler.activeTab.id, 'add_group', '600', '680', 'yes');
}
function AdmGroupsEdit(){
popup(baseURL+'?admin=1&sub=editgroup&gid='+AfianHandler.activeTab.selectedItem().input_value, 'edit_group', '500', '680', 'yes');
}
function AdmGroupsDeletePrompt(gid){
hideMenu('afian_admgroups_contextmenu');gid=gid?gid:AfianHandler.activeTab.selectedItem().input_value;b=new Array;b[0]=new Array;b[0]['title']='Ok';b[0]['onclick']='AdmGroupsDelete(\''+gid+'\')';b[1]=new Array;b[1]['title']=AfianMessages['Cancel'];b[1]['onclick']='hideMenu(\'popmenu-prompt\');AfianHandler.activeTab.onselect()';AfianPrompt(AfianMessages['group delete notice'], b);
}
function AdmGroupsDelete(gid){
hideMenu('popmenu-prompt');tb=AfianHandler.activeTab;if(!tb.isBusy()){
document.hiddenForm.action='?admin=1&section=groups&sub=acting';document.hiddenForm.action += '&act=delete';document.hiddenForm.action += '&tabid='+tb.id;document.hiddenForm.action += '&gid='+gid;document.hiddenForm.target='hifrm_'+tb.id;tb.unselectAll();document.hiddenForm.submit();tb.showHourGlass();
/* timers */
tabStartTimer(tb);
}
}
function openAdmUsers(gid, gname){
if(!gid){
selected=AfianHandler.activeTab.selectedItem();
}
gid=gid?gid:selected.input_value;gname=gname?gname:selected.icon_title;if(!AfianHandler.components['AdmUsersBaseMenu'].loaded){
window.setTimeout('loadComponentData(\'AdmUsersBaseMenu\', \'gid='+gid+'\')', 300);
}
if(!AfianHandler.components['AdmUsersMenus'].loaded){
window.setTimeout('loadComponentData(\'AdmUsersMenus\')', 300);
}
if(!AfianHandler.components['AdmUsersContextMenus'].loaded){
window.setTimeout('loadComponentData(\'AdmUsersContextMenus\')', 300);
}
focusOpened=false;for (var i=0 ;i < AfianHandler.allTabs.length;i++){
if(AfianHandler.allTabs[i]!=undefined){
if(AfianHandler.allTabs[i].section=='admin-users'){
if(AfianHandler.allTabs[i].gid==gid){
AfianHandler.allTabs[i].load();focusOpened=true;break;
}
}
}
}
if(!focusOpened){
users=new Afian_Tab(AfianMessages['\"%1\" user group'].replace('%1', gname), 'admin_users@afian', 'images/tree/groups.gif');users.viewMode='list';users.section='admin-users';users.onload=AdmUsersOnLoad;users.onselect=AdmUsersOnSelect;users.baseMenu='AdmUsersBaseMenu';users.detailHTML=AfianHandler.AdmUsersTemplate;users.load();users.gid=gid;users.gname=gname;users.AdmUsers_Browse(gid);
}
}
function AdmUsersOnLoad(){
tb=AfianHandler.activeTab;if(tb==this){
/* show the menu */
AfianHandler.showBaseMenu('AdmUsersBaseMenu');AfianHandler.hideBaseMenu('AdmGroupsBaseMenu');AfianHandler.hideBaseMenu('MyFilesBaseMenu');AfianHandler.hideBaseMenu('TrashBaseMenu');AfianHandler.hideBaseMenu('SearchBaseMenu');AfianHandler.hideBaseMenu('MySharesBaseMenu');AfianHandler.hideBaseMenu('BShareBaseMenu');AfianHandler.hideBaseMenu('BrowseZipBaseMenu');if(activeMenu){
hideMenu(activeMenu);
}
/* toggle the tree */
toggleTreeByPath('admin_groups@afian');
/* change the title */
AfianHandler.titleBar.innerHTML=tb.title;if(!tb.showHG){
AdmUsersStatusBar();
}else{
tb.showHourGlass();
}
}
}
function AdmUsersStatusBar(){
tb=AfianHandler.activeTab;if(tb.countSelected==0){
if(tb.countAll==0){
if(AfianHandler.activeTab.browsed){
AfianHandler.statusBar.innerHTML=AfianMessages['Group empty'];
}else{
AfianHandler.statusBar.innerHTML=AfianMessages['Listing users...'];
}
}else{
AfianHandler.statusBar.innerHTML=AfianMessages['%1 users'].replace('%1', tb.countAll);
}
} else if(tb.countSelected==1){
AfianHandler.statusBar.innerHTML=AfianMessages['One user selected'];
}else{
AfianHandler.statusBar.innerHTML=AfianMessages['%1 users selected'].replace('%1', tb.countSelected);
}
}
function AdmUsersOnSelect(){
showfuncname=showMenu;hidefuncname=hideMenu;if(AfianHandler.components['AdmUsersContextMenus'].loaded){
if(this.countSelected==0){
hidefuncname('afian_admusers_contextmenu');hidefuncname('afian_admusers_context_multiple');
} else if(this.countSelected==1){
showfuncname('afian_admusers_contextmenu');hidefuncname('afian_admusers_context_multiple');
}else{
showfuncname('afian_admusers_context_multiple');hidefuncname('afian_admusers_contextmenu');
}
}
AdmUsersStatusBar();
}
function AdmUsersDeletePrompt(){
hideMenu('afian_admusers_contextmenu');hideMenu('afian_admusers_context_multiple');b=new Array;b[0]=new Array;b[0]['title']=AfianMessages['Ok'];b[0]['onclick']='AdmUsersDelete()';b[1]=new Array;b[1]['title']=AfianMessages['Cancel'];b[1]['onclick']='hideMenu(\'popmenu-prompt\');AfianHandler.activeTab.onselect()';AfianPrompt(AfianMessages['user delete notice'], b);
}
function AdmUsersDelete(){
hideMenu('popmenu-prompt');tb=AfianHandler.activeTab;if(!tb.isBusy()){
document.hiddenForm.action='?admin=1&section=users&sub=acting';document.hiddenForm.action += '&act=delete';document.hiddenForm.action += '&tabid='+tb.id;document.hiddenForm.action += '&gid='+tb.gid;document.hiddenForm.target='hifrm_'+tb.id;fillHiddenFormItemList();tb.unselectAll();if(document.hiddenForm.itemlist.value.length > 1){
document.hiddenForm.submit();tb.showHourGlass();
/* timers */
tabStartTimer(tb);
}
}
}
function AdmUsersTransferPrompt(){
hideMenu('afian_admusers_contextmenu');hideMenu('afian_admusers_context_multiple');centeredMenu('popmenu-adm_users_transfer');
}
function AdmUsersTransfer(){
hideMenu('popmenu-adm_users_transfer');tb=AfianHandler.activeTab;if(!tb.isBusy()){
document.hiddenForm.action='?admin=1&section=users&sub=acting';document.hiddenForm.action += '&act=transfer';document.hiddenForm.action += '&tabid='+tb.id;document.hiddenForm.action += '&fromgid='+tb.gid;document.hiddenForm.action += '&togid='+document.getElementById('transfer2gid').value;document.hiddenForm.target='hifrm_'+tb.id;fillHiddenFormItemList();tb.unselectAll();if(document.hiddenForm.itemlist.value.length > 1){
document.hiddenForm.submit();tb.showHourGlass();
/* timers */
tabStartTimer(tb);
}
}
}
function AdmUsersViewActivityLog(){
centeredMenu('popmenu-activity_logs');AdminLoadCalendar(AfianHandler.activeTab.selectedItem().input_value);
}
function AdmUsersSummary(uid){
uid=uid?uid:AfianHandler.activeTab.selectedItem().input_value;popup(baseURL+'?file=adm_user_summary&uid='+uid, 'summary', '650', '600', 'yes');
}
function AdmUsersEditUser(){
selected=AfianHandler.activeTab.selectedItem();popup(baseURL+'?admin=1&sub=edituser&uid='+selected.input_value, 'edit_user', 500, 680, 'yes');
}
function AdmUsersEndAction(tb){
if(tb!=undefined){
if(tb.active){
AdmUsersStatusBar();
}
tb.hideHourGlass();cancelTimeOut(tb.id);
}
}
function loadZipBrowserComponents(){
if(!AfianHandler.components['BrowseZipBaseMenu'].loaded){
window.setTimeout('loadComponentData(\'BrowseZipBaseMenu\')',300);
}
}
function MyFilesBrowseZip(path){
tb=AfianHandler.activeTab;sel=tb.selectedItem();path=path?path:gluePath([tb.basepath, sel.input_value]);loadZipBrowserComponents();bzip=new Afian_Tab(sel.input_value, '', 'images/icons/taskbar/zip.gif');bzip.viewMode='list';bzip.section='browse-zip';bzip.singleSelection=true;bzip.basepath=path;bzip.innerpath='';bzip.detailHTML=AfianHandler.BrowseZipDetailsTemplate;bzip.onload=BrowseZipOnLoad;bzip.onselect=BrowseZipOnSelect;bzip.baseMenu='BrowseZipBaseMenu';bzip.load();tabStartTimer(bzip);BrowseZipCd('/');
}
function BrowseZipCd(innerpath){
tb=AfianHandler.activeTab;innerpath=innerpath?innerpath:gluePath([tb.basepath, tb.selectedItem().input_value]);tb.ifram.src='?zipbrowser=1&sub=listing&tabid='+AfianHandler.activeTab.id+'&path='+encodeURIComponent(tb.basepath)+'&innerpath='+encodeURIComponent(innerpath);tb.showHourGlass();
}
function BrowseZipOnLoad(){
if(AfianHandler.activeTab==this){
/* show the menu */
AfianHandler.showBaseMenu('BrowseZipBaseMenu');AfianHandler.hideBaseMenu('MyFilesBaseMenu');AfianHandler.hideBaseMenu('TrashBaseMenu');AfianHandler.hideBaseMenu('SearchBaseMenu');AfianHandler.hideBaseMenu('MySharesBaseMenu');AfianHandler.hideBaseMenu('BShareBaseMenu');
/*admin stuff*/
AfianHandler.hideBaseMenu('AdmGroupsBaseMenu');AfianHandler.hideBaseMenu('AdmUsersBaseMenu');AfianHandler.hideBaseMenu('AdmLogsBaseMenu');if(activeMenu){
hideMenu(activeMenu);
}
loadZipBrowserComponents();if(AfianHandler.components['BrowseZipBaseMenu']['loaded']){
AfianHandler.titleBar.innerHTML=this.title;
}
if(!this.showHG){
BrowseZipStatusBar();
}else{
this.showHourGlass();
}
}
}
function BrowseZipStatusBar(){
tb=AfianHandler.activeTab;if(tb.countSelected==0){
if(tb.countAll==0){
if(tb.browsed){
AfianHandler.statusBar.innerHTML=AfianMessages['Empty archive'];
}else{
AfianHandler.statusBar.innerHTML=AfianMessages['Accessing archive...'];
}
}else{
if(tb.countAll==1){
AfianHandler.statusBar.innerHTML=AfianMessages['One object'];
}else{
AfianHandler.statusBar.innerHTML=AfianMessages['%1 objects'].replace('%1', tb.countAll);
}
}
}else{
selected=tb.selectedItem();AfianHandler.statusBar.innerHTML=AfianMessages['%1, Actual size: %2, Compressed size: %3'].replace('%1',selected.icon_title).replace('%2',selected.formatedSize).replace('%3',formatFileSize(selected.extra));;
}
}
function BrowseZipOnSelect(){
 BrowseZipStatusBar();
}
