$(document).ready(function() {
    $('#quickLogin div.input input').focus(function() {
        $(this).siblings('span.inputLabel').hide();
    }).blur(function() {
        if ($(this).val() === '') { $(this).siblings('span.inputLabel').show(); }
    });

    $('#quickLogin div.input span.inputLabel').click(function() {
        $(this).siblings('input').focus();
    });

    $('#quickLogin div.input input').each(function(index) {
        if ($(this).val().length > 0) { $(this).siblings('span.inputLabel').hide(); }
        else { $(this).show(); }
    });
    
    $('a#srConnect').bind('click', function(event) {
        SR.Dialog.createWithPayload({
            title: 'SchoolRack CONNECT',
            content: '<p>Stay tuned! SchoolRack Connect will be here in June. Until then, <a href="/connect/">drop us a line</a> regarding CONNECT and we\'ll be sure to send you an email when it\'s ready!</p>',
            buttons: [
                { label: 'Close', type: 'target', callback: function() { SR.Dialog.destroy(); } },
            ]
        })
    });
    
    // Get recent blog posts from the SR Blog via JSON, and display them.
    $.getJSON('http://blog.schoolrack.com/feed/json/?callback=?', function(json) {
        $('ul.srBlogRSS li.loading').fadeOut();
        $.each(json.items, function(i, item) {
            if (i < 3) { $('ul.srBlogRSS').append('<li><a href="'+item.link+'">'+item.title+'</a></li>'); }
        });
        $('ul.srBlogRSS li a').click(function() {
            this.target = '_blank';
        });
    });
});