Index: /extensions/Piwecard/admin/admin_configuration.php
===================================================================
--- /extensions/Piwecard/admin/admin_configuration.php	(revision 20201)
+++ /extensions/Piwecard/admin/admin_configuration.php	(revision 20202)
@@ -33,5 +33,11 @@
     $configuration['sender_copy'] = ((isset($_POST['ecard_sender_copy']) && $_POST['ecard_sender_copy'] == '1') ? true : false);
 	$configuration['image_size'] = $_POST['ecard_image_size'];
-    $configuration['sender_email_change'] = ((isset($_POST['ecard_sender_email_change']) && $_POST['ecard_sender_email_change'] == '1') ? true : false);
+    
+	$configuration['image_border']['display'] = ((isset($_POST['ecard_image_border']) && $_POST['ecard_image_border'] == '1') ? true : false);
+	$configuration['image_border']['style'] = $_POST['ecard_image_border_style'];
+	$configuration['image_border']['width'] = ((isset($_POST['ecard_image_border_width']) && $_POST['ecard_image_border_width'] != '1') ? $_POST['ecard_image_border_width'] : $piwecard->get_default_config_param('ecard_image_border_width'));
+	$configuration['image_border']['color'] = ((isset($_POST['ecard_image_border_color']) && $_POST['ecard_image_border_color'] != '1') ? $_POST['ecard_image_border_color'] : $piwecard->get_default_config_param('ecard_image_border_color'));
+	
+	$configuration['sender_email_change'] = ((isset($_POST['ecard_sender_email_change']) && $_POST['ecard_sender_email_change'] == '1') ? true : false);
 	
 	$ecard_email_format_array = array();
