

<div id="actions">
	
	<ul id="for_messages">
		<li id="action_files_upload" title="<?php echo $this->translate('Upload File')?>"><a href="#"><span><strong><?php echo $this->translate('Upload File')?></strong></span></a></li>
		<li id="action_files_delete" title="<?php echo $this->translate('Delete')?>"><a href="#"><span><strong><?php echo $this->translate('Delete')?></strong></span></a></li>
		<li id="action_files_edit" title="<?php echo $this->translate('Rename')?>"><a href="#"><span><strong><?php echo $this->translate('Rename')?></strong></span></a></li>
		<!--
		<li id="action_files_share"><a href="#" class="shareFile"><span><strong><?php echo $this->translate('Share')?></strong></span></a></li>
		-->
	</ul>
		<ul id="jsddm">
			<li id="action_more_contacts" title="<?php echo $this->translate('More')?>"><a class="moredrop" href="#"><span><strong><?php echo $this->translate('More')?><span class="arrow">▼</span></strong></span></a>
				<ul class="menu_drop_more" style=" left: 278px;">
					<li id='action_more_files_selectall'><a href="#"><?php echo $this->translate('Select All')?></a></li>
					<li id='action_more_files_deselectall' class="bottom"><a href="#"><?php echo $this->translate('Deselect')?></a></li>
				</ul>
			</li>
		</ul>
		
	</ul>

		
</div>

<!-- File Sharing Popup Div -->
<div id="shareFileStorage">
	<img src="">
	<h1>fernfeather.jpg</h1>
	will be shared at:</br>
	http://atmail.com/files/fernfeather.jpg</br>
	
	<label class="file-link">
		<span>Send this link to:</span>
		<input type="text" value="">
	</label>
	
	<textarea rows="5"></textarea>
	
	<label class="file-password">
		<input type="checkbox"> 
		<span>Password protect file </span>
		<input type="text" value="" class="password-protect">
	</label>
	
	<label class="file-expiry">
		<input type="checkbox"> 
		<span>Link expires after</span>
		<input type="text" value="" class="file-expiry-amt">
		<span>days</span>
	</label>
	
	<ul class="ShareFile-Btns">
		<li class="ShareFileSave"><a href="#"><span><strong>Share</strong></span></a></li>
		<li class="ShareFileCancel"><a href="#"><span><strong>Cancel</strong></span></a></li>
	</ul>
</div>

<div id="primary">
	<div id="primary_header">
		<h1><?php echo $this->translate('My Files'); ?></h1>
		
		<div id="back_button">
			<!--
			<a href="#" id='toggleThreads'><span class="stronglastword"><?php echo $this->translate('Email File')?></span></a>
			<a href="#" id='collapseThreads'><span class="stronglastword"><?php echo $this->translate('Share')?></span></a>
			-->
		</div>
		
	</div>
	<div id="contact-hold">
		<div id="primary_content">
			<div id="primary_content_inner">
				<div class="cssSummaryPanel">
				<form method="post" name='listfiles' class="cssSummarySearch">
				
				
				<div id="webdav_files" >
					<div class="cssSummarySearchTop">
					<div class="cssSearchButton">					
						<div class="cssSummarySearchInput">
							<input type="text" id="listfilesSearch" class="scroll_off" autocomplete="off">
							<div class="files-search-delete" style="display: none;"></div>
						</div>				
					</div>
					</div>
					
					<?php echo $this->render('webdav/listfiles.phtml'); ?>
				</div>
				</div>
				</form>
			</div>
			<div id="file_info" class='fileview'>
				
			</div>
		</div>
	</div>
</div>

<div id="secondary">
<?php echo $this->render('webdav/listfolders.phtml'); ?>
</div>


