--- table.js.orig	2014-11-25 14:23:52.000000000 +0000
+++ table.js	2015-01-19 10:29:05.366528000 +0000
@@ -222,6 +222,37 @@
 					if ( !table.getAttribute( 'style' ) )
 						table.removeAttribute( 'style' );
 				}
+				
+				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');
 
 				// Insert the table element if we're creating one.
 				if ( !this._.selectedElement ) {
@@ -331,20 +362,105 @@
 							controlStyle: 'width:3em',
 							validate: CKEDITOR.dialog.validate[ 'number' ]( editor.lang.table.invalidBorder ),
 							setup: function( selectedTable ) {
-								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('');
+								}
 							},
 							commit: function( data, selectedTable ) {
-								if ( this.getValue() )
-									selectedTable.setAttribute( 'border', this.getValue() );
-								else
-									selectedTable.removeAttribute( 'border' );
+					      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');
 							}
 						},
+
+					    {
+							type: 'text',
+							id: 'txtBorderColor',
+							requiredContent: 'table{border-color}',
+							label: editor.lang.table.borderColor,
+							'default': '#cccccc',
+							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');
+					      } 
+							}
+						},
+
+							{
+							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', '');
+							  }
+							}
+						}, 
+
 							{
 							id: 'cmbAlign',
 							type: 'select',
 							requiredContent: 'table[align]',
-							'default': '',
+							'default': 'center',
 							label: editor.lang.common.align,
 							items: [
 								[ editor.lang.common.notSet, '' ],
@@ -353,13 +469,43 @@
 								[ editor.lang.common.alignRight, 'right' ]
 								],
 							setup: function( selectedTable ) {
-								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('');
+								}
 							},
 							commit: function( data, selectedTable ) {
-								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'); 
 							}
 						}
 						]
@@ -432,16 +578,34 @@
 							requiredContent: 'table[cellspacing]',
 							controlStyle: 'width:3em',
 							label: editor.lang.table.cellSpace,
-							'default': editor.filter.check( 'table[cellspacing]' ) ? 1 : 0,
+							'default': editor.filter.check( 'table[cellspacing]' ) ? 0 : 0,
 							validate: CKEDITOR.dialog.validate.number( editor.lang.table.invalidCellSpacing ),
 							setup: function( selectedTable ) {
-								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('');  
+								}
 							},
 							commit: function( data, selectedTable ) {
-								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');
 							}
 						},
 							{
@@ -450,10 +614,37 @@
 							requiredContent: 'table[cellpadding]',
 							controlStyle: 'width:3em',
 							label: editor.lang.table.cellPad,
-							'default': editor.filter.check( 'table[cellpadding]' ) ? 1 : 0,
+							'default': editor.filter.check( 'table[cellpadding]' ) ? 4 : 0,
 							validate: CKEDITOR.dialog.validate.number( editor.lang.table.invalidCellPadding ),
 							setup: function( selectedTable ) {
-								this.setValue( selectedTable.getAttribute( 'cellPadding' ) || '' );
+					      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('');
+								    }
+								  }
+								}
 							},
 							commit: function( data, selectedTable ) {
 								if ( this.getValue() )
