Index: /extensions/SmiliesSupport/admin.php
===================================================================
--- /extensions/SmiliesSupport/admin.php	(revision 9965)
+++ /extensions/SmiliesSupport/admin.php	(revision 9966)
@@ -10,8 +10,10 @@
 {
 	// the smilies.txt file is not saved if the directory is changed
-	if (isset($_POST['text1']) AND $_POST['text1'] != $conf_smiliessupport[0]) {
+	if (isset($_POST['text1']) AND $_POST['text1'] != $conf_smiliessupport[0]) 
+	{
 		$not_save_file = true;
 	}
 	
+	// new configuration
 	$conf_smiliessupport = array(
 		isset($_POST['text1']) ? $_POST['text1'] : 'plugins/SmiliesSupport/smilies_1',
@@ -19,14 +21,15 @@
 		isset($_POST['text3']) ? $_POST['text3'] : 'smile.png',
 	);
-	
 	if (empty($_POST['text'])) $_POST['text'] = ':)		smile.png';
 		
-    $new_value_smiliessupport = implode (",", $conf_smiliessupport);
-    $query = 'UPDATE ' . CONFIG_TABLE . '
-		SET value="' . $new_value_smiliessupport . '"
-		WHERE param="smiliessupport"';
+    $new_value_smiliessupport = implode(",", $conf_smiliessupport);
+    $query = "UPDATE " . CONFIG_TABLE . "
+		SET value='" . $new_value_smiliessupport . "'
+		WHERE param='smiliessupport'";
     pwg_query($query);
-    
-	if (!isset($not_save_file)) {
+	
+	// new definitions file
+	if (!isset($not_save_file)) 
+	{
 		$smilies_file = PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/smilies.txt';	    
 
@@ -38,7 +41,12 @@
 			$page['infos'][] = l10n('Information data registered in database');
 		} else {
-			$page['errors'][] = l10n('File/directory read error').' &nbsp; '.$smilies_file;
+			$page['errors'][] = l10n('File/directory read error').' : '.$smilies_file;
 		}
 	}
+}
+
+// check if the representant exists
+if (!file_exists(PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/'.$conf_smiliessupport[2])) {
+	$page['errors'][] = l10n('File/directory read error').' : '.$conf_smiliessupport[0].'/'.$conf_smiliessupport[2];
 }
 
@@ -49,9 +57,10 @@
 ));
 
+// build the table of smilies
 include_once(SMILIES_PATH . '/smiliessupport.inc.php');
-$template->assign('SMILIESSUPPORT_PAGE', SmiliesTable($conf_smiliessupport));
+$template->assign('smiliesfiles', get_smilies($conf_smiliessupport));
 
+// get the content of definitions file
 $smilies_file = PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/smilies.txt';
