/*
 * EasyGUI XP 1.0.293
 * Copyright(c) 2006-2008 Gaetan Lauff <glauff@plansoft.de>.
 * 
 * This code is licensed under BSD license. Use it as you wish, 
 * but keep the copyright intact.
 * 
 * ========================================================
 * 
 * Prototype JavaScript framework, version 1.6.0.2
 * (c) 2005-2008 Sam Stephenson
 * 
 * ========================================================
 * 
 * script.aculo.us scriptaculous.js v1.8.1
 * Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
 * 
 * ========================================================
 */

/**
 * @fileoverview EasyGUI Table Column Header Class
 *
 * @author	Gaetan Lauff	<glauff@plansoft.de>
 * @package	js.widgets.table
 *
 * @version	$Id: class.columnheader.js 286 2007-12-13 15:30:41Z glauff $
 */
var EasyGUI_TableColumnHeader = Class.create();
/**
 * This class creates the column header necessary if table has fixed lines
 *
 * @class EasyGUI_TableColumnHeader
 * @constructor
 * @param	{object}	table	Table Object
 * @private
 */ 
Object.extend( Object.extend( EasyGUI_TableColumnHeader.prototype, EasyGUI_TableHeader.prototype ), 
{
	render: function() 
	{
		this.zIndex		= 300;
		this.header.id 	= this.id + '_FL';
		
		var header = $(this.header.id);
		
		if ( header != null ) {
			header.remove();
		}
		
		this.container.parentNode.appendChild( this.header );
		
		this.setIframe();
		
		Element.setDimension(this.header, this.container.clientWidth, this.height);
	},
	
	setHeight_: function() 
	{
		var cellSpacing 	= 4;
		var borderIdx 		= (this.fl > 0) ? (this.fl - 1) : 0;
		var tabBorderTop 	= parseInt( Element.getStyle( this.element, 'border-top-width'));
			
		if (isNaN(tabBorderTop))
		{
			tabBorderTop = 0;
		}
		
		this.height += tabBorderTop;
		
		var rowBorderBottom = parseInt( Element.getStyle( this.element.rows[borderIdx], 'border-bottom-width' ));
		
		if ( isNaN( rowBorderBottom ))
		{
			rowBorderBottom = 0;
		}
	
		this.height += rowBorderBottom;
		
		if ( this.element.cellSpacing != '' )
		{
			cellSpacing = 2 * parseInt( this.element.cellSpacing ); 
		}
	
		for ( var i=0; i < this.fl; i++ ) 
		{
			if ( is.ie5up ) 
			{
				rowBorderTop = parseInt( Element.getStyle( this.element.rows[i], 'border-top-width' ));
				
				if ( isNaN( rowBorderTop ))
				{
					rowBorderTop = 0;
				}
			
				this.height += rowBorderTop;	
			}
			
			this.height += parseInt(this.element.rows[i].offsetHeight) + cellSpacing;
		}
	}
});