
function validate_form()
{
    var ret;
    var xmlhttp = getXmlHttpRequestObject();
    var military = "";

    if( document.forms[0].military.type == "hidden" )
    {
        military = document.forms[0].military.value;
    }
    else
    {
        if( document.forms[0].military[0].checked )
        {
            military = document.forms[0].military[0].value;
        }
        else if( document.forms[0].military[1].checked )
        {
            military = document.forms[0].military[1].value;
        }
    }

    var url = 'process.php?progress=validate' +
                          '&title='+escape(document.forms[0].firstname.value) +
                          '&firstname='+escape(document.forms[0].firstname.value) +
                          '&lastname='+escape(document.forms[0].lastname.value) +
                          '&email='+escape(document.forms[0].email.value) +
                          '&address1='+escape(document.forms[0].address1.value) +
                          '&city='+escape(document.forms[0].city.value) +
                          '&state='+escape(document.forms[0].state.value) +
                          '&zip='+escape(document.forms[0].zip.value) +
                          '&ssn1='+escape(document.forms[0].ssn1.value) +
                          '&ssn2='+escape(document.forms[0].ssn2.value) +
                          '&ssn3='+escape(document.forms[0].ssn3.value) +
                          '&homephone1='+escape(document.forms[0].homephone1.value) +
                          '&homephone2='+escape(document.forms[0].homephone2.value) +
                          '&homephone3='+escape(document.forms[0].homephone3.value) +
                          '&cellphone1='+escape(document.forms[0].cellphone1.value) +
                          '&cellphone2='+escape(document.forms[0].cellphone2.value) +
                          '&cellphone3='+escape(document.forms[0].cellphone3.value) +
                          '&monthob='+escape(document.forms[0].monthob.value) +
                          '&dayob='+escape(document.forms[0].dayob.value) +
                          '&yearob='+escape(document.forms[0].yearob.value) +
                          '&bank_aba='+escape(document.forms[0].bank_aba.value) +
                          '&bank_account_num='+escape(document.forms[0].bank_account_num.value) +
                          '&income_monthly_net='+escape(document.forms[0].income_monthly_net.value) +
                          '&military='+escape(military); 

    printDebugMsg( url );

    ret = doRequest( url );
    return ret;
}

function doRequest( url )
{
   if( xmlhttp.readyState == 4 || xmlhttp.readyState == 0 )
   {
       xmlhttp.open("GET", url, false);
       xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
       xmlhttp.send(null);

       printDebugMsg( 'Response: ' + xmlhttp.responseText.length + " : " + xmlhttp.responseText );

       if( xmlhttp.responseText.length <= 5 )
       {
           return true;
       }

       alert( "Please fix the following errors:\n\n"+xmlhttp.responseText );
       return false;
   }

   return true;
}

function printDebugMsg( msg )
{
//    alert( msg );
}
