(function(jq){
    jq.fn.standard = function() { 
        
        return this.each( function() {
            
            var _self = jq(this) ;          
            
            // OPEN CLOSE CONTENT
            var _button = jq('<a id="open_close_button" alt="" />').appendTo(_self);
            var _changeCss = function() {
                if(_button.hasClass('closed')) {
                    _button.removeClass('closed');
                } else {
                    _button.addClass('closed');
                }
            }
            
            var _openClose = function() {
                if(_self.position().left == 0) {
                    _self.animate({"left": "-472px"}, 500, _changeCss);
                } else {
                    _self.animate({"left": "0"}, 500, _changeCss);
                }
            }
            
            // SCROLL
            var _body = _self.find('div.text');
            if(_body.position()) {
                var _height = 450-_body.position().top
                if (_body.height()>_height) {
                    _body.css({
                        'height':_height + 'px',
                        'width':'430px'
                    }).jScrollPane({
                        verticalGutter:22
                    });
                }
            }
            
            var _verticalCenter = function() {
                var top = Math.round((jq('#main_content').height() - _self.outerHeight())/2);
                top = top > 0 ? top : 0;
                _self.css({'top':top+'px'});
            }
            
            // INIT
            _button.click(_openClose);
            jq(window).resize(_verticalCenter);
            _verticalCenter();
        });
    }
})(jQuery);