@@ -87,9 +93,8 @@
 
 if (isset($_POST['reset'])) {
-	require(PIWECARD_INSTALL_PATH.'default_values.inc.php');
-	
-	$piwecard->config['email_subject'] = $ecard_default_values['email_subject'];
-	$piwecard->config['email_message']['text'] = $ecard_default_values['email_message']['text'];
-	$piwecard->config['email_message']['html'] = $ecard_default_values['email_message']['html'];
+	$piwecard->config['email_subject'] = $piwecard->get_default_config_param('email_subject');
+	$email_message = $piwecard->get_default_config_param('email_message');
+	$piwecard->config['email_message']['text'] = $email_message['text'];
+	$piwecard->config['email_message']['html'] = $email_message['html'];
 	
 	$piwecard->set_config();
@@ -126,4 +131,15 @@
 $template->assign('generate_derivatives_types', $derivative_map);
 
+$template->assign('ecard_image_border', (($piwecard->config['image_border']['display']) ? 'checked="checked"' : ''));
+$template->assign('ecard_image_border_style', array(
+													'solid' => (($piwecard->config['image_border']['style'] == 'solid') ? 'checked="checked"' : ''),
+													'dashed' => (($piwecard->config['image_border']['style'] == 'dashed') ? 'checked="checked"' : ''),
+													'dotted' => (($piwecard->config['image_border']['style'] == 'dotted') ? 'checked="checked"' : ''),
+													'double' => (($piwecard->config['image_border']['style'] == 'double') ? 'checked="checked"' : ''),
+												)
+);
+$template->assign('ecard_image_border_width', $piwecard->config['image_border']['width']);
+$template->assign('ecard_image_border_color', $piwecard->config['image_border']['color']);
+
 $template->assign('ecard_sender_copy', $piwecard->config['sender_copy'] ? 'checked="checked"' : '');
 $template->assign('ecard_sender_email_change', $piwecard->config['sender_email_change'] ? 'checked="checked"' : '');
Index: /extensions/Piwecard/admin/admin_management.php
===================================================================
--- /extensions/Piwecard/admin/admin_management.php	(revision 20201)
+++ /extensions/Piwecard/admin/admin_management.php	(revision 20202)
@@ -6,5 +6,5 @@
 $piwecard = get_plugin_data($plugin_id);
 
-$query = 'SELECT * FROM '.PIWECARD_TABLE;
+$query = 'SELECT DISTINCT ecard_id, sender_name, sender_email, title, message, image, date_creation, date_validity FROM '.PIWECARD_TABLE;
 	
 if (isset($_POST['ecard_form_filter_submit'])) {
@@ -84,5 +84,5 @@
 
 $start =  (isset($_GET['start']) ? $_GET['start'] : 0);
-if ($start != 0 and $piwecard->get_nb_ecard() == $piwecard->config['nb_ecard_page'])
+if ($start != 0 and $piwecard->get_nb_ecard() <= $piwecard->config['nb_ecard_page'])
 	$start = 0;
 
@@ -101,17 +101,29 @@
 
 while($file = pwg_db_fetch_assoc($result)) {
-	$ecard_url = embellish_url(get_absolute_root_url() . './index.php?/ecard/'.$file['id']);
+	//Recipients
+	$recipients = array();
+	$query2 = 'SELECT recipient_name, recipient_email FROM piwigo_piwecard WHERE ecard_id="'.$file['ecard_id'].'";';
+	$result2 = pwg_query($query2);
+	
+	while($row = pwg_db_fetch_assoc($result2)) {
+		array_push($recipients, array(
+									'name' => $row['recipient_name'],
+									'email' => $row['recipient_email'],
+								)
+		);
+	}
+	
+	$ecard_url = embellish_url(get_absolute_root_url() . './index.php?/ecard/'.$file['ecard_id']);
 
 	// Check if the ecard is valid 
-	$valid = $piwecard->is_valid($file['id']);
+	$valid = $piwecard->is_valid($file['ecard_id']);
 
 	$template->append('ecard_file',array(
-									'id'				=> $file['id'],
+									'id'				=> $file['ecard_id'],
 									'title'				=> $file['title'],
 									'url' 				=> $ecard_url,
 									'sender_name'  		=> $file['sender_name'],
 									'sender_email'		=> $file['sender_email'],
-									'recipient_name'	=> $file['recipient_name'],
-									'recipient_email'	=> $file['recipient_email'],
+									'recipients'		=> $recipients,
 									'date_creation' 	=> strftime('%d/%m/%y %H:%M', strtotime($file['date_creation'])),
 									'date_validity'		=> (isset($file['date_validity'])) ? strftime('%d/%m/%y %H:%M', strtotime($file['date_validity'])) : l10n('piwecard_nolimit'),
Index: /extensions/Piwecard/admin/template/admin_configuration.tpl
===================================================================
--- /extensions/Piwecard/admin/template/admin_configuration.tpl	(revision 20201)
+++ /extensions/Piwecard/admin/template/admin_configuration.tpl	(revision 20202)
@@ -3,4 +3,6 @@
 {combine_script id='jquery.tokeninput' load='async' require='jquery' path='themes/default/js/plugins/jquery.tokeninput.js'}
 {combine_script id='piwecard' load="footer" path='plugins/Piwecard/js/piwecard.js'}
+{combine_script id='colorpicker' load="footer" path='plugins/Piwecard/js/colorpicker/js/colorpicker.js'}
+{combine_css path="plugins/Piwecard/js/colorpicker/css/colorpicker.css"}
 
 {footer_script require="piwecard"}
@@ -31,4 +33,34 @@
 			$("#ecard_email_format_default_text").prop('checked', true);
 		}
+	});
+	
+	if ($("#ecard_image_border").prop('checked') == true) {
+		$("#ecard_image_border_options").css("display","block");
+	} else {
+		$("#ecard_image_border_options").css("display","none");
+	}
+
+	$("#ecard_image_border").change(function(){
+		if ($("#ecard_image_border").prop('checked') == true) {
+			$("#ecard_image_border_options").show("fast");
+		} else {
+			$("#ecard_image_border_options").hide("fast");
+		}
+	});
+	
+	$('#ecard_image_border_color').ColorPicker({
+		onSubmit: function(hsb, hex, rgb, element) {
+			$(element).val(hex);
+			$(element).ColorPickerHide();
+		},
+		onBeforeShow: function () {
+			$(this).ColorPickerSetColor(this.value);
+		},
+		onChange: function (hsb, hex, rgb) {
+			$('#ecard_image_border_color').val(hex);
+		}
+	})
+	.bind('keyup', function(){
+		$(this).ColorPickerSetColor(this.value);
 	});
 });
