$(document).ready(function() {
	$('.tableHeader-hidden').remove();
	$triggerHeaderChange = -1;
	$floater = $('<div></div>').css({position:"fixed",top:"0px",'margin-top':'-10px'}).addClass('ie6-hide');
        moveScroller();
});

function moveScroller() {
	var a = function() {
		$headers = $(".tableHeader");
		var b = $(window).scrollTop();

		$header = $headers.first();

		$headers.each(function(i) {
			if ($(this).offset().top < b) {
				$header = $(this);
				$triggerHeaderChange = i;
			}
		});

		var d = $header.offset().top;

		if (b>d && ($triggerHeaderChange > -1 && !$floater.is(':visible') && ( b < $('tr:last', $header.parent()).offset().top )) ) {

			$row = $('<tr></tr>');

			$('th', $header).each(function(i) {
				$row.append(
						$('<th/>').html( $(this).html() )
								.css( {'width':$(this).width()+'px'} )
								.addClass( i == 0 ? 'left' : (i == $('th', $header).length-1 ? 'right' : '') )
					);
			});


			$floater.css({'left':$header.offset().left+'px', 'width':$header.width()+'px'})
                                .html('<table><tbody><tr>' + $row.html() + '</tr></tbody></table>')
                                .show();
			$('body').append($floater);
		} else {

			if (b<=d || ( b > $('tr:last', $header.parent()).offset().top ) ) {
				$floater.hide();
			}
		}
	};
	$(window).scroll(a);a()
}

