/* Copyright (c) 2009 Mustafa OZCAN (http://www.mustafaozcan.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 * Version: 1.0.2
 * Requires: jquery.1.3+
 */
jQuery.fn.fixedtableheader = function(options) { var settings = jQuery.extend({ headerrowsize: 1, highlightrow: false, highlightclass: "highlight" }, options); this.each(function(i) { var $tbl = $(this); var $tblhfixed = $tbl.find("tr:lt(" + settings.headerrowsize + ")"); var headerelement = "th"; if ($tblhfixed.find(headerelement).length == 0) headerelement = "td"; if ($tblhfixed.find(headerelement).length > 0) { $tblhfixed.find(headerelement).each(function() { $(this).css("width", $(this).width()); }); var $clonedTable = $tbl.clone().empty(); var tblwidth = GetTblWidth($tbl); $clonedTable.attr("id", "fixedtableheader" + i).css({ "position": "fixed", "top": "0", "left": $tbl.offset().left }).append($tblhfixed.clone()).width(tblwidth).hide().appendTo($("body")); if (settings.highlightrow) $("tr:gt(" + (settings.headerrowsize - 1) + ")", $tbl).hover(function() { $(this).addClass(settings.highlightclass); }, function() { $(this).removeClass(settings.highlightclass); }); $(window).scroll(function() { if (jQuery.browser.msie && jQuery.browser.version == "6.0") $clonedTable.css({ "position": "absolute", "top": $(window).scrollTop(), "left": $tbl.offset().left }); else $clonedTable.css({ "position": "fixed", "top": "0", "left": $tbl.offset().left - $(window).scrollLeft() }); var sctop = $(window).scrollTop(); var elmtop = $tblhfixed.offset().top; if (sctop > elmtop && sctop <= (elmtop + $tbl.height() - $tblhfixed.height())) $clonedTable.show(); else $clonedTable.hide(); }); $(window).resize(function() { if ($clonedTable.outerWidth() != $tbl.outerWidth()) { $tblhfixed.find(headerelement).each(function(index) { var w = $(this).width(); $(this).css("width", w); $clonedTable.find(headerelement).eq(index).css("width", w); }); $clonedTable.width($tbl.outerWidth()); } $clonedTable.css("left", $tbl.offset().left); }); } }); function GetTblWidth($tbl) { var tblwidth = $tbl.outerWidth(); return tblwidth; } };


/**
 *  jQuery Fixed Position Plugin
 *  @requires jQuery v1.3
 *  http://www.socialembedded.com/labs
 *
 *  Copyright (c)  Hernan Amiune (hernan.amiune.com)
 *  Dual licensed under the MIT and GPL licenses:
 *  http://www.opensource.org/licenses/mit-license.php
 *  http://www.gnu.org/licenses/gpl.html
 * 
 *  Version: 1.0
 */
 
(function($){ $.fn.fixedPosition = function(options){

    var defaults = {
	  vpos: null,    // posible values: "top", "middle", "bottom". if it is null the original position is taken
	  hpos: null     // posible values: "left", "center", "right". if it is null the original position is taken
	};
	
    var options = $.extend(defaults, options);
	
	return this.each(function(index) {
		
		
		var $this = $(this);
		$this.css("position","absolute");
		
		if(options.vpos === "top"){
		    $this.css("top","0");
		}
		else if(options.vpos === "middle"){
		    $this.css("top",((parseInt($(window).height())/2)-($(this).height()/2))+"px");
		}
		else if(options.vpos === "bottom"){
		    $this.css("bottom","0");
		}
		
		if(options.hpos === "left"){
		    $this.css("left","0");
		}
		else if(options.hpos === "center"){
		    $this.css("left",((parseInt($(window).width())/2)-($(this).width()/2))+"px");
		}
		else if(options.hpos === "right"){
		    $this.css("right","0");
		}
		
		var top = parseInt($this.offset().top);
		var left = parseInt($this.offset().left);
		$(window).scroll(function () {
			$this.css("top",top+$(document).scrollTop()).css("left",left+$(document).scrollLeft());
		});
	});

  
}})(jQuery);