@@ -110,4 +142,29 @@
 				{/foreach}
 			</div>
+			<div class="ecard_form_line">
+				<div>
+					<input type="checkbox" name="ecard_image_border" id="ecard_image_border" {$ecard_image_border} value="1" />
+					<label for="ecard_image_border"> {'piwecard_image_border'|@translate}</label>
+				</div>
+				<div id="ecard_image_border_options">
+					<span>
+						<label for="ecard_image_border_style">{'piwecard_image_border_style'|@translate}</label>
+						<select name="ecard_image_border_style" id="ecard_image_border_style">
+							<option value="solid" {$ecard_image_border_style.solid}>{'piwecard_image_border_solid'|@translate}</option>
+							<option value="dashed" {$ecard_image_border_style.dashed}>{'piwecard_image_border_dashed'|@translate}</option>
+							<option value="dotted" {$ecard_image_border_style.dotted}>{'piwecard_image_border_dotted'|@translate}</option>
+							<option value="double"{$ecard_image_border_style.double}>{'piwecard_image_border_double'|@translate}</option>
+						</select>
+					</span>
+					<span>
+						<label for="ecard_image_border_width">{'piwecard_image_border_width'|@translate}</label>
+						<input type="text" size="6" maxlength="20" name="ecard_image_border_width" id="ecard_image_border_width" value="{$ecard_image_border_width}" />
+					</span>
+					<span>
+						<label for="ecard_image_border_color">{'piwecard_image_border_color'|@translate}</label>
+						<input type="text" maxlength="6" size="6" name="ecard_image_border_color" id="ecard_image_border_color" value="{$ecard_image_border_color}" />
+					</span>
+				</div>
+			</div>
 		</fieldset>
 
Index: /extensions/Piwecard/admin/template/admin_management.tpl
===================================================================
--- /extensions/Piwecard/admin/template/admin_management.tpl	(revision 20201)
+++ /extensions/Piwecard/admin/template/admin_management.tpl	(revision 20202)
@@ -103,5 +103,5 @@
 							</td>
 							<td>
-								<a href="{$ecard_file.url}">{$ecard_file.title}</a>
+								<a href="{$ecard_file.url}" target="_blank">{$ecard_file.title}</a>
 							</td>
 							<td>
@@ -109,5 +109,7 @@
 							</td>
 							<td>
-								{$ecard_file.recipient_name} ({$ecard_file.recipient_email}) 
+								{foreach from=$ecard_file.recipients item=recipient}
+									{$recipient.name} ({$recipient.email})<br />
+								{/foreach}
 							</td>
 							<td>
@@ -123,4 +125,5 @@
 				</tbody>
 			</table>
+			{if !empty($navbar)}{include file='navigation_bar.tpl'|@get_extent:'navbar'}{/if}
 			<fieldset>
 				<legend>{'piwecard_delete_selected'|@translate}</legend>
@@ -144,3 +147,2 @@
 	{/if}
 </div>
-{if !empty($navbar)}{include file='navigation_bar.tpl'|@get_extent:'navbar'}{/if}
Index: /extensions/Piwecard/include/piwecard.class.php
===================================================================
--- /extensions/Piwecard/include/piwecard.class.php	(revision 20201)
+++ /extensions/Piwecard/include/piwecard.class.php	(revision 20202)
@@ -34,4 +34,10 @@
 	}
 