-
 if (file_exists($smilies_file)) {
 	$content_file = file_get_contents($smilies_file);
Index: /extensions/SmiliesSupport/main.inc.php
===================================================================
--- /extensions/SmiliesSupport/main.inc.php	(revision 9965)
+++ /extensions/SmiliesSupport/main.inc.php	(revision 9966)
@@ -19,7 +19,10 @@
 
 function add_smiliessupport() {
-	global $page;
-	if ($page['body_id'] == 'theCommentsPage' OR $page['body_id'] == 'thePicturePage') {
-		set_smiliessupport_page();
+	global $page, $pwg_loaded_plugins;
+	
+	if (!isset($pwg_loaded_plugins['bbcode_bar']) 
+		AND isset($page['body_id']) AND $page['body_id'] == 'thePicturePage')
+	{
+		set_smiliessupport();
 	}
 }
Index: /extensions/SmiliesSupport/smiliessupport.inc.php
===================================================================
--- /extensions/SmiliesSupport/smiliessupport.inc.php	(revision 9965)
+++ /extensions/SmiliesSupport/smiliessupport.inc.php	(revision 9966)
@@ -2,65 +2,69 @@
 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
 
-function set_smiliessupport_page()
+// add smilies button to the comment field
+function set_smiliessupport()
 {
-	global $template, $lang, $pwg_loaded_plugins;
+	global $conf, $lang;
+	$conf_smiliessupport = explode(',' , $conf['smiliessupport']);
+	
+	$smilies = get_smilies($conf_smiliessupport);
+	$lang['Comment'] .= SmiliesTable($conf_smiliessupport, $smilies);	
+}
 
-	if (!isset($pwg_loaded_plugins['bbcode_bar'])) {
-		$lang['Comment'] .= SmiliesTable();
+// return an array with available smilies (name and path) ## must received the unserialized configuration array
+function get_smilies($conf_smiliessupport)
+{
+	$accepted_ext = array('gif', 'jpg', 'png');
+	
+	if ($handle = opendir(PHPWG_ROOT_PATH.$conf_smiliessupport[0]))
+	{
+		$i = 1;
+		while (false !== ($file = readdir($handle)))
+		{
+			if ($file != '.' AND $file != '..' AND in_array(get_extension($file), $accepted_ext))
+			{
+				$smilies[] = array(
+					'PATH' => PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/'.$file,
+					'TITLE' => ':'.get_filename_wo_extension($file).':',
+					'TR' => ($i>0 AND $i%$conf_smiliessupport[1] == 0) ? '</tr><tr>' : null,
+				);
+				$i++;
+			}
+		}
+		
+		return $smilies;
+	} else {
+		return false;
 	}
 }
 
-function SmiliesTable($new_conf=null)
+// get the smilies button ## must received the unserialized configuration array AND the smilies array
+function SmiliesTable($conf_smiliessupport, $smilies)
 {
-	global $conf, $template, $page;
+	global $template;
+	load_language('plugin.lang', SMILIES_PATH);
 
-	// this is for live update on admin page
-	if (empty($new_conf)) {
-		$conf_smiliessupport = explode("," , $conf['smiliessupport']);
-	} else {
-		$conf_smiliessupport = $new_conf;
-	}
+	// edit field has different id
+	// if (
+		// (isset($_GET['action']) AND $_GET['action'] == 'edit_comment') 
+		// OR (isset($page['body_id']) AND $page['body_id'] == 'theCommentsPage')
+	// ) {
+		// $template->assign('form_name', 'editComment');
+	// } else {
+		// $template->assign('form_name', 'addComment');
+	// }
+	$template->assign('form_name', 'addComment');
 
-	// edit field has a different id
-	if (
-		(isset($_GET['action']) AND $_GET['action'] == 'edit_comment') 
-		OR (isset($page['body_id']) AND $page['body_id'] == 'theCommentsPage')
-	) {
-		$template->assign('form_name', 'editComment');
-	} else {
-		$template->assign('form_name', 'addComment');
-	}
-
-	$cnt = 1;
-	$template->assign('SMILIES_PATH', SMILIES_PATH);
+	$template->assign(array(
+		'SMILIES_PATH' => SMILIES_PATH,
+		'REPRESENTANT' => PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/'.$conf_smiliessupport[2],
+		'smiliesfiles' => $smilies,
+	));
+	
 	$template->set_filename('smiliessupport_page', dirname(__FILE__).'/template/smiliessupport_page.tpl');
-	$template->assign(array('REPRESENTANT' => PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/'.$conf_smiliessupport[2]));
-
-	if ($handle = opendir(PHPWG_ROOT_PATH.$conf_smiliessupport[0]))
-	{
-		while (false !== ($file = readdir($handle)))
-		{
-			$trvalue = '';
-
-			if ($file != "." && $file != ".." && ( get_extension($file) == "gif" || get_extension($file) == "png"))
-			{
-				if (( $cnt > 0 ) && ( $cnt % $conf_smiliessupport[1] == 0 )) {
-					$trvalue = '</tr><tr>';
-				}
-				$cnt = $cnt + 1;
-				$template->append('smiliesfiles',
-				array('PATH' => PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/'.$file,
-				'TITLE' => ':'.get_filename_wo_extension($file).':',
-				'TR'=>$trvalue));
-			}
-		}
-		
-	} else {
-		array_push($page['errors'], l10n('opendir failed : '.PHPWG_ROOT_PATH.$conf_smiliessupport[0].')' ));
-	}
-	
 	return $template->parse('smiliessupport_page', true);
 }
 
+// parse smilies
 function SmiliesParse($str)
 {
Index: /extensions/SmiliesSupport/template/markitup/jquery.markitup.js
===================================================================
--- /extensions/SmiliesSupport/template/markitup/jquery.markitup.js	(revision 9966)
+++ /extensions/SmiliesSupport/template/markitup/jquery.markitup.js	(revision 9966)
@@ -0,0 +1,60 @@
+// ----------------------------------------------------------------------------
+// markItUp! Universal MarkUp Engine, JQuery plugin
+// v 1.1.x
+// Dual licensed under the MIT and GPL licenses.
+// ----------------------------------------------------------------------------
+// Copyright (C) 2007-2010 Jay Salvat
+// http://markitup.jaysalvat.com/
+// ----------------------------------------------------------------------------
+(function($){$.fn.markItUp=function(settings,extraSettings){var options,ctrlKey,shiftKey,altKey;ctrlKey=shiftKey=altKey=false;options={id:'',nameSpace:'',root:'',previewInWindow:'',previewAutoRefresh:true,previewPosition:'after',previewTemplatePath:'~/templates/preview.html',previewParserPath:'',previewParserVar:'data',resizeHandle:true,beforeInsert:'',afterInsert:'',onEnter:{},onShiftEnter:{},onCtrlEnter:{},onTab:{},markupSet:[{}]};$.extend(options,settings,extraSettings);if(!options.root){$('script').each(function(a,tag){miuScript=$(tag).get(0).src.match(/(.*)jquery\.markitup(\.pack)?\.js$/);if(miuScript!==null){options.root=miuScript[1];}});}
+return this.each(function(){var $$,textarea,levels,scrollPosition,caretPosition,caretOffset,clicked,hash,header,footer,previewWindow,template,iFrame,abort;$$=$(this);textarea=this;levels=[];abort=false;scrollPosition=caretPosition=0;caretOffset=-1;options.previewParserPath=localize(options.previewParserPath);options.previewTemplatePath=localize(options.previewTemplatePath);function localize(data,inText){if(inText){return data.replace(/("|')~\//g,"$1"+options.root);}
+return data.replace(/^~\//,options.root);}
+function init(){id='';nameSpace='';if(options.id){id='id="'+options.id+'"';}else if($$.attr("id")){id='id="markItUp'+($$.attr("id").substr(0,1).toUpperCase())+($$.attr("id").substr(1))+'"';}
+if(options.nameSpace){nameSpace='class="'+options.nameSpace+'"';}
+$$.wrap('<div '+nameSpace+'></div>');$$.wrap('<div '+id+' class="markItUp"></div>');$$.wrap('<div class="markItUpContainer"></div>');$$.addClass("markItUpEditor");header=$('<div class="markItUpHeader"></div>').insertBefore($$);$(dropMenus(options.markupSet)).appendTo(header);footer=$('<div class="markItUpFooter"></div>').insertAfter($$);if(options.resizeHandle===true&&$.browser.safari!==true){resizeHandle=$('<div class="markItUpResizeHandle"></div>').insertAfter($$).bind("mousedown",function(e){var h=$$.height(),y=e.clientY,mouseMove,mouseUp;mouseMove=function(e){$$.css("height",Math.max(20,e.clientY+h-y)+"px");return false;};mouseUp=function(e){$("html").unbind("mousemove",mouseMove).unbind("mouseup",mouseUp);return false;};$("html").bind("mousemove",mouseMove).bind("mouseup",mouseUp);});footer.append(resizeHandle);}
+$$.keydown(keyPressed).keyup(keyPressed);$$.bind("insertion",function(e,settings){if(settings.target!==false){get();}
+if(textarea===$.markItUp.focused){markup(settings);}});$$.focus(function(){$.markItUp.focused=this;});}
+function dropMenus(markupSet){var ul=$('<ul></ul>'),i=0;$('li:hover > ul',ul).css('display','block');$.each(markupSet,function(){var button=this,t='',title,li,j;title=(button.key)?(button.name||'')+' [Ctrl+'+button.key+']':(button.name||'');key=(button.key)?'accesskey="'+button.key+'"':'';if(button.separator){li=$('<li class="markItUpSeparator">'+(button.separator||'')+'</li>').appendTo(ul);}else{i++;for(j=levels.length-1;j>=0;j--){t+=levels[j]+"-";}
+li=$('<li class="markItUpButton markItUpButton'+t+(i)+' '+(button.className||'')+'"><a href="" '+key+' title="'+title+'">'+(button.name||'')+'</a></li>').bind("contextmenu",function(){return false;}).click(function(){return false;}).bind("focusin",function(){$$.focus();}).mousedown(function(){if(button.call){eval(button.call)();}
+setTimeout(function(){markup(button)},1);return false;}).hover(function(){$('> ul',this).show();$(document).one('click',function(){$('ul ul',header).hide();});},function(){$('> ul',this).hide();}).appendTo(ul);if(button.dropMenu){levels.push(i);$(li).addClass('markItUpDropMenu').append(dropMenus(button.dropMenu));}}});levels.pop();return ul;}
+function magicMarkups(string){if(string){string=string.toString();string=string.replace(/\(\!\(([\s\S]*?)\)\!\)/g,function(x,a){var b=a.split('|!|');if(altKey===true){return(b[1]!==undefined)?b[1]:b[0];}else{return(b[1]===undefined)?"":b[0];}});string=string.replace(/\[\!\[([\s\S]*?)\]\!\]/g,function(x,a){var b=a.split(':!:');if(abort===true){return false;}
+value=prompt(b[0],(b[1])?b[1]:'');if(value===null){abort=true;}
+return value;});return string;}
+return"";}
+function prepare(action){if($.isFunction(action)){action=action(hash);}
+return magicMarkups(action);}
+function build(string){var openWith=prepare(clicked.openWith);var placeHolder=prepare(clicked.placeHolder);var replaceWith=prepare(clicked.replaceWith);var closeWith=prepare(clicked.closeWith);if(replaceWith!==""){block=openWith+replaceWith+closeWith;}else if(selection===''&&placeHolder!==''){block=openWith+placeHolder+closeWith;}else{string=string||selection;if(string.match(/ $/)){block=openWith+string.replace(/ $/,'')+closeWith+' ';}else{block=openWith+string+closeWith;}}
+return{block:block,openWith:openWith,replaceWith:replaceWith,placeHolder:placeHolder,closeWith:closeWith};}
+function markup(button){var len,j,n,i;hash=clicked=button;get();$.extend(hash,{line:"",root:options.root,textarea:textarea,selection:(selection||''),caretPosition:caretPosition,ctrlKey:ctrlKey,shiftKey:shiftKey,altKey:altKey});prepare(options.beforeInsert);prepare(clicked.beforeInsert);if(ctrlKey===true&&shiftKey===true){prepare(clicked.beforeMultiInsert);}
+$.extend(hash,{line:1});if(ctrlKey===true&&shiftKey===true){lines=selection.split(/\r?\n/);for(j=0,n=lines.length,i=0;i<n;i++){if($.trim(lines[i])!==''){$.extend(hash,{line:++j,selection:lines[i]});lines[i]=build(lines[i]).block;}else{lines[i]="";}}
+string={block:lines.join('\n')};start=caretPosition;len=string.block.length+(($.browser.opera)?n-1:0);}else if(ctrlKey===true){string=build(selection);start=caretPosition+string.openWith.length;len=string.block.length-string.openWith.length-string.closeWith.length;len=len-(string.block.match(/ $/)?1:0);len-=fixIeBug(string.block);}else if(shiftKey===true){string=build(selection);start=caretPosition;len=string.block.length;len-=fixIeBug(string.block);}else{string=build(selection);start=caretPosition+string.block.length;len=0;start-=fixIeBug(string.block);}
+if((selection===''&&string.replaceWith==='')){caretOffset+=fixOperaBug(string.block);start=caretPosition+string.openWith.length;len=string.block.length-string.openWith.length-string.closeWith.length;caretOffset=$$.val().substring(caretPosition,$$.val().length).length;caretOffset-=fixOperaBug($$.val().substring(0,caretPosition));}
+$.extend(hash,{caretPosition:caretPosition,scrollPosition:scrollPosition});if(string.block!==selection&&abort===false){insert(string.block);set(start,len);}else{caretOffset=-1;}
+get();$.extend(hash,{line:'',selection:selection});if(ctrlKey===true&&shiftKey===true){prepare(clicked.afterMultiInsert);}
+prepare(clicked.afterInsert);prepare(options.afterInsert);if(previewWindow&&options.previewAutoRefresh){refreshPreview();}
+shiftKey=altKey=ctrlKey=abort=false;}
+function fixOperaBug(string){if($.browser.opera){return string.length-string.replace(/\n*/g,'').length;}
+return 0;}
+function fixIeBug(string){if($.browser.msie){return string.length-string.replace(/\r/g,'').length;}
+return 0;}
+function insert(block){if(document.selection){var newSelection=document.selection.createRange();newSelection.text=block;}else{textarea.value=textarea.value.substring(0,caretPosition)+block+textarea.value.substring(caretPosition+selection.length,textarea.value.length);}}
+function set(start,len){if(textarea.createTextRange){if($.browser.opera&&$.browser.version>=9.5&&len==0){return false;}
+range=textarea.createTextRange();range.collapse(true);range.moveStart('character',start);range.moveEnd('character',len);range.select();}else if(textarea.setSelectionRange){textarea.setSelectionRange(start,start+len);}
+textarea.scrollTop=scrollPosition;textarea.focus();}
+function get(){textarea.focus();scrollPosition=textarea.scrollTop;if(document.selection){selection=document.selection;if($.browser.msie){var range=selection.createRange();var stored_range=range.duplicate();stored_range.moveToElementText(textarea);stored_range.setEndPoint('EndToEnd',range);var s=stored_range.text.length-range.text.length;caretPosition=s-(textarea.value.substr(0,s).length-textarea.value.substr(0,s).replace(/\r/g,'').length);selection=range.text;}else{caretPosition=textarea.selectionStart;}}else{caretPosition=textarea.selectionStart;selection=textarea.value.substring(caretPosition,textarea.selectionEnd);}
+return selection;}
+function preview(){if(!previewWindow||previewWindow.closed){if(options.previewInWindow){previewWindow=window.open('','preview',options.previewInWindow);$(window).unload(function(){previewWindow.close();});}else{iFrame=$('<iframe class="markItUpPreviewFrame"></iframe>');if(options.previewPosition=='after'){iFrame.insertAfter(footer);}else{iFrame.insertBefore(header);}
+previewWindow=iFrame[iFrame.length-1].contentWindow||frame[iFrame.length-1];}}else if(altKey===true){if(iFrame){iFrame.remove();}else{previewWindow.close();}
+previewWindow=iFrame=false;}
+if(!options.previewAutoRefresh){refreshPreview();}
+if(options.previewInWindow){previewWindow.focus();}}
+function refreshPreview(){renderPreview();}
+function renderPreview(){var phtml;if(options.previewParserPath!==''){$.ajax({type:'POST',dataType:'text',global:false,url:options.previewParserPath,data:options.previewParserVar+'='+encodeURIComponent($$.val()),success:function(data){writeInPreview(localize(data,1));}});}else{if(!template){$.ajax({url:options.previewTemplatePath,dataType:'text',global:false,success:function(data){writeInPreview(localize(data,1).replace(/<!-- content -->/g,$$.val()));}});}}
+return false;}
+function writeInPreview(data){if(previewWindow.document){try{sp=previewWindow.document.documentElement.scrollTop}catch(e){sp=0;}
+previewWindow.document.open();previewWindow.document.write(data);previewWindow.document.close();previewWindow.document.documentElement.scrollTop=sp;}}
+function keyPressed(e){shiftKey=e.shiftKey;altKey=e.altKey;ctrlKey=(!(e.altKey&&e.ctrlKey))?e.ctrlKey:false;if(e.type==='keydown'){if(ctrlKey===true){li=$("a[accesskey="+String.fromCharCode(e.keyCode)+"]",header).parent('li');if(li.length!==0){ctrlKey=false;setTimeout(function(){li.triggerHandler('mousedown');},1);return false;}}
+if(e.keyCode===13||e.keyCode===10){if(ctrlKey===true){ctrlKey=false;markup(options.onCtrlEnter);return options.onCtrlEnter.keepDefault;}else if(shiftKey===true){shiftKey=false;markup(options.onShiftEnter);return options.onShiftEnter.keepDefault;}else{markup(options.onEnter);return options.onEnter.keepDefault;}}
+if(e.keyCode===9){if(shiftKey==true||ctrlKey==true||altKey==true){return false;}
+if(caretOffset!==-1){get();caretOffset=$$.val().length-caretOffset;set(caretOffset,0);caretOffset=-1;return false;}else{markup(options.onTab);return options.onTab.keepDefault;}}}}
+init();});};$.fn.markItUpRemove=function(){return this.each(function(){var $$=$(this).unbind().removeClass('markItUpEditor');$$.parent('div').parent('div.markItUp').parent('div').replaceWith($$);});};$.markItUp=function(settings){var options={target:false};$.extend(options,settings);if(options.target){return $(options.target).each(function(){$(this).focus();$(this).trigger('insertion',[options]);});}else{$('textarea').trigger('insertion',[options]);}};})(jQuery);
Index: /extensions/SmiliesSupport/template/markitup/style.markitup.css
===================================================================
--- /extensions/SmiliesSupport/template/markitup/style.markitup.css	(revision 9966)
+++ /extensions/SmiliesSupport/template/markitup/style.markitup.css	(revision 9966)
@@ -0,0 +1,82 @@
+/* common */
+.markItUp {
+	display:inline-block;
+}
+.markItUp * {
+	margin:0px; padding:0px;
+	outline:none;
+}
+.markItUp a:link,
+.markItUp a:visited {
+	color:#000;
+	text-decoration:none;
+}
+.markItUpContainer  {
+	font:11px Verdana, Arial, Helvetica, sans-serif;
+}
+.markItUpEditor {
+	font:12px 'Courier New', Courier, monospace;
+	padding:5px;
+	clear:both;
+	overflow:auto;
+}
+.markItUpFooter {
+	display:none;
+}
+
+/* first row of buttons */
+.markItUpHeader ul li	{
+	list-style:none;
+	float:left;
+	position:relative;
+}
+.markItUpHeader ul li:hover > ul{
+	display:block;
+}
+.markItUpHeader ul .markItUpDropMenu {
+	background:transparent url(images/menu.png) no-repeat 120% 50%;
+	margin-right:5px;
+}
+/* next rows of buttons */
+.markItUpHeader ul ul {
+	display:none;
+	position:absolute;
+	top:22px; left:0px;	
+	background:#FFF;
+	border:1px solid #444;
+	border-radius:5px;
+}
+.markItUpHeader ul ul li {
+	float:none;
+	margin:0px;
+}
+/* links */
+.markItUpHeader ul a {
+	display:block;
+	width:16px; height:16px;
+	text-indent:-10000px;
+	background-position:center center;
+	background-repeat:no-repeat;
+	padding:2px;
+	border:1px solid transparent;
+}
+.markItUpHeader ul a:hover {
+	border-color:#08e;
+}
+.markItUpHeader ul ul a {
+	display:block;
+	text-indent:0;
+	border:0;
+}
+
+/* smiliessupport */
+#smiliesdiv a {
+	width:auto;	height:auto;
+	border:0;
+}
+#smiliesdiv img {
+	border:1px solid transparent;
+}
+#smiliesdiv img:hover {
+	border-color:#08e;
+}
Index: tensions/SmiliesSupport/template/smiliessupport.js
===================================================================
--- /extensions/SmiliesSupport/template/smiliessupport.js	(revision 9965)
+++ 	(revision )
@@ -1,43 +1,0 @@
-var theSelection = false;
-
-function SmiliesWrite(form, field, start, end, force) {
-	var textarea = document.forms[form].elements[field];	
-	
-	storeCaret(textarea);
-	
-	if (textarea.caretPos) {
-	  textarea.focus();
-		// Attempt to create a text range (IE).
-		theSelection = document.selection.createRange().text;		
-		if (force || theSelection != '') {
-			document.selection.createRange().text = start + theSelection + end;
-			textarea.focus();
-			return true;
-		}
-	} else if (typeof(textarea.selectionStart) != "undefined") {
-		// Mozilla text range replace.
-		var text = new Array();
-		text[0] = textarea.value.substr(0, textarea.selectionStart);
-		text[1] = textarea.value.substr(textarea.selectionStart, textarea.selectionEnd-textarea.selectionStart);
-		text[2] = textarea.value.substr(textarea.selectionEnd);
-		caretPos = textarea.selectionEnd+start.length+end.length;
-		if (force || text[1] != '') {
-			textarea.value = text[0]+start+text[1]+end+text[2];
-			if (textarea.setSelectionRange) {
-				textarea.focus();
-				textarea.setSelectionRange(caretPos, caretPos);
-			}
-			return true;
-		}
-	} else if (force) {		
-		// Just put it on the end.
-		textarea.value += start+end;
-		textarea.focus(textarea.value.length-1);
-		return true;
-	}
-	return false;
-}
-
-function storeCaret(text) {
-	if (text.createTextRange) text.caretPos = document.selection.createRange().duplicate();
-}
Index: /extensions/SmiliesSupport/template/smiliessupport_admin.tpl
===================================================================
--- /extensions/SmiliesSupport/template/smiliessupport_admin.tpl	(revision 9965)
+++ /extensions/SmiliesSupport/template/smiliessupport_admin.tpl	(revision 9966)
@@ -26,4 +26,8 @@
 		content:url('{$themeconf.admin_icon_dir}/help.png');
 	}
+	.properties textarea {ldelim}
+		width:60%;
+		margin:0 20%;
+	}
 </style>
 {/html_head}
@@ -50,5 +54,10 @@
 		</li>
 		<li>
-			<table><tr><td>{$SMILIESSUPPORT_PAGE}</td></tr></table>
+			<table><tr>
+			{foreach from=$smiliesfiles item=smileyfile} 
+				<td><a href="#" title="{$smileyfile.TITLE}"><img src="{$smileyfile.PATH}"/></a></td>
+				{$smileyfile.TR}
+			{/foreach}
+			</tr></table>
 		</li>
     </ul>
Index: tensions/SmiliesSupport/template/smiliessupport_page.css
===================================================================
--- /extensions/SmiliesSupport/template/smiliessupport_page.css	(revision 9965)
+++ 	(revision )
@@ -1,20 +1,0 @@
-div #smiliesdiv {   
-    position:absolute; 
-	z-index:1000; 
-	visibility:hidden; 
-}
-
-.smiliestable {
-    background: buttonface;
-    border: 1px solid;
-    margin: 1;
-}
-
-#smiliesdiv img {
-  cursor: pointer;
-}
-
-.properties textarea {
-	width:80%;
-	margin:0 10%;
-}
Index: /extensions/SmiliesSupport/template/smiliessupport_page.tpl
===================================================================
--- /extensions/SmiliesSupport/template/smiliessupport_page.tpl	(revision 9965)
+++ /extensions/SmiliesSupport/template/smiliessupport_page.tpl	(revision 9966)
@@ -1,20 +1,36 @@
-{combine_script id="jquery"}
-{combine_script id="smiliessupport" path=$SMILIES_PATH|@cat:"template/smiliessupport.js"}
-{combine_css path=$SMILIES_PATH|@cat:"template/smiliessupport_page.css"}
+{combine_script id="markitup" require='jquery' path=$SMILIES_PATH|@cat:"template/markitup/jquery.markitup.js"}
+{combine_css path=$SMILIES_PATH|@cat:"template/markitup/style.markitup.css"}
 
-<div width="500pt">
-	<img id="allsmilies" src="{$REPRESENTANT}" title="{'All Smilies'|@translate}" onmouseover="jQuery('#smiliesdiv').css('visibility','visible');">
+{footer_script require='jquery'}
+{literal}
+$(document).ready(function() {
+	if (jQuery('.markItUp').length == 0) {
+		jQuery('#{/literal}{$form_name}{literal} textarea').markItUp({markupSet: []});
+	}
+	jQuery('#SmiliesSupport').appendTo('.markItUpHeader ul:first-child');
+	jQuery('#allsmilies').mouseover(function(){ 
+		jQuery("#{/literal}{$form_name}{literal} textarea").focus();
+		jQuery('#smiliesdiv').css('display',''); 
+	});
+	jQuery('#smiliesdiv a').click(function() {
+		emoticon = jQuery(this).attr("title");
+		jQuery.markItUp({ replaceWith:emoticon });
+		jQuery('#smiliesdiv').css('display','none');
+		return false;
+	});
+});
+{/literal}
+{/footer_script}
 
-	<div id="smiliesdiv" >
-		<table class="smiliestable" 
-		onmouseover="jQuery('#smiliesdiv').css('visibility','visible');"
-		onmouseout="jQuery('#smiliesdiv').css('visibility','hidden');">
-			<tr>
-			{foreach from=$smiliesfiles item=smiliesfile} 
-				<td><img src="{$smiliesfile.PATH}" title="{$smiliesfile.TITLE}" onclick="SmiliesWrite('{$form_name}','content','','{$smiliesfile.TITLE}',true); jQuery('#smiliesdiv').css('visibility','hidden');"> </td>	
-				{$smiliesfile.TR}
-			{/foreach}
-			</tr>
-		</table>
-	</div>
-</div>
+<li id="SmiliesSupport" class="markItUpButton markItUpDropMenu">
+	<a id="allsmilies" style="background-image:url({$REPRESENTANT});" title="{'All Smilies'|@translate}"></a>
+
+	<ul id="smiliesdiv">
+		<li><table><tr>
+		{foreach from=$smiliesfiles item=smileyfile} 
+			<td><a href="#" title="{$smileyfile.TITLE}"><img src="{$smileyfile.PATH}"/></a></td>
+			{$smileyfile.TR}
+		{/foreach}
+		</tr></table></li>
+	</ul>
+</li>
