diff --git a/apps/calendar/ajax/duration.php b/apps/calendar/ajax/duration.php
new file mode 100644
index 0000000000000000000000000000000000000000..cdc41388abd232bb5501eab33ac29bc9d99e9510
--- /dev/null
+++ b/apps/calendar/ajax/duration.php
@@ -0,0 +1,12 @@
+<?php
+/**
+ * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+require_once('../../../lib/base.php');
+OC_JSON::checkLoggedIn();
+$duration = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'duration', "60");
+OC_JSON::encodedPrint(array("duration" => $duration));
+?> 
diff --git a/apps/calendar/ajax/moveevent.php b/apps/calendar/ajax/moveevent.php
new file mode 100644
index 0000000000000000000000000000000000000000..e2b777969daa1d12060387ca18b1fc14632eeae7
--- /dev/null
+++ b/apps/calendar/ajax/moveevent.php
@@ -0,0 +1,103 @@
+<?php
+/**
+ * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+error_reporting(E_ALL);
+require_once('../../../lib/base.php');
+OC_JSON::checkLoggedIn();
+$data = OC_Calendar_Object::find($_POST["id"]);
+$calendarid = $data["calendarid"];
+$cal = $calendarid;
+$id = $_POST["id"];
+$calendar = OC_Calendar_Calendar::findCalendar($calendarid);
+if(OC_User::getUser() != $calendar["userid"]){
+	OC_JSON::error();
+	exit;
+}
+$newdate = $_POST["newdate"];
+$caldata = array();
+//modified part of editeventform.php
+$object = Sabre_VObject_Reader::read($data['calendardata']);
+$vevent = $object->VEVENT;
+$dtstart = $vevent->DTSTART;
+$dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
+switch($dtstart->getDateType()) {
+	case Sabre_VObject_Element_DateTime::LOCALTZ:
+	case Sabre_VObject_Element_DateTime::LOCAL:
+		$startdate = $dtstart->getDateTime()->format('d-m-Y');
+		$starttime = $dtstart->getDateTime()->format('H:i');
+		$enddate = $dtend->getDateTime()->format('d-m-Y');
+		$endtime = $dtend->getDateTime()->format('H:i');
+		$allday = false;
+		break;
+	case Sabre_VObject_Element_DateTime::DATE:
+		$startdate = $dtstart->getDateTime()->format('d-m-Y');
+		$starttime = '00:00';
+		$dtend->getDateTime()->modify('-1 day');
+		$enddate = $dtend->getDateTime()->format('d-m-Y');
+		$endtime = '23:59';
+		$allday = true;
+		break;
+}
+$caldata["title"] = isset($vevent->SUMMARY) ? $vevent->SUMMARY->value : '';
+$caldata["location"] = isset($vevent->LOCATION) ? $vevent->LOCATION->value : '';
+$caldata["categories"] = array();
+if (isset($vevent->CATEGORIES)){
+       $caldata["categories"] = explode(',', $vevent->CATEGORIES->value);
+       $caldata["categories"] = array_map('trim', $categories);
+}
+foreach($caldata["categories"] as $category){
+	if (!in_array($category, $category_options)){
+		array_unshift($category_options, $category);
+	}
+}
+$caldata["repeat"] = isset($vevent->CATEGORY) ? $vevent->CATEGORY->value : '';
+$caldata["description"] = isset($vevent->DESCRIPTION) ? $vevent->DESCRIPTION->value : '';
+//end part of editeventform.php
+$startdatearray = explode("-", $startdate);
+$starttimearray = explode(":", $starttime);
+$startunix = mktime($starttimearray[0], $starttimearray[1], 0, $startdatearray[1], $startdatearray[0], $startdatearray[2]);
+$enddatearray = explode("-", $enddate);
+$endtimearray = explode(":", $endtime);
+$endunix = mktime($endtimearray[0], $endtimearray[1], 0, $enddatearray[1], $enddatearray[0], $enddatearray[2]);
+$difference = $endunix - $startunix;
+if(strlen($newdate) > 10){
+	$newdatestringarray = explode("-", $newdate);
+	if($newdatestringarray[1] == "allday"){
+		$allday = true;
+		$newdatestringarray[1] = "00:00";
+	}else{
+		if($allday == true){
+			$difference = 3600;
+		}
+		$allday = false;
+	}
+}else{
+	$newdatestringarray = array();
+	$newdatestringarray[0] = $newdate;
+	$newdatestringarray[1] = $starttime;
+}
+$newdatearray = explode(".", $newdatestringarray[0]);
+$newtimearray = explode(":", $newdatestringarray[1]);
+$newstartunix = mktime($newtimearray[0], $newtimearray[1], 0, $newdatearray[1], $newdatearray[0], $newdatearray[2]);
+$newendunix = $newstartunix + $difference;
+if($allday == true){
+	$caldata["allday"] = true;
+}else{
+	unset($caldata["allday"]);
+}
+$caldata["from"] = date("d-m-Y", $newstartunix);
+$caldata["fromtime"] = date("H:i", $newstartunix);
+$caldata["to"]  = date("d-m-Y", $newendunix);
+$caldata["totime"] = date("H:i", $newendunix);
+//modified part of editevent.php
+$vcalendar = Sabre_VObject_Reader::read($data["calendardata"]);
+OC_Calendar_Object::updateVCalendarFromRequest($caldata, $vcalendar);
+
+$result = OC_Calendar_Object::edit($id, $vcalendar->serialize());
+OC_JSON::success();
+//end part of editevent.php
+?>
\ No newline at end of file
diff --git a/apps/calendar/ajax/neweventform.php b/apps/calendar/ajax/neweventform.php
index 9bab2cd4846522dda48de2c9aab5dc0f35c37c69..9d4dcfa2e138b7bc4dae47c3b4a9279e1ab07b25 100644
--- a/apps/calendar/ajax/neweventform.php
+++ b/apps/calendar/ajax/neweventform.php
@@ -29,35 +29,21 @@ if($starttime != 'undefined' && !is_nan($starttime) && !$allday){
 	$starttime = '0';
 	$startminutes = '00';
 }else{
-	$starttime = date('H');
-	if(strlen($starttime) == 2 && $starttime <= 9){
-		$starttime = substr($starttime, 1, 1);
-	}
+	$starttime = date('G');
+
 	$startminutes = date('i');
 }
 
-$endday      = $startday;
-$endmonth    = $startmonth;
-$endyear     = $startyear;
-$endtime     = $starttime;
-$endminutes  = $startminutes;
-if($endtime == 23) {
-	if($startday == date(t, mktime($starttime, $startminutes, 0, $startmonth, $startday, $startyear))){
-		$datetimestamp = mktime(0, 0, 0, $startmonth, $startday, $startyear);
-		$datetimestamp = $datetimestamp + 86400;
-		$endmonth = date("m", $datetimestamp);
-		$endday = date("d", $datetimestamp);
-		$endyear = date("Y", $datetimestamp);
-	}else{
-		$endday++;
-		if($endday <= 9){
-			$endday = "0" . $endday;
-		}
-	}
-	$endtime = 0;
-} else {
-	$endtime++;
-}
+$datetimestamp = mktime($starttime, $startminutes, 0, $startmonth, $startday, $startyear);
+$duration = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'duration', "60");
+$datetimestamp = $datetimestamp + ($duration * 60);
+$endmonth = date("m", $datetimestamp);
+$endday = date("d", $datetimestamp);
+$endyear = date("Y", $datetimestamp);
+$endtime = date("G", $datetimestamp);
+$endminutes = date("i", $datetimestamp);
+
+
 
 $tmpl = new OC_Template('calendar', 'part.newevent');
 $tmpl->assign('calendar_options', $calendar_options);
diff --git a/apps/calendar/ajax/setduration.php b/apps/calendar/ajax/setduration.php
new file mode 100644
index 0000000000000000000000000000000000000000..a75c8faea4228fd3eae31500dce2321ec735cb99
--- /dev/null
+++ b/apps/calendar/ajax/setduration.php
@@ -0,0 +1,17 @@
+<?php
+/**
+ * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+require_once('../../../lib/base.php');
+OC_JSON::checkLoggedIn();
+if(isset($_POST["duration"])){
+	OC_Preferences::setValue(OC_User::getUser(), 'calendar', 'duration', $_POST["duration"]);
+	OC_JSON::success();
+}else{
+	OC_JSON::error();
+}
+?> 
+ 
diff --git a/apps/calendar/ajax/settimeformat.php b/apps/calendar/ajax/settimeformat.php
new file mode 100644
index 0000000000000000000000000000000000000000..7805120ba5efd756c08102ec9eb3a74bd5c8946d
--- /dev/null
+++ b/apps/calendar/ajax/settimeformat.php
@@ -0,0 +1,17 @@
+<?php
+/**
+ * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+require_once('../../../lib/base.php');
+OC_JSON::checkLoggedIn();
+if(isset($_POST["timeformat"])){
+	OC_Preferences::setValue(OC_User::getUser(), 'calendar', 'timeformat', $_POST["timeformat"]);
+	OC_JSON::success();
+}else{
+	OC_JSON::error();
+}
+?> 
+ 
diff --git a/apps/calendar/ajax/timeformat.php b/apps/calendar/ajax/timeformat.php
new file mode 100644
index 0000000000000000000000000000000000000000..3533adcf8e03303c80c34a389868c7e3e1263b61
--- /dev/null
+++ b/apps/calendar/ajax/timeformat.php
@@ -0,0 +1,12 @@
+<?php
+/**
+ * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+require_once('../../../lib/base.php');
+OC_JSON::checkLoggedIn();
+$timeformat = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'timeformat', "24");
+OC_JSON::encodedPrint(array("timeformat" => $timeformat));
+?> 
diff --git a/apps/calendar/export.php b/apps/calendar/export.php
index feb4755a3aa95c7fe8bc07eaa2059ebd442905a1..b3e5ecd6834f60bc813f4042d95431f625bcb0f9 100644
--- a/apps/calendar/export.php
+++ b/apps/calendar/export.php
@@ -10,15 +10,29 @@ require_once ("../../lib/base.php");
 OC_Util::checkLoggedIn();
 OC_Util::checkAppEnabled('calendar');
 $cal = $_GET["calid"];
-$calendar = OC_Calendar_Calendar::findCalendar($cal);
-if($calendar["userid"] != OC_User::getUser()){
-	header( 'Location: '.OC_Helper::linkTo('', 'index.php'));
-	exit;
-}
-$calobjects = OC_Calendar_Object::all($cal);
-header("Content-Type: text/Calendar");
-header("Content-Disposition: inline; filename=calendar.ics"); 
-for($i = 0;$i <= count($calobjects); $i++){
-	echo $calobjects[$i]["calendardata"] . "\n";
+$event = $_GET["eventid"];
+if(isset($cal)){
+	$calendar = OC_Calendar_Calendar::findCalendar($cal);
+	if($calendar["userid"] != OC_User::getUser()){
+		OC_JSON::error();
+		exit;
+	}
+	$calobjects = OC_Calendar_Object::all($cal);
+	header("Content-Type: text/Calendar");
+	header("Content-Disposition: inline; filename=calendar.ics"); 
+	for($i = 0;$i <= count($calobjects); $i++){
+		echo $calobjects[$i]["calendardata"] . "\n";
+	}
+}elseif(isset($event)){
+	$data = OC_Calendar_Object::find($_GET["eventid"]);
+	$calendarid = $data["calendarid"];
+	$calendar = OC_Calendar_Calendar::findCalendar($calendarid);
+	if($calendar["userid"] != OC_User::getUser()){
+		OC_JSON::error();
+		exit;
+	}
+	header("Content-Type: text/Calendar");
+	header("Content-Disposition: inline; filename=" . $data["summary"] . ".ics"); 
+	echo $data["calendardata"];
 }
 ?>
diff --git a/apps/calendar/js/calendar.js b/apps/calendar/js/calendar.js
index 554d1f1b0a4bdf30bc30498c20bde215a4ac1556..79689fbf8591b8cf4287d0ccced0f1c09e827933 100644
--- a/apps/calendar/js/calendar.js
+++ b/apps/calendar/js/calendar.js
@@ -155,6 +155,7 @@ Calendar={
 				Calendar.UI.updateView()
 			});
 		},
+		drageventid: '',
 		updateDate:function(direction){
 			if(direction == 'forward' && this.current.forward) {
 				this.current.forward();
@@ -247,6 +248,11 @@ Calendar={
 				.data('event_info', event)
 				.hover(this.createEventPopup,
 				       this.hideEventPopup)
+				.draggable({
+					drag: function() {
+						Calendar.UI.drageventid = event.id;
+					}
+				})
 				.click(this.editEvent);
 			var color = this.calendars[event['calendarid']]['color'];
 			if (color){
@@ -360,6 +366,12 @@ Calendar={
 					}
 				},"json");
 		},
+		moveevent:function(eventid, newstartdate){
+			$.post(OC.filePath('calendar', 'ajax', 'moveevent.php'), { id: eventid, newdate: newstartdate},
+			function(data) {
+				console.log("Event moved successfully");
+			});
+		},
 		showadvancedoptions:function(){
 			$("#advanced_options").css("display", "block");
 			$("#advanced_options_button").css("display", "none");
@@ -548,6 +560,22 @@ Calendar={
 				var today = new Date();
 				for(var i = 0; i <= 6; i++){
 					$("#oneweekview th." + Calendar.UI.weekdays[i]).html(Calendar.UI.formatDayShort((i+Calendar.firstdayofweek)%7) + Calendar.space + dates[i].getDate() + Calendar.space + Calendar.UI.formatMonthShort(dates[i].getMonth()));
+					$("#oneweekview td." + Calendar.UI.weekdays[i] + ".allday").attr('title', dates[i].getDate() + "." + String(parseInt(dates[i].getMonth()) + 1) + "." + dates[i].getFullYear() + "-" + "allday");
+					$("#oneweekview td." + Calendar.UI.weekdays[i] + ".allday").droppable({
+						drop: function() {
+							Calendar.UI.moveevent(Calendar.UI.drageventid, this.title);
+							Calendar.UI.loadEvents();
+						}
+					});
+					for(var ii = 0;ii <= 23; ii++){
+						$("#oneweekview td." + Calendar.UI.weekdays[i] + "." + String(ii)).attr('title', dates[i].getDate() + "." + String(parseInt(dates[i].getMonth()) + 1) + "." + dates[i].getFullYear() + "-" + String(ii) + ":00");
+						$("#oneweekview td." + Calendar.UI.weekdays[i] + "." + String(ii)).droppable({
+							drop: function() {
+								Calendar.UI.moveevent(Calendar.UI.drageventid, this.title);
+								Calendar.UI.loadEvents();
+							}
+						});
+					}
 					if(dates[i].getDate() == today.getDate() && dates[i].getMonth() == today.getMonth() && dates[i].getFullYear() == today.getFullYear()){
 						$("#oneweekview ." + Calendar.UI.weekdays[i]).addClass("thisday");
 					}
@@ -724,6 +752,13 @@ Calendar={
 					var month = dates[i].getMonth();
 					var year = dates[i].getFullYear();
 					$("#onemonthview .week_" + week + " ." + Calendar.UI.weekdays[weekday] + " .dateinfo").html(dayofmonth + Calendar.space + Calendar.UI.formatMonthShort(month));
+					$("#onemonthview .week_" + week + " ." + Calendar.UI.weekdays[weekday]).attr('title', dayofmonth + "." + String(parseInt(month) + 1) + "." + year);
+					$("#onemonthview .week_" + week + " ." + Calendar.UI.weekdays[weekday]).droppable({
+						drop: function() {
+							Calendar.UI.moveevent(Calendar.UI.drageventid, this.title);
+							Calendar.UI.loadEvents();
+						}
+					});
 					if(dayofmonth == today.getDate() && month == today.getMonth() && year == today.getFullYear()){
 						$("#onemonthview .week_" + week + " ." + Calendar.UI.weekdays[weekday]).addClass('thisday');
 					}
diff --git a/apps/calendar/js/settings.js b/apps/calendar/js/settings.js
index 5d048b83c36597485d6475b3379059cede592a3a..07e912aaa7aea3240b499839dc44259ceb4ac33f 100644
--- a/apps/calendar/js/settings.js
+++ b/apps/calendar/js/settings.js
@@ -34,6 +34,29 @@ $(document).ready(function(){
 			minWidth:'auto',
 		});
 	});
+	$("#timeformat").change( function(){
+		var data = $("#timeformat").serialize();
+		$.post( OC.filePath('calendar', 'ajax', 'settimeformat.php'), data, function(data){
+			if(data == "error"){
+				console.log("saving timeformat failed");
+			}
+		});
+	});
+	$.getJSON(OC.filePath('calendar', 'ajax', 'timeformat.php'), function(jsondata, status) {
+		$("#" + jsondata.timeformat).attr('selected',true);
+		$("#timeformat").chosen();
+	});
+	$("#duration").blur( function(){
+		var data = $("#duration").val();
+		$.post( OC.filePath('calendar', 'ajax', 'setduration.php'), {duration: data}, function(data){
+			if(data == "error"){
+				console.log("saving duration failed");
+			}
+		});
+	});
+	$.getJSON(OC.filePath('calendar', 'ajax', 'duration.php'), function(jsondata, status) {
+		$("#duration").val(jsondata.duration);
+	});
 	$("#weekend").change( function(){
 		var data = $("#weekend").serialize();
 		$.post( OC.filePath('calendar', 'ajax', 'setdaysofweekend.php'), data, function(data){
diff --git a/apps/calendar/templates/calendar.php b/apps/calendar/templates/calendar.php
index 25d92b0c7e422cbe9290ebbaf1bbfd414dcd3afd..317bb17ddbc881892e1ddd3fd3db0d56b8639b32 100644
--- a/apps/calendar/templates/calendar.php
+++ b/apps/calendar/templates/calendar.php
@@ -1,32 +1,4 @@
 <?php
-$hours = array(
-	'allday' => $l->t('All day'),
-	 0 => '0',
-	 1 => '1',
-	 2 => '2',
-	 3 => '3',
-	 4 => '4',
-	 5 => '5',
-	 6 => '6',
-	 7 => '7',
-	 8 => '8',
-	 9 => '9',
-	10 => '10',
-	11 => '11',
-	12 => '12',
-	13 => '13',
-	14 => '14',
-	15 => '15',
-	16 => '16',
-	17 => '17',
-	18 => '18',
-	19 => '19',
-	20 => '20',
-	21 => '21',
-	22 => '22',
-	23 => '23',
-);
-/*
 $hours24 = array(
 	'allday' => $l->t('All day'),
 	 0 => '0',
@@ -81,7 +53,11 @@ $hoursampm = array(
 	22 => '10 p.m.',
 	23 => '11 p.m.',
 );
-*/
+if(OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'timeformat', "24") == "24"){
+	$hours = $hours24;
+}else{
+	$hours = $hoursampm;
+}
 $weekdaynames = array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday');
 $dayforgenerator = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'firstdayofweek', "1");
 $weekdays = array();
