<xpage path="/RegisterCorp" title="Register as Corporation" access="public" bgcolor="eeeeee" ops="noindex">
    <xblock name="dogInclude"/>
    <xform name="formRegCorp" action="hdlRegCorp" class="corp" recaptcha="true">
    <xhide name="lastpage" value="%x:referer;"/>
    <table width="96%" align="center" border="0" cellspacing="0" cellpadding="0">
    <tr><td class="title">Corporate Registration</td></tr>
    <tr><td height="20"> </td></tr>
    <tr>
        <td valign="top" class="main">
        <p>Use this form to apply for corporate membership.</p>
        </td>
    </tr>
    <xwho user="public">
    <tr><td height="20"> </td></tr>
    <tr>
        <td height="20">
        Please be aware that by loging in, you are consenting to the use of cookies. Please read our cookie policy to <a href="/cookies">find out more</a>
        </td>
    </tr>
    </xwho>
    <tr><td height="40"> </td></tr>
    </table>
    <table width="96%" align="center" border="0" cellspacing="0" cellpadding="0" class="main">
    <tr>
        <td width="15"> </td>
        <td valign="fld">Organization details:</td>
        <td valign="fld">Description of your organization's interests and activities:</td>
    </tr>
    <tr>
        <td width="15"> </td>
        <td valign="top">
        <table class="main">
        <tr height="18"><td class="red">Organization:</td>   <td><xfield var="orgname"  fldspec="fsName"      flags="req"/></td></tr>
        <tr height="18"><td class="red">Corp reg no:</td>    <td><xfield var="regNo"    fldspec="fsRegNo"     flags="req"/></td></tr>
        <tr height="18"><td class="red">Street Address:</td> <td><xfield var="street"   fldspec="fsAddr"      flags="req"/></td></tr>
        <tr height="18"><td class="red">City:</td>           <td><xfield var="city"     fldspec="fsAddr"      flags="req"/></td></tr>
        <tr height="18"><td class="red">State/County:</td>   <td><xfield var="state"    fldspec="fsAddr"      flags="req"/></td></tr>
        <tr height="18"><td class="red">Zip/Post code:</td>  <td><xfield var="zcode"    fldspec="fsZip"       flags="req"/></td></tr>
        <tr height="18"><td class="red">Main Website:</td>   <td><xfield var="wsite"    fldspec="fsSite"      flags="req"/></td></tr>
        <tr height="18"><td class="fld">Primary Contact</td> <td> </td></tr>
        <tr height="18"><td class="red">Salutation:</td>     <td><xfield var="salute"   fldspec="enumSalute"  flags="req"/></td></tr>
        <tr height="18"><td class="red">Firstname:</td>      <td><xfield var="fname"    fldspec="fsName"      flags="req"/></td></tr>
        <tr height="18"><td class="red">Lastname:</td>       <td><xfield var="lname"    fldspec="fsName"      flags="req"/></td></tr>
        <tr height="18"><td class="red">EMail:</td>          <td><xfield var="email"    fldspec="fsEmail"     flags="unique/req" newin="subscriber.uname"/></td></tr>
        <tr height="18"><td class="red">Position:</td>       <td><xfield var="posn"     fldspec="fsDesc"      flags="req"/></td></tr>
        <tr height="18"><td class="red">Choose password:</td><td><xfield var="password" fldspec="fsPass"      flags="req"/></td></tr>
        </table>
        </td>
        <td valign="top"><xfield var="data" rows="12" cols="50" size="2000" type="string" flags="req"/></td></tr>
    </table>
    <table width="96%" align="center" border="0" cellspacing="0" cellpadding="0" class="fld">
    <tr height="50"><td align="center"><recaptcha/></td></tr>
    <tr height="50"><td align="center"><xbutton show="Submit"/></td></tr>
    <tr height="50" bgcolor="#CCCCCC"><td class="vb10blue"><center>MyWebsite</center></td></tr>
    </table>
    </xform>
