jQuery.fn.center = function(params) {
	var options = {
		vertical: true,
		horizontal: true
	};
	op = jQuery.extend(options, params);

	return this.each(function(){
		var css_position = $(this).parent().css('position');
		var el_flag = css_position == 'relative' || css_position == 'absolute';
		var cssProp = {position: 'absolute'};

		if(op.vertical) {
			vcenter = (el_flag)?Math.round($(this).parent().height()/2)
				:Math.round(window.screen.availHeight/2) + $(document).scrollTop();
			cssProp.top = vcenter - Math.round($(this).height()/2) + 'px';
		}
		if(op.horizontal) {
			hcenter = (el_flag)?Math.round($(this).parent().width()/2)
				:Math.round(window.screen.availWidth/2) + $(document).scrollLeft();
			cssProp.left = hcenter - Math.round($(this).width()/2) + 'px';
		}
		$(this).css(cssProp);
   });
};