Index: trunk/calendar_new/xsl/detailsDialog.xsl
===================================================================
--- trunk/calendar_new/xsl/detailsDialog.xsl	(revision 457)
+++ trunk/calendar_new/xsl/detailsDialog.xsl	(revision 492)
@@ -10,5 +10,5 @@
 	</td>
 	<td background="templates/default/images/iw_ne.png">
-		<img id="closeDialog" onclick="calendar.dialog()" src="templates/default/images/close.gif" style="position: absolute; z-index: 184; cursor: pointer;"/>
+		<img id="closeDialog" onclick="calendar.dialog()" src="templates/default/images/close.gif" style="position: absolute; top: 20px; left: 325px; z-index: 184; cursor: pointer;"/>
 	</td>
 </tr>
@@ -22,9 +22,10 @@
 			<xsl:variable name="location" select="location" />
 			Titulo:<br/>
-			<input type="text" value="{title}" size="30"></input><br/>
+			<input type="text" id="dragEventSubject" value="{title}" size="30"></input><br/>
 			Descricao:<br/>
-			<input type="text" value="{description}" size="50"></input><br/>
+			<input type="text" id="dragEventDescription" value="{description}" size="50"></input><br/>
 			Local:<br/>
-			<input type="text" value="{location}" size="30"></input><br/>
+			<input type="text" id="dragEventLocation" value="{location}" size="30"></input><br/>
+			<div id="saveLink" class="buttontype" style="width:60px;" onclick="saveEvent(null,document.getElementById('dragEventSubject').value,document.getElementById('dragEventDescription').value,document.getElementById('dragEventLocation').value,_dragArea.initEvent,_dragArea.endEvent);">Save event</div>
 
 		</div>
Index: trunk/calendar_new/xsl/addDialog.xsl
===================================================================
--- trunk/calendar_new/xsl/addDialog.xsl	(revision 464)
+++ trunk/calendar_new/xsl/addDialog.xsl	(revision 492)
@@ -41,5 +41,5 @@
 				<td>
 					<div id="addEventLink" class="buttontype" onclick="quickAddEvent(document.getElementById('dragEventSubject').value,document.getElementById('dragEventDescription').value,_dragArea.initEvent,_dragArea.endEvent);">Add event</div></td><td>
-					<div id="addDetailsLink" class="buttontype" onclick="addDetails(document.getElementById('dragEventSubject').value,document.getElementById('dragEventDescription').value,_dragArea.initEvent,_dragArea.endEvent);">Add with details</div></td>
+				<div id="addDetailsLink" class="buttontype" onclick="addDetails(null,document.getElementById('dragEventSubject').value,document.getElementById('dragEventDescription').value,_dragArea.initEvent,_dragArea.endEvent);">Add with details</div></td>
 			</tr>
 	</tbody></table>
Index: trunk/calendar_new/inc/class.uicalendar.inc.php
===================================================================
--- trunk/calendar_new/inc/class.uicalendar.inc.php	(revision 464)
+++ trunk/calendar_new/inc/class.uicalendar.inc.php	(revision 492)
@@ -37,4 +37,25 @@
 		return $this->db_obj->insertEvent($start, $end, $title, $description);
 	}
+
+	function saveEvent () {
+		$start = isset ($_REQUEST["start"]) ? $_REQUEST["start"] : NULL;
+		$end = isset ($_REQUEST["end"]) ? $_REQUEST["end"] : NULL;
+		$title = isset ($_REQUEST["title"]) ? $_REQUEST["title"] : NULL;
+		$description = isset ($_REQUEST["desc"]) ? $_REQUEST["desc"] : NULL;
+		$location = isset ($_REQUEST["location"]) ? $_REQUEST["location"] : NULL;	
+
+		if ($start == NULL || $end == NULL || $title == NULL)
+			return "false;Empty field";
+		if (!eregi("^[a-zA-Z_.0-9-]*",$title))
+			return "false;Invalid char in description";
+		if (!eregi("^[0-9]*",$start))
+			return "false;Wrong formed text";
+		if (!eregi("^[0-9]*",$end))
+			return "false;Wrong formed text";
+
+		return $this->db_obj->insertEvent($start, $end, $title, $description, $location);
+	}
+
+
 
 	function changeEvent()