</xpage>
<formhdl name="hdlRegCorp" form="formRegCorp" ops="cookie">
    <procdata>
        <setvar name="iniCode" type="unt32" value="%x:usecs;"/>
        <setvar name="userEm" type="emaddr" value="%e:email;"/>
        <commit class="subscriber">
            <seteq member="uname"   input="%e:email;"/>
            <seteq member="upass"   input="%e:password;"/>
            <seteq member="utype"   input="corp"/>
            <seteq member="crdate"  input="%x:datetime;"/>
            <seteq member="orgname" input="%e:orgname;"/>
        </commit>
        <commit class="corp">
            <seteq member="regNo"   input="%e:regNo;"/>
            <seteq member="street"  input="%e:street;"/>
            <seteq member="city"    input="%e:city;"/>
            <seteq member="state"   input="%e:state;"/>
            <seteq member="zcode"   input="%e:zcode;"/>
            <seteq member="wsite"   input="%e:wsite;"/>
            <seteq member="salute"  input="%e:salute;"/>
            <seteq member="fname"   input="%e:fname;"/>
            <seteq member="lname"   input="%e:lname;"/>
            <seteq member="posn"    input="%e:posn;"/>
            <seteq member="data"    input="%e:data;"/>
        </commit>
        <commit class="subscriber" modify="%e:email;">
            <seteq member="uaddr" input="%x:objid.corp;"/>
        </commit>
        <sendemail from="info@mysite.com" to="%e:email;" subject="My Site Membership Application">
        Dear %e:salute; %e:fname; %e:lname; of %e:orgname;
        Thankyou for registering with My Site. Your initial login code is %corpCode; and it is good for 1 hour. Enter this code instead of your
        selected password in the login screen.
        This email has been generated by a submission to the My Site Membership Application form (www.mysite.com/RegisterCorp)
        If you have recived this in error, please ignore
        </sendemail>
        <sendemail from="info@mysite.com" to="support@mysite.com" subject="My Site Membership Application">
        %e:fname; %e:lname; of %e:orgname;
        Has submitted the following contact details:-
        %data;
        </sendemail>
    </procdata>
    <error goto="/RegisterCorp"/>
    <response name="formRegCorp" bgcolor="eeeeee">
        <xblock name="myInclude"/>
        <xform name="formCkCorp1" action="hdlCkCorp">
        <table width="96%" align="center" border="0" cellspacing="0" cellpadding="0">
        <tr><td width=5 height=25> </td></tr>
        <tr><td align=center class=title>Email Verification</td></tr>
        <tr height="250">
            <td class="main">
            Thank you %u:fname; %u:lname; for your applicaion on belhalf of %u:orgname; for your application for membership of My Site. An email
            has been sent to %u:email; with a code. Please check your email (including the junk folder). Then cut and paste the code here.
            </td>
        </tr>
        <tr height="50"><td align="center" class="fld">Code:</td><td><xfield fldspec="fsUsec" var="testCode" flags="req"/></td></tr>
        <tr height="50"><td align="center"><xbutton show="Complete Registration"/></td></tr>
        </table>
        </xform>
    </response>
</formhdl>
<formhdl name="hdlCkCorp" form="formCkCorp1" ops="cookie">
    <procdata>
        <testeq param1="%e:testCode;" param2="%s:iniCode;"/>
        <commit class="subscriber" modify="%s:userEm;">
            <seteq member="status" input="%s:userEm;"/>
        </commit>
        <logon user="%s:userEm;"/>
    </procdata>
    <response name="CorpCodeOK" bgcolor="eeeeee">
        <xblock name="myInclude"/>
        <table width="96%" align="center" border="0" cellspacing="0" cellpadding="0">
        <tr><td width=5 height=25> </td></tr>
        <tr><td align=center class=title>Registration Complete</td></tr>
        <tr height="250">
            <td class="main">
            Your registration as %u:orgname; is now complete. You are logged in and may now use the members area.
            </td>
        </tr>
        <tr height="50"><td align="center"><xbutton show="Continue" goto="%s:lastpage;"/></td></tr>
        </table>
    </response>
    <error name="CorpCodeErr" bgcolor="eeeeee">
        <xblock name="myInclude"/>
        <xform name="formCkCorp2" action="hdlCkCorp">
        <table width="96%" align="center" border="0" cellspacing="0" cellpadding="0">
        <tr><td width=5 height=25> </td></tr>
        <tr><td align=center class=title>Oops! Wrong Code!</td></tr>
        <tr height="250"><td class="main">Please check the email again and type in or cut and paste the code.</td></tr>
        <tr height="50"><td align="center" class="fld">Code:</td><td><xfield fldspec="fsUsec" var="testCode" flags="req"/></td></tr>
        <tr height="50"><td align="center"><xbutton show="Complete Registration"/></td></tr>
        </table>
        </xform>
    </error>
</formhdl>