﻿$("#SoftsGuru").getTwitter({
    userName: "SoftsGuru",
    numTweets: 1,
    loaderText: "Loading tweets...",
    slideIn: true
});
$("#SoftsGuruUpBtn").click(function() {
    var curr = $('#SoftsGuru_update_list li').attr("id");
    if (curr != null) {
        curr = curr.substring(curr.lastIndexOf('_') + 1, curr.length);
        curr--;
        if (curr < 0 && SoftsGuru_Page > 0) {
            if ($('#SoftsGuru_loadscreen').is(":hidden")) {
                $('#SoftsGuru_loadscreen').show();
                $('#SoftsGuru_loadscreen').css({ opacity: 0.4 });
            } 
            $.getScript('http://pitguru.com/twitter-status.aspx?userName=SoftsGuru&rd=' + Math.random() + '&page=' + (SoftsGuru_Page - 1), function() {
                if (SoftsGuru_status_list.length > 0) {
                    SoftsGuru_Page--;
                    curr = SoftsGuru_status_list.length - 1;
                    displayItem(curr, 'SoftsGuru');
                    $('#SoftsGuru_loadscreen').hide();
                }
                else { 
                    $('#SoftsGuru_loadscreen').hide();
                }
            });
        }
        else if (curr < 0) {
            curr = 0;
            displayItem(curr, 'SoftsGuru');
        }
        else {
            if (SoftsGuru_status_list.length <= 0) {
                if ($('#SoftsGuru_loadscreen').is(":hidden")) {
                    $('#SoftsGuru_loadscreen').show();
                    $('#SoftsGuru_loadscreen').css({ opacity: 0.4 });
                }
                $.getScript('http://pitguru.com/twitter-status.aspx?userName=SoftsGuru&rd=' + Math.random() + '&page=' + SoftsGuru_Page, function() {
                    if (SoftsGuru_status_list.length > 0) {
                        curr = SoftsGuru_status_list.length - 2;
                        displayItem(curr, 'SoftsGuru');
                        $('#SoftsGuru_loadscreen').hide();
                    }
                    else {
                        $('#SoftsGuru_loadscreen').hide();
                    }
                });
            }
            displayItem(curr, 'SoftsGuru');
        }
    }
    return false;
});

$("#SoftsGuruDownBtn").click(function() {
    var curr = $('#SoftsGuru_update_list li').attr("id");
    if (curr != null) {
        curr = curr.substring(curr.lastIndexOf('_') + 1, curr.length);
        curr++;
        if (curr == SoftsGuru_status_list.length) {
            if ($('#SoftsGuru_loadscreen').is(":hidden")) {
                $('#SoftsGuru_loadscreen').show();
                $('#SoftsGuru_loadscreen').css({ opacity: 0.4 });
            }
            $.getScript('http://pitguru.com/twitter-status.aspx?userName=SoftsGuru&rd=' + Math.random() + '&page=' + (SoftsGuru_Page + 1), function() {
                if (SoftsGuru_status_list.length > 0) {
                    SoftsGuru_Page++;
                    curr = 0;
                    displayItem(curr, 'SoftsGuru');
                    $('#SoftsGuru_loadscreen').hide();
                }
                else { 
                    $('#SoftsGuru_loadscreen').hide();                
                }
            });
        }
        else {
            displayItem(curr, 'SoftsGuru');
        }

    }
    return false;
});
