﻿$(function() {
    $(".mytable tr").hover(
        function() { $(this).addClass("over"); },
        function() { $(this).removeClass("over"); }
    );
    $(".mytable tr:even").addClass("even");
    $(".mytable tr:odd").addClass("odd");
    $("input:text").each(function() {
        if (this.id != "AspNetPager1_input" && this.id != "txtlink")
            $(this).addClass("input_text");
    });
    
    $("#btnReset").click(function() {
        $("input:text").removeAttr("value");
        $('select').each(function() {
            $(this)[0].selectedIndex = 0;
        });
        return false;
    });
});
//获取触发事件目标的相对位置
function CPos(x, y)
{
     this.x = x;
     this.y = y;
}
function GetObjPos(ATarget)
{
    var target = ATarget;
    var pos = new CPos(target.offsetLeft, target.offsetTop);
    while(target = target.offsetParent)
    {
        pos.x += target.offsetLeft;
        pos.y += target.offsetTop;
    }
    return pos;
}

(function($) {
    $.fn.center = function(settings) {
        var style = $.extend({
            position: 'absolute', //absolute or fixed
            top: '50%', 		//50%即居中，将应用负边距计算，溢出不予考虑了。
            left: '50%',
            zIndex: 2009,
            relative: true		//相对于包含它的容器居中还是整个页面
        }, settings || {});

        return this.each(function() {
            var $this = $(this);

            if (style.top == '50%') style.marginTop = -$this.outerHeight() / 2;
            if (style.left == '50%') style.marginLeft = -$this.outerWidth() / 2;
            if (style.relative && !$this.parent().is('body') && $this.parent().css('position') == 'static')
                $this.parent().css('position', 'relative');
            delete style.relative;
            //ie6
            if (style.position == 'fixed' && $.browser.version == '6.0') {
                style.marginTop += $(window).scrollTop();
                style.position = 'absolute';
                $(window).scroll(function() {
                    $this.stop().animate({
                        marginTop: $(window).scrollTop() - $this.outerHeight() / 2
                    });
                });
            }

            $this.css(style);
        });
    };
})(jQuery);
