(function(){
	
	jQuery.fn.centerX = function(){
		return $(this).css({'position':'absolute','left':($(this).parent().width()/2) - ($(this).width()/2)+'px'});
	}
	jQuery.fn.centerY = function(){
		return $(this).css({'position':'absolute','top':($(this).parent().height()/2) - ($(this).height()/2)+'px'});
	}
	jQuery.fn.center = function(){
		return $(this).centerX().centerY();
	}
	jQuery.fn.toRight = function(){
		return $(this).css({'position':'absolute','left':'','right':0});
	}
	jQuery.fn.toLeft = function(){
		return $(this).css({'position':'absolute','left':'0px'});
	}
	jQuery.fn.toTop		= function(){
		return $(this).css({'position':'absolute','top':'0px'});
	}
	jQuery.fn.toBottom	= function(){
		return $(this).css({'position':'absolute','top':($(this).parent().height()) - ($(this).height())+'px'});
	}
	jQuery.fn.toRightOut = function(){
		return $(this).css({'position':'absolute','left':($(this).parent().width())+'px'});
	}
	jQuery.fn.toLeftOut = function(){
		return $(this).css({'position':'absolute','left':-($(this).width())+'px'});
	}
	jQuery.fn.toBottomOut = function(){
		return $(this).css({'position':'absolute','top':($(this).parent().height())+'px'});
	}
	jQuery.fn.toTopOut = function(){
		return $(this).css({'position':'absolute','top':-($(this).height())+'px'});
	}
	jQuery.fn.highlight = function(t){
		return $(this).fadeIn(100).fadeOut(t);
	}
	jQuery.fn.lowlight = function(t){
		return $(this).fadeOut(100).fadeIn(t);
	}
	jQuery.fn.changeBackColor = function(){
		var color = '#'+Math.floor(Math.random()*16777215).toString(16);
		return $(this).css({'background-color':color});
	}
	jQuery.fn.copySize = function(e, offset){
		return $(this).width(e.width() + offset).height(e.height() + offset);
	}
	jQuery.fn.overlap = function(e){
		var offset = e.offset();
		var css = {top : offset.top, left : offset.left}
		return $(this).css({top:'',left:'',bottom:'',right:''}).css(css);
	}
	jQuery.fn.bottomStick = function(){

                        var ie6 = (($.browser.msie) && ($.browser.version<7)) ? true : false;                                 

                        $this = $(this);

                        if(ie6){

                                   $this.absolutize();

                                   var top = ($(window).scrollTop() + $(window).height() - $this.height()) + "px";

                                   $this.css({bottom:'', top:top});                 

                        }

                        else{

                                   $this.css({bottom:0});

                                   $this.fixate();                 

                        }

                        return $this;                  

            }


	jQuery.fn.stick = function(){
		$this = $(this);
		(($.browser.msie) && ($.browser.version<7)) ? ($this.css({position: 'absolute'})) : ($this.css({position: 'fixed'}));			
	}
	jQuery.fn.unStick = function(){
		$(this).css({position:'absolute'});
	}
	jQuery.fn.fixate = function(){

                        return $(this).css({position:'fixed'});

            }

            jQuery.fn.absolutize = function(){

                        return $(this).css({position:'absolute'});

            }


	jQuery.fn.onTopOf = function(e){
		var $this = $(this);
		if(!e.isHidden()){
			var offset = e.offset();
			var top = offset.top - $(this).height();
			var css = {top : top, left : offset.left}
			$this.css({top:'',left:'',bottom:'',right:''}).css(css);
		}
		return $this;
	}
	jQuery.fn.isHidden = function(){
		return $(this).is(':hidden');
	}
})();
