$(document).ready(function () {

    $("a.smExpand").click(function () {
        var theHash = $(this).attr("href");
        var theText = $(this);
        var ulState = $("ul" + theHash);
        if (ulState.is(":visible")) {
            theText.text('List more...');
            ulState.slideUp("slow");
        } else {
            theText.text('Hide...');
            ulState.slideDown("slow");
        }
        return false;
    });

    $("a.expand").click(function () {
        var theHash = $(this).attr("href");
        var divState = $("div" + theHash);
        if (divState.is(":visible")) {
            divState.slideUp("slow");
        } else {
            divState.slideDown("slow");
        }
        return false;
    });

    $('.siteImage').load(function () {
        $(this).wrap(function () {
            return '<span class="' + $(this).attr('class') + '" style="background:url(' + $(this).attr('src') + ') no-repeat center center; width: ' + $(this).width() + 'px; height: ' + $(this).height() + 'px;" />';
        });
        $(this).css("opacity", "0");
    });

    $('input.searchButton').tipsy({ fade: true });
    $('a.signup').tipsy({ fade: true });
    $('a.becomefan').tipsy({ fade: true, gravity: 'e' });
    $('a.followus').tipsy({ fade: true, gravity: 'e' });
    $('img.featured').tipsy({ fade: true, gravity: 'w' });

    $("a.signin").click(function () {
        $("fieldset#signinMenu").toggle();
        return false;
    });

    $("fieldset#signinMenu").mouseup(function () {
        return false
    });    

    $(document).mouseup(function (e) {
        if ($(e.target).parent("a.signin").length == 0) {
            $("fieldset#signinMenu").hide();
        }
    });

    // placeholder text
    $('[placeholder]').focus(function () {
        var input = $(this);
        if (input.val() == input.attr('placeholder')) {
            input.val('');
            input.removeClass('placeholder');
        }
    }).blur(function () {
        var input = $(this);
        if (input.val() == '' || input.val() == input.attr('placeholder')) {
            input.addClass('placeholder');
            input.val(input.attr('placeholder'));
        }
    }).blur();

    $('[placeholder]').parents('form').submit(function () {
        $(this).find('[placeholder]').each(function () {
            var input = $(this);
            if (input.val() == input.attr('placeholder')) {
                input.val('');
            }
        })
    }); 



});
