(function() {

    var window = this,
    RA = window.RA = function() {
        return new RA.fn.initialize();
    };

    RA.fn = RA.prototype = {
        initialize: function() {
            return this;
        }
        ,foo:function() { return 'foo' }
    };
    RA.fn.initialize.prototype = RA.fn;

    RA.vars  = {};
    RA.begin = [];
    RA.ready = [];
    RA.utils = {};

    RA.run = function(dst) {
      RA.run_begin();
      RA.run_ready();
    }

    RA.run_begin = function() {
        var begin = this.begin;
        for (var i = 0; i < begin.length; i++) {
            (begin[i])();
        }
    }

    RA.run_ready = function(dst) {
        var ready = this.ready;
        $(document).ready(function() {
            if ( !dst ) dst = document.body;
            for (var i = 0; i < ready.length; i++) {
                (ready[i])(dst);
            }
        });
    }

    RA.dispatch = function(path, func) {
      if ( location.pathname.match(path) ) func();
    }

    String.prototype.toUpperCaseFirst = function() {
        return this.replace(/\w+/g, function(word) {
            return word.charAt(0).toUpperCase() + word.substr(1);
        });
    };

    $.ajaxSetup({
        scriptCharset: 'UTF-8',
    });

    $.fn.incr = function() {
      var $this = $(this);
      $this.text( (parseInt($this.text()) || 0 ) + 1 );
    };

    RA.utils.appendCss = function(href) {
        // append already
        if ( $('head link[href="' + href + '"]').size() ) return;

        var link = document.createElement('link');
        link.rel = 'stylesheet';
        link.type = 'text/css';
        link.charset = 'UTF-8';
        link.href = href;
        document.getElementsByTagName('head')[0].appendChild(link);
    };

    $.browser = $.extend( $.browser, {
        mobileSafari: /ipad|iphone|ipod/.test( navigator.userAgent.toLowerCase() ),
    });

})();