diff --git a/apps/calendar/templates/part.editevent.php b/apps/calendar/templates/part.editevent.php
index be637aeae550ce20766eaf97c7d0a8691ba09db8..ae969f2dc3b6d8658a659fa33eb298a10ba3bd63 100644
--- a/apps/calendar/templates/part.editevent.php
+++ b/apps/calendar/templates/part.editevent.php
@@ -6,6 +6,7 @@
 	<span id="actions">
 		<input type="button" class="submit" style="float: left;" value="<?php echo $l->t("Submit");?>" onclick="Calendar.UI.validateEventForm('ajax/editevent.php');">
 		<input type="button" class="submit" style="float: left;" name="delete" value="<?php echo $l->t("Delete");?>" onclick="Calendar.UI.submitDeleteEventForm('ajax/deleteevent.php');">
+		<input type="button" class="submit" style="float: right;" name="export" value="<?php echo $l->t("Export");?>" onclick="window.location='export.php?eventid=<?php echo $_['id'] ?>';">
 	</span>
 	</form>
 </div>
diff --git a/apps/calendar/templates/settings.php b/apps/calendar/templates/settings.php
index 7df357099e832213108370f5c9849da17d4433d0..75f094aab47bce3e2fe245b86bd0b16641e5ff9a 100644
--- a/apps/calendar/templates/settings.php
+++ b/apps/calendar/templates/settings.php
@@ -38,14 +38,21 @@ OC_UTIL::addStyle('', 'jquery.multiselect');
 		?>
 		</select>&nbsp;&nbsp;
 		<label for="weekend"><strong><?php echo $l->t('Days of weekend');?></strong></label>