Index: trunk/calendar_new/inc/class.bocalendar.inc.php
===================================================================
--- trunk/calendar_new/inc/class.bocalendar.inc.php	(revision 464)
+++ trunk/calendar_new/inc/class.bocalendar.inc.php	(revision 492)
@@ -85,5 +85,5 @@
 	}
 
-	function insertEvent ($datetime, $edatetime, $title, $description)
+	function insertEvent ($datetime, $edatetime, $title, $description, $location)
 	{
 		//Discover the event id
@@ -95,7 +95,6 @@
 			$id = $this->db->row();
 
-
 		// Performing SQL insert query
-		$query = "INSERT INTO phpgw_cal VALUES (".($id['max']+1).", '".$_SESSION['calendar']['user']['email']."', ".$this->user_id.", null, null, ".$datetime.", ".time().",".$edatetime.", 2, 'E', 0, '".$title."', '".$description."', null, 0, null, null, null )";
+		$query = "INSERT INTO phpgw_cal VALUES (".($id['max']+1).", '".$_SESSION['calendar']['user']['email']."', ".$this->user_id.", null, null, ".$datetime.", ".time().",".$edatetime.", 2, 'E', 0, '".$title."', '".$description."', '".$location."', 0, null, null, null )";
 
 		if ($this->db->query($query)){
Index: trunk/calendar_new/js/common_functions.js
===================================================================
--- trunk/calendar_new/js/common_functions.js	(revision 465)
+++ trunk/calendar_new/js/common_functions.js	(revision 492)
@@ -167,4 +167,6 @@
 		divAddDialog.innerHTML = xtools.parse(data, xsl);
 		divAddDialog.style.display = "block";
+		var saveBut = document.getElementById("saveLink");
+		saveBut.onclick = function () { saveEvent(eventId); }
 	}
 	XMLTools.__RETURN_MODE__ = 'XML';
@@ -201,4 +203,39 @@
 	}
 	XMLTools.request('$this.uicalendar.removeEvent&id='+id, 'GET', handler_removeEvent);
+}
+
+function saveEvent (id, title, description, locat, startTime, endTime){
+	if (id != null){
+		return changeEvent(id,'location',locat);
+	}
+		
+	var endDate = new Date();
+	endDate.setTime(id2timeStamp(endTime)+1800000);
+
+	var handler_Add = function (data) {
+		var xsl = XMLTools.load('xsl/returnData.xsl?'+ Date.parse(new Date));
+		var serverRet = xtools.parse(data, xsl);
+		serverRet = serverRet.substr(serverRet.indexOf('>')+1);
+		calendar.dialog('infowindow');
+		var retStatus = serverRet.substr(0,5);
+		if (retStatus == "false")
+			write_msg(get_lang("Error") + ": " +get_lang(serverRet.substr(6)));
+		else{
+			var tdElement = document.getElementById(startTime);
+			var eventDiv = document.createElement('DIV');
+			eventDiv.id = "event_" + serverRet.substr(6,serverRet.length);
+			var endDateDiv = document.createElement('DIV');
+			var startDateDiv = document.createElement('DIV');
+			endDateDiv.id = endDate.getTime();
+			startDateDiv.id = id2timeStamp(startTime);
+			eventDiv.appendChild(startDateDiv);
+			eventDiv.appendChild(endDateDiv);
+			eventDiv.innerHTML += title+"<br>"+description;
+
+			createEventDiv(eventDiv);
+			write_msg(get_lang("Event were added successfully!"));
+		}
+	}
+	XMLTools.request('$this.uicalendar.saveEvent&start='+parseInt(id2timeStamp(startTime)/1000)+'&end='+parseInt(endDate.getTime()/1000)+'&title='+title+'&desc='+description+'&location='+locat, 'GET', handler_Add);
 }
 
