myHostname=window.location.hostname;

var myTLD="."+myHostname.substring(myHostname.indexOf("logatti")+"logatti.".length).split(".")[0];


function afterLoad(){return}ieFixForFileSelectionOnChangeEventTimer=null;
function ieFixForFileSelectionOnChangeEvent(a){$("#siteName").toggle();if($("#inputFileSelection").val()==""){ieFixForFileSelectionOnChangeEventTimer=setTimeout("ieFixForFileSelectionOnChangeEvent()",200)}else{$("body")[0].focus()}}function urlencode(a){return escape(a.toString().replace(/\//g,"%2F").replace(/%/g,"%25").replace(/\+/g,"%2B")).replace(/%25/g,"%")}$(document).ajaxStart(function(){$("body").addClass("ajaxLoading")});

$(document).ajaxStop(function(){$("body").removeClass("ajaxLoading")});
$(document).ajaxError(function(d,c,a,b){CMApplication.Widgets.Dialog.close();

CMApplication.Widgets.Dialog.displayMessage(c.responseText,CMApplication.Widgets.Dialog.Types.exception)});
jQuery.setCookie=function(b,c,a){var d=new Date();d.setDate(d.getDate()+a);cookieDomain=".logatti"+myTLD;document.cookie=b+"="+escape(c)+((a==null)?"":";expires="+d.toUTCString()+"; path=/;domain="+cookieDomain+";")};
jQuery.getCookie=function(a){if(document.cookie.length>0){c_start=document.cookie.indexOf(a+"=");

if(c_start!=-1){c_start=c_start+a.length+1;c_end=document.cookie.indexOf(";",c_start);if(c_end==-1){c_end=document.cookie.length}return unescape(document.cookie.substring(c_start,c_end))}}return""};
jQuery.unparam=function(d){var f={},c=d.split("&"),e,b,a;

for(b=0,a=c.length;b<a;b++){e=c[b].split("=",2);
f[decodeURIComponent(e[0])]=(e.length==2?decodeURIComponent(e[1].replace(/\+/g," ")):true)}return f};

/* Begin Widgets */
CMApplication={
    
    User:{RolesNames:["anonymous","intranet","extranet"],
    RolesValues:{ANONYMOUS:0,INTRANET:1,EXTRANET:2},
    sessId:"",
    email:"",
    isAffiliate:false,
    isReseller:false,
    role:"anonymous"},
    
    Bootstrap:{
        run:function(){
            for(var a in this){
                if(a.indexOf("_init")===-1)
                {continue}this[a]()}CMApplication.Widgets.Ajax._init()}},
                
    Dictionnary:{
        SHARE:"Share",
        EDIT:"Edit",
        TRASH:"Trash",
        DOWNLOAD_READY:"Download Ready",
        START_DOWNLOAD_NOW:"Start download now!",
        LEAVING_WILL_CANCEL_UPLOADS:"If you continue, your upload(s) will be cancelled.",
        YOUR_UPLOADS:"Your uploads",
        COMPLETED:"Completed",
        CLOSE:"Close",
        VIEW_LINKS:"View Links",
        UNEXPECTED_PROCESS_ERROR:"Unexpected error during process",
        LOGIN_UNEXPECTED_PROCESS_ERROR:"Unexpected error during login",
        SYSTEM_ERROR:"Erro de Sistema.",
        ERROR:"Error",
        NOTICE:"Notice",
        FILESYSTEM_MOVE_INSTRUCTION:"Select the file/folder you want to move on the right side of the file browser.",
        FILESYSTEM_COPY_INSTRUCTION:"Select the file/folder you want to copy on the right side of the file browser.",
        FILESYSTEM_TRASH_INSTRUCTION:"Select the file/folder you want to delete on the right side of the file browser.",
        FILESYSTEM_GENERATELINKS_INSTRUCTION:"Select the file(s) you want to generate link on the right side of the file browser.",
        FILESYSTEM_PREMIUM_INSTRUCTION:"Select the file(s) you want to set only for premium on the right side of the file browser.",
        FOLDER_ID_REQUIRED:"Folder ID should be specified",
        FILESYSTEM_MOVE_SOURCE_IDENTICAL_TO_DESTINATION:"Impossible to move: The source folder is identical then the destination",
        FILESYSTEM_MOVE_DESTINATION_SUBFOLDER_OF_SOURCE:"Impossible to move: The destination folder is a subfolder of the source.",
        FILESYSTEM_MOVE_UNABLE_TO_MOVE:"Unable to move selected file/folder",
        FILESYSTEM_COPY_UNABLE_TO_COPY:"Unable to copy selected file/folder",
        FILESYSTEM_TRASH_UNABLE_TO_TRASH:"Unable to trash selected file/folder",
        FILESYSTEM_PREMIUM_UNABLE_TO_PREMIUM:"Unable to set only for premium selected file(s)",
        COPY_FOLDER_NOT_YET_IMPLEMENTED:"Copy of folder not yet implemented",
        PAGE_SHOULD_BE_OPENED_IN_NEW_WINDOW:"For technical reasons, this page should be opened in a new window/tab when uploading a file.",
        VIEW_ALL_LINKS:"View all links",
        SELECT_A_DESTINATION:"Select a destination",
        MOVE:"Move",
        CANCEL:"Cancel",
        ARE_YOU_SURE_YOU_WANT_TO_DELETE_THESE_FILES:"Are you sure you want to delete these files / folder ?",
        ARE_YOU_SURE_YOU_WANT_TO_SET_THESE_FILES_ONLY_PREMIUM:"Are you sure you want to set these files only for premium?",
        ARE_YOU_SURE_YOU_WANT_TO_UNSET_THESE_FILES_ONLY_PREMIUM:"Are you sure you want to unset these files only for premium?",
        DESCRIPTION:"Description:",
        IS_PUBLIC:"Is Public:",
        LINK:"Link",
        LINKS:"Links:",
        CREATED_ON:"Created On:",
        UPDATED_ON:"Updated On:",
        MUST_BE_PUBLIC:"Must be public",
        COPY:"Copy",
        REMOTE_UPLOAD:"Remote Upload",
        WEB_UPLOAD:"Web Upload",
        UNKNOWN:"Unknown",
        SIZE:"Size",
        SOURCE:"Source",
        PASSWORD:"Password",
        PREMIUM_ONLY:"Premium Only",
        HIDDEN:"Private file",
        TOTAL_SIZE:"Total Size:",
        FOLLOWING_ERROR_DURING_UPLOAD:"The following errors happen during the upload:",
        RENAME:"Rename",
        UPLOADING:"Uploading",
        FILES:"Files",
        RESTORE:"Restore",
        SELECT:"Select",
        MINIMIZE:"Minimize",
        FILES_UPLOADED_TO:"Files uploaded to:",
        UPLOAD_TO_THIS_FOLDER:"Upload to this folder:",
        CHOOSE_FILES_TO_UPLOAD:"Choose files to upload",
        UPLOAD_NOW:"Upload Now",
        YOU_SUCCESSFULLY_UPLOADED:"You successfully uploaded",
        YOU_UPLOADED:"You uploaded",
        ERROR_DURING_THE_UPLOAD:"Error during the upload",
        SHARE_ALL_LINKS:"Share ALL Links",
        GO_TO_MANAGE_FILES:"Go to Manage Files",
        CHOOSE_FILES_AND_THEN_PRESS_UPLOAD_NOW:"Choose the files you would like to upload and then press the Upload Now button.",
        TO_SELECT_MULTIPLE_FILES:"To select multiple files use CTRL + Mouse click",
        TOTAL_FILES:"Total Files:",
        FILE_NAME:"File name",
        PROGRESS:"Progress",
        DOWNLOAD_LINK:"Download Link",
        FAIL:"Fail",
        VIEW_LINK:"View Link",
        SELECTABLE:"Selectable",
        YOU_CAN_NOT_COPY_MORE_FILES:"You can not copy more than 1000 files at once!",
        YOU_CAN_NOT_MASS_COPY_TO_SAME_FOLDER:"You can not mass copy to the same folder!"},
        URLs:{languageFilesystemExportFolderLinks:"/filesystem/export-all-links/:folderId",
        languageFilesystemCopy:"/filesystem/copy/:id",languageFilesystemMove:"/filesystem/move/:id",
        languageFilesystemEditMultiple:"/filesystem/edit-multiple/:id",
        languageFilesystemShare:"/filesystem/share/:ids",
        languageFilesystemEdit:"/filesystem/edit/:id",
        languageFilesystemCreate:"/filesystem/create/:parentId",
        languageFilesystemTrash:"/filesystem/delete/:id",
        languageFilesystemGenerateLink:"/filesystem/generate-link/:id",
        languageFilesystemBrowse:"/filesystem/browse/:folderId/:page/:orderBy/:orderDirection/:globalSearch/:queryString",
        languageFilesystemRemoved:"/filesystem/removed",
        messagingInbox:"/messaging/inbox",
        messagingUnreadPreview:"/messaging/preview-unread",
        messagingRead:"/messaging/read/:id",
        uploadProgress:":hostserver/nginxuploadprogress?unique=:unique&ID=:progress_key&X-Progress-ID=:progress_key",
        uploadCallback:"/upload-completed/:uploadProgressId",
        domain:"http://"+window.location.host},
        foward:function(a){location.href=a},
        Viewport:{width:null,height:null,adjust:function()

/* begin Section */
{
    if(typeof window.innerWidth!="undefined")

{this.width=window.innerWidth,this.height=window.innerHeight}
else
{
    if(typeof document.documentElement!="undefined"&&typeof document.documentElement.clientWidth!="undefined"&&document.documentElement.clientWidth!=0)
        {this.width=document.documentElement.clientWidth,this.height=document.documentElement.clientHeight}
else
{this.width=document.getElementsByTagName("body")[0].clientWidth,this.height=document.getElementsByTagName("body")[0].clientHeight}
}

this.height=this.height-45;

var a=false;
if(navigator.userAgent.indexOf("MSIE 6")!=-1)
{a=true}
if(a){document.getElementById("container").style.height=this.height.toString()+"px"}else{document.getElementById("container").style.minHeight=this.height.toString()+"px"}}},
/* end Section */

Layout:{_init:function(){
    if(CMApplication.User.email!="")
    {$("body").addClass("loggedIn")}
    else
    {$("body").removeClass("loggedIn")}
    
    $("#lMainUsage a[href="+window.location+"]").parent("li").addClass("active");
    $("#lMainUsage li.active").parent("li").addClass("active");
    $("#lMainUsage li.active").parent("ul").parent("li").addClass("active");
    $("ul.main > li").live("mouseenter",function(a){$(this).addClass("hover");
    $("ul.lMore",this).show()});
    $("ul.main > li").live("mouseleave",function(a){
        $(this).removeClass("hover");
        $("ul.lMore",this).hide()})}},
        
        Widgets:{},Pages:{}};
     /* end Widgets */
        
        
sortFolders=function(d,c){
    var g=$("#sortFoldersBy").val();
    if(g=="name"){
        var f=encodeURI($(d).text()).replace("%0A%20%20%20%20%20%20%20%20","").replace("%0A%20%20%20%20","");
        var e=encodeURI($(c).text()).replace("%0A%20%20%20%20%20%20%20%20","").replace("%0A%20%20%20%20","")}
        else{
            if(g=="created_on"){
                var f=$(d).attr("data-date");
                var e=$(c).attr("data-date")}}
                
    if($("#orderFoldersDirection").val()=="desc"){return(f>e)?-1:(f<e)?1:0}
    else{
        return(f<e)?-1:(f>e)?1:0}};
        
        
        $(document).ready(function(){if(jQuery.getCookie("isJavascriptEnable")!=1){jQuery.setCookie("isJavascriptEnable",1,30)}$("#DialogWidget #signupCompleted form").live("successCallback",function(event,data){$(this).removeAttr("rel")});
isSearchResult=false;isGlobalSearch=0;$("#sort_dirs_btn").click(function(){var mylist=$("#ul_dirs");var listitems=mylist.children("li").get();listitems.sort(sortFolders);$.each(listitems,function(idx,itm){mylist.append(itm)});
ullist=$("#folderTree li. ul").get();
$.each(ullist,function(idx0,itm0){listitems=$(itm0).children("li").get();
listitems.sort(sortFolders);$.each(listitems,function(idx,itm){$(itm0).append(itm)})})});
$(".specialOffer a").click(function(e){e.preventDefault();
CMApplication.Widgets.Dialog.displayUrl($(this).attr("href"),750)});
CMApplication.Widgets.Ajax={Events:{click:function(e){if(e.isDefaultPrevented()){return}var internalLinkRegEx=/^(\#|\/|https?\:\/\/([^.]+\.)?filesonic(\.[a-z]{2,3})+\/?)/i;
destination=$(this).attr("href");
isInternal=internalLinkRegEx.test(destination);
var anchorRegEx=/(\#.*)$/i;
isAnchor=anchorRegEx.test(destination);
if(!isInternal){return}e.preventDefault();
localPath=CMApplication.Widgets.Ajax.getHash(destination).replace(anchorRegEx,"");
if(localPath!=""&&!(localPath==window.location.pathname&&isAnchor)){var intelligenceRegEx=/\/intelligence(\/.*)?$/i;
isIntelligence=intelligenceRegEx.test(localPath);if(!isIntelligence){$.history.load(localPath)}else{alert(CMApplication.Dictionnary.PAGE_SHOULD_BE_OPENED_IN_NEW_WINDOW);

window.open(localPath)}}anchor=anchorRegEx.exec(destination);if(anchor!==null&&$(anchor[0]).length==1){setTimeout("$('html,body').animate({scrollTop: "+$(anchor[0]).offset().top+"}, 800);",1)}},submit:function(e){if(e.isDefaultPrevented()){return}var internalLinkRegEx=/^(\#|\/|https?\:\/\/([^.]+\.)?filesonic(\.[a-z]{2,3})+\/?)/i;
destination=$(this).attr("action");
isInternal=internalLinkRegEx.test(destination);if(!isInternal){return}e.preventDefault();
localPath=CMApplication.Widgets.Ajax.getHash(destination);
jQuery.ajax({url:localPath,type:$(this).attr("method")||"get",data:$(this).serialize(),dataType:"html",complete:function(XMLHttpRequest,textStatus){$("#mainContent").html(XMLHttpRequest.responseText)}})}},start:function(){alert("Starting Ajax Browsing");$("form").live("submit",CMApplication.Widgets.Ajax.Events.submit);$("a").live("click",CMApplication.Widgets.Ajax.Events.click);$.history.init(function(hash){if(hash==""){url=CMApplication.Widgets.Ajax.getHash(location.href)}else{jQuery.ajax({url:hash,async:false,global:false,type:"get",dataType:"html",data:{isGlobalAjax:"1"},complete:function(XMLHttpRequest,textStatus){$("#mainContent").html(XMLHttpRequest.responseText)}});
$("html,body").animate({scrollTop:0},1)}},{unescape:",/"})},stop:function(){alert("Stopping Ajax Browsing");
$("form").die("submit",CMApplication.Widgets.Ajax.Events.submit);
$("a").die("click",CMApplication.Widgets.Ajax.Events.click);
$.history.init(function(){},{unescape:",/"})},_init:function(){},getHash:function(url){hostnameRegEx=/^(https?\:\/\/[^\/]+)/i;
return url.replace(hostnameRegEx,"")}};CMApplication.Widgets.Purchase={Events:{submit:function(e){e.preventDefault();CMApplication.Widgets.Dialog.displayUrl($(this).attr("action"));
editForm=$("form",CMApplication.Widgets.Dialog.dialogContainer);
editForm.bind("successCallback",function(event,data){if(data.data.paymentSystem==3){$(event.target).attr("rel","keep");
$("#DialogWidgetContent").load(data.redirect)}else{location.href=data.redirect}});
editForm.bind("failCallback",function(event,data){$(event.target).attr("rel","keep")})}},_init:function(){$(".form_payment_system_3, .form_payment_system_8.premiumEmail, .form_payment_system_9.premiumEmail").live("submit",CMApplication.Widgets.Purchase.Events.submit)}};
CMApplication.Widgets.Tools={Events:{click:function(e){e.preventDefault();
$(this).addClass("active");
$('#lUser li.lMore:not("#statsLinks") ul').show();
$(document).bind("click",closeUserMenuMore);
function closeUserMenuMore(e){clickedElement=$(e.target);
if(!clickedElement.is('#lUser li.lMore:not("#statsLinks") ul')&&clickedElement.parents('#lUser li.lMore:not("#statsLinks") ul').length<1){$('#lUser li.lMore:not("#statsLinks") a').removeClass("active");
$('#lUser li.lMore:not("#statsLinks") ul').hide();$(document).unbind("click",closeUserMenuMore)}}}},_init:function(){$('#lUser li.lMore:not("#statsLinks") > a:not(.active)').live("click",CMApplication.Widgets.Tools.Events.click)}};
CMApplication.Widgets.Stats={Events:{click:function(e){e.preventDefault();
$(this).addClass("active");
$("#lUser li.lMore#statsLinks ul").show();
$(document).bind("click",closeUserMenuMore);
function closeUserMenuMore(e){clickedElement=$(e.target);if(!clickedElement.is("#lUser li.lMore#statsLinks ul")&&clickedElement.parents("#lUser li.lMore#statsLinks ul").length<1){$("#lUser li.lMore#statsLinks a").removeClass("active");
$("#lUser li.lMore#statsLinks ul").hide();
$(document).unbind("click",closeUserMenuMore)}}}},_init:function(){$("#lUser li.lMore#statsLinks > a:not(.active)").live("click",CMApplication.Widgets.Stats.Events.click)}};
CMApplication.Widgets.Dialog={className:null,dialogContainer:null,Types:{exception:1,error:2,notice:3},Events:{close:function(event){event.preventDefault();
CMApplication.Widgets.Dialog.close()},submit:function(event){event.preventDefault();var formSubmitted=$(this);
jQuery.ajax({url:formSubmitted.attr("action"),data:formSubmitted.serializeArray(),type:formSubmitted.attr("method"),dataType:"json",success:function(data,textStatus,XMLHttpResponse){if(data.status=="success"){form=formSubmitted.trigger("successCallback",data)}else{form=formSubmitted.trigger("failCallback",data);if($(form).attr("rel")=="keep"){for(var i in data.messages){for(var j in data.messages[i]){message=data.messages[i][j];if($("#"+i).parent("div.elements").children(".errors").length==0){$("#"+i).parent("div.elements").append("<ul class='errors'><li>"+message+"</li></ul>")}else{$("#"+i).parent("div.elements").children(".errors").html("<li>"+message+"</li>")}}}}}if($(form).attr("rel")!="keep"){CMApplication.Widgets.Dialog.close()}}})}},displayMessage:function(message,type){
    
    switch(type){
    
case CMApplication.Widgets.Dialog.Types.exception:title=CMApplication.Dictionnary.SYSTEM_ERROR;
className="systemError";
break;

case CMApplication.Widgets.Dialog.Types.error:title=CMApplication.Dictionnary.ERROR;
className="error";
break;

case CMApplication.Widgets.Dialog.Types.notice:title=CMApplication.Dictionnary.NOTICE;
className="notice";
break
}

html='<div id="DialogWidgetMessage" class="'+className+'"><h2><span>'+title+"</span></h2>"+message+"</div>";CMApplication.Widgets.Dialog.open(html,400)},displayUrl:function(url,width){var width;ajaxUrl=url;jQuery.ajax({url:ajaxUrl,type:"get",dataType:"html",async:false,success:function(data,textStatus,XMLHttpResponse){CMApplication.Widgets.Dialog.displayContent(data,width)}})},displayContent:function(content,width){CMApplication.Widgets.Dialog.open(content,width)},open:function(content,width){if(undefined===width){width="700"}dContainer=CMApplication.Widgets.Dialog.dialogContainer;if(dContainer==null){CMApplication.Widgets.Dialog._init()}if(CMApplication.Widgets.Dialog.className!==null){$("#DialogWidget").addClass(CMApplication.Widgets.Dialog.className)}else{$("#DialogWidget").attr("class","")}$("#DialogWidgetContent").html(content);$("#DialogWidgetContainer, #DialogWidgetContent").css("width",width);if($("body").scrollTop()>$("html").scrollTop()){scrolltopValue=$("body").scrollTop()}else{scrolltopValue=$("html").scrollTop()}dContainer.css("top",scrolltopValue);$("body").addClass("displayDialog");heightDiff=CMApplication.Viewport.height-$("#DialogWidgetContainer").outerHeight();if(heightDiff<0){newHeight=$("#DialogWidgetContainer").height()-Math.abs(heightDiff)-20;$("#DialogWidgetContainer").css("height",newHeight);$("#DialogWidgetContent").css("height",newHeight-30);heightDiff=CMApplication.Viewport.height-$("#DialogWidgetContainer").outerHeight()}newPosition=0;$("#DialogWidgetContainer").css("top",25)},close:function(){dContainer=CMApplication.Widgets.Dialog.dialogContainer;if(dContainer==null){return}CMApplication.Widgets.Dialog.className=null;$("body").removeClass("displayDialog");$("#DialogWidget").attr("class","");$("#DialogWidgetContent").html("");

$("#DialogWidgetContainer").css("height","auto");
$("#DialogWidgetContent").css("height","auto")},setClass:function(className)
{
    CMApplication.Widgets.Dialog.className=className;
    if($("#DialogWidget").length==1){
     if(className===null){
        $("#DialogWidget").attr("class","")}
        else{
            $("#DialogWidget").addClass(className)}
}
}
,_init:function(){markup='<div id="DialogWidget"><div id="DialogWidgetBackground"></div><div id="DialogWidgetContainer"><div id="DialogWidgetClose"><span>close</span></div><div id="DialogWidgetContent"></div></div></div>';

CMApplication.Widgets.Dialog.dialogContainer=$(markup).appendTo("body");
dContainer=CMApplication.Widgets.Dialog.dialogContainer;
$("#DialogWidgetBackground,#DialogWidgetClose").live("click",CMApplication.Widgets.Dialog.Events.close);
$("#DialogWidgetContent form:not(.noDynamicSubmit form):not(#DialogWidgetContent #premiumPrices form)").live("submit",CMApplication.Widgets.Dialog.Events.submit)}};
CMApplication.Widgets.AdvancedUpload={_uploadServerHostname:null,getUploadServerHostname:function(){
    if(CMApplication.Widgets.AdvancedUpload._uploadServerHostname===null)
    {id=Math.floor(Math.random()*50);CMApplication.Widgets.AdvancedUpload._uploadServerHostname="s"+id+".filesonic"+myTLD}
    return CMApplication.Widgets.AdvancedUpload._uploadServerHostname},Uploads:{},Progress:{updateResponse:function(uploadIdentifier,data){CMApplication.Widgets.AdvancedUpload.setUploadProgress(uploadIdentifier,data)}},Events:{close:function(e){e.preventDefault();CMApplication.Widgets.AdvancedUpload.close($(this).closest(".WebUploadWidget").attr("rel"))},minimize:function(e){e.preventDefault();
    $("body").removeClass("displayWebUpload");uploadContainer=$("#WebUploadWidget").hide().addClass("uploadMinimized").attr("id","WebUploadWidget_"+$("#WebUploadWidget").attr("rel"));minimizer=$("#WebUploadMinimizer");if(minimizer.length==0){xhtml="";xhtml+='<div id="WebUploadMinimizer">';xhtml+="    <h3><span>"+CMApplication.Dictionnary.WEB_UPLOAD+"</span></h3>";xhtml+='    <ul class="actions">';xhtml+='        <li class="close"><a href="#"><span>'+CMApplication.Dictionnary.CLOSE+"</span></a></li>";xhtml+="    </ul>";xhtml+="</div>";minimizer=$(xhtml).appendTo($("body"))}xhtml="";xhtml+='<div class="WebUploadWidget" rel="'+uploadContainer.attr("rel")+'">';if(CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].files.length>1){heading=CMApplication.Dictionnary.UPLOADING+" "+CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].files.length+" "+CMApplication.Dictionnary.FILES}else{heading=CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].files[0].name}xhtml+="    <h4><span>"+heading+"</span></h4>";xhtml+='    <ul class="actions">';xhtml+='        <li class="restore"><a href="#"><span>'+CMApplication.Dictionnary.RESTORE+"</span></a></li>";xhtml+='        <li class="close"><a href="#"><span>'+CMApplication.Dictionnary.CLOSE+"</span></a></li>";xhtml+="    </ul>";xhtml+="</div>";uploadMinimized=$(xhtml).appendTo(minimizer);uploadMinimized.append($(".progressbar",uploadContainer).clone());uploadMinimized.append($(".WebUploadWidgetResult",uploadContainer).clone())},restore:function(e){e.preventDefault();$("body").addClass("displayWebUpload");minimizerContainer=$(this).closest(".WebUploadWidget");uploadIdentifier=minimizerContainer.attr("rel");minimizerContainer.remove();if($("#WebUploadMinimizer .WebUploadWidget").length==0){$("#WebUploadMinimizer").remove()}$('.WebUploadWidget[rel="'+uploadIdentifier+'"]').removeClass("uploadMinimized").attr("id","WebUploadWidget").show();if($("body").scrollTop()>$("html").scrollTop()){scrolltopValue=$("body").scrollTop()}else{scrolltopValue=$("html").scrollTop()}$("#WebUploadWidget").css("top",scrolltopValue)},selectDestinationFolder:function(e){e.preventDefault();$(this).hide();if($("#folderTree li.root > ul").length==1){$("#folderTree li.root ul script").remove();list="<ul>"+$("#folderTree li.root > ul").html()+"</ul>"}else{list=CMApplication.Widgets.FolderBrowser.browse()}html="<h4>"+CMApplication.Dictionnary.SELECT_A_DESTINATION+"</h4>";html+='<form id="selectUploadDestinationForm" action="#"><div class="content folderTree" id="selectUploadDestination">';html+='   <input type="hidden" name="destination" value="" />';html+='   <ul class="main">';html+='       <li class="root active" rel="D0"><a href="#" class="highlight">root</a>'+list+"</li>";html+="   </ul>";html+='   <button type="submit">'+CMApplication.Dictionnary.SELECT+"</button>";html+='   <button type="reset" class="cancel">'+CMApplication.Dictionnary.CANCEL+"</button>";html+="</div></form>";CMApplication.Widgets.Dialog.displayContent(html,650);$("#selectUploadDestination li.root li a em").replaceWith($("#selectUploadDestination li.root li a em").text());$("#selectUploadDestination li.root li.active").removeClass("active");$('#selectUploadDestination button[type="submit"]').click(function(e){e.preventDefault();if($("#selectUploadDestination li.active").length>0){destination=$("#selectUploadDestination li.active");folderName=destination.children("a").text();folderId=destination.attr("rel").replace("D","");$("#WebUploadWidget span.destination strong").text(folderName);$("#WebUploadWidget form select option").val(folderId).text(folderName);CMApplication.Widgets.Dialog.close();$("#WebUploadWidget form select").show()}});$('#selectUploadDestination button[type="reset"]').click(function(e){e.preventDefault();$("#WebUploadWidget form select").show();CMApplication.Widgets.Dialog.close()});$("#selectUploadDestination li").die("click");$("#selectUploadDestination li").live("click",function(e){e.preventDefault();e.stopPropagation();$(this).toggleClass("collapse");if($("ul",$(this)).length==0){$(this).append(CMApplication.Widgets.FolderBrowser.browse($(this).attr("rel")))}});$("#selectUploadDestination li a").die("click");$("#selectUploadDestination li a").live("click",function(e){e.preventDefault();$("#selectUploadDestination li.active").removeClass("active");$("#selectUploadDestination li a.highlight").removeClass("highlight");$(this).addClass("highlight");$(this).parent().addClass("active")})},submit:function(e){uploadIdentifier=$("#WebUploadWidget").attr("rel");CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].step="progress";CMApplication.Widgets.AdvancedUpload.open(uploadIdentifier);if("undefined"==(typeof CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].originalAction)){CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].originalAction=$(this).attr("action")}$(this).attr("action",CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].originalAction+"?callbackUrl="+CMApplication.URLs.domain+CMApplication.URLs.uploadCallback+"&X-Progress-ID="+uploadIdentifier);$("body").prepend('<iframe class="webUploadProxy" name="'+uploadIdentifier+'" src="#"></iframe>');$(this).attr("target",uploadIdentifier);$('input[type="file"]',this).each(function(key,elem){if($(elem).val()==""){$(elem).remove()}});CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].upload.lastUpdate=new Date().getTime();CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].progressTimer=setTimeout("CMApplication.Widgets.AdvancedUpload.getUploadProgress('"+uploadIdentifier+"');",1000);$(".buttons",this).append('<button type="button" class="webUploadCancel"><span>'+CMApplication.Dictionnary.CANCEL+"</span></button>");setTimeout("$('#WebUploadWidget button[type=\"submit\"]').remove();",100)},addFilesFromInstructionStep:function(event){uploadIdentifier=$("#WebUploadWidget").attr("rel");CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].step="fileSelection";CMApplication.Widgets.AdvancedUpload.open(uploadIdentifier)},addFiles:function(event){CMApplication.Widgets.AdvancedUpload._updateFiles();$('<input type="file" name="files[]" multiple="multiple" />').appendTo($("#WebUploadWidget form .files"))}},start:function(){uploadIdentifier="upload_"+new Date().getTime()+"_"+CMApplication.User.sessId+"_"+Math.floor(Math.random()*90000);CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier]={id:uploadIdentifier,files:[],step:"instructions",upload:{timerDelay:1000,speed:0,percent:0,size:0,lastSize:0,total:0}};eval("CMApplication.Widgets.AdvancedUpload.open"+CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].step.charAt(0).toUpperCase()+CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].step.slice(1)+'("'+uploadIdentifier+'")')},close:function(uploadIdentifier){confirmation=true;uploadContainer=$('.uploadMinimized.WebUploadWidget[rel="'+uploadIdentifier+'"]');if(uploadContainer.is(".progress")){confirmation=confirm(CMApplication.Dictionnary.LEAVING_WILL_CANCEL_UPLOADS)}if(confirmation){$('iframe.webUploadProxy[name="'+uploadIdentifier+'"]').remove();$('.WebUploadWidget[rel="'+uploadIdentifier+'"]').remove();if($("#WebUploadMinimizer .WebUploadWidget").length==0){$("#WebUploadMinimizer").remove()}if($("#WebUploadWidget").length==0){$("body").removeClass("displayWebUpload")}}},open:function(uploadIdentifier){eval("CMApplication.Widgets.AdvancedUpload.open"+CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].step.charAt(0).toUpperCase()+CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].step.slice(1)+'("'+uploadIdentifier+'")')},_open:function(uploadIdentifier){if($("#WebUploadWidget").length>0){return}xhtml="";xhtml+='<div id="WebUploadWidget" class="WebUploadWidget" rel="'+uploadIdentifier+'">';xhtml+='   <div class="WebUploadWidgetBackground"></div>';xhtml+='   <div class="WebUploadWidgetContainer">';xhtml+="       <h3><span>"+CMApplication.Dictionnary.WEB_UPLOAD+"</span></h3>";xhtml+='       <ul class="actions">';xhtml+='           <li class="restore"><a href=""><span>'+CMApplication.Dictionnary.RESTORE+"</span></a></li>";xhtml+='           <li class="minimize"><a href=""><span>'+CMApplication.Dictionnary.MINIMIZE+"</span></a></li>";xhtml+='           <li class="close"><a href=""><span>'+CMApplication.Dictionnary.CLOSE+"</span></a></li>";xhtml+="       </ul>";if(jQuery.getCookie("email")!=""){xhtml+='       <span class="destination">'+CMApplication.Dictionnary.FILES_UPLOADED_TO+"<strong></strong></span>"}xhtml+='       <form action="http://'+CMApplication.Widgets.AdvancedUpload.getUploadServerHostname()+'" method="post" enctype="multipart/form-data">';if(jQuery.getCookie("email")!=""){xhtml+='           <div class="destination">';xhtml+='               <label for="">'+CMApplication.Dictionnary.UPLOAD_TO_THIS_FOLDER+"</label> ";xhtml+='               <select name="folderId" class="destinationFolderId">';xhtml+='                  <option value="0">root</option>';xhtml+="               </select>";xhtml+="           </div>"}xhtml+='           <div class="files">';xhtml+="               <label><span>"+CMApplication.Dictionnary.CHOOSE_FILES_TO_UPLOAD+"</span></label>";xhtml+='               <input type="file" name="files[]" multiple="multiple" />';xhtml+="           </div>";xhtml+='           <div class="buttons">';xhtml+='               <button type="submit" class="webUploadSubmit"><span>'+CMApplication.Dictionnary.UPLOAD_NOW+"</span></button>";xhtml+="           </div>";xhtml+="       </form>";xhtml+="   </div>";xhtml+="</div>";$("body").addClass("displayWebUpload").append(xhtml);if($("body").scrollTop()>$("html").scrollTop()){scrolltopValue=$("body").scrollTop()}else{scrolltopValue=$("html").scrollTop()}$("#WebUploadWidget").css("top",scrolltopValue)},openComplete:function(uploadIdentifier,data){CMApplication.Widgets.AdvancedUpload.setUploadProgress(uploadIdentifier,{total:CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].upload.total,current:CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].upload.total});clearTimeout(CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].progressTimer);uploadContainer=$('.WebUploadWidget[rel="'+uploadIdentifier+'"]');uploadContainer.addClass("complete").removeClass("instructions").removeClass("progress").removeClass("fileSelection");var files=[];var failedCnt=0;if(typeof data=="string"){$(CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].files).each(function(key,value){failedCnt++;value.isSuccess=false;value.statusMessage=data;files.push(value)})}else{$(data).each(function(key,value){file={name:value.filename};switch(value.statusCode){case 0:file.isSuccess=true;file.size=value.link.size;file.id=value.link.id;break;default:file.isSuccess=false;file.statusMessage=value.statusMessage;failedCnt++}files.push(file)})}CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].files=files;uploadContainer=$('.WebUploadWidget[rel="'+uploadIdentifier+'"]');if(uploadContainer.length>0){CMApplication.Widgets.AdvancedUpload._updateFiles(uploadIdentifier);$("form, .progressbar",uploadContainer).remove();if(failedCnt==0){resultClass="success";resultHeading=CMApplication.Dictionnary.YOU_SUCCESSFULLY_UPLOADED+" "+files.length+" file"+(files.length>1?"s":"")}else{if(files.length>failedCnt){resultClass="warning";resultHeading=CMApplication.Dictionnary.YOU_UPLOADED+" "+(files.length-failedCnt)+" of "+files.length+CMApplication.Dictionnary.FILES}else{resultClass="error";resultHeading=CMApplication.Dictionnary.ERROR_DURING_THE_UPLOAD}}xhtml="";xhtml+='<div class="WebUploadWidgetResult '+resultClass+'">';xhtml+="    <h4><span>"+resultHeading+"</span></h4>";if(files.length!=failedCnt){xhtml+='    <a href="'+CMApplication.URLs.languageFilesystemGenerateLink.replace(":id","")+'" class="viewAllLinks"><span>'+CMApplication.Dictionnary.VIEW_ALL_LINKS+"</span></a>";if(jQuery.getCookie("email")!=""){xhtml+='    <a href="'+CMApplication.URLs.languageFilesystemShare.replace(":ids","")+'" class="shareAllLinks"><span>'+CMApplication.Dictionnary.SHARE_ALL_LINKS+"</span></a>"}xhtml+='    <a href="#" class="manageFiles"><span>'+CMApplication.Dictionnary.GO_TO_MANAGE_FILES+"</span></a>"}xhtml+="</div>";uploadContainer.each(function(key,container){if($(container).parent().is("body")){$(".WebUploadWidgetContainer",container).append(xhtml)}else{$(container).append(xhtml)}})}if($("#fileBrowser").length==1){CMApplication.Widgets.FileManager.FileBrowser.browse()}$('iframe.webUploadProxy[name="'+uploadIdentifier+'"]').remove()},openInstructions:function(uploadIdentifier){CMApplication.Widgets.AdvancedUpload._open(uploadIdentifier);uploadContainer=$('.WebUploadWidget[rel="'+uploadIdentifier+'"]');uploadContainer.addClass("instructions").removeClass("complete").removeClass("fileSelection").removeClass("progress");if($("div.instructions",uploadContainer).length==0){xhtml="";xhtml+='       <div class="instructions">';xhtml+="           <p>"+CMApplication.Dictionnary.CHOOSE_FILES_AND_THEN_PRESS_UPLOAD_NOW+"</p>";xhtml+="           <p>"+CMApplication.Dictionnary.TO_SELECT_MULTIPLE_FILES+"</p>";xhtml+="       </div>";$(xhtml).insertAfter($("ul.actions",uploadContainer))}},openFileSelection:function(uploadIdentifier){CMApplication.Widgets.AdvancedUpload._open(uploadIdentifier);uploadContainer=$('.WebUploadWidget[rel="'+uploadIdentifier+'"]');uploadContainer.addClass("fileSelection").removeClass("complete").removeClass("instructions").removeClass("progress");$(".files label span",uploadContainer).text("Add More Files");if($("table",uploadContainer).length==0){xhtml="";xhtml+='       <div class="fileListing">';xhtml+="       <table>";xhtml+="           <thead>";xhtml+="               <tr>";xhtml+='                   <th class="fileName">'+CMApplication.Dictionnary.FILE_NAME+"</th>";xhtml+='                   <th class="fileSize">'+CMApplication.Dictionnary.SIZE+"</th>";xhtml+="               </tr>";xhtml+="           </thead>";xhtml+="           <tfoot>";xhtml+="               <tr>";xhtml+='                   <th class="total">'+CMApplication.Dictionnary.TOTAL_FILES+" 0</th>";xhtml+='                   <th class="size">0 B</th>';xhtml+="               </tr>";xhtml+="           </tfoot>";xhtml+="           <tbody>";xhtml+="           </tbody>";xhtml+="       </table>";xhtml+="       </div>";$(xhtml).insertBefore($("form",uploadContainer))}},openProgress:function(uploadIdentifier){CMApplication.Widgets.AdvancedUpload._open(uploadIdentifier);uploadContainer=$('.WebUploadWidget[rel="'+uploadIdentifier+'"]');uploadContainer.addClass("progress").removeClass("complete").removeClass("instructions").removeClass("fileSelection");if($("div.progressbar",uploadContainer).length==0){xhtml="";xhtml+='       <div class="progressbar">';xhtml+="           <strong>"+CMApplication.Dictionnary.PROGRESS+"</strong>";xhtml+='           <div class="total">';xhtml+='              <div class="progress">';xhtml+="              </div>";xhtml+="           </div>";xhtml+='           <div class="info">';xhtml+='               <span class="percent">0%</span>';xhtml+='               <span class="speed">0b/s</span>';xhtml+="           </div>";xhtml+="       </div>";$(xhtml).insertAfter($("form",uploadContainer));CMApplication.Widgets.AdvancedUpload.updateProgress(uploadIdentifier,500)}},updateProgress:function(uploadIdentifier,nextCallDelay){uploadContainers=$('.WebUploadWidget[rel="'+uploadIdentifier+'"]');uploadContainers.each(function(key,value){uploadContainer=$(value);if($("div.progressbar",uploadContainer).length>0){myUpload=CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].upload;$("div.progressbar span.percent",uploadContainer).text(myUpload.percent+"%");$("div.progressbar span.speed",uploadContainer).text(CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.getHumanReadableSize(myUpload.speed)+"/s");newWidth=""+Math.round(myUpload.percent)+"%";$(".progress",uploadContainer).css("width",newWidth)}})},getUploadProgress:function(uploadIdentifier){if(CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].upload.percent<100){jQuery.ajax({url:"/keep-alive.php",cache:false,global:false});xhtml='<script type="text/javascript" src="'+CMApplication.URLs.uploadProgress.replace(":unique",new Date().getTime().toString()).replace(":hostserver",CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].originalAction).replace(":progress_key",uploadIdentifier).replace(":progress_key",uploadIdentifier)+'"><\/script>';$("body").append(xhtml)}},setUploadProgress:function(uploadIdentifier,data){if("undefined"==(typeof CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier])){return}uploadStatus=CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].upload;now=new Date().getTime();uploadStatus.lastSize=uploadStatus.size;uploadStatus.size=data.current;uploadStatus.total=data.total;uploadStatus.percent=Math.round(data.current*100/data.total);if(uploadStatus.percent>=100){clearTimeout(CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].progressTimer);uploadStatus.percent=100}if("undefined"==(typeof uploadStatus.onePercentSize)){uploadStatus.onePercentSize=1/100*data.total}if(uploadStatus.lastUpdate!=now){uploadStatus.speed=(uploadStatus.size-uploadStatus.lastSize)/((parseInt(now)-parseInt(uploadStatus.lastUpdate))/1000)}else{uploadStatus.speed=0}timerDelay=0;if(uploadStatus.percent<100){nextSizeProgressCall=(uploadStatus.percent+1)*uploadStatus.onePercentSize;byteDiff=nextSizeProgressCall-uploadStatus.size;timerDelay=Math.ceil(byteDiff/uploadStatus.speed*1000);if(timerDelay<500){timerDelay=300}if(timerDelay>8000){timerDelay=8000}CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].progressTimer=setTimeout("CMApplication.Widgets.AdvancedUpload.getUploadProgress('"+uploadIdentifier+"')",timerDelay)}uploadStatus.lastUpdate=now;CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].upload=uploadStatus;CMApplication.Widgets.AdvancedUpload.updateProgress(uploadIdentifier,timerDelay)},_updateFiles:function(uploadIdentifier){if("undefined"==(typeof uploadIdentifier)&&$("#WebUploadWidget").length>0){uploadIdentifier=$("#WebUploadWidget").attr("rel")}if("undefined"==(typeof uploadIdentifier)){return}uploadContainer=$('.WebUploadWidget[rel="'+uploadIdentifier+'"]');filesElements=$('form input[type="file"]',uploadContainer);if(filesElements.length>0&&CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].step!="complete"){var files=[];$(filesElements).each(function(key,input){if("undefined"!=(typeof input.files)){$(input.files).each(function(key,value){files.push({name:value.name,size:value.size})})}else{files.push({name:$(input).val(),size:null})}});CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier]["files"]=files}var xhtml="";var totalSize=0;$(CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier]["files"]).each(function(key,file){trClass=new Array();if(CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].step=="complete"){trClass.push(file.isSuccess?"success":"fail")}if(!(key%2)){trClass.push("odd")}xhtml+="               <tr"+(trClass.length>0?' class="'+trClass.join(" ")+'"':"")+(CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].step=="complete"&&file.isSuccess?' rel="F'+file.id+'"':"")+">";xhtml+='                   <th class="fileName"><span>'+file.name+"</span></th>";xhtml+='                   <td class="fileSize"><span>'+(!isNaN(file.size)&&file.size!==null?CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.getHumanReadableSize(file.size):"N/A")+"</span></td>";if(CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].step=="complete"){if(file.isSuccess){xhtml+='                   <td class="link"><a href="/file/'+file.id+'"><span>'+CMApplication.Dictionnary.DOWNLOAD_LINK+"</span></a></td>";if(jQuery.getCookie("email")!=""){xhtml+='                   <td class="share"><a href="'+CMApplication.URLs.languageFilesystemShare.replace(":ids","F"+file.id)+'"><span>'+CMApplication.Dictionnary.SHARE+"</span></a></td>"}}else{xhtml+='                   <th class="message" colspan="2"><strong>'+CMApplication.Dictionnary.FAIL+"</strong> "+file.statusMessage+"</th>"}}xhtml+="               </tr>";if(CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].step=="complete"){url=CMApplication.URLs.domain+"/file/"+file.id;xhtml+='               <tr style="display: none;"'+(trClass.length>0?' class="links '+trClass.join(" ")+'"':"")+' rel="F'+file.id+'">';colspan=(jQuery.getCookie("email")!="")?4:3;xhtml+='                   <td class="links" colspan="'+colspan+'">';xhtml+='                       <label for="link_url_'+file.id+'">URL: <input type="text" id="link_url_'+file.id+'" value="'+url+'" /></label>';xhtml+='                       <label for="link_forum_'+file.id+'">Forum Link: <input type="text" id="link_forum_'+file.id+'" value="[URL='+url+"]"+url+'[/URL]" /></label>';xhtml+='                       <label for="link_html_'+file.id+'">Html Link: <input type="text" id="link_html_'+file.id+'" value="&lt;a href=&quot;'+url+"&quot;&gt;"+url+'&lt;/a&gt;" /></label>';xhtml+="                   </td>";xhtml+="               </tr>"}if(!isNaN(file.size)&&file.size!==null){totalSize+=parseInt(file.size)}});$("table tbody",uploadContainer).html(xhtml);CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].upload.total=totalSize;xhtml="";xhtml+="               <tr>";xhtml+='                   <th class="total">'+CMApplication.Dictionnary.TOTAL_FILES+CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier]["files"].length+"</th>";xhtml+='                   <th class="size">'+(totalSize!==0?CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.getHumanReadableSize(totalSize):"N/A")+"</th>";if(CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].step=="complete"){if(totalSize>0){xhtml+='                   <td class="link"><a href="/file/"><span>'+CMApplication.Dictionnary.DOWNLOAD_LINK+"</span></a></td>";if(jQuery.getCookie("email")!=""){xhtml+='                   <td class="share"><a href="'+CMApplication.URLs.languageFilesystemShare.replace(":ids","")+'"><span>'+CMApplication.Dictionnary.SHARE+"</span></a></td>"}}else{xhtml+='                   <td colspan="2">&nbsp;</td>'}}xhtml+="               </tr>";$("table tfoot",uploadContainer).html(xhtml);if(CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier].step=="complete"){xhtml="";xhtml+='                   <th class="link">'+CMApplication.Dictionnary.VIEW_LINK+"</th>";if(jQuery.getCookie("email")!=""){xhtml+='                   <th class="share">'+CMApplication.Dictionnary.SHARE+"</th>"}$("table thead tr",uploadContainer).append(xhtml)}},_init:function(){$("#div_adv_upload_files .chooseFiles a").live("click",function(e){e.preventDefault();CMApplication.Widgets.AdvancedUpload.start()});$(".WebUploadWidget li.restore a").live("click",CMApplication.Widgets.AdvancedUpload.Events.restore);$("#WebUploadMinimizer > ul.actions li.close a").live("click",function(e){e.preventDefault();$("#WebUploadMinimizer .WebUploadWidget li.close a").trigger("click")});$(".WebUploadWidget li.close a, .WebUploadWidget .webUploadCancel").live("click",CMApplication.Widgets.AdvancedUpload.Events.close);$(".WebUploadWidget li.minimize a").live("click",CMApplication.Widgets.AdvancedUpload.Events.minimize);$(".WebUploadWidget.fileSelection form").live("submit",CMApplication.Widgets.AdvancedUpload.Events.submit);if(jQuery.browser.msie){$('.WebUploadWidget.instructions input[type="file"]').live("click",function(e){$("#inputFileSelection").removeAttr("id");clearTimeout(ieFixForFileSelectionOnChangeEventTimer);$(this).attr("id","inputFileSelection");ieFixForFileSelectionOnChangeEventTimer=setTimeout("ieFixForFileSelectionOnChangeEvent()",200)})}$('.WebUploadWidget.instructions input[type="file"]').live("change",CMApplication.Widgets.AdvancedUpload.Events.addFilesFromInstructionStep);$('.WebUploadWidget input[type="file"]').live("change",CMApplication.Widgets.AdvancedUpload.Events.addFiles);$(".WebUploadWidget select.destinationFolderId").live("click",CMApplication.Widgets.AdvancedUpload.Events.selectDestinationFolder);$(".WebUploadWidget tbody td.share a").live("click",function(e){e.preventDefault();CMApplication.Widgets.Dialog.displayUrl($(this).attr("href"))});$(".WebUploadWidget tbody td.link a").live("click",function(e){e.preventDefault();$(this).closest("tr").next().toggle()});$(".WebUploadWidgetResult a.manageFiles").live("click",function(e){e.preventDefault();CMApplication.foward(CMApplication.URLs.languageFilesystemBrowse.replace(/\/\:[a-z]*/gi,""))});$(".WebUploadWidget tfoot td.share a").live("click",function(e){e.preventDefault();$(".WebUploadWidgetResult a.shareAllLinks",$(this).closest(".WebUploadWidget")).trigger("click")});$(".WebUploadWidgetResult a.shareAllLinks").live("click",function(e){e.preventDefault();var ids=new Array();$('.WebUploadWidget[rel="'+$(this).closest(".WebUploadWidget").attr("rel")+'"] table tbody tr.success:not(.links)').each(function(key,value){ids.push($(value).attr("rel"))});CMApplication.Widgets.Dialog.displayUrl($(this).attr("href")+ids)});$(".WebUploadWidget tfoot td.link a").live("click",function(e){e.preventDefault();$(".WebUploadWidgetResult a.viewAllLinks",$(this).closest(".WebUploadWidget")).trigger("click")});$(".WebUploadWidgetResult a.viewAllLinks").live("click",function(e){e.preventDefault();var ids=new Array();$('.WebUploadWidget[rel="'+$(this).closest(".WebUploadWidget").attr("rel")+'"] table tbody tr.success:not(.links)').each(function(key,value){ids.push($(value).attr("rel"))});CMApplication.Widgets.Dialog.displayUrl($(this).attr("href")+ids)})}};CMApplication.Widgets.Upload={Events:{submit:function(event){uploadIdentifier="upload_"+new Date().getTime()+"_"+CMApplication.User.sessId+"_"+Math.floor(Math.random()*90000);if(undefined!=$("#input-file")[0]&&undefined!=$("#input-file")[0].files&&undefined!=$("#input-file")[0].files.length&&$("#input-file")[0].files.length>1){uploadFilename="Upload of "+$("#input-file")[0].files.length+" files"}else{uploadFilename=$('input[type="file"]',this).val()}if(!$("form.webUpload").attr("originalAction")){$("form.webUpload").attr("originalAction",$("form.webUpload").attr("action"))}$("form.webUpload").attr("action",$("form.webUpload").attr("originalAction")+"/?X-Progress-ID="+uploadIdentifier);$("body").prepend('<iframe rel="'+uploadIdentifier+'" originalAction="'+$("form.webUpload").attr("originalAction")+'" class="upload" name="'+uploadIdentifier+'" src="#"></iframe>');$(this).attr("target",uploadIdentifier);CMApplication.Widgets.Upload.Progress._construct(uploadIdentifier,uploadFilename);setTimeout("if ($('.webUpload').length > 0) $('.webUpload')[0].reset()",500);callbackUrlField=$('input[name="callbackUrl"]',this);if(callbackUrlField.length==0){callbackUrlField=jQuery('<input type="hidden" name="callbackUrl" value="" />').appendTo($(this))}callbackUrlField.val(CMApplication.URLs.domain+CMApplication.URLs.uploadCallback);if(CMApplication.User.role==CMApplication.User.RolesValues.ANONYMOUS){$("#quickUpload").hide()}if(false&&$("iframe.upload").length==1){CMApplication.Widgets.Ajax.start()}}},Progress:{InProgressTimer:{},_construct:function(uploadIdentifier,uploadFilename){uploadStatusWrapper=$("#uploadStatusWrapper");if(uploadStatusWrapper.length==0){$('<div id="uploadStatusContainer"><h3>'+CMApplication.Dictionnary.YOUR_UPLOADS+'</h3><div id="uploadStatusWrapper"></div><a id="viewAllLinks" href="">'+CMApplication.Dictionnary.VIEW_ALL_LINKS+"</a></div>").appendTo("body");$("#viewAllLinks").live("click",function(event){event.preventDefault();var patt1=new RegExp("[^/]*$");var links="";$("#uploadStatusWrapper a.link").each(function(){links+=patt1.exec($(this).attr("href"))+","});CMApplication.Widgets.Dialog.displayUrl(CMApplication.URLs.languageFilesystemGenerateLink.replace(":id",links))});uploadStatusWrapper=$("#uploadStatusWrapper")}if(uploadFilename.length>37){uploadFilename=uploadFilename.substring(0,17)+"..."+uploadFilename.substring(uploadFilename.length-17)}uploadStatusWrapper.append('<div id="'+uploadIdentifier+'" class="uploadStatus"><span class="filename">'+uploadFilename+'</span><div class="progressBar"><div class="state"></div></div><span class="percentageCompleted"></span></div>');CMApplication.Widgets.Upload.Progress.updateRequest(uploadIdentifier)},complete:function(uploadIdentifier,results){clearTimeout(CMApplication.Widgets.Upload.Progress.InProgressTimer[uploadIdentifier]);$("#"+uploadIdentifier+" .progressBar").remove();$('iframe[rel="'+uploadIdentifier+'"]').remove();var xhtml="";var errorsMsg="";var successLinks=[];$(results).each(function(key,value){xhtml+='<div class="element">';if(value.statusCode==0&&value.linkId!=0){successLinks.push(value.linkId)}else{xhtml+=CMApplication.Dictionnary.ERROR+" <span>"+value.filename+"</span>";errorsMsg+="<li><strong>"+value.filename+"</strong>: "+value.statusMessage+"</li>"}xhtml+="</div>"});if(successLinks.length>0){viewLinkUrl=CMApplication.URLs.languageFilesystemGenerateLink.replace(":id",successLinks.join(","));xhtml+='<div class="element">';xhtml+=CMApplication.Dictionnary.COMPLETED+" ";xhtml+='<a href="'+viewLinkUrl+'" onclick="CMApplication.Widgets.Dialog.displayUrl(this.href, 700); return false;" class="link" title="'+CMApplication.Dictionnary.VIEW_LINKS+'"><span>'+CMApplication.Dictionnary.VIEW_LINKS+"</span></a>";xhtml+="</div>"}xhtml+='<a href="#" onclick="CMApplication.Widgets.Upload.Progress.close(\''+uploadIdentifier+'\'); return false;" class="close" title="'+CMApplication.Dictionnary.CLOSE+'"><span>'+CMApplication.Dictionnary.CLOSE+"</span></a>";$("#"+uploadIdentifier+" .percentageCompleted").html(xhtml);if(false&&$("iframe.upload").length==0){CMApplication.Widgets.Ajax.stop()}if(errorsMsg!=""){errorsMsg=CMApplication.Dictionnary.FOLLOWING_ERROR_DURING_UPLOAD+"<ul>"+errorsMsg+"</ul>";CMApplication.Widgets.Dialog.displayMessage(errorsMsg,CMApplication.Widgets.Dialog.Types.error)}},close:function(uploadIdentifier){$("#"+uploadIdentifier).remove();if($("#uploadStatusWrapper").children().length==0){$("#uploadStatusContainer").remove()}},updateRequest:function(uploadIdentifier){jQuery.ajax({url:"/keep-alive.php",cache:false});xhtml='<script type="text/javascript" src="'+CMApplication.URLs.uploadProgress.replace(":unique",new Date().getTime().toString()).replace(":hostserver",$('iframe[rel="'+uploadIdentifier+'"]').attr("originalAction")).replace(":progress_key",uploadIdentifier).replace(":progress_key",uploadIdentifier)+'"><\/script>';CMApplication.Widgets.Upload.Progress.InProgressTimer[uploadIdentifier]=setTimeout("$('body').append('"+xhtml+"');",2000)},updateResponse:function(uploadIdentifier,data){if("undefined"!=(typeof CMApplication.Widgets.AdvancedUpload.Uploads[uploadIdentifier])){CMApplication.Widgets.AdvancedUpload.setUploadProgress(uploadIdentifier,data)}else{if(data.current!=null){percent=Math.ceil(parseInt(data.current)/parseInt(data.total)*100).toString()+"%";$("#"+uploadIdentifier+" .state").css("width",percent);if(data.percent!=100){CMApplication.Widgets.Upload.Progress.updateRequest(uploadIdentifier);$("#"+uploadIdentifier+" .percentageCompleted").text(percent)}}}}},_init:function(){$(".webUpload").live("submit",CMApplication.Widgets.Upload.Events.submit)}};CMApplication.Widgets.Internationalization={widgetLink:$("#internationalization"),Events:{open:function(e){if(!$(this).hasClass("active")){e.preventDefault();e.stopPropagation();CMApplication.Widgets.Internationalization.open(this)}},close:function(e){CMApplication.Widgets.Internationalization.close()}},open:function(){this.widgetLink.addClass("active");$(document).bind("click",this.Events.close)},close:function(){this.widgetLink.removeClass("active");$(document).unbind("click",this.Events.close)}};CMApplication.Widgets.FolderBrowser={url:CMApplication.URLs.languageFilesystemBrowse.replace(/\/\:[a-z]*/gi,"")+"?partial=folderTree&widget=folderBrowser&orderFoldersBy=name&orderFoldersDirection=desc",response:null,browse:function(folderId){$("#selectAllFiles").attr("checked",null);$("#globalSearch").attr("checked",null);if(folderId==undefined){var myUrl=CMApplication.Widgets.FolderBrowser.url}else{var myUrl=CMApplication.Widgets.FolderBrowser.url.replace("browse?","browse/"+folderId+"?")}$.ajax({async:false,url:myUrl,dataType:"html",success:function(data,textStatus,XMLHttpRequest){CMApplication.Widgets.FolderBrowser.response=data}});return"<ul>"+CMApplication.Widgets.FolderBrowser.response+"</ul>"}};CMApplication.Widgets.FileManager={Items:{_items:{},add:function(items){CMApplication.Widgets.FileManager.Items._items=jQuery.extend({},CMApplication.Widgets.FileManager.Items._items,items)},getInfo:function(id){return CMApplication.Widgets.FileManager.Items._items[id]}},History:{log:[0],current:0,Previous:{exec:function(){newPosition=CMApplication.Widgets.FileManager.History.current-1;absoluteNewPosition=Math.abs(newPosition);positionAvailable=CMApplication.Widgets.FileManager.History.log.length;positionInArray=positionAvailable-absoluteNewPosition-1;if(positionInArray<0){return}CMApplication.Widgets.FileManager.History.current=newPosition;folderId=CMApplication.Widgets.FileManager.History.log[positionInArray];CMApplication.Widgets.FileManager.FileBrowser.browse(folderId,false)}},Next:{exec:function(){newPosition=CMApplication.Widgets.FileManager.History.current+1;if(newPosition>0){return}absoluteNewPosition=Math.abs(newPosition);positionAvailable=CMApplication.Widgets.FileManager.History.log.length;positionInArray=positionAvailable-absoluteNewPosition-1;CMApplication.Widgets.FileManager.History.current=newPosition;folderId=CMApplication.Widgets.FileManager.History.log[positionInArray];CMApplication.Widgets.FileManager.FileBrowser.browse(folderId,false)}},addLog:function(folderId){CMApplication.Widgets.FileManager.History.log.push(folderId)}},NavigationBar:{Previous:{linkElement:$("#navigationBar li.back a"),Events:{click:function(event){event.preventDefault();CMApplication.Widgets.FileManager.History.Previous.exec();CMApplication.Widgets.FileManager.NavigationBar.Previous.updateLinkStyle();CMApplication.Widgets.FileManager.NavigationBar.Next.updateLinkStyle()}},updateLinkStyle:function(){currentPosition=Math.abs(CMApplication.Widgets.FileManager.History.current);availablePosition=CMApplication.Widgets.FileManager.History.log.length;linkElement=CMApplication.Widgets.FileManager.NavigationBar.Previous.linkElement;if(availablePosition==(currentPosition+1)){linkElement.addClass("disabled")}else{linkElement.removeClass("disabled")}}},Next:{linkElement:$("#navigationBar li.foward a"),Events:{click:function(event){event.preventDefault();CMApplication.Widgets.FileManager.History.Next.exec();CMApplication.Widgets.FileManager.NavigationBar.Previous.updateLinkStyle();CMApplication.Widgets.FileManager.NavigationBar.Next.updateLinkStyle()}},updateLinkStyle:function(){currentPosition=Math.abs(CMApplication.Widgets.FileManager.History.current);linkElement=CMApplication.Widgets.FileManager.NavigationBar.Next.linkElement;if(currentPosition==0){linkElement.addClass("disabled")}else{linkElement.removeClass("disabled")}}},Parent:{linkElement:$("#navigationBar li.parent a"),Events:{click:function(event){event.preventDefault();parentFolder=$("#folderTree li:has(li.active)");if(parentFolder.length==0){return}folderId=parentFolder.attr("rel");CMApplication.Widgets.FileManager.FileBrowser.browse(folderId);CMApplication.Widgets.FileManager.NavigationBar.Parent.updateLinkStyle()}},updateLinkStyle:function(){parentFolder=$("#folderTree li:has(li.active)");linkElement=CMApplication.Widgets.FileManager.NavigationBar.Parent.linkElement;if(parentFolder.length==0){linkElement.addClass("disabled")}else{linkElement.removeClass("disabled")}}},New:{linkElement:$("#navigationBar li.new a"),Events:{click:function(event){event.preventDefault();currentFolderId=$("#folderTree li.active").attr("rel");CMApplication.Widgets.FileManager.FileBrowser.newFolder(currentFolderId)}}},Copy:{linkElement:$("#navigationBar li.copy a"),Events:{click:function(event){event.preventDefault();if(!$("#selectAllFolder").attr("checked")){elementsId=[];$("#fileList li.selected").each(function(){elementsId.push($(this).attr("rel"))});if(elementsId.length==0){CMApplication.Widgets.Dialog.displayMessage(CMApplication.Dictionnary.FILESYSTEM_COPY_INSTRUCTION,CMApplication.Widgets.Dialog.Types.notice);return}}else{elementsId=[-1]}CMApplication.Widgets.FileManager.FileBrowser.copy(elementsId)}},updateLinkStyle:function(){parentFolder=$("#folderTree li:has(li.active)");linkElement=CMApplication.Widgets.FileManager.NavigationBar.Copy.linkElement;if($("#fileList li.selected").length==0){linkElement.addClass("disabled")}else{linkElement.removeClass("disabled")}if(!$("#selectAllFolder").attr("checked")){linkElement.addClass("disabled")}else{linkElement.removeClass("disabled")}}},Move:{linkElement:$("#navigationBar li.move a"),Events:{click:function(event){event.preventDefault();var ids=new Array();$("#fileList input:checked").each(function(){ids.push($(this).val())});if(ids.length==0){CMApplication.Widgets.Dialog.displayMessage(CMApplication.Dictionnary.FILESYSTEM_MOVE_INSTRUCTION,CMApplication.Widgets.Dialog.Types.notice);return}CMApplication.Widgets.FileManager.FileBrowser.move(ids)}},updateLinkStyle:function(){parentFolder=$("#folderTree li:has(li.active)");linkElement=CMApplication.Widgets.FileManager.NavigationBar.Move.linkElement;if($("#fileList li.selected").length==0){linkElement.addClass("disabled")}else{linkElement.removeClass("disabled")}}},GenerateLink:{linkElement:$("#navigationBar li.links a"),Events:{submit:function(event){event.preventDefault();event.stopPropagation();var myUrl=$(this).attr("action");var myParams=$(this).serialize();jQuery.ajax({async:false,url:myUrl,type:"POST",data:myParams,dataType:"html",success:function(data,textStatus,XMLHttpRequest){CMApplication.Widgets.Dialog.displayContent(data);$("#linksForm").submit(CMApplication.Widgets.FileManager.NavigationBar.GenerateLink.Events.submit)}})},click:function(event){event.preventDefault();elementsId=[];$("#fileList li.selected").each(function(){elementsId.push($(this).attr("rel"))});if(elementsId.length==0){CMApplication.Widgets.Dialog.displayMessage(CMApplication.Dictionnary.FILESYSTEM_GENERATELINKS_INSTRUCTION,CMApplication.Widgets.Dialog.Types.notice);return}if(elementsId[0].substring(0,1)=="Z"||elementsId[0].substring(0,1)=="D"){CMApplication.Widgets.Dialog.displayMessage("Can not generate links from the dropbox folder. Please copy these files into your FileSonic account before.",CMApplication.Widgets.Dialog.Types.notice);return}var xHtml="";jQuery.ajax({async:false,url:CMApplication.URLs.languageFilesystemGenerateLink.replace("/:id",""),type:"POST",data:{id:elementsId.join(",")},dataType:"html",success:function(data,textStatus,XMLHttpRequest){xHtml=data}});CMApplication.Widgets.Dialog.displayContent(xHtml);$("#linksForm").submit(CMApplication.Widgets.FileManager.NavigationBar.GenerateLink.Events.submit)}},updateLinkStyle:function(){parentFolder=$("#folderTree li:has(li.active)");linkElement=CMApplication.Widgets.FileManager.NavigationBar.Move.linkElement;if($("#fileList li.selected").length==0){linkElement.addClass("disabled")}else{linkElement.removeClass("disabled")}}},Trash:{linkElement:$("#navigationBar li.trash a"),Events:{click:function(event){event.preventDefault();elementsId=[];$("#fileList li.selected").each(function(){elementsId.push($(this).attr("rel"))});if(elementsId.length==0){CMApplication.Widgets.Dialog.displayMessage(CMApplication.Dictionnary.FILESYSTEM_TRASH_INSTRUCTION,CMApplication.Widgets.Dialog.Types.notice);return}CMApplication.Widgets.FileManager.FileBrowser.trash(elementsId)}},updateLinkStyle:function(){parentFolder=$("#folderTree li:has(li.active)");linkElement=CMApplication.Widgets.FileManager.NavigationBar.Trash.linkElement;if($("#fileList li.selected").length==0){linkElement.addClass("disabled")}else{linkElement.removeClass("disabled")}}},Premium:{linkElement:$("#navigationBar li.premium a"),Events:{click:function(event){if(!$("#selectAllFolder").attr("checked")){event.preventDefault();elementsId=[];$("#fileList li.selected").each(function(){elementsId.push($(this).attr("rel"))});if(elementsId.length==0){CMApplication.Widgets.Dialog.displayMessage(CMApplication.Dictionnary.FILESYSTEM_PREMIUM_INSTRUCTION,CMApplication.Widgets.Dialog.Types.notice);return}}else{elementsId=[-1]}CMApplication.Widgets.FileManager.FileBrowser.premium(elementsId)}},updateLinkStyle:function(){parentFolder=$("#folderTree li:has(li.active)");linkElement=CMApplication.Widgets.FileManager.NavigationBar.Premium.linkElement;if($("#fileList li.selected").length==0){linkElement.addClass("disabled")}else{linkElement.removeClass("disabled")}}},Unpremium:{linkElement:$("#navigationBar li.unsetPremium a"),Events:{click:function(event){event.preventDefault();elementsId=[];$("#fileList li.selected").each(function(){elementsId.push($(this).attr("rel"))});if(elementsId.length==0){CMApplication.Widgets.Dialog.displayMessage(CMApplication.Dictionnary.FILESYSTEM_PREMIUM_INSTRUCTION,CMApplication.Widgets.Dialog.Types.notice);return}CMApplication.Widgets.FileManager.FileBrowser.unpremium(elementsId)}},updateLinkStyle:function(){parentFolder=$("#folderTree li:has(li.active)");linkElement=CMApplication.Widgets.FileManager.NavigationBar.Unpremium.linkElement;if($("#fileList li.selected").length==0){linkElement.addClass("disabled")}else{linkElement.removeClass("disabled")}}},Upload:{linkElement:$("#navigationBar li.upload a"),Events:{click:function(event){event.preventDefault();CMApplication.Widgets.AdvancedUpload.start();$("#WebUploadWidget select.destinationFolderId option").val($("#folderTree li.active").attr("rel").replace("D","")).text($("#folderTree li.active > a").text())}}},updateLinksStyles:function(){CMApplication.Widgets.FileManager.NavigationBar.Previous.updateLinkStyle();CMApplication.Widgets.FileManager.NavigationBar.Next.updateLinkStyle();CMApplication.Widgets.FileManager.NavigationBar.Parent.updateLinkStyle();CMApplication.Widgets.FileManager.NavigationBar.Copy.updateLinkStyle();CMApplication.Widgets.FileManager.NavigationBar.Move.updateLinkStyle();CMApplication.Widgets.FileManager.NavigationBar.Trash.updateLinkStyle();CMApplication.Widgets.FileManager.NavigationBar.Premium.updateLinkStyle();CMApplication.Widgets.FileManager.NavigationBar.Unpremium.updateLinkStyle();CMApplication.Widgets.FileManager.NavigationBar.GenerateLink.updateLinkStyle();$("#selectAllFiles").attr("checked",null)},_init:function(){CMApplication.Widgets.FileManager.NavigationBar.updateLinksStyles();CMApplication.Widgets.FileManager.NavigationBar.Previous.linkElement.bind("click",CMApplication.Widgets.FileManager.NavigationBar.Previous.Events.click);CMApplication.Widgets.FileManager.NavigationBar.Next.linkElement.bind("click",CMApplication.Widgets.FileManager.NavigationBar.Next.Events.click);CMApplication.Widgets.FileManager.NavigationBar.Parent.linkElement.bind("click",CMApplication.Widgets.FileManager.NavigationBar.Parent.Events.click);CMApplication.Widgets.FileManager.NavigationBar.New.linkElement.bind("click",CMApplication.Widgets.FileManager.NavigationBar.New.Events.click);CMApplication.Widgets.FileManager.NavigationBar.Copy.linkElement.bind("click",CMApplication.Widgets.FileManager.NavigationBar.Copy.Events.click);CMApplication.Widgets.FileManager.NavigationBar.Move.linkElement.bind("click",CMApplication.Widgets.FileManager.NavigationBar.Move.Events.click);CMApplication.Widgets.FileManager.NavigationBar.Trash.linkElement.bind("click",CMApplication.Widgets.FileManager.NavigationBar.Trash.Events.click);CMApplication.Widgets.FileManager.NavigationBar.Upload.linkElement.bind("click",CMApplication.Widgets.FileManager.NavigationBar.Upload.Events.click);CMApplication.Widgets.FileManager.NavigationBar.Premium.linkElement.bind("click",CMApplication.Widgets.FileManager.NavigationBar.Premium.Events.click);CMApplication.Widgets.FileManager.NavigationBar.Unpremium.linkElement.bind("click",CMApplication.Widgets.FileManager.NavigationBar.Unpremium.Events.click);CMApplication.Widgets.FileManager.NavigationBar.GenerateLink.linkElement.bind("click",CMApplication.Widgets.FileManager.NavigationBar.GenerateLink.Events.click)}},NavigationHelper:{Breadcrumb:{breadcrumbContainer:$("#fileManager div.navigationHelper div.breadcrumb"),folders:{},Events:{click:function(event){event.preventDefault();$("#selectAllFiles").attr("checked",null);CMApplication.Widgets.FileManager.FileBrowser.browse($(this).attr("rel"))}},update:function(){folders={};lastLi=$("#folderTree li.active");folders[lastLi.attr("rel")]=lastLi.children("a").text();for(i=0;i<=1;i++){tmpLastLi=lastLi.parent().closest("#folderTree li");if(tmpLastLi.length>0){lastLi=tmpLastLi;folders[lastLi.attr("rel")]=lastLi.children("a").text()}else{break}}breadcrumb="";CMApplication.Widgets.FileManager.NavigationHelper.Breadcrumb.breadcrumbContainer.html("");count=0;for(var folderId in folders){count++;if(count>1){CMApplication.Widgets.FileManager.NavigationHelper.Breadcrumb.breadcrumbContainer.prepend(" » ")}CMApplication.Widgets.FileManager.NavigationHelper.Breadcrumb.breadcrumbContainer.prepend('<a href="'+CMApplication.URLs.languageFilesystemBrowse.replace(":folderId",folderId).replace(/\/\:[a-z]*/gi,"")+'" rel="'+folderId+'">'+folders[folderId]+"</a>")}if(lastLi.parent().closest("#folderTree li").length>0){CMApplication.Widgets.FileManager.NavigationHelper.Breadcrumb.breadcrumbContainer.prepend("[...] ")}CMApplication.Widgets.FileManager.NavigationHelper.Breadcrumb.folders=folders}},selectAll:{selectAll:function(){if($("input.select:not(:checked)").length){$("div.selectAll > input").attr("checked",true);$("input.select:not(:checked)").attr("checked",true).parent("li").addClass("selected")}else{$("div.selectAll > input").attr("checked",false);$("input.select:checked").attr("checked",false).parent("li").removeClass("selected")}CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.update();CMApplication.Widgets.FileManager.NavigationBar.updateLinksStyles()}},selectAllFolder:{selectAllFolder:function(){CMApplication.Widgets.FileManager.NavigationBar.updateLinksStyles()}},sortBy:{sortBy:function(){$("#selectAllFiles").attr("checked",null);if(window.location.href.indexOf(CMApplication.URLs.languageFilesystemRemoved)>-1){CMApplication.foward(CMApplication.URLs.languageFilesystemRemoved+"/1/"+$("#sortby").val()+"/"+$("#direction").val())}else{CMApplication.Widgets.FileManager.FileBrowser.browse(undefined,false)}}},setDisplayLinks:{setDisplayLinks:function(){$.post("/filesystem/set-link-count",{linkCount:$("#linksToDisplay").val()},function(data){CMApplication.Widgets.FileManager.FileBrowser.browse()})}},_init:function(){$("#fileManager div.navigationHelper div.breadcrumb a").live("click",CMApplication.Widgets.FileManager.NavigationHelper.Breadcrumb.Events.click);CMApplication.Widgets.FileManager.NavigationHelper.Breadcrumb.update();$("div.selectAll a").live("click",function(event){event.preventDefault();CMApplication.Widgets.FileManager.NavigationHelper.selectAll.selectAll()});$("div.selectAll input").live("click",function(event){CMApplication.Widgets.FileManager.NavigationHelper.selectAll.selectAll()});$("#selectAllFolder").live("click",function(event){CMApplication.Widgets.FileManager.NavigationHelper.selectAllFolder.selectAllFolder()});$("#linksToDisplay").live("change",function(event){$("#selectAllFiles").attr("checked",null);CMApplication.Widgets.FileManager.NavigationHelper.setDisplayLinks.setDisplayLinks()});$("#searchForm").submit(function(event){event.preventDefault();$(".paginator b").replaceWith($(".paginator b big a"));$(".paginator > a:nth-child(2)").wrap("<b><big /></b>");$("#selectAllFiles").attr("checked",false);isSearchResult=$("#queryString").val();if($("#globalSearch").attr("checked")){isGlobalSearch=1}CMApplication.Widgets.FileManager.FileBrowser.browse()});$("#sortForm").submit(function(event){event.preventDefault();CMApplication.Widgets.FileManager.NavigationHelper.sortBy.sortBy()})}},FileBrowser:{browserElement:$("#fileBrowser"),Events:{browse:function(event){event.stopPropagation();event.preventDefault();if($(this).parent().is(".dropboxRoot.setupRequired")){CMApplication.Widgets.Dialog.displayUrl("/dropbox/setup");return false}isSearchResult=false;isGlobalSearch=0;$("#queryString").val("");$("#globalSearch").attr("checked",false);$("#selectAllFiles").attr("checked",false);if($(this).closest("li").hasClass("collapse")){$(this).closest("li").trigger("click")}CMApplication.Widgets.FileManager.FileBrowser.browse($(this).closest("li").attr("rel"))},search:function(event){event.stopPropagation();event.preventDefault();CMApplication.Widgets.FileManager.FileBrowser.browse($(this).closest("li").attr("rel"))}},getUrl:function(folderId){if(folderId===undefined){folderId=$("#folderTree li.active").length==1?$("#folderTree li.active").attr("rel"):"D0"}queryString=$("#queryString").val();globalSearch=$("#globalSearch:checked").val()==1?1:0;orderBy=$("#sortby").val();orderDirection=$("#direction").val();page=$(".paginator b big a").length==1?$(".paginator b big a").text():1;myUrl=CMApplication.URLs.languageFilesystemBrowse;myUrl=myUrl.replace(":folderId",urlencode(folderId));myUrl=myUrl.replace(":page",urlencode(page));myUrl=myUrl.replace(":orderBy",urlencode(orderBy));myUrl=myUrl.replace(":orderDirection",urlencode(orderDirection));myUrl=myUrl.replace(":globalSearch",urlencode(globalSearch));myUrl=myUrl.replace(":queryString",urlencode(queryString));return myUrl},browse:function(folderId,addLog){$("#selectAllFiles").attr("checked",false);var addLog;if(typeof(addLog)!=="boolean"){addLog=true}if(folderId===undefined){folderId=$("#folderTree li.active").length==1?$("#folderTree li.active").attr("rel"):"D0"}if(folderId.substring(0,1)=="B"&&$("#exportFolderLinks").attr("rel")==""){$("#exportFolderLinks").attr("rel",$("#exportFolderLinks").attr("href")).removeAttr("href").css("text-decoration","line-through").attr("title","Not available when browsing Dropbox Folders");$("#searchForm, #searchForm button, #searchForm input, #sortForm, #sortForm select, #sortForm button").attr("disabled","disabled")}else{if(folderId.substring(0,1)!="B"&&$("#exportFolderLinks").attr("rel")!=""){$("#exportFolderLinks").attr("href",$("#exportFolderLinks").attr("rel")).attr("rel","").css("text-decoration","underline").removeAttr("title");$("#searchForm, #searchForm button, #searchForm input, #sortForm, #sortForm select, #sortForm button").removeAttr("disabled")}}jQuery.ajax({url:CMApplication.Widgets.FileManager.FileBrowser.getUrl(folderId)+"?partial=fileList",type:"POST",data:{folderId:folderId},dataType:"html",success:function(data,textStatus,XMLHttpRequest){queryParams=jQuery.unparam(this.data);folderId=queryParams.folderId;CMApplication.Widgets.FileManager.FileBrowser.FileList.populate(data,folderId);CMApplication.Widgets.FileManager.FileBrowser.FolderTree.updateActiveElement(folderId);CMApplication.Widgets.FileManager.NavigationHelper.Breadcrumb.update();if(addLog){CMApplication.Widgets.FileManager.History.addLog(folderId)}CMApplication.Widgets.FileManager.NavigationBar.updateLinksStyles();CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.update()}})},move:function(filesId){if(filesId.length==0){alert("Please select an item to move");return false}isDropboxMove=(filesId[0].substring(0,1)=="Z"||filesId[0].substring(0,1)=="B");if(isDropboxMove&&$("#selectAllFiles").attr("checked")){if(typeof(totalItemCount)=="undefined"){totalItemCount=totalFilesInFolder}if(totalItemCount>100){if(!confirm("Are you sure you want to move "+totalItemCount+" files?")){return}}}rootClass=(!isDropboxMove?"root":"dropboxRoot");if($("#folderTree li."+rootClass+" > ul").length==1){$("#folderTree li."+rootClass+" ul script").remove();list="<ul>"+$("#folderTree li."+rootClass+" > ul").html()+"</ul>"}else{if(!isDropboxMove){list=CMApplication.Widgets.FolderBrowser.browse()}else{list=CMApplication.Widgets.FolderBrowser.browse("B")}}html="<h4>"+CMApplication.Dictionnary.SELECT_A_DESTINATION+"</h4>";var action=$("#navigationBar li.move a").attr("href")+"/";html+='<form id="selectMoveDestinationForm" action="'+action+'"><div class="content folderTree" id="selectMoveDestination">';html+='   <input type="hidden" name="destination" value="" />';if(isDropboxMove||!$("#selectAllFiles").attr("checked")){for(i=0;i<filesId.length;i++){html+='   <input type="hidden" name="files[]" value="'+filesId[i]+'" />'}}if(!isDropboxMove&&$("#selectAllFiles").attr("checked")){currentFolder=$("#folderTree li.active").attr("rel");if(!isDropboxMove&&isSearchResult){currentFolder=currentFolder+"|"+isSearchResult+"|"+isGlobalSearch}html+='   <input type="hidden" name="currentFolder" value="'+currentFolder+'" />'}html+='   <ul class="main">';if(!isDropboxMove){html+='       <li class="root active" rel="D0"><a href="#" class="highlight">My Files</a>'+list+"</li>"}else{html+='       <li class="dropboxRoot active" rel="B"><a href="#" class="highlight">My Dropbox</a>'+list+"</li>"}html+="   </ul>";html+='   <button type="submit">'+CMApplication.Dictionnary.MOVE+"</button>";html+='   <button type="reset" class="cancel">'+CMApplication.Dictionnary.CANCEL+"</button>";html+="</div></form>";CMApplication.Widgets.Dialog.displayContent(html,650);$("#selectMoveDestination li."+rootClass+" li a em").replaceWith($("#selectMoveDestination li."+rootClass+" li a em").text());$("#selectMoveDestination li."+rootClass+" li.active").removeClass("active");$('#selectMoveDestination button[type="submit"]').click(function(e){e.preventDefault();if($("#selectMoveDestination li.active").length>0){$('#selectMoveDestinationForm input[name="destination"]').val($("#selectMoveDestination li.active").attr("rel"));$.post($("#selectMoveDestinationForm").attr("action"),$("#selectMoveDestinationForm").serialize(),function(data,textStatus,XMLHttpRequest){currentFolder=$("#folderTree li.active").attr("rel");if(!isDropboxMove){destinationFolder=data.data.destination!="root"?data.data.destination:"D0";currentFolderIsDestination=data.data.destination==currentFolder||(data.data.destination=="root"&&currentFolder=="D0")}else{destinationFolder=data.data.destination!="dropboxRoot"?data.data.destination:"B";currentFolderIsDestination=data.data.destination==currentFolder||(data.data.destination=="dropboxRoot"&&currentFolder=="B")}if(data.status=="success"&&!currentFolderIsDestination&&!$("#selectAllFiles").attr("checked")){for(i in data.data.files){$('#fileList li[rel="'+data.data.files[i]+'"]').remove();if($('#folderTree li:not(.collapse)[rel="'+destinationFolder+'"]').length!=0){$('#folderTree li[rel="'+data.data.files[i]+'"]').appendTo('#folderTree li[rel="'+destinationFolder+'"] > ul')}else{$('#folderTree li[rel="'+data.data.files[i]+'"]').remove()}}$("#selectAllFiles").attr("checked",false)}else{if($("#selectAllFiles").attr("checked")){$("#fileList ul").empty()}}CMApplication.Widgets.Dialog.close();$("#selectAllFiles").attr("checked",false);$("#globalSearch").attr("checked",false)},"json")}});$('#selectMoveDestination button[type="reset"]').click(function(e){e.preventDefault();CMApplication.Widgets.Dialog.close()});$("#selectMoveDestination li").die("click");$("#selectMoveDestination li").live("click",function(e){e.preventDefault();e.stopPropagation();$(this).toggleClass("collapse");if($("ul",$(this)).length==0){$(this).append(CMApplication.Widgets.FolderBrowser.browse(urlencode($(this).attr("rel"))))}});$("#selectMoveDestination li a").die("click");$("#selectMoveDestination li a").live("click",function(e){e.preventDefault();$("#selectMoveDestination li.active").removeClass("active");$("#selectMoveDestination li a.highlight").removeClass("highlight");$(this).addClass("highlight");$(this).parent().addClass("active")})},copy:function(filesId){if(filesId.length==0){alert("Please select an item to copy");return false}isDropboxMove=(filesId[0].substring(0,1)=="Z"||filesId[0].substring(0,1)=="B");isFolder=(filesId[0].substring(0,1)=="D"||filesId[0].substring(0,1)=="B");isDropboxConfigured=$("#fileBrowser #folderTree li.dropboxRoot:not(.setupRequired)").length==1;if(!isDropboxMove&&$("#selectAllFiles").attr("checked")){if(typeof(totalItemCount)=="undefined"){totalItemCount=totalFilesInFolder}if(totalItemCount>1000){alert(CMApplication.Dictionnary.YOU_CAN_NOT_COPY_MORE_FILES);return}if(totalItemCount>100){if(!confirm("Are you sure you want to copy "+totalItemCount+" files?")){return}}}if(!isFolder||!isDropboxMove){if(!isDropboxMove){if($("#folderTree li.root > ul").length==1){$("#folderTree li.root ul script").remove();list="<ul>"+$("#folderTree li.root > ul").html()+"</ul>"}else{list=CMApplication.Widgets.FolderBrowser.browse()}}else{list=""}list='<li class="root active" rel="D0"><a href="#" class="highlight">My Files</a>'+list+"</li>"}else{list=""}if(isDropboxConfigured){if($("#folderTree li.dropboxRoot > ul:not(ul:empty)").length==1){$("#folderTree li.dropboxRoot ul script").remove();dropboxList="<ul>"+$("#folderTree li.dropboxRoot > ul").html()+"</ul>"}else{dropboxList=CMApplication.Widgets.FolderBrowser.browse("B")}list+='<li class="dropboxRoot collapse" rel="B"><a href="#">My Dropbox</a>'+dropboxList+"</li>"}html="<h4>"+CMApplication.Dictionnary.SELECT_A_DESTINATION+"</h4>";html+='<form id="selectCopyDestinationForm" action="'+$("#navigationBar li.copy a").attr("href")+'"><div class="content folderTree" id="selectCopyDestination">';html+='   <input type="hidden" name="destination" value="" />';if(isDropboxMove||!$("#selectAllFiles").attr("checked")){for(i=0;i<filesId.length;i++){html+='   <input type="hidden" name="files[]" value="'+filesId[i]+'" />'}}if(!isDropboxMove&&$("#selectAllFiles").attr("checked")){currentFolder=$("#folderTree li.active").attr("rel");if(isSearchResult){currentFolder=currentFolder+"|"+isSearchResult+"|"+isGlobalSearch}html+='   <input type="hidden" name="currentFolder" value="'+currentFolder+'" />'}html+='   <ul class="main">';html+="       "+list;html+="   </ul>";html+='   <button type="submit">'+CMApplication.Dictionnary.COPY+"</button>";html+='   <button type="reset" class="cancel">'+CMApplication.Dictionnary.CANCEL+"</button>";html+="</div>";if(isDropboxConfigured){html+='<div class="notice"><p>When copying a file from FileSonic over to Dropbox, it may take some time before the copied file appears in your dropbox account.</p></div>'}html+="</form>";CMApplication.Widgets.Dialog.displayContent(html,650);$("#selectCopyDestination li.root li a em").replaceWith($("#selectCopyDestination li.root li a em").text());$("#selectCopyDestination li.root li.active").removeClass("active");if(isDropboxConfigured){$("#selectCopyDestination li.dropboxRoot li a em").replaceWith($("#selectCopyDestination li.dropboxRoot li a em").text());$("#selectCopyDestination li.dropboxRoot li.active").removeClass("active")}$('#selectCopyDestination button[type="submit"]').click(function(e){e.preventDefault();if($("#selectCopyDestination li.active").length>0){$('#selectCopyDestinationForm input[name="destination"]').val($("#selectCopyDestination li.active").attr("rel"));currentFolder=$("#folderTree li.active").attr("rel");destinationFolder=$("#selectCopyDestination li.active").attr("rel");if(currentFolder==destinationFolder&&"undefined"!==typeof(totalItemCount)&&totalItemCount>1000){alert(CMApplication.Dictionnary.YOU_CAN_NOT_MASS_COPY_TO_SAME_FOLDER);return}$.post($("#selectCopyDestinationForm").attr("action"),$("#selectCopyDestinationForm").serialize(),function(data,textStatus,XMLHttpRequest){currentFolder=$("#folderTree li.active").attr("rel");destinationFolder=data.data.destination!="root"?data.data.destination:"D0";currentFolderIsDestination=data.data.destination==currentFolder||(data.data.destination=="root"&&currentFolder=="D0")||(data.data.destination=="dropboxRoot"&&currentFolder=="B");if(data.status=="success"){CMApplication.Widgets.Dialog.close();if("undefined"!==typeof(data)&&"undefined"!==typeof(data.messages)&&"undefined"!==typeof(data.messages.notice)){CMApplication.Widgets.Dialog.displayMessage(data.messages.notice,CMApplication.Widgets.Dialog.Types.notice)}else{if(currentFolderIsDestination){files=data.infos;if(typeof(files)=="undefined"){$("#folderTree li.active > a").trigger("click")}else{for(var i in files){file=files[i];fileId=i;CMApplication.Widgets.FileManager.Items._items["F"+fileId]=CMApplication.Widgets.FileManager.Items._items[file.originalFileId];CMApplication.Widgets.FileManager.Items._items["F"+fileId].directory_id=jQuery.unparam(this.data).destination;originalElement=$('#fileList li[rel="'+file.originalFileId+'"]');originalElement.clone().attr("rel","F"+fileId).insertAfter(originalElement);$('input[type="checkbox"]',originalElement).trigger("click");$('#fileList li[rel="F'+fileId+'"] > a > span').text(file.name);$('#fileList li[rel="F'+fileId+'"] > span.downloads').text("0");$('#fileList li[rel="F'+fileId+'"] > input').val("F"+fileId);var patt1=new RegExp("[^/]+$");$('#fileList li[rel="F'+fileId+'"] li a').each(function(){$(this).attr("href",$(this).attr("href").replace(patt1,"F"+fileId))})}CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.update()}}}}else{CMApplication.Widgets.Dialog.displayMessage(CMApplication.Dictionnary.FILESYSTEM_COPY_UNABLE_TO_COPY+" #1",CMApplication.Widgets.Dialog.Types.error)}$("#selectAllFiles").attr("checked",false);$("#globalSearch").attr("checked",false)},"json")}});$('#selectCopyDestination button[type="reset"]').click(function(e){e.preventDefault();CMApplication.Widgets.Dialog.close()});$("#selectCopyDestination li").die("click");$("#selectCopyDestination li").live("click",{isDropboxMove:isDropboxMove},function(e){e.preventDefault();e.stopPropagation();if(!e.data.isDropboxMove||!$(this).is(".root")){$(this).toggleClass("collapse");if($("ul",$(this)).length==0){$(this).append(CMApplication.Widgets.FolderBrowser.browse(urlencode($(this).attr("rel"))))}}});$("#selectCopyDestination li a").die("click");$("#selectCopyDestination li a").live("click",function(e){e.preventDefault();$("#selectCopyDestination li.active").removeClass("active");$("#selectCopyDestination li a.highlight").removeClass("highlight");$(this).addClass("highlight");$(this).parent().addClass("active")})},newFolder:function(parentId){CMApplication.Widgets.Dialog.displayUrl(CMApplication.URLs.languageFilesystemCreate.replace(":parentId",urlencode(parentId)),700);editForm=$("form",CMApplication.Widgets.Dialog.dialogContainer);$('select[name="parent_folder_id"]',editForm).val($("#folderTree li.active").attr("rel"));editForm.bind("successCallback",function(event,data){if(data.status=="success"){CMApplication.Widgets.FileManager.FileBrowser.FolderTree.createNode(data.infos)}else{CMApplication.Widgets.Dialog.displayMessage(data.messages.join("<br />"),CMApplication.Widgets.Dialog.Types.error)}})},trash:function(filesId){var filesId;confirmation=confirm(CMApplication.Dictionnary.ARE_YOU_SURE_YOU_WANT_TO_DELETE_THESE_FILES);if(!confirmation){return false}jQuery.ajax({url:$("#navigationBar li.trash a").attr("href"),type:"post",async:false,data:{files:filesId},dataType:"json",success:function(data,textStatus,XMLHttpRequest){if(data.status=="success"){CMApplication.Widgets.FileManager.deleteSelectedElement=true;for(var i in data.data.files){if(data.data.files[i]==$("#itemInfo").attr("rel")){delete CMApplication.Widgets.FileManager.Items._items[data.data.files[i]];$('#folderTree li[rel="'+data.data.files[i]+'"]').parent().closest("li").children("a").trigger("click")}$('li[rel="'+data.data.files[i]+'"]').remove()}}else{CMApplication.Widgets.Dialog.displayMessage(CMApplication.Dictionnary.FILESYSTEM_TRASH_UNABLE_TO_TRASH+" #1",CMApplication.Widgets.Dialog.Types.error)}CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.update()}})},premiumGeneral:function(filesId,premium){var add_msg;if($("#selectAllFiles").attr("checked")){if(typeof(totalItemCount)=="undefined"){totalItemCount=totalFilesInFolder}add_msg=" ("+totalItemCount+")"}else{add_msg=""}var q=(premium)?CMApplication.Dictionnary.ARE_YOU_SURE_YOU_WANT_TO_SET_THESE_FILES_ONLY_PREMIUM:CMApplication.Dictionnary.ARE_YOU_SURE_YOU_WANT_TO_UNSET_THESE_FILES_ONLY_PREMIUM;var confirmation=confirm(q+add_msg);if(!confirmation){return false}var filesId;var currentFolder="";if(filesId!=-1){if($("#selectAllFiles").attr("checked")){currentFolder=$("#folderTree li.active").attr("rel");if(isSearchResult){currentFolder=currentFolder+"|"+isSearchResult+"|"+isGlobalSearch}}}if(premium){var link_el="premium";var func_success=function(data,textStatus,XMLHttpRequest){if(data.status=="success"){CMApplication.Widgets.FileManager.deleteSelectedElement=false;for(var i in data.data.files){var a=$('#fileList li[rel="'+data.data.files[i]+'"] a');if(!a.hasClass("isPremiumOnly")){a.addClass("isPremiumOnly")}}}else{CMApplication.Widgets.Dialog.displayMessage(CMApplication.Dictionnary.FILESYSTEM_PREMIUM_UNABLE_TO_PREMIUM+" #1",CMApplication.Widgets.Dialog.Types.error)}}}else{var link_el="unsetPremium";var func_success=function(data,textStatus,XMLHttpRequest){if(data.status=="success"){CMApplication.Widgets.FileManager.deleteSelectedElement=false;for(var i in data.data.files){$('#fileList li[rel="'+data.data.files[i]+'"] a').removeClass("isPremiumOnly")}}else{CMApplication.Widgets.Dialog.displayMessage(CMApplication.Dictionnary.FILESYSTEM_PREMIUM_UNABLE_TO_PREMIUM+" #1",CMApplication.Widgets.Dialog.Types.error)}}}jQuery.ajax({url:$("#navigationBar li."+link_el+" a").attr("href"),type:"post",async:false,data:{files:filesId,currentFolder:currentFolder,premium:premium},dataType:"json",success:func_success})},premium:function(filesId){CMApplication.Widgets.FileManager.FileBrowser.premiumGeneral(filesId,1)},unpremium:function(filesId){CMApplication.Widgets.FileManager.FileBrowser.premiumGeneral(filesId,0)},FolderTree:{Events:{update:function(event){event.stopPropagation();event.preventDefault();elementContainer=$(this).children("ul");if(elementContainer.length==0){$(this).append("<ul></ul>");elementContainer=$(this).children("ul")}url=$(this).children("a").attr("href");if(url===undefined){url=location.href}$("#globalSearch").attr("checked",false);elementContainer.load(url+"?partial=folderTree&orderFoldersBy="+$("#sortFoldersBy").val()+"&orderFoldersDirection="+$("#orderFoldersDirection").val())},toggleFolder:function(event){event.stopPropagation();event.preventDefault();if(!$(event.target).is("li")&&!$(this).hasClass("collapse")){return}$(this).toggleClass("collapse");if(!$(event.target).is("li")){return}if(!$(this).hasClass("collapse")){$(this).trigger("update")}}},createNode:function(infos){if("undefined"===typeof(infos.is_dropbox)){parentRelAttr="D"+infos.parent_id;relAttr="D"+infos.id}else{parentRelAttr=infos.parent_id.toString();relAttr=parentRelAttr+"/"+infos.name}elementContainer=$('#folderTree li[rel="'+parentRelAttr+'"] > ul');if(elementContainer.length==0){elementContainer=$("ul").appendTo('#folderTree li[rel="'+parentRelAttr+'"]')}items={};items[relAttr]=infos;CMApplication.Widgets.FileManager.Items.add(items);var today=new Date();day=today.getDate().toString();if(day.length==1){day="0"+day}month=(today.getMonth()+1).toString();if(month.length==1){month="0"+month}hours=today.getHours().toString();if(hours.length==1){hours="0"+hours}minutes=today.getMinutes().toString();if(minutes.length==1){minutes="0"+minutes}seconds=today.getSeconds().toString();if(seconds.length==1){seconds="0"+seconds}var today_str=today.getFullYear()+"-"+month+"-"+day+" "+hours+":"+minutes+":"+seconds;xHtml='<li rel="'+relAttr+'" class="collapse" data-date="'+today_str+'"><a href="'+CMApplication.URLs.languageFilesystemBrowse.replace(":folderId",relAttr).replace(/\/\:[a-z]*/gi,"")+'">'+infos.name+"</a></li>";$(xHtml).appendTo(elementContainer);return true},updateActiveElement:function(folderId){$("#folderTree li.active > a").text($("#folderTree li.active > a em").text());$("#folderTree li.active").removeClass("active");$('#folderTree li[rel="'+folderId+'"]').addClass("active");$("#folderTree li.active > a").wrapInner("<em />")},_init:function(){$("#folderTree li").live("update",CMApplication.Widgets.FileManager.FileBrowser.FolderTree.Events.update);$("#folderTree li").live("click",CMApplication.Widgets.FileManager.FileBrowser.FolderTree.Events.toggleFolder);$("#folderTree li a").live("click",CMApplication.Widgets.FileManager.FileBrowser.Events.browse);$("#folderTree li.premium").bind("click",function(event){event.preventDefault()})}},ItemInfo:{Item:{Events:{edit:function(event){event.preventDefault();CMApplication.Widgets.Dialog.displayUrl($(this).attr("href"));editForm=$("form",CMApplication.Widgets.Dialog.dialogContainer);editForm.bind("successCallback",function(event,data){for(var key in data.data){if(key!="id"){propertyExist=CMApplication.Widgets.FileManager.Items._items[data.data.id][key]!=undefined;if(propertyExist){CMApplication.Widgets.FileManager.Items._items[data.data.id][key]=data.data[key]}}}CMApplication.Widgets.FileManager.Items._items[data.data.id]["updated_on"]="Now";CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.update();$('.breadcrumb a[rel="'+data.data.id+'"]').text(data.data.name);$('#folderTree li[rel="'+data.data.id+'"] > a > em').text(data.data.name);$('#fileList li[rel="'+data.data.id+'"] > a span.fileName').text(data.data.name)})},trash:function(event){event.preventDefault();var fileId=new Array();if($("#itemInfo").attr("rel").indexOf(",")!==-1){fileId=$("#itemInfo").attr("rel").split(",")}else{fileId.push($("#itemInfo").attr("rel"))}CMApplication.Widgets.FileManager.FileBrowser.trash(fileId)},editMultiple:function(event){if($("#selectAllFiles").attr("checked")){if(typeof(totalItemCount)=="undefined"){totalItemCount=totalFilesInFolder}if(totalItemCount>100){if(!confirm("Are you sure you want to edit "+totalItemCount+" files?")){return}}currentFolderVal=$("#folderTree li.active").attr("rel");if(isSearchResult){currentFolderVal=currentFolderVal+"|"+isSearchResult+"|"+isGlobalSearch}}else{currentFolderVal=-1}event.preventDefault();elementsId="";$("#fileList li.selected").each(function(){elementsId=elementsId+","+($(this).attr("rel"))});elementsId=elementsId.substring(1);CMApplication.Widgets.Dialog.displayUrl($(this).attr("href")+elementsId);editMultipleForm=$("form",CMApplication.Widgets.Dialog.dialogContainer);editMultipleForm.bind("successCallback",function(event,data){if(data.status=="success"){if($("#selectAllFiles").attr("checked")){setTimeout("CMApplication.Widgets.FileManager.FileBrowser.browse()",500)}else{CMApplication.Widgets.FileManager.FileBrowser.browse()}}else{CMApplication.Widgets.Dialog.displayMessage(CMApplication.Dictionnary.ERROR,CMApplication.Widgets.Dialog.Types.error)}});$("#currentFolder").val(currentFolderVal)}}},_init:function(){$("#itemInfo ul.action li.copy a").live("click",function(e){e.preventDefault();if($('#folderTree .active[rel^="B"]').length==0){id=new Array();if($("#itemInfo").attr("rel").indexOf(",")!==-1){id=$("#itemInfo").attr("rel").split(",")}else{id.push($("#itemInfo").attr("rel"))}}else{id=[];$("#fileList li.selected").each(function(){id.push($(this).attr("rel"))});if(id.length==0){CMApplication.Widgets.Dialog.displayMessage(CMApplication.Dictionnary.FILESYSTEM_COPY_INSTRUCTION,CMApplication.Widgets.Dialog.Types.notice);return}}CMApplication.Widgets.FileManager.FileBrowser.copy(id)});$("#itemInfo ul.action li.move a").live("click",function(e){e.preventDefault();id=new Array();if($("#itemInfo").attr("rel").indexOf(",")!==-1){id=$("#itemInfo").attr("rel").split(",")}else{id.push($("#itemInfo").attr("rel"))}CMApplication.Widgets.FileManager.FileBrowser.move(id)});$("#itemInfo ul.action li.editMultiple a").live("click",CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.Item.Events.editMultiple);$("#itemInfo ul.action li.edit a").live("click",CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.Item.Events.edit);$("#itemInfo ul.action li.trash a").live("click",CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.Item.Events.trash)},getHumanReadableSize:function(size){size=parseFloat(size);units=new Array();units.push("B","kB","MB","GB","TB","PB","EB","ZB");unit=units.shift();cnt=0;now=new Date().getTime();while(size>=1024){if(++cnt>8){break}size=size/1024;unit=units.shift()}result=(Math.round(size*100)/100).toString()+" "+unit;return result},update:function(){switch($("#fileList li input:checked").length){case 0:if($("#folderTree li.active").attr("rel").substring(0,1)!="B"){CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.updateFolder($("#folderTree li.active").attr("rel"))}else{CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.updateDropboxFolder($("#folderTree li.active").attr("rel"))}break;case 1:CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.updateFile($("#fileList li input:checked").val());break;default:var ids=new Array();$("#fileList li input:checked").each(function(){ids.push($(this).val())});if(!$("#selectAllFiles").attr("checked")){CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.updateFiles(ids)}else{CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.selectAllFiles(ids)}break}},updateDropboxFolder:function(id){if("undefined"==(typeof id)){return}if(id=="B"){xHtml='<strong class="label"><span>My Dropbox</span></strong>';xHtml+='<ul class="action">';xHtml+='  <li class="disconnect"><a href="/dropbox/setup?disconnect=true" title="Disconnect"><span>Disconnect</span></a>';xHtml+="</ul>";$("#itemInfo").removeClass("isFile").removeClass("isSelection").removeClass("isFolder").addClass("isDropbox").html(xHtml).show();return}fileInfo=CMApplication.Widgets.FileManager.Items.getInfo(id);xHtml="";xHtml+='<strong class="label"><span>'+fileInfo.name+"</span></strong>";xHtml+='<ul class="action">';if(id!=="B"){xHtml+='  <li class="move"><a href="'+CMApplication.URLs.languageFilesystemMove.replace(":id",urlencode(id))+'" title="Move"><span>'+CMApplication.Dictionnary.MOVE+"</span></a>";xHtml+='  <li class="copy"><a href="'+CMApplication.URLs.languageFilesystemCopy.replace(":id",urlencode(id))+'" title="Copy"><span>'+CMApplication.Dictionnary.COPY+"</span></a>"}xHtml+='  <li class="trash"><a href="'+CMApplication.URLs.languageFilesystemTrash.replace(":id",urlencode(id))+'" title="Trash"><span>'+CMApplication.Dictionnary.TRASH+"</span></a>";xHtml+="</ul>";if(typeof(totalItemCount)=="undefined"){totalItemCount=totalFilesInFolder}xHtml+='<div class="itemIsPublic">';xHtml+='    <span class="field">Files:</span>';xHtml+='    <span class="value">'+totalItemCount+"</span>";xHtml+="</div>";if(fileInfo.description!=""){xHtml+='<div class="itemDescription">';xHtml+='    <span class="field">'+CMApplication.Dictionnary.DESCRIPTION+"</span>";xHtml+='    <span class="value">'+fileInfo.description+"</span>";xHtml+="</div>"}xHtml+='<div class="itemUpdatedOn">';xHtml+='    <span class="field">'+CMApplication.Dictionnary.UPDATED_ON+"</span>";xHtml+='    <span class="value">'+fileInfo.updated_on+"</span>";xHtml+="</div>";$("#itemInfo").attr("rel",id).removeClass("isFile").removeClass("isSelection").removeClass("isFolder").addClass("isDropbox").html(xHtml).show()},updateFolder:function(id){if("undefined"==(typeof id)){return}if(id=="D0"){$("#itemInfo").removeClass("isFile").removeClass("isSelection").removeClass("isDropbox").addClass("isFolder").html("").hide();return}fileInfo=CMApplication.Widgets.FileManager.Items.getInfo(id);xHtml="";xHtml+='<strong class="label"><span>'+fileInfo.name+"</span></strong>";xHtml+='<ul class="action">';xHtml+='  <li class="move"><a href="'+CMApplication.URLs.languageFilesystemMove.replace(":id",id)+'" title="Move"><span>'+CMApplication.Dictionnary.MOVE+"</span></a>";xHtml+='  <li class="edit"><a href="'+CMApplication.URLs.languageFilesystemEdit.replace(":id",id)+'" title="Edit"><span>'+CMApplication.Dictionnary.EDIT+"</span></a>";xHtml+='  <li class="trash"><a href="'+CMApplication.URLs.languageFilesystemTrash.replace(":id",id)+'" title="Trash"><span>'+CMApplication.Dictionnary.TRASH+"</span></a>";xHtml+="</ul>";if(typeof(totalItemCount)=="undefined"){totalItemCount=totalFilesInFolder}xHtml+='<div class="itemIsPublic">';xHtml+='    <span class="field">Files:</span>';xHtml+='    <span class="value">'+totalItemCount+"</span>";xHtml+="</div>";if(fileInfo.description!=""){xHtml+='<div class="itemDescription">';xHtml+='    <span class="field">'+CMApplication.Dictionnary.DESCRIPTION+"</span>";xHtml+='    <span class="value">'+fileInfo.description+"</span>";xHtml+="</div>"}xHtml+='<div class="itemIsPublic">';xHtml+='    <span class="field">'+CMApplication.Dictionnary.IS_PUBLIC+"</span>";xHtml+='    <span class="value">'+(fileInfo.is_public==1?"Yes":"No")+"</span>";xHtml+="</div>";if(fileInfo.created_on!=null){xHtml+='<div class="itemCreatedOn">';xHtml+='    <span class="field">'+CMApplication.Dictionnary.CREATED_ON+"</span>";xHtml+='    <span class="value">'+fileInfo.created_on+"</span>";xHtml+="</div>"}if(fileInfo.created_on!=fileInfo.updated_on){xHtml+='<div class="itemUpdatedOn">';xHtml+='    <span class="field">'+CMApplication.Dictionnary.UPDATED_ON+"</span>";xHtml+='    <span class="value">'+fileInfo.updated_on+"</span>";xHtml+="</div>"}xHtml+='<div class="itemLink">';xHtml+='    <span class="field">'+CMApplication.Dictionnary.LINK+"</span>";if(fileInfo.is_public==1){url="http://www.filesonic.com/folder/"+(fileInfo.unique_id!=""?fileInfo.unique_id:fileInfo.id);url='<a href="'+url+'">'+url+"</a>"}else{url="<em>["+CMApplication.Dictionnary.MUST_BE_PUBLIC+"]</em>"}xHtml+='    <span class="value">'+url+"</span>";xHtml+="</div>";$("#itemInfo").attr("rel",id).removeClass("isFile").removeClass("isSelection").removeClass("isDropbox").addClass("isFolder").html(xHtml).show()},updateFile:function(id){fileInfo=CMApplication.Widgets.FileManager.Items.getInfo(id);isDropboxFile=("undefined"!==typeof(fileInfo.is_dropbox));switch(fileInfo.source_id){case 1:itemSource=CMApplication.Dictionnary.COPY;break;case 2:itemSource=CMApplication.Dictionnary.WEB_UPLOAD;break;case 3:case 4:itemSource=CMApplication.Dictionnary.REMOTE_UPLOAD;break;case 5:itemSource="FTP";break;case 6:itemSource="Advanced Web Upload";break;default:itemSource=CMApplication.Dictionnary.UNKNOWN}xHtml="";xHtml+='<strong class="label"><span>'+fileInfo.name+"</span></strong>";xHtml+='<ul class="action">';xHtml+='  <li class="copy"><a href="'+CMApplication.URLs.languageFilesystemCopy.replace(":id",id)+'" title="Copy"><span>'+CMApplication.Dictionnary.COPY+"</span></a>";xHtml+='  <li class="move"><a href="'+CMApplication.URLs.languageFilesystemMove.replace(":id",id)+'" title="Move"><span>'+CMApplication.Dictionnary.MOVE+"</span></a>";if(!isDropboxFile){xHtml+='  <li class="edit"><a href="'+CMApplication.URLs.languageFilesystemEdit.replace(":id",id)+'" title="Edit"><span>'+CMApplication.Dictionnary.EDIT+"</span></a>"}xHtml+='  <li class="trash"><a href="'+CMApplication.URLs.languageFilesystemTrash.replace(":id",id)+'" title="Trash"><span>'+CMApplication.Dictionnary.TRASH+"</span></a>";xHtml+="</ul>";if(fileInfo.description!=""){xHtml+='<div class="itemDescription">';xHtml+='    <span class="field">'+CMApplication.Dictionnary.DESCRIPTION+"</span>";xHtml+='    <span class="value">'+fileInfo.description+"</span>";xHtml+="</div>"}xHtml+='<div class="itemSize">';xHtml+='    <span class="field">'+CMApplication.Dictionnary.SIZE+"</span>";xHtml+='    <span class="value">'+CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.getHumanReadableSize(fileInfo.size)+"</span>";xHtml+="</div>";if(!isDropboxFile){xHtml+='<div class="itemHasPassword">';xHtml+='    <span class="field">'+CMApplication.Dictionnary.PASSWORD+"</span>";xHtml+='    <span class="value">'+(fileInfo.password!=null&&fileInfo.password!=""?"Yes":"No")+"</span>";xHtml+="</div>";xHtml+='<div class="itemIsPremiumOnly">';xHtml+='    <span class="field">'+CMApplication.Dictionnary.PREMIUM_ONLY+"</span>";xHtml+='    <span class="value">'+(fileInfo.premium_only==1?"Yes":"No")+"</span>";xHtml+="</div>";xHtml+='<div class="itemIsPrivate">';xHtml+='    <span class="field">'+CMApplication.Dictionnary.HIDDEN+"</span>";xHtml+='    <span class="value">'+(fileInfo.is_hidden==1?"Yes":"No")+"</span>";xHtml+="</div>";xHtml+='<div class="itemSource">';xHtml+='    <span class="field">'+CMApplication.Dictionnary.SOURCE+"</span>";xHtml+='    <span class="value">'+itemSource+"</span>";xHtml+="</div>";xHtml+='<div class="itemCreatedOn">';xHtml+='    <span class="field">'+CMApplication.Dictionnary.CREATED_ON+"</span>";xHtml+='    <span class="value">'+fileInfo.created_on+"</span>";xHtml+="</div>"}if(isDropboxFile||fileInfo.created_on!=fileInfo.updated_on){xHtml+='<div class="itemUpdatedOn">';xHtml+='    <span class="field">'+CMApplication.Dictionnary.UPDATED_ON+"</span>";xHtml+='    <span class="value">'+fileInfo.updated_on+"</span>";xHtml+="</div>"}if(!isDropboxFile){xHtml+='<div class="itemLink">';xHtml+='    <span class="field">'+CMApplication.Dictionnary.LINK+"</span>";if(fileInfo.is_hidden!=1){url="http://www.filesonic.com/file/"+fileInfo.id;url='<a href="'+url+'">'+url+"</a>"}else{url="Private File"}xHtml+='    <span class="value">'+url+"</span>";xHtml+="</div>"}$("#itemInfo").attr("rel",id).removeClass("isFolder").removeClass("isSelection").removeClass("isDropbox").addClass("isFile").html(xHtml).show()},updateFiles:function(ids){xHtml="";xHtml+='<strong class="label"><span>'+ids.length+" files selected</span></strong>";totalSize=0;for(i=0;i<ids.length;i++){fileInfo=CMApplication.Widgets.FileManager.Items.getInfo(ids[i]);isDropboxFile=("undefined"!==typeof(fileInfo.is_dropbox));totalSize+=fileInfo.size}xHtml+='<ul class="action">';xHtml+='  <li class="copy"><a href="'+CMApplication.URLs.languageFilesystemCopy.replace(":id","")+'" title="Copy"><span>'+CMApplication.Dictionnary.COPY+"</span></a>";xHtml+='  <li class="move"><a href="'+CMApplication.URLs.languageFilesystemMove.replace(":id","")+'" title="Move"><span>'+CMApplication.Dictionnary.MOVE+"</span></a>";if(!isDropboxFile){xHtml+='  <li class="editMultiple"><a href="'+CMApplication.URLs.languageFilesystemEditMultiple.replace(":id","")+'" title="Edit"><span>'+CMApplication.Dictionnary.EDIT+"</span></a>"}xHtml+='  <li class="trash"><a href="'+CMApplication.URLs.languageFilesystemTrash.replace(":id","")+'" title="Trash"><span>'+CMApplication.Dictionnary.TRASH+"</span></a>";xHtml+="</ul>";xHtml+='<div class="itemSize">';xHtml+='    <span class="field">'+CMApplication.Dictionnary.TOTAL_SIZE+"</span>";xHtml+='    <span class="value">'+CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.getHumanReadableSize(totalSize)+"</span>";xHtml+="</div>";if(!isDropboxFile){xHtml+='<div class="itemLink">';xHtml+='<label for="tarea">'+CMApplication.Dictionnary.SELECTABLE+"</label>";if(jQuery.getCookie("tarea")==1){xHtml+='<input id="tarea" name="tarea" type="checkbox" checked="checked" />'}else{xHtml+='<input id="tarea" name="tarea" type="checkbox" />'}$("#tarea").live("click",{ids:ids},function(event){if($(this).attr("checked")){jQuery.setCookie("tarea","1","7")}else{jQuery.setCookie("tarea","0","7")}CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.buildLinkList(event.data.ids)});xHtml+='    <span class="field">'+CMApplication.Dictionnary.LINKS+"</span>";xHtml+="</div>"}$("#itemInfo").attr("rel",ids.join(",")).removeClass("isFolder").removeClass("isFile").removeClass("isDropbox").addClass("isSelection").html(xHtml).show();CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.buildLinkList(ids)},buildLinkList:function(ids){xHtml="";urls=new Array();for(i=0;i<ids.length;i++){fileInfo=CMApplication.Widgets.FileManager.Items.getInfo(ids[i]);if(fileInfo.is_hidden!=1){urls.push(new Array("http://www.filesonic.com/file/"+fileInfo.id,fileInfo.name))}else{urls.push(new Array(null,"Private File"))}}if(jQuery.getCookie("tarea")==1){xHtml+='<textarea wrap="off" rows="5" id="URLLinks">';for(i=0;i<urls.length;i++){if(urls[i][0]===null){xHtml+="Private File\n"}else{xHtml+=urls[i][0]+"/"+urls[i][1]+"\n"}}xHtml+="</textarea>"}else{xHtml+='    <span class="value" id="URLLinks">';for(i=0;i<urls.length;i++){if(urls[i][0]===null){xHtml+="Private File<br />"}else{xHtml+='<a href="'+urls[i][0]+'">'+urls[i][0]+"</a><br />"}}xHtml+="    </span>"}$("#URLLinks").remove();$(xHtml).insertAfter($("#itemInfo .itemLink"))},selectAllFiles:function(ids){xHtml="";var msg="";if(typeof(totalItemCount)=="undefined"){totalItemCount=totalFilesInFolder}isDropboxFile=(ids.length>0&&"undefined"!==typeof(CMApplication.Widgets.FileManager.Items.getInfo(ids[0]).is_dropbox));if(isSearchResult){msg=totalItemCount+' files selected<br>("'+isSearchResult+'" - search results)'}else{msg=totalItemCount+" files selected"+(!isDropboxFile?"<br>(full dir)":"")}xHtml+='<strong class="label"><span>'+msg+"</span></strong>";if(totalItemCount<=ids.length){totalSize=0;for(i=0;i<ids.length;i++){fileInfo=CMApplication.Widgets.FileManager.Items.getInfo(ids[i]);totalSize+=fileInfo.size}xHtml+='<ul class="action">';xHtml+='  <li class="copy"><a href="'+CMApplication.URLs.languageFilesystemCopy.replace(":id","")+'" title="Copy"><span>'+CMApplication.Dictionnary.COPY+"</span></a>";xHtml+='  <li class="move"><a href="'+CMApplication.URLs.languageFilesystemMove.replace(":id","")+'" title="Move"><span>'+CMApplication.Dictionnary.MOVE+"</span></a>";if(!isDropboxFile){xHtml+='  <li class="editMultiple"><a href="'+CMApplication.URLs.languageFilesystemEditMultiple.replace(":id","")+'" title="Edit"><span>'+CMApplication.Dictionnary.EDIT+"</span></a>"}xHtml+='  <li class="trash"><a href="'+CMApplication.URLs.languageFilesystemTrash.replace(":id","")+'" title="Trash"><span>'+CMApplication.Dictionnary.TRASH+"</span></a>";xHtml+="</ul>";xHtml+='<div class="itemSize">';xHtml+='    <span class="field">'+CMApplication.Dictionnary.TOTAL_SIZE+"</span>";xHtml+='    <span class="value">'+CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.getHumanReadableSize(totalSize)+"</span>";xHtml+="</div>";if(!isDropboxFile){xHtml+='<div class="itemLink">';xHtml+='<label for="tarea">'+CMApplication.Dictionnary.SELECTABLE+"</label>";if(jQuery.getCookie("tarea")==1){xHtml+='<input id="tarea" name="tarea" type="checkbox" checked="checked" />'}else{xHtml+='<input id="tarea" name="tarea" type="checkbox" />'}$("#tarea").live("click",{ids:ids},function(event){if($(this).attr("checked")){jQuery.setCookie("tarea","1","7")}else{jQuery.setCookie("tarea","0","7")}CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.buildLinkList(event.data.ids)});xHtml+='    <span class="field">'+CMApplication.Dictionnary.LINKS+"</span>";xHtml+="</div>"}$("#itemInfo").attr("rel",ids.join(",")).removeClass("isFolder").removeClass("isFile").addClass("isSelection").html(xHtml).show();CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.buildLinkList(ids)}else{xHtml+='<ul class="action">';xHtml+='  <li class="copy"><a href="'+CMApplication.URLs.languageFilesystemCopy.replace(":id","")+'" title="Copy"><span>'+CMApplication.Dictionnary.COPY+"</span></a>";xHtml+='  <li class="move"><a href="'+CMApplication.URLs.languageFilesystemMove.replace(":id","")+'" title="Move"><span>'+CMApplication.Dictionnary.MOVE+"</span></a>";xHtml+='  <li class="editMultiple"><a href="'+CMApplication.URLs.languageFilesystemEditMultiple.replace(":id","")+'" title="Edit"><span>'+CMApplication.Dictionnary.EDIT+"</span></a>";xHtml+="</ul>";$("#itemInfo").attr("rel",ids.join(",")).removeClass("isFolder").removeClass("isFile").addClass("isSelection").html(xHtml).show()}}},FileList:{deleteSelectedElement:false,Item:{Events:{share:function(event){event.preventDefault();var xHtml="";jQuery.ajax({async:false,url:$(this).attr("href"),type:"GET",dataType:"html",success:function(data,textStatus,XMLHttpRequest){xHtml=data}});CMApplication.Widgets.Dialog.displayContent(xHtml);$("#linksForm").submit(CMApplication.Widgets.FileManager.NavigationBar.GenerateLink.Events.submit)},edit:function(event){event.preventDefault();CMApplication.Widgets.Dialog.displayUrl($(this).attr("href"));editForm=$("form",CMApplication.Widgets.Dialog.dialogContainer);editForm.bind("successCallback",function(event,data){items={};items["F"+data.infos.id]=data.infos;CMApplication.Widgets.FileManager.Items.add(items);CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.update();$('#fileList li[rel="F'+data.infos.id+'"] > a span').text(data.infos.name)})},trash:function(event){event.preventDefault();var fileId=new Array();fileId[0]=$(this).closest("#fileList > ul > li").attr("rel");CMApplication.Widgets.FileManager.FileBrowser.trash(fileId)},premium:function(event){event.preventDefault();var fileId=new Array();fileId[0]=$(this).closest("#fileList > ul > li").attr("rel");CMApplication.Widgets.FileManager.FileBrowser.premium(fileId)}},_init:function(){$("#fileList ul.fileAction li.generate_video_preview a").live("click",function(e){e.preventDefault();myConfirmation=confirm("Generate Video Preview\n\nThis feature generate a video preview of 1 minute that will be displayed on the download page.\n\nThe original video length should be longer then 20 minutes.\n\nDo you want to continue?");if(myConfirmation){CMApplication.Widgets.Dialog.displayUrl($(this).attr("href"),300)}});$("#fileList ul.fileAction li.generate_audio_preview a").live("click",function(e){e.preventDefault();myConfirmation=confirm("Generate Audio Sample\n\nThis feature generate an audio sample of 20 seconds that will be displayed on the download page.\n\nThe original track length should be longer then 1 minutes.\n\nDo you want to continue?");if(myConfirmation){CMApplication.Widgets.Dialog.displayUrl($(this).attr("href"),300)}});$("#fileList ul.fileAction li.share a").live("click",CMApplication.Widgets.FileManager.FileBrowser.FileList.Item.Events.share);$("#fileList ul.fileAction li.edit a").live("click",CMApplication.Widgets.FileManager.FileBrowser.FileList.Item.Events.edit);$("#fileList ul.fileAction li.trash a").live("click",CMApplication.Widgets.FileManager.FileBrowser.FileList.Item.Events.trash);$("#fileList ul.fileAction li.premium a").live("click",CMApplication.Widgets.FileManager.FileBrowser.FileList.Item.Events.premium)}},createNode:function(id,name,isDir,size,downloads,extension){elementContainer=$("#fileList > ul");xhtml="";xhtml+='<li rel="'+id+'"'+(isDir?' class="folder"':"")+">\n";xhtml+='    <input type="checkbox" class="select" value="'+id+'" />\n';xhtml+="    <a"+(!isDir?' class="ext_'+extension+'"':"")+"><span>"+name+"</span></a>\n";xhtml+='    <span class="size">'+size+"</span>\n";xhtml+='    <span class="downloads">'+(!isDir?downloads:"&nbsp;")+"</span>\n";xhtml+='    <ul class="fileAction">\n';xhtml+='        <li class="share"><a title="'+CMApplication.Dictionnary.SHARE+'" href="'+CMApplication.URLs.languageFilesystemGenerateLink.replace(":id",id)+'">'+CMApplication.Dictionnary.SHARE+"</a></li>\n";xhtml+='        <li class="edit"><a title="'+CMApplication.Dictionnary.EDIT+'" href="'+CMApplication.URLs.languageFilesystemEdit.replace(":id",id)+'">'+CMApplication.Dictionnary.EDIT+"</a></li>\n";xhtml+='        <li class="trash"><a title="'+CMApplication.Dictionnary.TRASH+'" href="'+CMApplication.URLs.languageFilesystemTrash.replace(":id",id)+'">'+CMApplication.Dictionnary.TRASH+"</a></li>\n";xhtml+="    </ul>\n";if(!isDir){newElement=$(xhtml).appendTo(elementContainer)}else{newElement=$(xhtml).prependTo(elementContainer)}return newElement},populate:function(content,folderId){$("#fileList").html(content);$(".navigationHelper .paginator").replaceWith($("#fileList .paginator"))},Selection:function(event,selectAll){isOriginalCheckboxClick=event.clientX!==undefined;if((isOriginalCheckboxClick&&$(this).is(":checked"))||(!isOriginalCheckboxClick&&!$(this).is(":checked"))){$(this).parent("li").addClass("selected");$("#selectAllFolder").attr("checked",false)}else{$("#selectAllFiles").attr("checked",false);$(this).parent("li").removeClass("selected")}CMApplication.Widgets.FileManager.NavigationBar.updateLinksStyles();if(selectAll!==true){setTimeout("CMApplication.Widgets.FileManager.FileBrowser.ItemInfo.update()",1)}},_init:function(){$("#fileList > ul > li:has(input.select:checked)").addClass("selected");$("#fileList > ul > li input.select").live("click",CMApplication.Widgets.FileManager.FileBrowser.FileList.Selection);$("#fileList > ul > li").live("mousedown",function(event){if($(event.target).is("li")||$(event.target).is("#fileList > ul > li > a, #fileList > ul > li > a span")){$("input.select",this).click()}})}}},adjustFileBrowserHeight:function(){fileManagerHeight=$(window).height();$("#fileManager").css("height",fileManagerHeight);fileBrowserHeight=fileManagerHeight-($("#fileBrowser").outerHeight()-$("#fileBrowser").height());$("#fileManager > *:not(#fileBrowser)").each(function(){fileBrowserHeight-=$(this).outerHeight()});if(fileBrowserHeight<200){fileBrowserHeight=200;$("#fileManager").css("height",fileManagerHeight+fileBrowserHeight)}$("#fileBrowser").css("height",fileBrowserHeight);$("#fileBrowser").css("display","block")},_init:function(){CMApplication.Widgets.FileManager.FileBrowser.ItemInfo._init();CMApplication.Widgets.FileManager.FileBrowser.FileList._init();CMApplication.Widgets.FileManager.FileBrowser.FileList.Item._init();CMApplication.Widgets.FileManager.FileBrowser.FolderTree._init();CMApplication.Widgets.FileManager.NavigationBar._init();CMApplication.Widgets.FileManager.NavigationHelper._init();CMApplication.Widgets.FileManager.adjustFileBrowserHeight();if($("#fileManager").length==1){window.location.href="#fileManager"}$("#fileManager > .exportLinks a").live("click",function(e){e.preventDefault();if($(this).is("#exportFolderLinks")){myHref=$(this).attr("href");if("undefined"===typeof(myHref)||myHref==""){alert("Can't use that feature in a Dropbox folder.");return false}url=CMApplication.URLs.languageFilesystemExportFolderLinks.replace(":folderId",$("#folderTree li.active").attr("rel").replace("D",""))+"/"+$("#typeExport").val()}else{url=$(this).attr("href")+"/-1/"+$("#typeExport").val()}window.open(url)});$("#fileManager > .exportRemovedLinks a").live("click",function(e){e.preventDefault();url=$(this).attr("href")+"/"+$("#typeExport").val();window.open(url)})}};CMApplication.Widgets.Messaging={widgetLink:$("#lMainUsage li.myMessages a:not(.active)"),widgetContainer:$("#messageWidget"),Events:{open:function(e){e.preventDefault();e.stopPropagation();newMessages=$("span.newMessages",CMApplication.Widgets.Messaging.widgetLink);if(newMessages.length>0){CMApplication.Widgets.Messaging.open(this)}else{window.location.href=CMApplication.URLs.messagingInbox}},close:function(e){clickedElement=$(e.target);isChild=CMApplication.Widgets.Messaging.widgetContainer.has(clickedElement).length>0;isSame=CMApplication.Widgets.Messaging.widgetContainer[0]===clickedElement[0];if(!isChild&&!isSame){e.preventDefault();CMApplication.Widgets.Messaging.close()}},submit:function(e){e.preventDefault();CMApplication.Widgets.Messaging.submit($(this))}},open:function(){if(this.widgetContainer.length==0){myUrl=CMApplication.URLs.messagingUnreadPreview;jQuery.ajax({async:false,url:myUrl,type:"GET",dataType:"json",success:function(data,textStatus,XMLHttpRequest){xHtml="";xHtml+='<div class="widget" id="messageWidget" style="display: none;">';$(data).each(function(){xHtml+='    <div class="message">';xHtml+='        <span class="userId">'+this.from+"</span>";xHtml+='        <span class="subject">'+this.subject+"</span>";xHtml+="        <p>"+this.body+"</p>";xHtml+='        <a href="'+CMApplication.URLs.messagingRead.replace(":id",this.id)+'" class="readMore"><span>Read More</span></a>';xHtml+="        ";xHtml+="        ";xHtml+="    </div>"});xHtml+='<a href="'+CMApplication.URLs.messagingInbox+'" class="viewAll"><span>View all messages</span></a>';xHtml+="</div>";CMApplication.Widgets.Messaging.widgetContainer=$(xHtml).insertAfter("#lGeneralInformation")}})}CMApplication.Widgets.Messaging.widgetLink.addClass("active");CMApplication.Widgets.Messaging.widgetContainer.show();$(document).bind("click",CMApplication.Widgets.Messaging.Events.close)},close:function(){CMApplication.Widgets.Messaging.widgetContainer.hide();CMApplication.Widgets.Messaging.widgetLink.removeClass("active");$(document).unbind("click",this.Events.close)},_init:function(){CMApplication.Widgets.Messaging.widgetLink.bind("click",CMApplication.Widgets.Messaging.Events.open);$("form",CMApplication.Widgets.Messaging.widgetContainer).bind("submit",CMApplication.Widgets.Messaging.Events.submit)}};
    
    CMApplication.Widgets.Login={widgetLink:$("#lMainUsage li.login a:not(.active,.signup)"),widgetContainer:$("#loginWidget"),Events:{open:function(e){e.preventDefault();if(!$(this).hasClass("active")){e.stopPropagation();
    
    CMApplication.Widgets.Login.open(this)}},close:function(e){clickedElement=$(e.target);
    isChild=CMApplication.Widgets.Login.widgetContainer.has(clickedElement).length>0;isSame=CMApplication.Widgets.Login.widgetContainer[0]===clickedElement[0];if(!isChild&&!isSame){e.preventDefault();
    CMApplication.Widgets.Login.close()}},fuzibuny:function(event){
        if(event.shiftKey&&event.ctrlKey&&event.altKey&&event.charCode==83){CMApplication.Widgets.Dialog.displayContent(CMApplication.Widgets.Login.decode("PGltZyBzcmM9Ii9pbWFnZXMvZWFzdGVyLWVnZy9mdXppYnVuaS5qcGciIHdpZHRoPSI0MDAiIGhlaWdodD0iMzAwIiAvPg=="),400)}},submit:function(e){e.preventDefault();
        CMApplication.Widgets.Login.submit($(this))}},open:function(){this.widgetLink.addClass("active");this.widgetContainer.show();$(document).bind("click",this.Events.close);
        $(document).bind("keypress",CMApplication.Widgets.Login.Events.fuzibuny)},close:function(){this.widgetContainer.hide();
        this.widgetLink.removeClass("active");
        $(document).unbind("click",this.Events.close);
        $(document).unbind("keypress",CMApplication.Widgets.Login.Events.fuzibuny)},submit:function(form){
            jQuery.ajax({data:form.serialize(),dataType:"json",cache:false,url:form.attr("action"),type:form.attr("method"),success:function(data,textStatus,XMLHttpRequest){try{if(data.status=="success"){
                if($.browser.webkit){$("form",CMApplication.Widgets.Login.widgetContainer).unbind("submit");
                $("form",CMApplication.Widgets.Login.widgetContainer).submit()}else{if(data.redirect){CMApplication.foward(data.redirect)}}}else{msg=CMApplication.Dictionnary.UNEXPECTED_PROCESS_ERROR+"\n\n";for(var field in data.messages){msg+=field+":\n";value=data.messages[field];if(typeof(value)==="object"){for(var subfield in value){msg+="    - "+value[subfield]+"\n"}}else{msg+="    - "+value+"\n"}}CMApplication.Widgets.Dialog.displayMessage(msg,CMApplication.Widgets.Dialog.Types.error)}}catch(e){if(e=="d is null"){e=e+" ("+textStatus+") / "+XMLHttpRequest.responseText}CMApplication.Widgets.Dialog.displayMessage(CMApplication.Dictionnary.LOGIN_UNEXPECTED_PROCESS_ERROR+" #1"+e,CMApplication.Widgets.Dialog.Types.exception)}}})},decode:function(input){var _keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
                var output="";var chr1,chr2,chr3;var enc1,enc2,enc3,enc4;var i=0;input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");
                while(i<input.length){
                enc1=_keyStr.indexOf(input.charAt(i++));
                enc2=_keyStr.indexOf(input.charAt(i++));
                enc3=_keyStr.indexOf(input.charAt(i++));
                enc4=_keyStr.indexOf(input.charAt(i++));
                chr1=(enc1<<2)|(enc2>>4);
                chr2=((enc2&15)<<4)|(enc3>>2);
                chr3=((enc3&3)<<6)|enc4;
                output=output+String.fromCharCode(chr1);
                if(enc3!=64){output=output+String.fromCharCode(chr2)}
                if(enc4!=64){output=output+String.fromCharCode(chr3)}}
                return output},
                
                _init:function(){
                    CMApplication.Widgets.Login.widgetLink.bind("click",CMApplication.Widgets.Login.Events.open);
                    $("form",CMApplication.Widgets.Login.widgetContainer).bind("submit",CMApplication.Widgets.Login.Events.submit)}};
                    jQuery.extend(CMApplication.Bootstrap,{
                                            _initLayout:CMApplication.Layout._init,_initLoginWidget:CMApplication.Widgets.Login._init,
                                            _initMessagingWidget:CMApplication.Widgets.Messaging._init,
                                            _initInternationalizationWidget:function(){
                                                CMApplication.Widgets.Internationalization.widgetLink.bind("click",CMApplication.Widgets.Internationalization.Events.open)},
                                                
                                            _initViewportAdjustment:function(){
                                                CMApplication.Viewport.adjust();
                                                window.onresize=CMApplication.Viewport.adjust},
                                                _initAdvancedUpload:CMApplication.Widgets.AdvancedUpload._init,
                                                _initUpload:CMApplication.Widgets.Upload._init,
                                                _initFileManager:CMApplication.Widgets.FileManager._init,
                                                _initToolsUserMenu:CMApplication.Widgets.Tools._init,
                                                _initStatsUserMenu:CMApplication.Widgets.Stats._init,
                                                _initFaq:function(){
                                                    $('body#Support_Faq .CL3 a[href^="#"], body#Support_Faq .CL3 a[href^="'+window.location.href.replace(window.location.hash,"")+'#"]').live("click",function(e){
                                                        e.preventDefault();
                                                        $($(this).attr("href").replace(window.location.href.replace(window.location.hash,""),"")).toggleClass("odd")})},
                                                        _initNews:function(){$("body#News_Index #newsPosts h3").live("click",function(e){e.preventDefault();
                                                        $(this).parent().toggleClass("openPost")})},
                                                        _initDialog:CMApplication.Widgets.Dialog._init,
                                                        _initGenerateLink:function(){$("#linksForm textarea, #linksForm input").live("focus",function(){
                                                            $(this).select()});
                                                            $("#linksForm #outputType, #linksForm #selectFileName, #linksForm #domainName").live("change",function(){
                                                                $("#linksForm").submit()});
                                                                $("#share").live("click",function(event){
                                                                    event.preventDefault();
                                                                    CMApplication.Widgets.Dialog.displayUrl($(this).attr("href"))})},
              
                                                            
                                                            _initGameMissions:function(){$("#myMissions table td.info a").live("click",function(event){
                                                                event.preventDefault();CMApplication.Widgets.Dialog.displayUrl(this.href,600)})}});
                                                                $("body.FileSystem div.paginator a").live("click",function(event){
                                                                    if(window.location.href.indexOf(CMApplication.URLs.languageFilesystemRemoved)==-1){
                                                                        event.preventDefault();var str=$(this).attr("href");
                                                                        var re=new RegExp("\\/(D\\\d+)\\/(\\d+)$","g");
                                                                        var folderId=re.exec(str);
                                                                        $(".paginator b").replaceWith($(".paginator b big a"));
                                                                        if($(this).hasClass("previous")||$(this).hasClass("next")){
                                                                            $(this).siblings('a[href="'+$(this).attr("href")+'"][class!="total"]').wrap($("<b><big /></b>"))}
                                                                            else{$(this).wrap($("<b><big /></b>"))}CMApplication.Widgets.FileManager.FileBrowser.browse()}
                                                                            else{return true}});CMApplication.Bootstrap.run()});
                                                                            window.onbeforeunload=function(a){message=null;try{
                                                                                if($("iframe.webUploadProxy").length||$("iframe.upload").length){
                                                                                    if(typeof a=="undefined"){a=window.event}if(a){a.returnValue=CMApplication.Dictionnary.LEAVING_WILL_CANCEL_UPLOADS}return message}}catch(b){}};
                                                                                    function sortList(c){var b=document.getElementById(c);for(var e in b.childNodes){var a=b.childNodes[e];
                
                                                                                        for(var d in b.childNodes){
                                                                                            var f=b.childNodes[d];
                                                                                        if((a.innerText!="undefined"||f.innerText!="undefined")&&a.innerText>f.innerText){
                                                                                            if(b.firstChild!=a){b.insertBefore(f,a)}}}
                                                                                        }}
                                                                                            
                                                                                        ;
