(function(){
            //PLUGINS//
            jQuery.fn.draw = function(conf){
                        var $this = $(this);
                        $this.addClass(conf.cssClass);
                        (conf.prepend)   ? (conf.location.prepend($this)) : (conf.location.append($this));
                        (conf.html !='') ? ($this.append(conf.html)) : void(0);
                        for(d in conf.css){
                                   $this.css(d, conf.css[d]);
                        }
                        return $this;
            }
            jQuery.fn.fakeImage = function(c){
                        //c = Math.sqrt(t);
                        var w = ($(this).width()  /c);
                        var h = ($(this).height()  /c);
                        for(var i=0;i<(c * c);i++){
                                   new hoverTile({container:$(this),dimentions:{width:w,height:h},highlight:false,colorchange:false,hide:true}); 
                        }
            }
            jQuery.fn.isHidden = function(){
                        return ($(this).css('display')=='none');
            }
            jQuery.fn.isVisible = function(){
                        return (!$(this).isHidden());
            }
            jQuery.random = function(hi,low){
                        var adjustedHigh = (parseFloat(hi) - parseFloat(low)) + 1;
        var numRand = Math.floor(Math.random()*adjustedHigh) + parseFloat(low);
        return numRand;
            }
            
            //EFFECTS
            jQuery.fn.scale              = function(c, t){
                        $this = $(this);
                        $this.delay(40).animate({width: c, height:c}, t);
            }
            jQuery.fn.UnScale                     = function(c, t){
                        $this = $(this);
                        $this.stop();
                        $this.animate({width: $this.width() - c, height:$this.height() - c}, t);
            }
            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':($(this).parent().width()) - ($(this).width()) + 'px'});
            }
            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.getRandomColor = function(){
                        return    '#'+Math.floor(Math.random()*16777215).toString(16);
            }
            jQuery.fn.changeColor = function(c){
                        var color = (c!=undefined)?c:$(this).getRandomColor();
                        return $(this).css({'display':'','background-color':color});
            }
            jQuery.fn.blink = function(conf){
                        var aux = jQuery.fn.blink;
                        jQuery.fn.blink = function(){};

                        conf = conf || {};
                        var $this = $(this);
                        var oldColor = $this.css('background-color');
                        var newColor = conf.color!=undefined?conf.color:$this.getRandomColor();
                        $this.css({'background-color':newColor});
                        setTimeout(function(){
                                   $this.css({'background-color':oldColor});              
                                   jQuery.fn.blink = aux;
                        },conf.duration);
            }
            jQuery.fn.classBlink = function(conf){
                        var aux = jQuery.fn.classBlink;
                        jQuery.fn.classBlink = function(){};
                        conf = conf || {};
                        var $this = $(this);
                        $this.addClass(conf.cssClass);
                        setTimeout(function(){
                                   $this.removeClass(conf.cssClass);                     
                                   jQuery.fn.classBlink = aux;
                        },conf.duration);
            }
            jQuery.fn.adjustToParent = function(){
                        var $this = $(this);
                        $this.height($this.parent().height()).width($this.parent().width());
                        return $this;
            }
            
            //POSICIONAMIENTO
            jQuery.fn.top = function(){
                        var $this = $(this);
                        $(this).css('top'); 
                        return $this;
            }
            jQuery.fn.top = function(t){
                        var $this = $(this);
                        $this.css({top:t});
                        return $this;
            }
            jQuery.fn.left = function(){
                        var $this = $(this);
                        $(this).css('left');            
                        return $this;
            }
            jQuery.fn.left = function(l){
                        var $this = $(this);
                        $(this).css({left:l});
                        return $this;
            }
            jQuery.fn.right = function(){
                        var $this = $(this);
                        $(this).css('right');
                        return $this;
            }
            jQuery.fn.right = function(r){
                        var $this = $(this);
                        $(this).css({right:r});
                        return $this;
            }
            jQuery.fn.bottom = function(){
                        var $this = $(this);
                        $(this).css('bottom');
                        return $this;
            }
            jQuery.fn.bottom = function(b){
                        var $this = $(this);
                        $(this).css({bottom:b});
                        return $this;
            }
            jQuery.fn.removePos = function(){
                        var $this = $(this);
                        $this.css({top:'',left:'',right:'',bottom:''});
                        return $this;
            }
            jQuery.fn.overlap = function(o){
                        $this = $(this);
                        return $this.removePos().top(o.top()).left(o.left()).right(o.right()).bottom(o.bottom());                                                
            }
            jQuery.fn.onTop = function(o){
                        $this = $(this);
                        pos   = o.position();
                        return $this.removePos().top(pos.top - $this.height()).left(pos.left);                                               
            }
            jQuery.fn.onBottom = function(o){
                        $this = $(this);
                        pos   = o.position();
                        return $this.removePos().top(pos.top + o.height()).left(pos.left);                                        
            }
            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.fixate = function(){
                        return $(this).css({position:'fixed'});
    }
            jQuery.fn.absolutize = function(){
                        return $(this).css({position:'absolute'});
            }
            jQuery.fn.relativize = function(){
                        return $(this).css({position:'relative'});
            }
            jQuery.fn.apilar = function(){
                        var $this = $(this);
                        var $prev = $this.prev();
                        if($prev.length > 0){
                                   var prevPos = $prev.position();
                                   var thisPos = {};
                                   thisPos.left = prevPos.left + parseInt($prev.width()) + parseInt($this.css('margin-left'));
                                   return $this.css({left:thisPos.left});
                        }
                        else{
                                   return $this.css({left:0})
                        }
            }
            jQuery.fn.apilar = function(){
                        var $this = $(this);
                        var $prev = $this.prev();
                        if($prev.length > 0){
                                   var prevPos = $prev.position();
                                   var thisPos = {};
                                   thisPos.left = prevPos.left + parseInt($prev.width()) + parseInt($this.css('margin-left'));
                                   return $this.css({left:thisPos.left});
                        }
                        else{
                                   return $this.css({left:0})
                        }
            }
            
            

})();