-		<select id="weekend" name="weekend[]" multiple="multiple" title="<?php echo "Wochenende"; ?>">
+		<select id="weekend" name="weekend[]" multiple="multiple" title="<?php echo $l->t("Weekend"); ?>">
 		<?php
 		$weekdays = array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
 		for($i = 0;$i <= 6;$i++){
 			echo '<option value="'.$weekdays[$i].'" id="selectweekend_' . $weekdays[$i] . '">' . $l->t($weekdays[$i]) . '</option>';
 		}
 		?>
-		</select>
+		</select>&nbsp;&nbsp;
+		<label for="timeformat"><strong><?php echo $l->t('Timeformat');?></strong></label>
+		<select style="display: none;" id="timeformat" title="<?php echo "timeformat"; ?>" name="timeformat">
+			<option value="24" id="24h"><?php echo $l->t("24 h"); ?></option>
+			<option value="ampm" id="ampm"><?php echo $l->t("am/pm"); ?></option>
+		</select>&nbsp;&nbsp;
+		<label for="duration"><strong><?php echo $l->t('Event duration');?></strong></label>
+		<input type="text" maxlength="3" size="3" style="width: 2em;" id="duration" name="duration" /> <strong><?php echo $l->t("Minutes");?></strong>
 		<br />
 		Calendar CalDAV syncing address: 
   		<?php echo OC_Helper::linkTo('apps/calendar', 'caldav.php', null, true); ?><br />
