/*
 * jquery.fixedie.js 0.0.1
 *
 * Copyright (c) 2010 Naoki Matsuda
 * Licensed under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * Since:     2010-07-23
 * Modified:  2010-07-23
 */

(function($){
	$.fn.fixedIE = function(options) {
		/* 初期値を設定 */
		var s = $.extend({'fixed' : true,'top': 0,'left': 0}, options);

		/* セレクタで指定した要素を処理 */
		this.each(function() {
			if(s.fixed){
				if(!$.support.style){	/* IE6,7 */
					var el = $(this).css({'position':'absolute'})[0];
					el.style.setExpression(
						'top','eval('+ s.top +'+(document.body.scrollTop||document.documentElement.scrollTop))'
					);
					el.style.setExpression(
						'left','eval('+ s.left +'+(document.body.scrollLeft||document.documentElement.scrollLeft))'
					);
					$('html').css({
						'background-image':'url(null)',
						'background-attachment':'fixed'
					});
				}
				else {	/* Other */
					$(this).css({'position':'fixed'}).css('top',s.top+'px');
				}
			}else{
				if(!$.support.style){	/* IE6,7 */
					var el = $(this).css({'position':'absolute'})[0];
					el.style.setExpression('top', s.top);
					el.style.setExpression('left', s.left);
				}
				else {	/* Other */
					$(this).css({'position':'absolute'})[0];
				}
			}
		});

		/* メソッドチェーン用 */
		return this;
	};
})(jQuery);

