// Javascript for the signup page
function signupSubmit() {
    $(".error-msg").css ("display", "none");
    $("input[type=text]").removeClass ("invalid");
    elt = $("#name");
    var name = elt.val();
    if (!name || name.length > 120) {
        elt.addClass ("invalid").focus();
        var errorPanel = $("#name-error").css ("display", "block");
        // setTimeout (function () { errorPanel.slideUp (2000);}, 2000);
        return  false;
    }
    var elt = $("#email");
    var email = sf.data.TypeInfo.converter ("emailAddress") (elt.val());
    if (!email || email.length > 120) {
        elt.addClass ("invalid").focus();
        var errorPanel = $("#email-error").css ("display", "block");
        // setTimeout (function () { errorPanel.slideUp (2000);}, 2000);
        return  false;
    }
    return true;
}

$(function () {
    $(".signup-submit").css ("display", "block");
    var dlg = new ModalDialog();
    $(".signup-note a").click (function () {
        dlg.show ($("#tos-modal"));        
    });
    $("#close-modal").click (function () { dlg.hide(); });
    $("#name").focus();
    var theForm = document.signupForm; // This seems to be the only way to refer to the form that works with IE
    theForm.onsubmit = signupSubmit;
    theForm.action = "/pages/ec/thankyou.html";
})
