var email_text = 'Email';
var pass_text = 'Password';
var real_pass_field = '';
var fake_pass_field = '<input type="text" id="fakeField" name="fake" value="' + pass_text + '" class="vetLoginField vetLoginPassword" />';

$(document).ready(function() {
    $(".homeCenterboxDescription").hide();
    $('.homeCenterbox').cycle({
        fx:     'scrollLeft',
        speed:   300,
        timeout: 5000,
        pager:   '.homeCenterboxNav',
        pause:   1,
        before:  onBefore
     });

    $(".vetLoginSubmit").click(function() {
        document.loginform.submit();
    });

    /* Email Field */
    if( $("input.vetLoginUsername").attr("value") == '' ) {
        $("input.vetLoginUsername").attr("value", email_text);
    }

    $("input.vetLoginUsername").focus(function () {
        if( $(this).attr("value") == email_text ) {
            $(this).attr("value", '');
        }
    });

    $("input.vetLoginUsername").blur(function () {
        if( $(this).attr("value") == '' ) {
            $(this).attr("value", email_text);
        }
    });

    /* Password Field */
    if( $("input.vetLoginPassword").attr("value") == '' ) {
        real_pass_field = $("#fieldPassword").html();
        $("#fieldPassword").html(fake_pass_field);
    }

    $("input#fakeField").focus(function () {
        $("#fieldPassword").html(real_pass_field);
        $("#fieldPassword input").focus();
    });
});

function onBefore() {
    $(".homeCenterboxDescription").hide();
    var html_id = $(this).attr("id");

    // Make sure it's not hidden
    if( $("#cntrBx" + html_id).attr("title") != "hide" ) {
        // Load the text
        var title = $("#cntrBx" + html_id + " .cntrBxTitle").html();
        var description = $("#cntrBx" + html_id + " .cntrBxDesc").html();
        var url = $(this).attr("href");
        $("#cntrBxTitle").html(title);
        $("#cntrBxDesc").html(description);
        $("a.homeCenterboxLearnMore").attr("href",url);

        // Get the height of the text box
        var cntrBxHeight = $(".homeCenterboxDescription").height();

        // Set it outside of viewability then slide it up
        $(".homeCenterboxDescription").css("bottom", "-" + cntrBxHeight + "px")
            .show()
            .animate({"bottom": "+=" + cntrBxHeight + "px"}, "fast");
    }
}

