
var tweetURI = {
    open: function(anchor) {
        var width = 550;
        var height = 450;
    
        var left = Math.round(screen.width / 2 - width / 2);
        var top = 0;
        
        if (screen.height > height)
            top = Math.round(screen.height / 2 - height / 2);
        
        var popup = window.open(
            anchor.href, 'twitter_tweet', 
            'left=' + left + ",top=" + top + ",width=" + width + ",height=" + height
            + ",personalbar=0,toolbar=0,scrollbars=1,resizable=1");
        
        if (popup) {
            popup.focus();
        }
        else {
            window.location.href = elem.parentNode.href;
        }
    },

    isIE: (document.documentElement.getAttribute('style') == document.documentElement.style),

    bind: function(anchor) {
        this.anchor = anchor;
        
        tweetURI.isIE ? anchor.setAttribute('onclick', new Function('tweetURI.open(this); return false;'))
            : anchor.setAttribute('onclick', 'tweetURI.open(this); return false;');
    },

    set: function(uri, text) {
        this.anchor.href = 
            'http://twitter.com/share?url=' + encodeURIComponent(uri) + '&text=' + encodeURIComponent(text);
    }
};


