Index: /CKEditor/branches/prototype/_source/plugins/smiley/dialogs/smiley.js
===================================================================
--- /CKEditor/branches/prototype/_source/plugins/smiley/dialogs/smiley.js	(revision 2991)
+++ /CKEditor/branches/prototype/_source/plugins/smiley/dialogs/smiley.js	(revision 2992)
@@ -6,47 +6,25 @@
 CKEDITOR.dialog.add( 'smiley', function( editor )
 {
-	var smileySelector =
-	{
-		type : 'html',
-		onClick : function( evt )
-		{
-			var target = evt.data.getTarget(),
-				targetName = target.getName();
-			if ( targetName != 'td' && targetName != 'img' )
-				return;
+	var config = editor.config.smiley,
+		images = config.images,
+		columns = config.columns,
+		i;
 
-			if ( targetName == 'td' )
-				target = target.getChild(0).$;
-			else
-				target = target.$;
-
-			this.getDialog().restoreSelection();
-			editor.insertElement( CKEDITOR.dom.element.createFromHtml( '<img src="' +
-			CKEDITOR.tools.htmlEncode( target.src ) + '" title="' +
-			CKEDITOR.tools.htmlEncode( target.title ) + '" alt="' +
-			CKEDITOR.tools.htmlEncode( target.title ) + '" '
-					+ '_cke_saved_src="' + CKEDITOR.tools.htmlEncode( target.src ) + '" />',
-				editor.document ) );
-			this.getDialog().hide();
-		},
-		style : 'width: 100%; height: 100%; border-collapse: separate;'
-	},
-		html = [ '<table cellspacing="2" cellpadding="2" border="0"><tbody>' ],
-		cellWidth = parseInt( 100 / editor.config.smiley.columns ) + '%',
-		images = editor.config.smiley.images,
-		columns = editor.config.smiley.columns,
-		i;
+	// Build the HTML for the smiley images table.
+	var html = [ '<table cellspacing="2" cellpadding="2"><tbody>' ];
 
 	for ( i = 0 ; i < images.length ; i++ )
 	{
-		if ( i % editor.config.smiley.columns == 0 )
+		if ( i % columns == 0 )
 			html.push( '<tr>' );
 
-		html.push( '<td class="dark_background hand centered" style="vertical-align: middle;"><img border="0" title="'+
-		editor.config.smiley.descriptions[i] +'" src="' +
-				CKEDITOR.tools.htmlEncode( editor.config.smiley.path + images[i] ) + '" ' +
-				// IE BUG: Below is a workaround to an IE image loading bug to ensure the image sizes are correct.
-				( CKEDITOR.env.ie ? 'onload="this.setAttribute(\'width\', 2); this.removeAttribute(\'width\');" ' : '' ) +
-				'class="hand" /></td>' );
+		html.push( 
+			'<td class="dark_background hand centered" style="vertical-align: middle;">' +
+				'<img border="0" class="hand" title="', config.descriptions[i], '"' +
+					' src="', CKEDITOR.tools.htmlEncode( config.path + images[ i ] ), '"',
+					// IE BUG: Below is a workaround to an IE image loading bug to ensure the image sizes are correct.
+					( CKEDITOR.env.ie ? ' onload="this.setAttribute(\'width\', 2); this.removeAttribute(\'width\');" ' : '' ),
+				'>' +
+			'</td>' );
 
 		if ( i % columns == columns - 1 )
@@ -62,10 +40,46 @@
 
 	html.push( '</tbody></table>' );
-	smileySelector.html = html.join( '' );
+
+	var smileySelector =
+	{
+		type : 'html',
+		html : html.join( '' ),
+		onClick : function( evt )
+		{
+			var target = evt.data.getTarget(),
+				targetName = target.getName();
+
+			if ( targetName == 'td' )
+				target = target.getChild(0);
+			else if ( targetName != 'img' )
+				return;
+
+			this.getDialog().restoreSelection();
+			
+			var src = target.getAttribute( 'src' ),
+				title = target.getAttribute( 'title' );
+			
+			var img = editor.document.createElement( 'img',
+				{
+					attributes :
+					{
+						src : src,
+						_cke_saved_src : src,
+						title : title,
+						alt : title
+					}
+				});
+			
+			editor.insertElement( img );
+			
+			this.getDialog().hide();
+		},
+		style : 'width: 100%; height: 100%; border-collapse: separate;'
+	};
 
 	return {
 		title : editor.lang.smiley.title,
-		minWidth : editor.config.smiley.windowWidth,
-		minHeight : editor.config.smiley.windowHeight,
+		minWidth : config.windowWidth,
+		minHeight : config.windowHeight,
 		contents : [
 			{
