diff --git a/apps/contacts/ajax/movetoaddressbook.php b/apps/contacts/ajax/movetoaddressbook.php
new file mode 100644
index 0000000000000000000000000000000000000000..a3336c3cb6cba05cf6a7da6b9f669189ff8dde42
--- /dev/null
+++ b/apps/contacts/ajax/movetoaddressbook.php
@@ -0,0 +1,41 @@
+<?php
+/**
+* @author  Victor Dubiniuk
+* Copyright (c) 2012 Victor Dubiniuk <victor.dubiniuk@gmail.com>
+* Copyright (c) 2012 Thomas Tanghus <thomas@tanghus.net>
+* This file is licensed under the Affero General Public License version 3 or
+* later.
+* See the COPYING-README file.
+*/
+	
+OCP\JSON::checkLoggedIn();
+OCP\JSON::checkAppEnabled('contacts');
+OCP\JSON::callCheck();
+
+$ids = $_POST['ids'];
+$aid = intval($_POST['aid']);
+OC_Contacts_App::getAddressbook($aid);
+	
+if(!is_array($ids)) {
+	$ids = array($ids,);
+}
+$goodids = array();
+foreach ($ids as $id){
+	try {
+		$card = OC_Contacts_App::getContactObject( intval($id) );
+		if($card) {
+			$goodids[] = $id;
+		}
+	} catch (Exception $e) {
+		OCP\Util::writeLog('contacts', 'Error moving contact "'.$id.'" to addressbook "'.$aid.'"'.$e->getMessage(), OCP\Util::ERROR);
+	}
+}
+try {
+	OC_Contacts_VCard::moveToAddressBook($aid, $ids);
+}  catch (Exception $e) {
+	$msg = $e->getMessage();
+	OCP\Util::writeLog('contacts', 'Error moving contacts "'.implode(',', $ids).'" to addressbook "'.$aid.'"'.$msg, OCP\Util::ERROR);
+	OC_JSON::error(array('data' => array('message' => $msg,)));
+}
+	
+OC_JSON::success(array('data' => array('ids' => $goodids,)));
\ No newline at end of file
diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js
index 39e45224858338156f2cdb39a995ebebaa4a74ee..d5f09fbc722fab0eac7ad9f3d02e0de428736c69 100644
--- a/apps/contacts/js/contacts.js
+++ b/apps/contacts/js/contacts.js
@@ -1505,6 +1505,36 @@ Contacts={
 			}
 		},
 		Contacts:{
+			drop:function(event, ui) {
+				var dragitem = ui.draggable, droptarget = $(this);
+				//console.log('Drop ' + dragitem.data('id') +' on: ' + droptarget.data('id'));
+				if(dragitem.data('bookid') == droptarget.data('id')) {
+					return false;
+				}
+				var droplist = (droptarget.is('ul'))?droptarget:droptarget.next();
+				$.post(OC.filePath('contacts', 'ajax', 'movetoaddressbook.php'), { ids: dragitem.data('id'), aid: $(this).data('id') },
+					function(jsondata){
+						if(jsondata.status == 'success'){
+							// Do some inserting/removing/sorting magic
+							var name = $(dragitem).find('a').html();
+							var added = false;
+							$(droplist).children().each(function(){
+								if ($(this).text().toLowerCase() > name.toLowerCase()) {
+									$(this).before(dragitem.detach()); //.fadeIn('slow');
+									added = true;
+									return false;
+								}
+							});
+							if(!added) {
+								$(droplist).append(dragitem.detach());
+							}
+							dragitem.data('bookid', droptarget.data('id'));
+							Contacts.UI.Contacts.scrollTo(dragitem.data('id'));
+						} else {
+							OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
+						}
+				});
+			},
 			// Reload the contacts list.
 			update:function(id){
 				$.getJSON(OC.filePath('contacts', 'ajax', 'contacts.php'),{},function(jsondata){
@@ -1522,6 +1552,12 @@ Contacts={
 							setTimeout(Contacts.UI.Contacts.lazyupdate, 500);*/
 						});
 						Contacts.UI.Card.update(id);
+						$('#contacts h3,#contacts ul').droppable({ drop: Contacts.UI.Contacts.drop});
+						$('#contacts li').draggable({
+							axis: 'y', containment: '#contacts',
+							scroll: true, scrollSensitivity: 100,
+							opacity: 0.7, helper: 'clone'
+						});
 					}
 					else{
 						OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));