﻿
//PAGE SPECIFIC for ~/access/claim.aspx

$(document).ready(function()
    {
        //setup events
        $(aContinue).click(function(){aContinue_OnClick();return false;});

        //focus
        if (txtEmailAddress.value.length > 0)
            txtClaimNumber.focus();
        else
            txtEmailAddress.focus();
    }
);

function Validates()
{
    ErrorClear(txtEmailAddress);
    ErrorClear(txtClaimNumber);
    ErrorClear(txtPin);

    if (txtEmailAddress.value.length == 0)
    {
        ErrorSet(txtEmailAddress, "Please enter your Email Address.");
        return false;
    }
    else
    {
        if (!IsValidTextEmailAddress(txtEmailAddress.value))
        {
            ErrorSet(txtEmailAddress, "This Email Address is invalid.");
            return false;
        }
    }

    if (txtClaimNumber.value.length == 0)
    {
        ErrorSet(txtClaimNumber, "Please enter your Claim Number.");
        return false;
    }

    if (txtPin.value.length == 0)
    {
        ErrorSet(txtPin, "Please enter a PIN. &nbsp;This was provided to you in the email.");
        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();
    self.scrollTo(0, 0);
}
function aContinue_OnClick()
{
    if (Validates())
    {
        $(aContinue).children("span.Mid").html("Please wait...");
        $(aContinue).removeAttr("href");
        $(aContinue).unbind();

        lnkContinue_Click();
    }
}
