var Buzz = {
    init: function(){
        this.bindData();
    },   
    
    bindData: function(){
        var q = $.query.get('q');
        
        if (q == ""){
            q = "Just tweeted 2 grant a childs wish, #leapfish donates to #makeawish";
        }
                
        $.ajax({
            type:"GET",
            url:"/ResultsPages/tweetacause_buzz.aspx?text=" + q,
            success: function(msg){
                $('#olBuzz').html($(msg).find("#twitterResults").html());
            }
        });
                
        $.ajax({
            type:"GET",
            url:"/ResultsPages/tweetacause_meter.aspx",
            success: function(msg){
                var c = parseInt($(msg).find("#MeterPixels .Count").html());
                var h = parseInt($(msg).find("#MeterPixels .Pixels").html());
                if (h > 360){
                    h = 360;
                }

                $("#tweetCount").html(c);
                setTimeout(function(){
                    $("#tdMeter").animate({height: h + "px"}, 2000);
                }, 750)
                
            }
        });
        
        $('#tweetAboutDonation').live('click', function(){TweetACause();});
    }
}

function TweetACause(){
    var txtTweet = $('.tweetMessage');
    var url = 'http://twitter.com/home?status=' + $.URLEncode($('.tweetMessage').val());
    window.open(url);
}

$(document).ready(function() {
        Buzz.init();
    });