$(document).ready(function() {

    var pw = $('#webmail_password, #basecamp_password, #extranet_password');
    var pwc = $('#webmail_password_clear, #basecamp_password_clear, #extranet_password_clear');

    pw.hide();
    pwc.show();


    pwc.focus(function() {

        var i = $(this);
        var id = i.attr('id');


        // console.log();

        $('#' + id.substring(0, id.lastIndexOf('_'))).show().select();

        i.hide();

    });

    pw.blur(function() {

        var i = $(this);
        var id = i.attr('id');

        if (i.val() == '') {
            i.hide();
            $('#' + id + '_clear').show();
        }
    });


    var animateDirection = "down";

    $("#client_login_button_link").click(function(event) {
        event.preventDefault();
        var topValue = (animateDirection == "down") ? 0 : -178;
        animateDirection = (animateDirection == "down") ? "up" : "down";
        $("#client_login").animate(
        {
            top: topValue
        }, 500, "easeInOutCirc");
    });

    $('#webmail_username, #basecamp_username, #extranet_username').focus(function() {
        if (this.value == this.defaultValue) {
            this.value = '';
        }
        if (this.value != this.defaultValue) {
            this.select();
        }
    }).blur(function() {
        if ($.trim(this.value) == '') {
            this.value = (this.defaultValue ? this.defaultValue : '');
        }
    });
});