jQuery.fn.center = function (flag) {
    this.css("position","fixed");
	if (flag==1 ||flag==0)
    this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");
	if (flag==2 ||flag==0)
    this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");
    return this;
}