diff --git a/lib/appconfig.php b/lib/appconfig.php
index 392782b2586c99e131697291a56fe45dcee65779..f43ef14173224e5b0c60571ab05bf8278ff5167c 100644
--- a/lib/appconfig.php
+++ b/lib/appconfig.php
@@ -100,7 +100,18 @@ class OC_Appconfig{
 			return $default;
 		}
 	}
-
+	
+	/**
+	 * @brief check if a key is set in the appconfig
+	 * @param string $app
+	 * @param string $key
+	 * @return bool
+	 */
+	public static function hasKey($app,$key){
+		$exists = self::getKeys( $app );
+		return in_array( $key, $exists );
+	}
+	
 	/**
 	 * @brief sets a value in the appconfig
 	 * @param $app app
@@ -112,10 +123,7 @@ class OC_Appconfig{
 	 */
 	public static function setValue( $app, $key, $value ){
 		// Does the key exist? yes: update. No: insert
-		$exists = self::getKeys( $app );
-
-		// null: does not exist
-		if( !in_array( $key, $exists )){
+		if(! self::hasKey($app,$key)){
 			$query = OC_DB::prepare( 'INSERT INTO *PREFIX*appconfig ( appid, configkey, configvalue ) VALUES( ?, ?, ? )' );
 			$query->execute( array( $app, $key, $value ));
 		}