Index: ckeditor/plugins/table/dialogs/table.js
===================================================================
@@ -222,6 +222,40 @@
 					if ( !table.getAttribute( 'style' ) )
 						table.removeAttribute( 'style' );
 				}
+				
+        //////////////////////////// Patched By Stephen ////////////////////////////
+
+				for ( row = 0; row < table.$.rows.length; row++ ) { 
+				  for (index = 0, len = table.$.rows[ row ].cells.length; index < len; ++index) {
+					  newCell = new CKEDITOR.dom.element( table.$.rows[ row ].cells[ index ] );
+					  if(table.getStyle('border-width')){
+					    newCell.setStyle('border-width', table.getStyle('border-width'));
+					  }
+				    else{
+					    newCell.removeStyle('border');
+					  }		
+				    if(table.getAttribute('cellPadding')>0){
+				      newCell.setStyle('padding', table.getAttribute('cellPadding')+'px');
+				    }
+					  else{
+					    newCell.removeStyle('padding');
+					  }
+					  if(table.getStyle('border-color')){
+					    newCell.setStyle('border-color', table.getStyle('border-color'));
+					  }
+					  else{
+					    newCell.removeStyle('border-color');
+					  }
+					  if(table.getStyle('border-style')){
+					    newCell.setStyle('border-style', table.getStyle('border-style'));  
+					  }
+					  else{
+					    newCell.removeStyle('border-style');
+					  }
+					}
+				}
+        table.removeAttribute('cellPadding');
+        //////////////////////////// Patched By Stephen ////////////////////////////
 
 				// Insert the table element if we're creating one.
 				if ( !this._.selectedElement ) {
@@ -331,20 +365,134 @@
 							controlStyle: 'width:3em',
 							validate: CKEDITOR.dialog.validate[ 'number' ]( editor.lang.table.invalidBorder ),
 							setup: function( selectedTable ) {
-								this.setValue( selectedTable.getAttribute( 'border' ) || '' );
+							  ////////////////////////////// Patched By Stephen //////////////////////////////////
+								//this.setValue( selectedTable.getAttribute( 'border' ) || '' );
+								if(selectedTable.getStyle('border-width')){
+								  this.setValue(selectedTable.getStyle('border-width').replace('px', ''));
+								}
+								else if(selectedTable.getAttribute('border')){
+								  this.setValue(selectedTable.getAttribute('border'));
+								  selectedTable.setStyle('border-style', 'solid'); 
+								}
+								else{
+								  this.setValue('');
+								}
+								////////////////////////////// Patched By Stephen //////////////////////////////////
 							},
 							commit: function( data, selectedTable ) {
-								if ( this.getValue() )
-									selectedTable.setAttribute( 'border', this.getValue() );
-								else
-									selectedTable.removeAttribute( 'border' );
+							  ////////////////////////////// Patched By Stephen //////////////////////////////////
+								//if ( this.getValue() ) // removed
+								//	selectedTable.setAttribute( 'border', this.getValue() ); // removed
+								//else // removed
+								//	selectedTable.removeAttribute( 'border' ); // removed
+					      if(this.getValue()){
+					        if(this.getValue()>0){
+						        selectedTable.setStyle('border-width', this.getValue()+'px');
+					        }
+					        else{
+					          selectedTable.removeStyle('border');
+					        }
+					      }
+					      else{
+					        selectedTable.removeStyle('border');
+					      }	
+					      selectedTable.removeAttribute('border');
+							  ////////////////////////////// Patched By Stephen //////////////////////////////////
+							}
+						},
+
+
+
+              ////////////////////////////// Patched By Stephen //////////////////////////////////
+							{
+							id: 'cmbBorderstyle',
+							type: 'select',
+							requiredContent: 'table{border-style}',
+							'default': 'solid',
+							label: editor.lang.common.borderstyle,
+							items: [
+								[ editor.lang.common.notSet, '' ],
+								[ editor.lang.common.borderstyleNone, 'none' ],
+								[ editor.lang.common.borderstyleSolid, 'solid' ],
+								[ editor.lang.common.borderstyleDotted, 'dotted' ],
+								[ editor.lang.common.borderstyleDashed, 'dashed' ],
+								[ editor.lang.common.borderstyleHidden, 'hidden' ],
+								[ editor.lang.common.borderstyleDouble, 'double' ],
+								[ editor.lang.common.borderstyleGroove, 'groove' ],
+								[ editor.lang.common.borderstyleRidge, 'ridge' ],
+								[ editor.lang.common.borderstyleInset, 'inset' ],
+								[ editor.lang.common.borderstyleOutset, 'outset' ],
+								[ editor.lang.common.borderstyleInitial, 'initial' ],
+								[ editor.lang.common.borderstyleInherit, 'inherit' ]
+								],
+							setup: function( selectedTable ) {
+							  if(this.getValue(selectedTable.getStyle('border-style'))){
+							    this.setValue(selectedTable.getStyle('border-style'));
+							  }
+							  //else{
+							  //  this.setValue('solid');
+							  //}
+							},
+							commit: function( data, selectedTable ) {
+							  if (this.getValue()){
+							    selectedTable.setStyle('border-style', this.getValue());
+							  }
+							  else {
+							    selectedTable.setStyle('border-style', '');
+							  }
+							}
+						}, 
+					  ////////////////////////////// Patched By Stephen //////////////////////////////////
+
+
+
+
+						  ////////////////////////////// Patched By Stephen //////////////////////////////////
+					    {
+							type: 'text',
+							id: 'txtBordercolor',
+							requiredContent: 'table',
+							controlStyle: 'width:6em',
+							'default': '#cccccc',
+							label: editor.lang.table.tablebordercolor,
+							setup: function( selectedTable ) {
+								if(selectedTable.getStyle('border-color')){
+								  this.setValue(selectedTable.getStyle('border-color'));
+								}
+								else if(selectedTable.getAttribute('bordercolor')){
+								  this.setValue(selectedTable.getAttribute('bordercolor'));
+								  selectedTable.removeAttribute('bordercolor');
+								}
+								else{
+								  this.setValue(''); 
+								}
+							},
+							commit: function( data, selectedTable ) {
+					      if(this.getValue()){
+						      selectedTable.setStyle('border-color', this.getValue());  
+					      }
+					      else{
+					        selectedTable.removeStyle('border-color');
+					      } 
 							}
 						},
