﻿$("#MetalsGuru").getTwitter({
    userName: "MetalsGuru",
    numTweets: 1,
    loaderText: "Loading tweets...",
    slideIn: true
});
$("#MetalsGuruUpBtn").click(function() {

    var curr = $('#MetalsGuru_update_list li').attr("id");
    if (curr != null) {
        curr = curr.substring(curr.lastIndexOf('_') + 1, curr.length);
        curr--;
        if (curr < 0 && MetalsGuru_Page > 0) {
            $.getScript('http://pitguru.com/twitter-status.aspx?userName=MetalsGuru&rd=' + Math.random() + '&page=' + (MetalsGuru_Page - 1), function() {
                if (MetalsGuru_status_list.length > 0) {
                    MetalsGuru_Page--;
                    curr = MetalsGuru_status_list.length - 1;
                    displayItem(curr, 'MetalsGuru');
                }
                else { // end of status list
                    // todo

                }
            });
        }
        else if (curr < 0) {
            curr = 0;
            displayItem(curr, 'MetalsGuru');
        }
        else {
            if (MetalsGuru_status_list.length <= 0) {
                $.getScript('http://pitguru.com/twitter-status.aspx?userName=MetalsGuru&rd=' + Math.random() + '&page=' + MetalsGuru_Page, function() {
                    if (MetalsGuru_status_list.length > 0) {
                        curr = MetalsGuru_status_list.length - 2;
                        displayItem(curr, 'MetalsGuru');
                    }
                    else { // end of status list
                        // todo

                    }
                });
            }
            displayItem(curr, 'MetalsGuru');
        }
    }
    return false;
});

$("#MetalsGuruDownBtn").click(function() {
    var curr = $('#MetalsGuru_update_list li').attr("id");
    if (curr != null) {
        curr = curr.substring(curr.lastIndexOf('_') + 1, curr.length);
        curr++;
        if (curr == MetalsGuru_status_list.length) {
            $.getScript('http://pitguru.com/twitter-status.aspx?userName=MetalsGuru&rd=' + Math.random() + '&page=' + (MetalsGuru_Page + 1), function() {

                if (MetalsGuru_status_list.length > 0) {

                    MetalsGuru_Page++;
                    curr = 0;
                    displayItem(curr, 'MetalsGuru');
                }
                else { // end of status list
                    // todo                                
                }
            });
        }
        else {
            displayItem(curr, 'MetalsGuru');
        }

    }
    return false;
});