<script type="text/javascript" language="JavaScript">
$(function() {

	$('#action_files_share a').qtip(
	{
		show: 'click',
		content: $("DIV#shareFileStorage").html(),
		hide: {
		when: {
		target: $(document.body).children().not( $(self) ).not( $('#ui-datepicker-div')),
		event: 'mousedown scroll mousewheel'
		},
		effect: { type: 'fade' }
		},

		style: {
		classes: { tooltip: 'ShareFile' }
		}
		
	});
		
	// Make the folder list a tree menu!
	var simpleTreeViewOptions = {
		open: '',
		close: '',
		classOpen: 'folderOpened',
		classClose: 'folderClosed',
		slide: true,
		speed: 'fast',
		collapsed: true,
		expand: '0'
	};
	
	folderTreeView = $("ul#nav_secondary", '#Files').simpletreeview( simpleTreeViewOptions );	
	folderTreeView.expand( $('.current', '#Files').parent().children('ul') );

	$('#folder_actions #folder_add a', '#Files').click( function() { $(this).folderCreate( $('#Files #nav_secondary'), true ) } )
	$('#folder_actions #folder_remove a', '#Files').click( function() { $(this).folderDelete( $('#Files #nav_secondary') ) } )
	
	//needed for new skin
	$('#folder_actions .folder-add', '#Files').click( function() { $(this).folderCreate( $('#Files #nav_secondary'), true ) } )
	$('#folder_actions .folder-remove', '#Files').click( function() { $(this).folderDelete( $('#Files #nav_secondary') ) } )
	
	// Make the more menu
	$('#Files #jsddm > li').bind('mousedown', jsddm_open);
	
	//$('a.contactLink').bind("dblclick", function() { return editContactDblClick($('#contact_table:first')) } );
	$('#action_files_edit a').bind("click", function() { 
		$("DIV#shareUrl").hide();
		return editContactDblClick();
	} );
	$('#action_files_delete a').bind("click", function() { return $(this).deleteFile(); } );
	$('#action_files_folder a').bind("click", function() { return newContact(true) } );
	$('#action_files_share a').bind("click", function() { return exportContact() } );
	
	$("#action_more_files_selectall").bind("click", function() {
		jsddm_close();
		$("DIV.activeFile", "#Files").each(function() {
		$(this).find('INPUT[type=checkbox]').attr('checked', true);
		$(this).addClass('selected');
		});
	});

	$("#action_more_files_deselectall").bind("click", function() {
		jsddm_close();
		$("DIV.activeFile", "#Files").each(function() {
		$(this).find('INPUT[type=checkbox]').attr('checked', false);
		$(this).removeClass('selected');
		});
	});
	
	$("#action_files_edit").bind("click", function() {
				
		$("LI#attachment1 A", "#Files").hide();
		$("DIV.attachments INPUT.rename", "#Files").show();
		
		$("DIV.attachments INPUT.rename", "#Files").select().focus(); 
		$("DIV.fileview").scrollTo(0);
		
		$("FORM#fileForm", "#Files").unbind('submit');		
		$("FORM#fileForm", "#Files").bind('submit', function(e) {
									
			return false;
		});
		$('DIV.attachments INPUT.rename', '#Files').unbind('keypress');
		$('DIV.attachments INPUT.rename', '#Files').bind('keypress', function(e) { if(e.keyCode == 13) $(this).trigger('blur'); });
		$('DIV.attachments INPUT.rename', "#Files").unbind('blur');
		$('DIV.attachments INPUT.rename', '#Files').bind('blur', function(e) {

			// Hide the select box
			$("DIV.attachments INPUT.rename", "#Files").hide();

			// Show the previous name
			$("LI#attachment1 A", "#Files").show();
			
			var newFile = $("DIV.attachments INPUT.rename", "#Files").val();
			var oldFile = $("INPUT[name=oldFile]", "#Files").val();

			// Take away the directory path
			newFile = newFile.replace(/\//g,'_');
			oldFile = oldFile.replace(/\//g,'_');
			
			// Return if the same name, or blank
			if(newFile == oldFile || !newFile)
				return false;
			
			// Change the name of the view on the view pane
			//$("LI#attachment1 A", "#Files").html( newFile );
			$("a.filename", "#Files").html( newFile);
			$("a#shareFile", "#Files").html( 'Share File' );
			<?php $this->fileMD5 = "" ?>
			$("INPUT[name=fileRename], INPUT[name=oldFile], INPUT[name=Filename]", "#Files").val( newFile );
			
			$("DIV.attachments INPUT.rename").renameFile(oldFile, newFile);
						
			// Now update the file list to reflect the new name
			$("DIV.selected INPUT.fileSelect", "#Files").val(newFile);
			$("DIV.selected DIV.name", "#Files").html(newFile);
			e.stopPropagation();
			
			return false;
		}).select()
				
	});
	
	// Mail button
	$('#action_contact_mail a').bind("click", function() { return emailSelected(); } );
	
	// Configure Ajax uploader for image
	var upload = new AjaxUpload('#action_files_upload', {
	  // Location of the server-side upload script
	  action: "<?php echo $this->moduleBaseUrl ?>/webdav/upload/",
	  // File upload name
	  name: 'newAttachment',
	  // Additional data to send
	  autoSubmit: true,
	  onChange: function(file, extension){ },
	  onSubmit: function(file, extension) {
		
		upload.setData({'folder': $("#action_files_upload").getActiveFolder()});
		$("DIV#primary_header H1", "#Files").html("Uploading ...");
		
	  },
	
	  // Fired when file upload is completed
	  // @param file basename of uploaded file
	  // @param response server response
	  onComplete: function(file, response) {
		if(response && response.indexOf('Error') >= 0)
		{
			alert(response);
		}

		$("#webdav_files").loadFiles( $("#action_files_upload").getActiveFolder(), response );
	 }

	});
	
	// Set the folder to DND
	$("#nav_secondary li a", '#Files').each( function() { 
		$(this).folderDndInit(); 

		$(this).bind('dblclick', function() {
			editStorageFolderDblClick($(this));
		})
	});
	
	if(!$.browser.msie) {
		$("DIV#Files").dropzone({
			url: function() { return siteBaseUrl + "index.php/mail/webdav/uploaddnd/?Directory=" + urlencode($(this).getActiveFolder()); },
			printLogs : true,
			uploadRateRefreshTime : 250,
			numConcurrentUploads : 1
		});			
	}

	// Load the default folder
	$("#webdav_files").loadFiles( $("#Files").getActiveFolder() );
	
	// Attach the event when clicking a directory/files
	$("A.webdavFolder").bind('click', function() {
		$(this).folderClickFiles();
	}); 
	
	// Show delete button in search field when user has entered chracters
		$('#listfilesSearch').keypress(function() {
	  	$('.files-search-delete').css('display','block');
	});
	
	// Delete data in search textbox 
	$(".files-search-delete").click(function() { 
	   $("#listfilesSearch").attr("value", ""); 
	   $('.files-search-delete').fadeOut('medium');

		$("#webdav_files").loadFiles( $("#Files").getActiveFolder() );

		// Attach the event when clicking a directory/files
		$("A.webdavFolder").bind('click', function() {
			$(this).folderClickFiles();
		});

	});

});

</script>
<div id="draggableFilesContainer" style="position:absolute;"></div>