+						////////////////////////////// Patched By Stephen //////////////////////////////////
+
+
+
+
+
+
+
+
 							{
 							id: 'cmbAlign',
 							type: 'select',
 							requiredContent: 'table[align]',
-							'default': '',
+							////////////////////////////// Patched By Stephen //////////////////////////////////
+							//'default': '',
+							'default': 'center',
+							////////////////////////////// Patched By Stephen //////////////////////////////////
 							label: editor.lang.common.align,
 							items: [
 								[ editor.lang.common.notSet, '' ],
@@ -353,13 +501,52 @@
 								[ editor.lang.common.alignRight, 'right' ]
 								],
 							setup: function( selectedTable ) {
-								this.setValue( selectedTable.getAttribute( 'align' ) || '' );
+							  ////////////////////////////// Patched By Stephen //////////////////////////////////
+								//this.setValue( selectedTable.getAttribute( 'align' ) || '' );
+								if(selectedTable.getStyle('float')){
+								  this.setValue(selectedTable.getStyle('float'));
+								}
+								else if(selectedTable.getStyle('margin-left')){
+								  this.setValue('center');
+								}
+								else if(selectedTable.getAttribute('align')){
+								  this.setValue(selectedTable.getAttribute('align'));
+								}
+								else{
+								  this.setValue('');
+								}
+								////////////////////////////// Patched By Stephen //////////////////////////////////
 							},
 							commit: function( data, selectedTable ) {
-								if ( this.getValue() )
-									selectedTable.setAttribute( 'align', this.getValue() );
-								else
-									selectedTable.removeAttribute( 'align' );
+							  ////////////////////////////// Patched By Stephen ////////////////////////////////// 
+								//if ( this.getValue() )
+								//	selectedTable.setAttribute( 'align', this.getValue() );
+								//else
+								//	selectedTable.removeAttribute( 'align' );
+								if(this.getValue()){
+								  if(this.getValue()=='left'){
+								    selectedTable.setStyle('float', 'left');
+								    selectedTable.removeStyle('margin-left');
+								    selectedTable.removeStyle('margin-right');
+								  }
+								  else if(this.getValue()=='right'){
+								    selectedTable.setStyle('float', 'right');
+								    selectedTable.removeStyle('margin-left');
+								    selectedTable.removeStyle('margin-right');
+								  }
+								  else if(this.getValue()=='center'){
+								    selectedTable.setStyle('margin-left', 'auto');
+								    selectedTable.setStyle('margin-right', 'auto');
+								    selectedTable.removeStyle('float');
+								  }
+								}
+								else{
+								  selectedTable.removeStyle('margin-left');
+								  selectedTable.removeStyle('margin-right');
+								  selectedTable.removeStyle('float');
+								}
+								selectedTable.removeAttribute('align'); 
+								////////////////////////////// Patched By Stephen //////////////////////////////////
 							}
 						}
 						]
@@ -432,16 +619,46 @@
 							requiredContent: 'table[cellspacing]',
 							controlStyle: 'width:3em',
 							label: editor.lang.table.cellSpace,
