Index: trunk/admin/templates/default/category_form.tpl
===================================================================
--- trunk/admin/templates/default/category_form.tpl	(revision 577)
+++ trunk/admin/templates/default/category_form.tpl	(revision 662)
@@ -26,11 +26,17 @@
             <td valign="center" colspan="2"><input type="text" id="search_group" size=30 autocomplete="off" onkeyup="javascript:search_object(this,'cal_span_searching','groupsfound','g')"/>
             &nbsp;<font color="red"><span id="cal_span_searching">&nbsp;</span></font><br/>
-            <select id="groupsfound" style="width: 300px" size="4"></select>
-            <button type="button" onClick="javascript:add('groupsfound','group');"><img src="{template_set}/images/add.png" style="vertical-align: bottom;"/></button></td>
+            <select multiple id="groupsfound" style="width: 300px" size="4"></select>
+            <button type="button" onClick="javascript:add('groupsfound','td_group');"><img src="{template_set}/images/add.png" style="vertical-align: bottom;"/></button></td>
         </tr>
 	<tr class="row_off">
 		<td colspan="2">{lang_Owner}</td>
-		<td valign="center" colspan="2"><label id="namegroup" style="font-weight:bold">{category_namegroup}</label>
-		<button valign="top" style="visibility:{bt_rem_id_group_visibility}" id="bt_rem_idgroup" type="button" onClick="javascript:remove('group');"><img src="{template_set}/images/delete.png" style="vertical-align: middle;" /></button></td>
+		<td id="td_group" id="namegroup" valign="center" colspan="2">
+			<div>
+			<label id="{cat_id_group}" style="font-weight:bold">{category_namegroup}</label>
+			<button valign="top" type="button" onClick="javascript:remove({cat_id_group});">
+			<img src="{template_set}/images/delete.png" style="vertical-align: middle;">
+			</button>
+			</div>
+		</td>
 	</tr>
 
@@ -48,7 +54,10 @@
 		<td>{td_data}</td>
 	</tr>
-<!-- END data_row -->
+	<!-- END data_row -->
 	<tr valign="bottom" height="50">
-		<td><input type="submit" name="save" value="{lang_save}"></td>
+	<input type="hidden" name="cat_id" value="{cat_id}">
+	<input type="hidden" name="old_parent" value="{cat_parent}">
+	<input type="hidden" id="idgroup" name="idgroup" value="{cat_id_group}">
+	<td><input onclick="return verifyCatOwners('td_group')" type="submit" name="save" value="{lang_save}"></td>
 		<td><form method="POST" action="{cancel_url}"><input type="submit" name="cancel" value="{lang_cancel}"></form></td>
 		<td align="right">{delete}</td>
@@ -57,11 +66,11 @@
 </form>
 </center>
-
 <!-- END form -->
 <script language="JavaScript" type="text/javascript">
 function remove(to){
-	document.getElementById("name"+to).innerHTML = '';
-	document.getElementById("id"+to).value = '-1';
-	show_button("id"+to);
+	var to_el = document.getElementById(to);
+	var gId = to_el.id;
+	document.getElementById('idgroup').value = document.getElementById('idgroup').value.replace(gId,'');
+	document.getElementById(to).parentNode.innerHTML = '';
 } 
 function show_button(id){
@@ -71,13 +80,29 @@
 function add(from, to){
 	var sel_from = document.getElementById(from);
+	to_el = document.getElementById(to);
 	for (i = 0 ; i < sel_from.length; i++){
 		if (sel_from[i].selected) {
-			var name = document.getElementById("name"+to);
-			var id = document.getElementById("id"+to);
-			name.innerHTML = sel_from.options[i].text;
-			id.value  = sel_from[i].value;
-			show_button("id"+to);
-			break;
+			var div_el = document.createElement('DIV');
+			el_name = document.createElement('LABEL');
+			el_name.innerHTML = sel_from.options[i].text;
+			el_name.id = sel_from[i].value;
+			document.getElementById('idgroup').value += ","+sel_from[i].value;
+			el_name.style.fontWeight = "bold";
+			el_name.innerHTML += '<button valign="top" type="button" onClick="javascript:remove('+sel_from[i].value+');"><img src="{template_set}/images/delete.png" style="vertical-align: middle;"></button>';
+			div_el.appendChild(el_name);
+			to_el.appendChild(div_el);
 		}
+	}
+}
+function verifyCatOwners(field){
+	var sel_ = document.getElementById(field);
+	var groups = document.getElementById('idgroup').value;
+	if (groups.indexOf(',') == 0)
+		document.getElementById('idgroup').value = groups.substr(1,groups.length);
+	if (document.getElementById('idgroup').value.indexOf(',') != -1)
+	{
+		var add_mult = confirm("{lang_add_multiple_categories}");
+		if (!add_mult)
+			return false;
 	}
 }
