function resetInviteRequestForm()
{
    try
    {
        document.getElementById('initialId').value = '';
        document.getElementById('ISAF_ranking').value = '';
        document.getElementById('ISAF_ID').value = '';
        document.getElementById('date').value = '';
        document.getElementById('skipper').value = '';
        document.getElementById('email').value = '';
        document.getElementById('address').value = '';
        document.getElementById('telephone').value = '';
        document.getElementById('city').value = '';
        document.getElementById('post_code').value = '';
        document.getElementById('country').value = '';
        document.getElementById('crew1').value = '';
        document.getElementById('email1').value = '';
        document.getElementById('crew2').value = '';
        document.getElementById('email2').value = '';
        document.getElementById('crew3').value = '';
        document.getElementById('email3').value = '';
        document.getElementById('crew4').value = '';
        document.getElementById('email4').value = '';
        document.getElementById('crew5').value = '';
        document.getElementById('email5').value = '';
        document.getElementById('club').value = '';
        document.getElementById('authority').value = '';
        document.getElementById('advertising').value = '';
    }
    catch(ex)
    {
        alert('An error occured while clearing the invite request form.');
        return;
    }
}

function validateInviteRequestForm()
{
    try
    {
        //valid id is LWM2008<010[4200 to 4599]> . Case is ignored.
        if(!(new RegExp('^LWM2008<0104[2-5][0-9][0-9]>$','i').test(document.getElementById('initialId').value)))
        {
            alert('Request form ID must be valid.');
            document.getElementById('initialId').focus();
            return;
        }
        
        if(document.getElementById('ISAF_ranking').value == '')
        {
            alert('ISAF Match Race Ranking is a mandatory field.');
            document.getElementById('ISAF_ranking').focus();
            return;
        }
        if(document.getElementById('ISAF_ID').value == '')
        {
            alert('ISAF Sailor ID is a mandatory field.');
            document.getElementById('ISAF_ID').focus();
            return;
        }
        if(document.getElementById('date').value == '')
        {
            alert('Date is a mandatory field.');
            document.getElementById('date').focus();
            return;
        }
        if(document.getElementById('skipper').value == '')
        {
            alert('Skipper is a mandatory field.');
            document.getElementById('skipper').focus();
            return;
        }
        if(document.getElementById('email').value == '')
        {
            alert('E-mail is a mandatory field.');
            document.getElementById('email').focus();
            return;
        }
        if(document.getElementById('address').value == '')
        {
            alert('Address is a mandatory field.');
            document.getElementById('address').focus();
            return;
        }
        if(document.getElementById('telephone').value == '')
        {
            alert('Mobile is a mandatory field.');
            document.getElementById('telephone').focus();
            return;
        }
        if(document.getElementById('city').value == '')
        {
            alert('City is a mandatory field.');
            document.getElementById('city').focus();
            return;
        }
        if(document.getElementById('post_code').value == '')
        {
            alert('Post code is a mandatory field.');
            document.getElementById('post_code').focus();
            return;
        }
        if(document.getElementById('country').value == '')
        {
            alert('Country is a mandatory field.');
            document.getElementById('country').focus();
            return;
        }
        if(document.getElementById('club').value == '')
        {
            alert('Club is a mandatory field.');
            document.getElementById('club').focus();
            return;
        }
        if(document.getElementById('authority').value == '')
        {
            alert('National Authority is a mandatory field.');
            document.getElementById('authority').focus();
            return;
        }
        
        document.getElementById('submitButton').click();
        return;
    }
    catch(ex)
    {
        alert('An error occured while submitting the invite request form. Try again.');
        return;
    }
}