+	//Get the default value of a parameter
+	function get_default_config_param($param) {
+	    require(PIWECARD_INSTALL_PATH.'default_values.inc.php');
+		return $ecard_default_values[$param];
+	}
+	
 	// Save  general configuration to config_database
 	function set_config() {
@@ -80,5 +86,5 @@
 	// Get the number of ecard in the database
 	function get_nb_ecard() {
-		$query = 'SELECT COUNT(DISTINCT id) AS nb FROM '.PIWECARD_TABLE.' ORDER BY date_creation;';
+		$query = 'SELECT COUNT(DISTINCT ecard_id) AS nb FROM '.PIWECARD_TABLE.' ORDER BY date_creation;';
 		$result = pwg_query($query);
 		
@@ -92,5 +98,5 @@
 	// Get the number of valid ecard in the database
 	function get_nb_valid_ecard() {
-		$query = 'SELECT COUNT(DISTINCT id) AS nb FROM '.PIWECARD_TABLE.' WHERE date_validity IS NULL OR date_validity > NOW();';
+		$query = 'SELECT COUNT(DISTINCT ecard_id) AS nb FROM '.PIWECARD_TABLE.' WHERE date_validity IS NULL OR date_validity > NOW();';
 		$result = pwg_query($query);
 		
@@ -106,5 +112,5 @@
 	function get_ecard($ecard_id = null) {
 		if ($ecard_id!== null) {
-			$query = 'SELECT * FROM ' . PIWECARD_TABLE .' WHERE id ="' . $ecard_id . '" LIMIT 1;';
+			$query = 'SELECT * FROM ' . PIWECARD_TABLE .' WHERE ecard_id="' . $ecard_id . '" LIMIT 1;';
 
 			$result = pwg_query($query);
@@ -144,5 +150,5 @@
 	function delete_ecard($ecard_id = null) {
 		if (isset($ecard_id)) {
-			$query = 'DELETE FROM ' . PIWECARD_TABLE .' WHERE id="' . $ecard_id  . '";';
+			$query = 'DELETE FROM ' . PIWECARD_TABLE .' WHERE ecard_id="' . $ecard_id  . '";';
 			pwg_query($query);
 		} else
@@ -294,13 +300,4 @@
 							return;
 						
-						foreach ($_POST['ecard_recipient_name'] as $recipient)
-							if ($recipient == '')
-								return;
-						
-						foreach ($_POST['ecard_recipient_email'] as $recipient)
-						if ($recipient == '' OR !$this->is_valid_email($recipient)) {
-							return;
-						}
-						
 						// Initialize the array for image element
 						$image_element = array();
@@ -314,5 +311,5 @@
 						// Generate random number
 						$next_element_id_random  = $this->random(64);
-						while (pwg_db_num_rows(pwg_query('SELECT id FROM '.PIWECARD_TABLE.' WHERE id="'.$next_element_id_random.'";')) != 0) {
+						while (pwg_db_num_rows(pwg_query('SELECT ecard_id FROM '.PIWECARD_TABLE.' WHERE ecard_id="'.$next_element_id_random.'";')) != 0) {
 							$next_element_id_random  = $this->random(64);
 						}
@@ -348,4 +345,7 @@
 						$recipient_infos = array_combine($_POST['ecard_recipient_name'], $_POST['ecard_recipient_email']);
 						foreach ($recipient_infos as $recipient_name => $recipient_email) {
+							if ($recipient_name == '' OR $recipient_email == '' OR !$this->is_valid_email($recipient_email))
+								continue;
+						
 							$parse_list = array(
 												'ecard_sender_name' => $_POST['ecard_sender_name'],
@@ -357,25 +357,23 @@
 							);
 						
-							$email_subject = htmlspecialchars_decode($this->parse($this->config['email_subject'], $parse_list, $image_element));
-							$email_message = htmlspecialchars_decode($this->parse($this->config['email_message'][$email_format], $parse_list, $image_element));
-							$email_arg=array(	'from' 				=> $_POST['ecard_sender_email'],
-												'subject'	 		=> $email_subject,
-											);
+							$email_infos = array(
+												'from_name' => $_POST['ecard_sender_name'],
+												'from_email' => (isset($_POST['ecard_sender_email']) ? $_POST['ecard_sender_email'] : $user['email']),
+												'to' => $recipient_email,
+												'subject' => htmlspecialchars_decode($this->parse($this->config['email_subject'], $parse_list, $image_element)),
+							);
 							
+							$email_message_text = stripslashes(strip_tags($this->parse($this->config['email_message']['text'], $parse_list, $image_element)));
+							$email_message_html = stripslashes($this->parse($this->config['email_message']['html'], $parse_list, $image_element));
 							switch($email_format) {
 								case 'text': // text
-									$email_arg = array_merge($email_arg, array(
-																				'content' 			=> $email_message,
-																				'content_format' 	=> "text/html",
-																				'email_format' 		=> "text/plain"
-																			)
+									$email_infos['message'] = array(
+																	'text' => $email_message_text
 									);
 									break;
 								case 'html': // html
-									$email_arg = array_merge($email_arg, array(
-																				'content' 			=> '<html><head><title>'.$email_subject.'</title></head><body>'.$email_message.'</body></html>',
-																				'content_format' 	=> "text/html",
-																				'email_format' 		=> array("text/plain", "text/html"),
-																			)
+									$email_infos['message'] = array(
+																	'text' => $email_message_text,
+																	'html' => $email_message_html,
 									);
 								default:
@@ -383,12 +381,13 @@
 							}
 							
+							$this->mail($email_infos);
+							
 							// Add the copy to expe if param.
 							if (isset($_POST['ecard_copy']))	// send copy to sender
-								$email_arg['Bcc'] = array((isset($_POST['ecard_sender_email']) ? $_POST['ecard_sender_email'] : $user['email']));
-							
-							pwg_mail($recipient_email, $email_arg);
-							
+								$email_infos['bcc'] = $email_infos['from_email'];
+
+							//Insert into database
 							$insert = array(
-										'id' 				=> $image_element['next_element_id'],
+										'ecard_id'			=> $image_element['next_element_id'],
 										'sender_name' 		=> $_POST['ecard_sender_name'],
 										'recipient_name' 	=> $recipient_name,
@@ -412,4 +411,43 @@
 		}
 	}
+	
+	//Send an email
+	function mail($email_infos) {
+		$from = $email_infos['from_name']." <".$email_infos['from_email'].">";
+		$subject = encode_mime_header(trim(preg_replace('#[\n\r]+#s', '', $email_infos['subject'])));
+		$boundary = '_----------='.md5(uniqid(mt_rand()));
+
+		$headers  = 'From: '.$from."\n";
+		$headers .= 'Reply-To: '.$from."\n";
+		if (!empty($email_infos['bcc']))
+			$headers .= 'Bcc: '.$email_infos['bcc']."\n";
+		$headers .= 'X-Sender: <'.get_absolute_root_url().'>'."\n";
+		$headers .= 'X-Mailer: Piwigo Mailer'."\n";
+		$headers .= 'X-auth-smtp-user: '.$from."\n";
+		$headers .= 'X-abuse-contact: '.$from."\n";
+		$headers .= 'Date: '.date("D, j M Y G:i:s O")."\n";
+
+		$message = '';
+		
+		if (empty($email_infos['message']['html'])) {		//Text plain email
+			$headers .= 'Content-Transfer-Encoding: 8bit'."\n";
+			$message .= $email_infos['message']['text'];
+		} else {
+			$headers .= 'MIME-Version: 1.0'."\n";
+			$headers .= 'Content-Type: multipart/alternative; boundary="'.$boundary.'"';
+			$message  .= 'This is a multi-part message in MIME format'."\n\n";
+			$message .= '--'.$boundary."\n";
+			$message .= 'Content-Type: text/plain; charset="'.get_pwg_charset().'"'."\n";
+			$message .= 'Content-Transfer-Encoding: binary'."\n\n";
+			$message .= $email_infos['message']['text']."\n\n";
+			$message .= '--'.$boundary."\n";
+			$message .= 'Content-Type: text/html; charset="'.get_pwg_charset().'"'."\n";
+			$message .= 'Content-Transfer-Encoding: binary;'."\n\n";
+			$message .= $email_infos['message']['html']."\n\n";
+			$message .= '--'.$boundary."--\n";
+		}
+		
+		mail($email_infos['to'], $subject, $message, $headers);
+	}
 }
 ?>
Index: /extensions/Piwecard/include/publish.inc.php
===================================================================
--- /extensions/Piwecard/include/publish.inc.php	(revision 20201)
+++ /extensions/Piwecard/include/publish.inc.php	(revision 20202)
@@ -10,9 +10,9 @@
 
 if (isset($ecard_id) and $ecard_id != '' and $piwecard->is_valid($ecard_id)) {
-	$query = 'SELECT * FROM '.PIWECARD_TABLE.' WHERE id = "'.$ecard_id.'";';
+	$query = 'SELECT * FROM '.PIWECARD_TABLE.' WHERE ecard_id="'.$ecard_id.'";';
 	$result = pwg_query($query);
 	$result_array = pwg_db_fetch_assoc($result);
 
-	if (isset($result_array['id'])) {
+	if (isset($result_array['ecard_id'])) {
 		//Recover img infos.
 		$query = 'SELECT DISTINCT * FROM '.IMAGES_TABLE.' AS img WHERE img.id = '.$result_array['image'].';';
@@ -41,5 +41,12 @@
 				'image_title'	=> (($piwecard->config['show_image_infos'] == '1') ? $row['name'] : null),
 				'image_author' 	=> (($piwecard->config['show_image_infos'] == '1') ? $row['author'] : null),
-				));
+				'image_border' 	=> array(
+										'display' => $piwecard->config['image_border']['display'],
+										'style' => $piwecard->config['image_border']['style'],
+										'width' => $piwecard->config['image_border']['width'],
+										'color' => $piwecard->config['image_border']['color'],
+				),
+			)
+		);
 		
 	}
Index: /extensions/Piwecard/install/default_values.inc.php
===================================================================
--- /extensions/Piwecard/install/default_values.inc.php	(revision 20201)
+++ /extensions/Piwecard/install/default_values.inc.php	(revision 20202)
@@ -12,4 +12,10 @@
 $ecard_default_values['validity_default'] = '10'; 					//Default number of days a card is available
 $ecard_default_values['validity_choice'] = true;					//Add function for a user to choose the valid duration of an ecard
+$ecard_default_values['image_border'] = array(						//Add a border to the image in the ecard page
+							'display' 	=> false,
+							'style'		=> 'solid',
+							'width'		=> '10px',
+							'color'		=> '#FFFFFF',
+);
 $ecard_default_values['sender_copy'] = false;						//Send a copy to sender
 $ecard_default_values['image_size'] = 'small';						//Size of the image in the ecard
Index: /extensions/Piwecard/install/functions.inc.php
===================================================================
--- /extensions/Piwecard/install/functions.inc.php	(revision 20201)
+++ /extensions/Piwecard/install/functions.inc.php	(revision 20202)
@@ -2,5 +2,6 @@
 function piwecard_db_create($table) {
 	$query = 'CREATE TABLE ' . $table . ' (
-						id CHAR(64) NOT NULL,
+						unique_id INT NOT NULL AUTO_INCREMENT,
+						ecard_id CHAR(64) NOT NULL,
 						sender_name CHAR(100) NOT NULL,
 						sender_email CHAR(100) NOT NULL,
@@ -12,5 +13,5 @@
 						date_creation DATETIME NOT NULL,
 						date_validity DATETIME DEFAULT NULL,
-						PRIMARY KEY (id)
+						PRIMARY KEY (unique_id)
 					) DEFAULT CHARSET=utf8;';
 	pwg_query($query);
@@ -22,5 +23,5 @@
 }
 
-function piwecard_db_populate($old_table, $new_table) {
+function piwecard_db_update_from_2_3($old_table, $new_table) {
 	$query = 'SELECT * FROM '.$old_table.';';
 	$result = pwg_query($query);
@@ -28,5 +29,5 @@
 	while($data = pwg_db_fetch_assoc($result)) {
 		$insert = array(
-					'id' => $data['numero'],
+					'ecard_id' => $data['numero'],
 					'sender_name' => $data['nomexp'],
 					'sender_email' => $data['adrexp'],
@@ -48,4 +49,13 @@
 }
 
+function piwecard_db_update_from_2_4a_b3($table) {
+	$query = 'ALTER TABLE '.$table.' DROP PRIMARY KEY;';
+	$result = pwg_query($query);
+	$query = 'ALTER TABLE '.$table.' ADD unique_id INT NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (unique_id);';
+	$result = pwg_query($query);
+	$query = 'ALTER TABLE '.$table.' CHANGE id ecard_id CHAR(64) NOT NULL;';
+	$result = pwg_query($query);
+}
+
 function piwecard_conf_create($name) {
 	$query = 'INSERT INTO '.CONFIG_TABLE.' (param,value,comment) VALUES ("'.$name.'","","'.ucfirst($name).' configuration");';
Index: /extensions/Piwecard/js/piwecard.js
===================================================================
--- /extensions/Piwecard/js/piwecard.js	(revision 20201)
+++ /extensions/Piwecard/js/piwecard.js	(revision 20202)
@@ -11,5 +11,5 @@
 		switch (elementType) {
 			case TEXT:
-				if (element.value == '' || (element.value == element.title || element.className == "DefaultText")) {
+				if (element.value == '' || element.className.indexOf("ecard_defaultTextActive") > 0) {
 					document.getElementById(element.id+'_error').style.display = 'block';
 					element.className += " ecard_error_input";
Index: /extensions/Piwecard/language/en_UK/plugin.lang.php
===================================================================
--- /extensions/Piwecard/language/en_UK/plugin.lang.php	(revision 20201)
+++ /extensions/Piwecard/language/en_UK/plugin.lang.php	(revision 20202)
@@ -56,4 +56,12 @@
 $lang['piwecard_ecard_image_infos'] 			= 'Image info (title and author)';
 $lang['piwicard_email_reset']					= 'Reset * fields with default values in your language';
+$lang['piwecard_image_border']					= 'Add a border to the e-card image:';
+$lang['piwecard_image_border_style']			= 'Style:';
+$lang['piwecard_image_border_solid']			= 'Solid';
+$lang['piwecard_image_border_dashed']			= 'Dashed';
+$lang['piwecard_image_border_dotted']			= 'Dotted';
+$lang['piwecard_image_border_double']			= 'Double';
+$lang['piwecard_image_border_width']			= 'Width:';
+$lang['piwecard_image_border_color']			= 'Color:';
 
 //admin_management.tpl
Index: /extensions/Piwecard/language/fr_FR/plugin.lang.php
===================================================================
--- /extensions/Piwecard/language/fr_FR/plugin.lang.php	(revision 20201)
+++ /extensions/Piwecard/language/fr_FR/plugin.lang.php	(revision 20202)
@@ -56,4 +56,12 @@
 $lang['piwecard_ecard_image_infos'] = 'Informations de l\'image (titre et auteur)';
 $lang['piwicard_email_reset'] = 'RAZ champs * avec les valeurs par défaut dans votre langue';
+$lang['piwecard_image_border'] = 'Ajoute une bordure à l\'image dans l\'ecard';
+$lang['piwecard_image_border_style'] = 'Style :';
+$lang['piwecard_image_border_solid'] = 'Continue';
+$lang['piwecard_image_border_dashed'] = 'Tirets';
+$lang['piwecard_image_border_dotted'] = 'Pointillés';
+$lang['piwecard_image_border_double'] = 'Double';
+$lang['piwecard_image_border_width'] = 'Largeur :';
+$lang['piwecard_image_border_color'] = 'Couleur :';
 
 //admin_management.tpl
Index: /extensions/Piwecard/maintain.inc.php
===================================================================
--- /extensions/Piwecard/maintain.inc.php	(revision 20201)
+++ /extensions/Piwecard/maintain.inc.php	(revision 20202)
@@ -27,9 +27,15 @@
 		if (pwg_db_num_rows($result_piwecard) == 0){
 			piwecard_db_create($prefixeTable.'piwecard');
-			piwecard_db_populate($prefixeTable.'ecard', $prefixeTable.'piwecard');
+			piwecard_db_update_from_2_3($prefixeTable.'ecard', $prefixeTable.'piwecard');
 		}
 		piwecard_db_delete($prefixeTable.'ecard');
 		
 		piwecard_conf_rename('ecard', 'piwecard');
+	}
+	
+	$query_unique_id = 'SHOW COLUMNS FROM '.$prefixeTable.'piwecard LIKE "unique_id"';
+	$result_unique_id = pwg_query($query_unique_id);
+	if(pwg_db_num_rows($result_unique_id) == 0) {
+		piwecard_db_update_from_2_4a_b3($prefixeTable.'piwecard');
 	}
 }
Index: /extensions/Piwecard/template/ecard.tpl
===================================================================
--- /extensions/Piwecard/template/ecard.tpl	(revision 20201)
+++ /extensions/Piwecard/template/ecard.tpl	(revision 20202)
@@ -3,6 +3,6 @@
 
 {footer_script require="piwecard"}{literal}
-jQuery(document).ready(function(){
-	jQuery(".createECardOpen").colorbox({
+jQuery(document).ready(function(){	
+	jQuery("#createECardOpen").colorbox({
 		inline:true,
 		href:"#addECardForm",
@@ -11,4 +11,5 @@
 		height:"90%",
 		onComplete:function(){
+			$("#cboxLoadedContent").css('background-color', $("#the_page #content").css('background-color'));
 			$(".ecard_defaultText").blur();
 		}
@@ -79,13 +80,15 @@
 	var allRecipientEmailsOK = false;
 	
-	recipientNameOK[0] = piwecard_checkField(form.ecard_recipient_name_0, 0);
-	recipientEMailOK[0] = piwecard_checkField(form.ecard_recipient_email_0, 1);
-	
-	while(document.getElementById("ecard_recipient_email_" + (nbAdditionalRecipients++))) {
+	while(document.getElementById("ecard_recipient_email_" + nbAdditionalRecipients)) {
 		var id_name = "ecard_recipient_name_"+nbAdditionalRecipients;
 		var id_email = "ecard_recipient_email_"+nbAdditionalRecipients;
 		recipientEMailOK[nbAdditionalRecipients] = piwecard_checkField(document.getElementById(id_email), 1, true);
-		if (recipientEMailOK[nbAdditionalRecipients] && document.getElementById(id_email).value != '')
+		if (nbAdditionalRecipients == 0) {
+			recipientNameOK[0] = piwecard_checkField(form.ecard_recipient_name_0, 0);
+			recipientEMailOK[0] = piwecard_checkField(form.ecard_recipient_email_0, 1);
+		} else if (recipientEMailOK[nbAdditionalRecipients] && document.getElementById(id_email).value != '') {
 			recipientNameOK[nbAdditionalRecipients] = piwecard_checkField(document.getElementById(id_name), 0, true);
+		}
+		nbAdditionalRecipients++;
 	}
 	
@@ -184,4 +187,4 @@
 </div>
 <p>
-	<a href="#" class="createECardOpen" title="{'piwecard_send_link'|@translate}">{'piwecard_send_link'|@translate}</a>
+	<a href="#" class="createECardOpen" id="createECardOpen" title="{'piwecard_send_link'|@translate}">{'piwecard_send_link'|@translate}</a>
 </p><p>
Index: /extensions/Piwecard/template/publish.tpl
===================================================================
--- /extensions/Piwecard/template/publish.tpl	(revision 20201)
+++ /extensions/Piwecard/template/publish.tpl	(revision 20202)
@@ -1,2 +1,14 @@
+{html_head}
+{if $ecard.image_border.display}
+	<style type="text/css">
+		#ecard_image {ldelim}
+			border-style: {$ecard.image_border.style} !important;
+			border-width: {$ecard.image_border.width} !important;
+			border-color: #{$ecard.image_border.color} !important;
+		{rdelim}
+	</style>
+{/if}
+{/html_head}
+
 <div id="ecard">
 	{if !isset($ecard)}
@@ -7,5 +19,5 @@
 			<div class="ecard_center">
 				<a href="{$ecard.url}" alt="{$ecard.url}"> 
-					<img class="theImage" src="{$ecard.image}" alt="{$ecard.name}" title="{$ecard.name}"/> 
+					<img class="theImage" id="ecard_image" src="{$ecard.image}" alt="{$ecard.name}" title="{$ecard.name}"/> 
 				</a>
 
