var Twuixe = function(){
    var HOME_URL = 'http://juixe.com/tweetbox/';
    
    var doc = function() {
        return {
            win:window,
            loc:window.location,
            doc:window.document,
            enc:encodeURIComponent,
            x:'undefined'
        }
    }();
    
    var  getURL = function (post) {
        return HOME_URL+'t/'+post+'.php';
    }
    
    return {
        setStatus: function(user, text) {
            var update = $('#upate-status-'+user.username);
            update.hide();
            var action = getURL('update');
            $.post(action,
                { status: text, source: 'Juixe', username: user.username, password: user.password},
                function(data) {
                    update.html(text);
                    update.fadeIn(1000);
                },
                'json'
            );
        },
        getTinyurl: function(user, url) {
            var status_block = $('#status-'+user.username);
            var action = getURL('tinyurl');
            $.post(action,
                {tiny: url},
                function(data) {
                    status_block.val(status_block.val() + data.tinyurl);
                },
                'json'
            );
        },
        createShortcut: function() {
            var desktop = google.gears.factory.create('beta.desktop');
            desktop.createShortcut('Tweetbox 0.1',
                HOME_URL,
                {
                    '128x128': HOME_URL + 'logo-128.png',
                    '48x48': HOME_URL + 'logo-48.png',
                    '32x32': HOME_URL + 'logo-32.png',
                    '16x16': HOME_URL + 'logo-16.png'
                },
                'Juixe Tweebox 0.1 Twitter Client'
            );
        }
    };
}();
