/*
 * version 1.0
 * DTA
 # nécessite dimesions.
 * Center box
 */
jQuery.fn.center = function(element, params) {

	var defaultoptions = {
		vertical: true,
		horizontal: true
	}
	
	centeroptions = jQuery.extend(defaultoptions, params);
		
	if ( this[0] != window && this[0] != document ) {
		
		var optionscss = {
			position: 'absolute'
		};
			
		if(typeof(element) == 'undefined') {
			element = this.parent().get(0);
		}
		
		if(centeroptions.vertical) {
			optionscss.top = (jQuery(element).height() - this.height()) / 2;
			optionscss.top += jQuery(element).scrollTop();
		}
		if(centeroptions.horizontal) {
			optionscss.left = (jQuery(element).width() - this.width()) / 2;
			optionscss.left += jQuery(element).scrollLeft();
		}
		
		this.css(optionscss);
	}
};

jQuery.fn._height = jQuery.fn.height;
jQuery.fn._width  = jQuery.fn.width;

jQuery.fn.width = function() {
	if ( this[0] == window )
		return self.innerWidth ||
			jQuery.boxModel && document.documentElement.clientWidth ||
			document.body.clientWidth;

	if ( this[0] == document )
		return Math.max( document.body.scrollWidth, document.body.offsetWidth );

	return this._width(arguments[0]);
};

jQuery.fn.height = function() {
	if ( this[0] == window )
		return self.innerHeight ||
			jQuery.boxModel && document.documentElement.clientHeight ||
			document.body.clientHeight;

	if ( this[0] == document )
		return Math.max( document.body.scrollHeight, document.body.offsetHeight );

	return this._height(arguments[0]);
};

jQuery.fn.scrollLeft = function() {
	if ( this[0] == window || this[0] == document )
		return self.pageXOffset ||
			jQuery.boxModel && document.documentElement.scrollLeft ||
			document.body.scrollLeft;

	return this[0].scrollLeft;
};

jQuery.fn.scrollTop = function() {
	if ( this[0] == window || this[0] == document )
		return self.pageYOffset ||
			jQuery.boxModel && document.documentElement.scrollTop ||
			document.body.scrollTop;

	return this[0].scrollTop;
};