-							'default': editor.filter.check( 'table[cellspacing]' ) ? 1 : 0,
+							////////////////////////////// Patched By Stephen //////////////////////////////////
+							//'default': editor.filter.check( 'table[cellspacing]' ) ? 1 : 0,
+							'default': editor.filter.check( 'table[cellspacing]' ) ? 0 : 0,
+							////////////////////////////// Patched By Stephen //////////////////////////////////
 							validate: CKEDITOR.dialog.validate.number( editor.lang.table.invalidCellSpacing ),
 							setup: function( selectedTable ) {
-								this.setValue( selectedTable.getAttribute( 'cellSpacing' ) || '' );
+							  ////////////////////////////// Patched By Stephen //////////////////////////////////
+								//this.setValue( selectedTable.getAttribute( 'cellSpacing' ) || '' );
+								if(selectedTable.getStyle('border-spacing')){
+								  this.setValue(selectedTable.getStyle('border-spacing').replace('px','')); 
+								}
+								else if(selectedTable.getAttribute('cellspacing')){
+								  this.setValue(selectedTable.getAttribute('cellspacing'));
+								}
+								else{
+								  this.setValue('');  
+								}
+								////////////////////////////// Patched By Stephen //////////////////////////////////
 							},
 							commit: function( data, selectedTable ) {
-								if ( this.getValue() )
-									selectedTable.setAttribute( 'cellSpacing', this.getValue() );
-								else
-									selectedTable.removeAttribute( 'cellSpacing' );
+							  ////////////////////////////// Patched By Stephen //////////////////////////////////
+								//if ( this.getValue() )
+								//	selectedTable.setAttribute( 'cellSpacing', this.getValue() );
+								//else
+								//	selectedTable.removeAttribute( 'cellSpacing' );
+								if(this.getValue()){
+								  if(this.getValue()>0){
+								    selectedTable.setStyle('border-collapse', 'separate');
+								  }
+								  else{
+								    selectedTable.setStyle('border-collapse', 'collapse');
+								  }
+								  selectedTable.setStyle('border-spacing', this.getValue()+'px');
+								}
+								else{
+								  selectedTable.setStyle('border-collapse', 'collapse');
+								  selectedTable.removeStyle('border-spacing');
+								}
+								selectedTable.removeAttribute('cellSpacing');
+							  ////////////////////////////// Patched By Stephen //////////////////////////////////
 							}
 						},
 							{
@@ -450,10 +667,42 @@
 							requiredContent: 'table[cellpadding]',
 							controlStyle: 'width:3em',
 							label: editor.lang.table.cellPad,
-							'default': editor.filter.check( 'table[cellpadding]' ) ? 1 : 0,
+							////////////////////////////// Patched By Stephen //////////////////////////////////
+							//'default': editor.filter.check( 'table[cellpadding]' ) ? 1 : 0,
+							'default': editor.filter.check( 'table[cellpadding]' ) ? 4 : 0,
+							////////////////////////////// Patched By Stephen //////////////////////////////////
 							validate: CKEDITOR.dialog.validate.number( editor.lang.table.invalidCellPadding ),
 							setup: function( selectedTable ) {
-								this.setValue( selectedTable.getAttribute( 'cellPadding' ) || '' );
+							  ////////////////////////////// Patched By Stephen //////////////////////////////////
+					      if(selectedTable.getAttribute('cellpadding')){
+					        this.setValue(selectedTable.getAttribute('cellpadding'));
+					      }
+					      else if(selectedTable.getElementsByTag('tbody').getItem(0)){
+					        var cellpadding=0;
+								  var tbody = selectedTable.getElementsByTag('tbody').getItem(0);
+								  var theRow = tbody.getElementsByTag('tr').getItem(0);
+								  var td = theRow.getChild(0);
+								  if(td.getStyle('padding')){
+								    this.setValue(td.getStyle('padding').replace('px','')); 
+								  }
+								  else{
+								    if(selectedTable.getElementsByTag('thead').getItem(0)){
+								      var thead = selectedTable.getElementsByTag('thead').getItem(0);
+								      var thead = tbody.getElementsByTag('tr').getItem(0);
+								      var th = theRow.getChild(0);
+								      if(th.getStyle('padding')){
+								        this.setValue(th.getStyle('padding').replace('px','')); 
+								      }
+								      else{
+								        this.setValue('');
+								      }
+								    }
+								    else{
+								      this.setValue('');
+								    }
+								  }
+								}
+								////////////////////////////// Patched By Stephen //////////////////////////////////
 							},
 							commit: function( data, selectedTable ) {
 								if ( this.getValue() )
