﻿//(function ($) {
//    $.fn.extend({
//        "followDiv": function (str) {
//            var _self = this;
//            var pos; //层的绝对定位位置
//            switch (str) {
//                case ("lefttop"): //左上角
//                    pos = { "left": "0px","top": "0px" };
//                    break;
//                default:   //默认为右下角
//                    pos = { "right": "0px", "bottom": "0px" };
//                    break;
//            }
//            /*FF和IE7可以通过position:fixed来定位，*/
//            _self.css({ "position": "absolute", "z-index": "9999" }).css(pos);
//            /*ie6需要动态设置距顶端高度top.*/
//            if ($.browser.msie && $.browser.version == 6) {
//                _self.css('position', 'absolute');
//                $(window).scroll(function () {
//                    var topIE6;
//                    if (str == "rightbottom" || str == "leftbottom") {
//                        topIE6 = $(window).scrollTop() + $(window).height() - _self.outerWidth();
//                    } else if (str == "lefttop" || str == "righttop") {
//                        topIE6 = $(window).scrollTop();
//                    } else {
//                        topIE6 = $(window).scrollTop() + $(window).height() - _self.outerWidth();
//                    }
//                    _self.css('top', topIE6);
//                });
//            }
//            return _self;  //返回this，使方法可链。
//        }
//    });
//})(jQuery);

//$(document).ready(function () {
//    $(".left").height($(".right").height());
//    $(window).scroll(function () {
//        if ($(document).scrollTop() > 285) {
//            //$('#menu').followDiv("lefttop");
//            var y = ($(document).scrollTop() - 285) + "px";
//            $(".left").animate({ top: y }, 100);
//        }
//        else {
//            $(".left").css('top', '0');
//        }
//    });
//});



//$.fn.stickyfloat = function (options, lockBottom) {
//    var $obj = this;
//    var parentPaddingTop = parseInt($obj.parent().css('padding-top'));
//    var startOffset = $obj.parent().offset().top;
//    var opts = $.extend({ startOffset: startOffset, offsetY: parentPaddingTop, duration: 250, lockBottom: true }, options);

//    $obj.css({ position: 'absolute' });

//    if (opts.lockBottom) {
//        var bottomPos = $obj.parent().height() - $obj.height() + parentPaddingTop; //get the maximum scrollTop value
//        if (bottomPos < 0)
//            bottomPos = 0;
//    }

//    $(window).scroll(function () {
//        $obj.stop(); // stop all calculations on scroll event

//        var pastStartOffset = $(document).scrollTop() > opts.startOffset; // check if the window was scrolled down more than the start offset declared.
//        var objFartherThanTopPos = $obj.offset().top > startOffset; // check if the object is at it's top position (starting point)
//        var objBiggerThanWindow = $obj.outerHeight() < $(window).height(); // if the window size is smaller than the Obj size, then do not animate.

//        // if window scrolled down more than startOffset OR obj position is greater than
//        // the top position possible (+ offsetY) AND window size must be bigger than Obj size
//        if ((pastStartOffset || objFartherThanTopPos) && objBiggerThanWindow) {
//            var newpos = ($(document).scrollTop() - startOffset + opts.offsetY);
//            if (newpos > bottomPos)
//                newpos = bottomPos;
//            if ($(document).scrollTop() < opts.startOffset) // if window scrolled < starting offset, then reset Obj position (opts.offsetY);
//                newpos = parentPaddingTop;

//            $obj.animate({ top: newpos }, opts.duration);
//        }
//    });
//};
//$(function () {
//    $('#divGuangGao').stickyfloat({ duration: 400 });
//});

; (function ($) {

$.fn.extend({

	"followDiv":function(str){

		var _self = this;

		var pos; //层的绝对定位位置

		switch(str){

			case("rightbottom")://右下角

				pos={"right":"10px","bottom":"10px"};

				break;

			case("leftbottom")://左下角

				pos={"left":"0px","bottom":"0px"};

				break;	

			case("lefttop"): //左上角

				pos={"left":"0px","top":"0px"};

				break;

			case("righttop")://右上角

				pos={"right":"0px","top":"0px"};

				break;

			default :   //默认为右下角

				pos={"right":"10px","bottom":"10px"};

				break;

		}

		/*FF和IE7可以通过position:fixed来定位，*/

		_self.css({"position":"fixed","z-index":"9999"}).css(pos);

		/*ie6需要动态设置距顶端高度top.*/

		if($.browser.msie && $.browser.version == 6) {

				_self.css('position','absolute');						

				$(window).scroll(function(){

					var topIE6;

					if(str=="rightbottom"||str=="leftbottom"){

						topIE6=$(window).scrollTop() + $(window).height() - _self.outerWidth();

					}else if(str=="lefttop"||str=="righttop"){

						topIE6=$(window).scrollTop();

					}else{

						topIE6=$(window).scrollTop() + $(window).height() - _self.outerWidth();

					}

					_self.css( 'top' , topIE6 );

				});

		}

		return _self;  //返回this，使方法可链。

	}

});

})(jQuery);



$(document).ready(function(){
   $('#divGuangGao').followDiv();

});


