
//PAGE SPECIFIC for ~/controls/signupform.aspx

$(document).ready(function()
    {
        //setup events
        $(aContinue).click(function(){aContinue_OnClick();return false;});
        $(txtComments).keyup(function(e){return txtComments_OnKeyUp(e);});
    }
);

function Validates()
{
    ErrorClear(txtFirstName);
    ErrorClear(txtLastName);
    ErrorClear(txtEmailAddress);
    ErrorClear(txtPhoneNumber);
    ErrorClear(txtCity);
    ErrorClear(ddlStateId);
    ErrorClear(txtZipCode);

    if (txtFirstName.value.length == 0)
    {
        ErrorSet(txtFirstName, "Please enter a First Name. &nbsp;(Feel free to make something up)");
        return false;
    }

    if (txtLastName.value.length == 0)
    {
        ErrorSet(txtLastName, "Please enter a First Name. &nbsp;(Feel free to make something up)");
        return false;
    }

    if (txtEmailAddress.value.length > 0 && !IsValidTextEmailAddress(txtEmailAddress.value))
    {
        ErrorSet(txtEmailAddress, "The Email Address you entered is invalid. &nbsp;This isn't required.");
        return false;
    }

    if (txtZipCode.value.length == 0)
    {
        ErrorSet(txtZipCode, "Please enter your Zip Code. &nbsp;(This is just so we can see how everyone is spread out)");
        return false;
    }

    return true;
}
function ErrorClear(el)
{
    var par = $(el).parent()

    par.attr("class", "Control");
    par.children("span.Message").html("");
}
function ErrorSet(el, Message)
{
    var par = $(el).parent()

    par.attr("class", "Control Errored");
    par.children("span.Message").html(Message);
    el.focus();
}
function aContinue_OnClick()
{
    if (Validates())
    {
        $(aContinue).children("span.Mid").html("Please wait...");
        $(aContinue).removeAttr("href");
        $(aContinue).unbind();
        $("div.Buttons a.Cancel").hide();

        lnkContinue_Click();
    }
}
function txtComments_OnKeyUp(e)
{
    if (txtComments.value.length > 1000)
    {
        txtComments.value = txtComments.value.substring(0, 1000);
    }
}
