diff --git a/files/js/admin.js b/files/js/admin.js
new file mode 100644
index 0000000000000000000000000000000000000000..5cbb2b9f5ac5aa163ff3bad64eb3629ecd177574
--- /dev/null
+++ b/files/js/admin.js
@@ -0,0 +1,15 @@
+function switchPublicFolder()  
+{
+        var publicEnable = $('#publicEnable').is(':checked');
+        var sharingaimGroup = $('input:radio[name=sharingaim]'); //find all radiobuttons of that group
+        $.each(sharingaimGroup, function(index, sharingaimItem) {
+                sharingaimItem.disabled = !publicEnable;	 //set all buttons to the correct state
+        });
+}
+
+$(document).ready(function(){
+       switchPublicFolder(); // Execute the function after loading DOM tree
+       $('#publicEnable').click(function(){
+               switchPublicFolder(); // To get rid of onClick()
+       });
+});
diff --git a/files/js/files.js b/files/js/files.js
index 431b49131ce1921c0c7f0c623754079dcd922e0c..3c02110fe2613f61f7cb79294f454ac116381d65 100644
--- a/files/js/files.js
+++ b/files/js/files.js
@@ -39,7 +39,7 @@ $(document).ready(function() {
 	// Sets the file link behaviour :
 	$('td.filename a').live('click',function(event) {
 		event.preventDefault();
-		var filename=$(this).text();
+		var filename=$(this).parent().parent().attr('data-file');
 		var mime=$(this).parent().parent().attr('data-mime');
 		var type=$(this).parent().parent().attr('data-type');
 		var action=FileActions.getDefault(mime,type);
@@ -245,7 +245,7 @@ function formatDate(date){
 
 //options for file drag/dropp
 var dragOptions={
-	distance: 20, revert: true, opacity: 0.7,
+	distance: 20, revert: 'invalid', opacity: 0.7,
 	stop: function(event, ui) {
 		$('#fileList tr td.filename').addClass('ui-draggable');
 	}
diff --git a/files/templates/admin.php b/files/templates/admin.php
index 4dde9c510c4ae2be97fa15fa1df1a55684d46946..ff331f860e626937fbd0136329ca52224af29d7e 100644
--- a/files/templates/admin.php
+++ b/files/templates/admin.php
@@ -1,21 +1,13 @@
-<script type="text/javascript">
-function switchPublicFolder()
-{
-	var publicEnable = document.forms['filesForm'].elements['publicEnable'].checked;
-	var sharingaimGroup = document.forms['filesForm'].elements['sharingaim'];
-	for(i=0;i<sharingaimGroup.length;i++) {
-		sharingaimGroup[i].disabled = !publicEnable;
-	}
-}
-</script>
+<?php OC_UTIL::addScript('files','admin'); ?>
+
 <form name="filesForm" action='#' method='post'>
 	<?php if($_['htaccessWorking']):?>
 		<label for="maxUploadSize"><?php echo $l->t( 'Maximum upload size' ); ?> </label><input name='maxUploadSize' id="maxUploadSize" value='<?php echo $_['uploadMaxFilesize'] ?>'/><br/>
 	<?php endif;?>
-	<input type="checkbox" name="publicEnable" id="publicEnable" onClick="switchPublicFolder()" /><label for="publicEnable"> <?php echo $l->t( 'Allow public folders' ); ?></label><br>
+	<input type="checkbox" name="publicEnable" id="publicEnable" /><label for="publicEnable"> <?php echo $l->t( 'Allow public folders' ); ?></label><br>
 
 	<div style="padding-left: 20px">
-		<input type="radio" name="sharingaim" id="separated" checked="checked" /><label for="separated"> <?php echo $l->t( 'separated from webdav storage' ); ?></label><br>
+		<input type="radio" name="sharingaim" id="separated" /><label for="separated"> <?php echo $l->t( 'separated from webdav storage' ); ?></label><br>
 		<input type="radio" name="sharingaim" id="userdecide" /><label for="userdecide"> <?php echo $l->t( 'let the user decide' ); ?></label><br>
 		<input type="radio" name="sharingaim" id="inwebdav" /><label for="inwebdav"> <?php echo $l->t( 'folder "/public" in webdav storage' ); ?></label>
 	</div>