var i=1;
var ua = navigator.userAgent;
var opera = /opera [56789]|opera\/[56789]/i.test(ua);
var ie = !opera && /MSIE/.test(ua);
var ie50 = ie && /MSIE 5\.[01234]/.test(ua);
var ie6 = ie && /MSIE [6789]/.test(ua);
var ieBox = ie && (document.compatMode == null || document.compatMode != "CSS1Compat");
var moz = !opera && /gecko/i.test(ua);
var nn6 = !opera && /netscape.*6\./i.test(ua);
var safari = ua.indexOf('Safari')>-1;
function removeFileField(d){
var ftr=document.getElementById("fid"+d);
ftr=ftr.parentNode.parentNode;
ftr.parentNode.removeChild(ftr);
}
function cloneFileField(){
var ftr=document.getElementById("fileTR");
var ftr2= ftr.cloneNode(true);
var td=ftr2.getElementsByTagName("input")[0];
td.name="fff"+i;
td.id="fid"+i;
var a=ftr2.getElementsByTagName("a")[0];
a.href="javascript:removeFileField("+i+")";
a.style.display="inline";
var ftable=document.getElementById("fileTBODY");
ftable.appendChild(ftr2);
i++;
}
function createDirectory(e){
var desc = "Please enter folder name";
var title = "Create a new folder";
var baseValue = "";
promptIE7(e,desc, title , baseValue, "createDirectoryAction");
}
function createDirectoryAction(dirName){
if (dirName){
document.theForm.newdir.value=dirName;
document.theForm.submit();
}
return false;
}
function upDir(){
document.theForm.updir.value="1";
document.theForm.submit();
}
function emptyRecycleBin(){
if(window.confirm("Are you sure you want to permanently delete all files in the Recycle Bin?")){
massAction(18);
}
}
function deldir(id,name){
delImpl(id,name,1);
}
function delfile(id,name){
delImpl(id,name,2);
}
function delImpl(id,name,w){
var confirmMsg = "Are you sure you want to move $[p1] to the Recycle Bin?\nFiles in your Recycle Bin are subject to deletion at any time.";
confirmMsg = confirmMsg.replace(/\$\[p1\]/,"\""+name+"\"");
if (window.confirm(confirmMsg)){
if (w==1){
document.theForm.deldir.value=id;
}else {
document.theForm.delfile.value=id;
}
document.theForm.submit();
}
}
function delfilePerm(id,name){
delImplPerm(id,name,2);
}
function delImplPerm(id,name,w){
var confirmMsg = "Are you sure you want to delete $[p1] permanently?";
confirmMsg = confirmMsg.replace(/\$\[p1\]/,"\""+name+"\"");
if (window.confirm(confirmMsg)){
if (w==1){
document.theForm.deldir.value=id;
}else {
document.theForm.delfile.value=id;
}
document.theForm.submit();
}
}
function restoreFile(id,name){
var confirmMsg = "Are you sure you want to restore $[p1] ?";
confirmMsg = confirmMsg.replace(/\$\[p1\]/,"\""+name+"\"");
if (window.confirm(confirmMsg)){
document.theForm.restorefile.value=id;
document.theForm.submit();
}
}
function checkIt(checked){
var f=document.theForm;
var rowIndex=0;
//dirs
if (f.ch_d!=null){
if(f.ch_d.checked!=checked && f.ch_d.parentNode!=null){
fileDown(f.ch_d.parentNode.parentNode,rowIndex,true)
fileOut(f.ch_d.parentNode.parentNode,false,null,rowIndex++);
}
f.ch_d.checked=checked;
var i=0
while (f.ch_d[i]!=null){
if(f.ch_d[i].checked!=checked){
fileDown(f.ch_d[i].parentNode.parentNode,rowIndex,true);
fileOut(f.ch_d[i].parentNode.parentNode,false,null,rowIndex++);
}
f.ch_d[i].checked=checked;
i++;
}
}
//files
if (f.ch_f!=null){
if(f.ch_f.checked!=checked && f.ch_f.parentNode!=null){
fileDown(f.ch_f.parentNode.parentNode,rowIndex,false);
fileOut(f.ch_f.parentNode.parentNode,false,null,rowIndex++);
}
f.ch_f.checked=checked;
var i=0
while (f.ch_f[i]!=null){
if(f.ch_f[i].checked!=checked){
fileDown(f.ch_f[i].parentNode.parentNode,rowIndex,false);
fileOut(f.ch_f[i].parentNode.parentNode,false,null,rowIndex++);
}
f.ch_f[i].checked=checked;
i++;
}
}
}
var selectAll=true;
function selectAllOrNone(){
var sAll=document.getElementById("selectAll");
if (selectAll){
checkIt(true);
sAll.title="Select None";
selectAll=false;
} else {
checkIt(false);
sAll.title="Select All";
selectAll=true;
}
}
function checkFileWithId(fileid){
var f=document.theForm;
//files
if (f.ch_f!=null){
if(f.ch_f.value==fileid) f.ch_f.checked=true;
var i=0
while (f.ch_f[i]!=null){
if(f.ch_f[i].value==fileid) f.ch_f[i].checked=true;
i++;
}
}
}
function checkDirWithId(dirid){
var f=document.theForm;
//files
if (f.ch_d!=null){
if(f.ch_d.value==dirid) f.ch_d.checked=true;
var i=0
while (f.ch_d[i]!=null){
if(f.ch_d[i].value==dirid) f.ch_d[i].checked=true;
i++;
}
}
}
function uncheckAll(){
checkDirsImpl(false);
checkFilesImpl(false);
}
function checkDirs(){
checkDirsImpl(true);
}
function checkDirsImpl(checkValue){
var f=document.theForm;
//dirs
if (f.ch_d!=null){
f.ch_d.checked=checkValue;
var i=0
while (f.ch_d[i]!=null){
f.ch_d[i].checked=checkValue;
i++;
}
}
}
function checkFiles(){
checkFilesImpl(true);
}
function unCheckFiles(){
checkFilesImpl(false);
}
function checkFilesImpl(checkValue){
var f=document.theForm;
//files
if (f.ch_f!=null){
f.ch_f.checked=checkValue;
var i=0
while (f.ch_f[i]!=null){
f.ch_f[i].checked=checkValue;
i++;
}
}
}
function hasCheckedFiles(){
var res=false;
var f=document.theForm;
//files
if (f.ch_f!=null){
if (f.ch_f.checked) return true;
var i=0
while (f.ch_f[i]!=null){
if (f.ch_f[i].checked){
return true;
}
i++;
}
}
//dirs
if (f.ch_d!=null){
if (f.ch_d.checked) return true;
var j=0
while (f.ch_d[j]!=null){
if (f.ch_d[j].checked){
return true;
}
j++;
}
}
return false;
}
function toEmail(mode){
if (!hasCheckedFiles()){
alert("Please check files to email");
}else {
massAction(mode);
}
}
function massAction(mode){
document.theForm.homemode.value=mode;
document.theForm.submit();
}
function goForward(){
massAction(14);
}
function goBack(){
massAction(13);
}
function copyFiles(mode){
if (!hasCheckedFiles()){
alert("Please check files to copy");
}else {
massAction(mode);
}
}
function makeRenameWOEvent(oldname,fid,isItFileToRename){
document.theForm.renamefileid.value=fid;
document.theForm.isFileToRename.value=isItFileToRename;
var desc = "Please enter new name";
var title = "Rename";
promptIE7(contextMenuEvent,desc, title , oldname, "renameFileAction2",contextMenuEventX,contextMenuEventY,true);
}
function renameFile(event,oldname,fid,isItFileToRename,offx,offy){
document.theForm.renamefileid.value=fid;
document.theForm.isFileToRename.value=isItFileToRename;
var desc = "Please enter new name";
var title = "Rename";
promptIE7(event, desc , title , oldname, "renameFileAction2",offx,offy);
}
function renameFileAction2(s){
if(s.length==0){
alert("Name should not be empty");
}else {
document.theForm.newfilename.value=s;
massAction(12);
}
return false;
}
function cutFiles(mode){
if (!hasCheckedFiles()){
alert("Please check files to cut");
}else {
massAction(mode);
}
}
function deleteFiles(mode){
if (!hasCheckedFiles()){
alert("Please check files to move to the Recycle Bin");
}else {
if (window.confirm("Are you sure you want to move selected files to the Recycle Bin?\nFiles in your Recycle Bin are subject to deletion at any time.")){
massAction(mode);
}
}
}
function restoreFiles(mode){
if (!hasCheckedFiles()){
alert("Please check files to restore");
}else {
if (window.confirm("Are you sure you want to restore selected files?")){
massAction(mode);
}
}
}
function deleteFilesPerm(mode){
if (!hasCheckedFiles()){
alert("Please check files to delete");
}else {
if (window.confirm("Are you sure you want to delete selected files permanently?")){
massAction(mode);
}
}
}
function zipFiles(event,offx,offy){
if (!hasCheckedFiles()){
alert("Please check files to zip");
}else {
var desc = "Please enter zip filename";
var title = "Zip";
promptIE7(event, desc , title ,document.theForm.defaultZipName.value , "zipFilesAction",offx,offy);
}
}
function zipFilesAction(s){
var enteredZipName=s;
if(enteredZipName==null || enteredZipName=='undefined' || enteredZipName==''){
alert("You should enter zip filename");
return false;
}
writeDrag.hide();
document.theForm.zipname.value=enteredZipName;
var oldTarget =document.theForm.target;
var oldAction =document.theForm.action;
document.theForm.target='zipframe';
document.theForm.action=document.theForm.zipFormURL.value;
top.zipStarts = true;
massAction(9);
showProgressBar('zip');
document.theForm.target=oldTarget;
document.theForm.action=oldAction;
return false;
}
function markFiles(mode){
if (!hasCheckedFiles()){
alert("Please check files to mark as public");
}else {
massAction(mode);
}
}
function markOffFiles(mode){
if (!hasCheckedFiles()){
alert("Please check files to mark off as public");
}else {
massAction(mode);
}
}
function showPreview(url){
var img=document.getElementById("smallImg");
img.src = url;
img.style.display="inline";
}
function hidePreview(){
var img=document.getElementById("smallImg");
img.style.display="none";
}
function fileOver(page,isImg,link,rowNum){
// if (isImg){
// showPreview(link);
// }
setPointer(page,rowNum, 'over', 'Window', (safari?'#FFFFDE':'InfoBackground'), '#C3D9FF');
//setPointer(page,rowNum, 'over', '#E5E5E5', '#CCFFCC', '#C3D9FF');
}
function fileOut(page,isImg,link,rowNum){
// if (isImg){
// hidePreview();
// }
//setPointer(page,rowNum, 'out', '#E5E5E5', '#CCFFCC', '#C3D9FF');
setPointer(page, rowNum, 'out', 'Window', (safari?'#FFFFDE':'InfoBackground'), '#C3D9FF');
}
function fileDown(page,rowNum,isFile){
//if (isFile){
setPointer(page, rowNum, 'click', 'Window', (safari?'#FFFFDE':'InfoBackground'), '#C3D9FF');
//}
}
function fileDownCheckBox(isFile,fid,td,rowNum){
if (isFile){
var f=document.theForm;
//files
if (f.ch_f!=null){
if (f.ch_f.value==fid){
f.ch_f.checked!=!f.ch_f.checked;
}
var i=0
while (f.ch_f[i]!=null){
//alert(f.ch_f[i].value);
if (f.ch_f[i].value==fid){
f.ch_f[i].checked=!f.ch_f[i].checked;
}
i++;
}
}
} else {
var f=document.theForm;
//folders
if (f.ch_d!=null){
if (f.ch_d.value==fid){
f.ch_d.checked!=!f.ch_d.checked;
}
var j=0
while (f.ch_d[j]!=null){
//alert(f.ch_f[i].value);
if (f.ch_d[j].value==fid){
f.ch_d[j].checked=!f.ch_d[j].checked;
}
j++;
}
}
}
fileDown(td.parentNode,rowNum,isFile);
}
function cloneObjShallow(myObj)
{
if(typeof(myObj) != 'object') return myObj;
if(myObj == null) return myObj;
var myNewObj = new Object();
for(var ifield in myObj)
myNewObj[ifield] = myObj[ifield];
return myNewObj;
}
//writeDrag.writeId = "cntnt";
function wrapContent(e, img, w, h, txt,
downloadLink, fileExt,
wd, offx, offy) {
var imgStr, cntnt, win, str;
imgStr = '';
if( downloadLink ){
window.originalMediaPreviewEvent=cloneObjShallow(e);
txt += '\n';
txt += '\n
';
}
if ( dragObj.supported && typeof document.body.innerHTML != "undefined" ) {
cntnt = '
' + txt + '
':""); str += '' win.document.write(str); win.document.close(); if (win && !win.closed) win.focus(); } return false; } function showMediaPreview(e, url, ext) { var spanStr, cntnt, win, str; spanStr = ''; var w = 330; var h = 250; // size if ( dragObj.supported && typeof document.body.innerHTML != "undefined" ) { cntnt = '