<?php
   /*
    * 20101125 - added email for registration - stephen
    * 20111031 - added Province ddl - pj    *
    */

   include_once("_nemo.basic.cls.php");

   $page = new NemoBasic();
   $page->title = " - Register";
   //captach module
   $_SESSION["security_code"] = "";
   include_once($page->Modules["captcha.mod.incl.php"]);
   include_once("webadmin/_nemo.email.cls.php");

   $captcha = $strOutput;

//Events
      //print_rr($_POST); die;
     // var_dump($_POST['Action']);
      if(isset($_POST['Action'])){
         // print_r($_POST);
         // die;
         $url = "https://www.google.com/recaptcha/api/siteverify";
         $data = [
            'secret'=> '6LezXNkZAAAAANHYxGKxW7BAv4ycocFxt-Nklrqe',
            'response' =>$_POST['g-recaptcha-response']
         ];
         $options = array(
            'http' => array(
              'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
              'method'  => 'POST',
              'content' => http_build_query($data)
            )
          );
  
        $context  = stream_context_create($options);
          $response = file_get_contents($url, false, $context);
  
        $res = json_decode($response, true);
      //   var_dump($res);
      if($res['success'] == true) {

			// Perform you logic here for ex:- save you data to database
  			echo '
			  		<strong>Success!</strong> Your inquiry successfully submitted.
		 		  ';
		} else {
			echo '
					  <strong>Error!</strong> You are not a human.
				  ';
		}
       

     }

   if($Action == "Submit")
   {
      //20110603 - reg post checks - pj

      //20120716 - added registration $post insert
      $xdb->doQuery("INSERT INTO `sysRegistration` (`IP`,`POST`)
         VALUES ('".$_SERVER['REMOTE_ADDR']."', \"". qs(serialize($_POST)) ."\")");
      //die;

      if(!isset($_POST['radPackage'])){
         header('Location: message.php?MID=2');
      }

      if(stripos($_POST[strEmail], "googlemail.com")){
         tblSpamInsert($_POST[strName], $_POST[strEmail]);
      }

      $row = $xdb->getRowSQL("SELECT * FROM sysSpam WHERE strEmail = ". $xdb->qs($_POST[strEmail]));//strIP = '".$_SERVER['REMOTE_ADDR']."' OR
      if($row)
         header('Location: message.php?MID=3');

      //save client
      //INI
      //$Debug = 1;
      $cdb = new NemoDatabase("tblClient", 0, null, $Debug);
      //print_rr($cdb->Fields);
      if($_POST[txtAddressPostal] == "") $_POST[txtAddressPostal] = $_POST[txtAddressPysical];
      $row = $cdb->getRowSQL("SELECT MAX(strMembershipNumber) as strMembershipNumber FROM tblClient WHERE strMembershipNumber > 0 AND strMembershipNumber < 9999999");//20110203 - added membership number



      $cdb->Fields[strMembershipNumber] = $row->strMembershipNumber + 1;
      $cdb->Fields[strClient] = $_POST[strName];
      $cdb->Fields[strID] = $_POST[strID];
      $cdb->Fields[strEmail] = $_POST[strEmail];
      $cdb->Fields[strPhone] = $_POST[strPhone];
      $cdb->Fields[strCell] = $_POST[strCell];
      $cdb->Fields[strWork] = $_POST[strWork];
      $cdb->Fields[txtAddressHome] = $_POST[txtAddressHome];
      $cdb->Fields[txtAddressPostal] = $_POST[txtAddressPostal];
      $cdb->Fields[strPostalCode] = $_POST[strPostalCode];
      $cdb->Fields[refAreaID] = $_POST[refAreaID];

      $cdb->Fields[strAccountHoldersName] = $_POST[strAccountHoldersName];
      $cdb->Fields[strAccountNumber] = $_POST[strAccountNumber];
      $cdb->Fields[strAccountType] = $_POST[strAccountType];
      $cdb->Fields[strBankName] = $_POST[strBankName];
      $cdb->Fields[strBranchCode] = $_POST[strBranchCode];
      $cdb->Fields[strSurvey] = $_POST[strSurvey];

      $cdb->Fields[blnActive] = 1;
      $cdb->Fields[dtRegistered] = date("Y-m-d");

      $cdb->Fields[strFirstUser] =
      $cdb->Fields[strLastUser] = "Registration";

      $cdb->Fields[dtFirstEdit] = date("Y-m-d H:i:s");
      $result = $cdb->Save();

      if($result->Error == 0)
      {
         if($_POST['PackageID'] > 0)
         {
         //get new ClientID
            $newClientID = $result->ID;
            $vdb = new NemoDatabase("tblVehicle", 0, null, $Debug);
            $vdb->Fields[refClientID] = $newClientID;
            $vdb->Fields[strVehicle] = $_POST['strVehicle'];
            $vdb->Fields[strRegistration] = $_POST['strRegistration'];
            $vdb->Fields[strColour] = $_POST['strColour'];
            $vdb->Fields[blnDefault] = 1;
            $vdb->Fields[dateLastUsedOn] = "";
            $vdb->Save();

            $row = $xdb->getRowSQL("SELECT * FROM tblPackage WHERE PackageID = '".$_POST['PackageID']."'");
            $strPackage = $row->strPackage;

            $cpdb = new NemoDatabase("tblClientPackage", null, null, $Debug);
            $cpdb->Fields[refClientID] = $newClientID;
            $cpdb->Fields[refPackageID] = $_POST['PackageID'];
            $cpdb->Fields[dblPrice] = $row->dblPriceInc;
            $cpdb->Fields[dblMinCharge] = $row->dblMinCharge;
            $cpdb->Fields[dblFreeKM] = $row->dblFreeKM;
            $cpdb->Fields[dblMinimumTrip] = $row->dblMinimumTrip;
            $cpdb->Fields[dblChargePerKM] = $row->dblChargePerKM;

            $cpdb->Fields[dblAmount] = $row->dblPriceInc * 1;
            $cpdb->Fields[intQuantity] = 1;
            $cpdb->Fields[blnActive] = 1;
            $cpdb->Fields[strFirstUser] =
            $cpdb->Fields[strLastUser] = "Registration";
            $cpdb->Fields[dtFirstEdit] = date("Y-m-d H:i:s");
            $cpdb->Save();

            $quantity = 0;
            if($_POST['chkFamilyDiscount'] == "on")
            {//20110707 - FM changes: only register a FM if FM -pj
               $row = $xdb->getRowSQL("SELECT * FROM tblPackage WHERE blnFamilyDiscountPackage = '1'");

               $quantity = $_POST['intQuantity'];

               $cpdb = new NemoDatabase("tblClientPackage", 0, null, 0);
               $cpdb->Fields[refClientID] = $newClientID;
               $cpdb->Fields[refPackageID] = $row->PackageID;

               $cpdb->Fields[dblPrice] = $row->dblPriceInc;
               $cpdb->Fields[dblAmount] = $row->dblPriceInc * $quantity;
               $cpdb->Fields[intQuantity] = $quantity;

               $cpdb->Fields[blnActive] = 1;
               $cpdb->Fields[strFirstUser] =
               $cpdb->Fields[strLastUser] = "Registration";
               $cpdb->Fields[dtFirstEdit] = date("Y-m-d H:i:s");
               $cpdb->Save();
            }

         }

         //Send the Email
         $nemoEmail = new NemoEmail($_POST[strEmail] , "Welcome new 1 For the Road Subscriber" , 0);
         $nemoEmail->addHeader("FROM", $page->SystemSettings["SMTP Send As"]);
         $nemoEmail->addHeader("BCC", $page->SystemSettings["SMTP BCC"]);
         $nemoEmail->Bcc = $page->SystemSettings["SMTP BCC"];
         $nemoEmail->From = $page->SystemSettings["SMTP Send As"];
         $nemoEmail->arrBody[1] = "Attention: ".$_POST[strName].",<br /><br />
You have successfully registered with 1 For The Road.<br /><br />
Your service will be activated shortly and you will be contacted.<br /><br />
You have registered with the following details:<br />
Name: ".$_POST[strName]."<br />
Email: ".$_POST[strEmail]."<br />
Cell: ".$_POST[strCell]."<br />
Phone: ".$_POST[strPhone]."<br />
Package: ".$strPackage."<br />
# Family members: ".$quantity."<br /><br />
Thanks<br />
The 1 For the Road Team";
         $nemoEmail->Save($arrFields);
         $nemoEmail->Send();

         //goto message page
         header('Location: message.php?MID=1');
         exit();
      }
      else
      {
         header('Location: message.php?MID=2');
      }
   }//eoSave

//begin form
//INI

   $required = "<B class='textRed' style='font-size: 20;'>*</B>";//"<img src='images/asterisk22.png' >";
   $intMonths = 1;

   $widthA = "5%";
   $widthB = "40%";
   $widthC = "55%";

   $rst = $xdb->doQuery("SELECT *, `blnOption:FamilyDiscount` as blnFamilyDiscount FROM tblPackage WHERE `blnOption:SellOnline` = 1 ORDER BY strDisplayOrder, strPackage");
   //make page dynamic: phase 2
   while($row = $xdb->fetch())
   { //print_rr($row);
      if($row->PackageID != 5){

         if($row->dblPriceInc != 0)
         {
            $intPriceInc = number_format($row->dblPriceInc/$intMonths,2);
            $strPriceOutput = "R".number_format($row->dblPriceInc/$intMonths,2);
         }
         else
         {
            $intPriceInc = 0;
            $strPriceOutput = "n/a";
         }

         $jsOnclick = "blnShowF.value = Math.abs($row->blnFamilyDiscount -1);
                        jsShowElement(\"divF\", blnShowF);
                        jsResetDiscount();
                        jsReTotal();
                        /*jsShowPackageInfo($row->PackageID);*/";
         //value='$row->PackageID'
         $familyDiscount = "blnOption:FamilyDiscount";
         $tblPackages .= "
         <tr>
            <td align=center>
               <input ".($_REQUEST['PID'] == $row->PackageID ? "checked" : "")." type=radio name='radPackage' id='radPackage[$row->PackageID]' onclick='$jsOnclick' value = '$row->PackageID'>
            </td>
            <td align=left>$row->strPackageHTML</td>
            <td align=right class=''>
               <input id ='intPriceInc_$row->PackageID' type=hidden name ='intPriceInc[$row->PackageID]' value='$intPriceInc' >
              <input id ='blnFamilyDiscount_$row->PackageID' type = hidden name ='blnFamilyDiscount[$row->PackageID]' value='".$row->$familyDiscount."' >". $strPriceOutput ."
            </td>
         </tr>";

         if($_REQUEST['PID'] == $row->PackageID)
         {
            $pickmeautoload = "blnShowF.value = Math.abs($row->blnFamilyDiscount -1); jsShowElement(\"divF\", blnShowF); jsReTotal(); ";
         }
      }
   }

   $tblPackages = "
      <input id ='PackageID' type = hidden name ='PackageID' value='0' />
      <table border='0' cellpadding='2' cellspacing='1' width='100%' id='tblPackages'>
         <caption>Purchase a Package</caption>
         <col width='$widthA'>
         <col width='$widthB'>
         <col width='$widthC'>
         <tr>
            <th>Select</th>
            <th>Package</th>
            <th colspan=1>Monthly Debit-Order Amount</th>
         </tr>
         $tblPackages
      </table>";

   $row = $xdb->getRowSQL("SELECT * FROM tblPackage WHERE blnFamilyDiscountPackage = 1");

   if($row->dblPriceInc != 0)
   {
      $strPackagePriceInc = number_format($row->dblPriceInc/$intMonths,2);
   }
   else
   {
      $strPackagePriceInc = "n/a";
   }
   $tblOptionFamilyDiscount = "
      <table border='0' cellpadding='2' cellspacing='1' width='100%' id='tblOptions'>
         <col width='30%'>
         <col width='20%'>
         <col width=''>
         <tr>
            <th>Add Family Discount</th>
            <th>Quantity</th>
            <th colspan=1>Monthly Debit-Order Amount</th>
         </tr>
         <tr>
            <td align=center><input type=checkbox name='chkFamilyDiscount' id='chkFamilyDiscount[$row->PackageID]' onclick='jsReTotal();'></td>
            <td align=center><input type=text name='intQuantity' onChange='jsReTotal()' id='intQuantity' value='1' onchange='removeAlpha(this);' class='controlText controlNumeric' maxlength=1></td>
            <td align=right><input id ='strPackagePriceInc_$row->PackageID' type=hidden name ='strPackagePriceInc[$row->PackageID]' value='$strPackagePriceInc' >R". $strPackagePriceInc ."</td>
      </table>";

   $widthA = "40%";
   $widthB = "60%";

   $ddlArea = $xdb->ListOptions("SELECT 0 as ControlValue, '- Select -' AS ControlText
                                UNION ALL
                                SELECT AreaID as ControlValue, strArea AS ControlText FROM tblArea WHERE refProvince = strArea
                                ORDER BY ControlText", null);

   //Security question calculation
   $r1 = rand(4,10);
   $r2 = rand(2,6);
   $arrOp = array("+","-","*");
   $op = $arrOp[rand(0,2)];

   $strQuestion = "$r1 $op $r2";
   $strAnswer = "";
   eval("\$strAnswer = $r1 $op $r2; ");
//





//CONTENT
   //20160623 - added package name, promotion code fieldsets - neils
   $page->Content =
      js("
      var blnShowF = Object();
      blnShowF.value=1;

      $js
      function jsResetDiscount()
      {
         if( $('input[name=chkFamilyDiscount]:checkbox:checked').length > 0)
         {
            $('input[name=chkFamilyDiscount]').removeAttr('checked');
         }
         $('#intQuantity').val(1);
      }
      function jsReTotal()
      {
         /*ini*/
         var packageID = $('input[name=radPackage]:checked').attr('id');
         var packageID = packageID.slice(11, -1);

         $('#PackageID').val(packageID);

         var blnPackageOptionFamilyDiscount = $('#blnFamilyDiscount_'+packageID+'').val();
         var intPackagePrice = $('#intPriceInc_'+packageID+'').val();
         var intFamilyDiscountTotal = 0.0;
         var totalAmount = 0.0;

         if(intPackagePrice == 'n/a')
         {
            intPackagePrice = 0;
         }

         /*Processing*/
         if( $('input[name=chkFamilyDiscount]:checkbox:checked').length > 0)
         {
            if(blnPackageOptionFamilyDiscount == 1)
            {
               var packageID = $('input[name=chkFamilyDiscount]').attr('id');
               var packageID = packageID.slice(18, -1);
               var intDiscountPrice = $('#strPackagePriceInc_'+packageID).val();
               if($('#intQuantity').val() > 0)
               {
                  intFamilyDiscountTotal = parseInt($('#intQuantity').val()) * parseFloat(intDiscountPrice);
               }
            }
         }
         else
         {
            $('#intQuantity').val(1);
         }

         totalAmount = parseFloat(intPackagePrice) + parseFloat(intFamilyDiscountTotal);
         vatAmount = totalAmount * 0.14;

         /*display*/
         $('#dblDtAmount').val(totalAmount);
      }
      ". getJSRemoveAlpha());
   $page->Content .="
   <form action='register.php' name='form' method=post>
   <p><span class='heading'>Subscribe & Become a Member</span></p>

   <fieldset>
      <legend>Packages</legend>
         <p>
            For more a more detailed description of each package, see the <a href='packages.php'>Packages</a> page.
         </p>

         $tblPackages
         $BR
         <div class='blokkie' id='divF' style='display:none;margin-bottom:20px;'>
            <p>
               <B>Family discounts</B>
               $BR
               Family members on the <B>
               <span class='textRed'>1</span> for
               <span class='textRed'>20</span>/
               <span class='textRed'>40</span>/<span class='textRed'>80</span></B> packages,
               living in the same household can take advantage of discounted membership and pay only R40 per person, per month.
            </p>
            $tblOptionFamilyDiscount
         </div>

         <table border='0' cellpadding='2' cellspacing='1' width='100%' id='tblPackages'>
            <caption>Check Out</caption>
            <col width='60%'>
            <col width='40%'>
            <tr>
               <td align=right>Package Name: </td>
               <td>
                  <input type=text class='controlText controlNumeric controlLabel' name='strPackageName' id='strPackageName' value=\"- None -\" readonly>
               </td>
            </tr>
            <tr>
               <td align=right>Monthly Debit-Order Amount:</td>
               <td>R
                  <input type=text class='controlText controlNumeric controlLabel' name='dblDtAmount' id='dblDtAmount' value=\"0.00\" readonly>
               </td>
            </tr>
         </table>
   </fieldset>
   $BR
   <fieldset>
      <legend>Member Details</legend>
      <table border='0' cellpadding='2' cellspacing='1' width='100%'>
         <col width='$widthA'/>
         <col width='$widthB'/>

         <!--<tr>
            <td valign=top align=right><label for='strName'>Promotion Code:</label> $required</td>
            <td valign=top align=left><input type=text name='strName' id='strName' class='controlText controlWideMax' value=\"$strName\" maxlength='255'></td>
         <tr>-->

         <tr>
            <td valign=top align=right><label for='strName'>Name and Surname:</label> $required</td>
            <td valign=top align=left><input type=text name='strName' id='strName' class='controlText controlWideMax' value=\"$strName\" maxlength='255'></td>
         <tr>
            <td valign=top align=right><label for='strID'>South African ID Number:</label> $required<BR> (or Passport)</td>
            <td valign=top align=left><input type=text name='strID' id='strID' class='controlText controlWideMax' value=\"\" maxlength='255'></td>
         <tr>
            <td valign=top align=right><label for='strEmail'>Email Address:</label> $required</td>
            <td valign=top align=left><input type=text name='strEmail' id='strEmail' class='controlText controlWideMax' value=\"\" maxlength='255'></td>
         <tr>
            <td valign=top align=right><label for='strPhone'>Home Phone Number:</label></td>
            <td valign=top align=left><input type=text name='strPhone' id='strPhone' class='controlText controlWideMax' value=\"\" maxlength='255'></td>
         <tr>
            <td valign=top align=right><label for='strCell'>Cell Phone Number:</label> $required</td>
            <td valign=top align=left><input type=text name='strCell' id='strCell' class='controlText controlWideMax' value=\"\" maxlength='255'></td>
         <tr>
            <td valign=top align=right><label for='strWork'>Work Phone Number:</label></td>
            <td valign=top align=left><input type=text name='strWork' id='strWork' class='controlText controlWideMax' value=\"\" maxlength='255'></td>
         <tr>
            <td valign=top align=right><label for='txtAddressHome'>Home Address:</label> $required</td>
            <td valign=top align=left><textarea type=text name='txtAddressHome' id='txtAddressHome' class='controlText controlWideMax' rows=3></textarea></td>
         <tr>
            <td valign=top align=right><label for='txtAddressPostal'>Postal Address:</label> <br>(if not the same as above)</td>
            <td valign=top align=left><textarea type=text name='txtAddressPostal' id='txtAddressPostal' class='controlText controlWideMax' rows=3 ></textarea></td>
         <tr>
            <td valign=top align=right><label for='strPostalCode'>Postal Code:</label> $required</td>
            <td valign=top align=left><input type=text name='strPostalCode' id='strPostalCode' class='controlText controlWideMax' value=\"\" maxlength='30'></td>
         <tr>
            <td valign=top align=right><label for='refAreaID'>Province:</label> $required</td>
            <td valign=top align=left>
               <select name='refAreaID' id='refAreaID' class='controlText controlWideMax' >
                  $ddlArea
               </select></td>
         <tr>
            <td valign=top align=right><label for='strSurvey'>How did you hear about us:</label></td>
            <td valign=top align=left>
               <select name='strSurvey' id='strSurvey' class='controlText controlWideMax'>
                  <option value=''>- Select a Value -</option>
                  <option value='Bangersandnash'>Bangersandnash</option>
                  <option value='Facebook'>Facebook</option>
                  <option value='Friends'>Friends</option>
                  <option value='Twitter'>Twitter</option>
                  <option value='Web'>Web</option>
                  <option value='Other'>Other</option>
               </select>
            </td></tr>
      </table>
   </fieldset>
   <fieldset>
      <legend>Vehicle Details</legend>
      <table border='0' cellpadding='2' cellspacing='1' width='100%'>
         <col width='$widthA'>
         <col width='$widthB'>
         <col width='$widthC'>
         <tr>
            <td valign=top align=right><label for='strVehicle'>Make & Model:</label> $required</td>
            <td valign=top align=left><input type=text name='strVehicle' id='strVehicle' class='controlText controlWideMax' value=\"\" maxlength='255'></td>

         <tr>
            <td valign=top align=right><label for='strRegistration'>Registration Number:</label> $required</td>
            <td valign=top align=left ><input type=text name='strRegistration' id='strRegistration' class='controlText controlWideMax' value=\"\" maxlength='255'></td>

         <tr>
            <td valign=top align=right><label for='strColour'>Colour:</label> $required</td>
            <td valign=top align=left><input type=text name='strColour'  id='strColour' class='controlText controlWideMax' value=\"\" maxlength='255'></td>
      </table>
   </fieldset>
   <fieldset>
      <legend>Banking Details</legend>
      <table border='0' cellpadding='2' cellspacing='1' width='100%'>
         <col width='$widthA'>
         <col width='$widthB'>
         <tr>
            <td valign=top align=right><label for='strBankName'>Bank Name:</label> $required</td>
            <td valign=top align=left><input type=text name='strBankName'  id='strBankName' class='controlText controlWideMax' value=\"\" maxlength='255'></td></tr>
         <tr>
            <td valign=top align=right><label for='strBranchCode'>Branch Code:</label> $required</td>
            <td valign=top align=left><input type=text name='strBranchCode'  id='strBranchCode' class='controlText controlWideMax' value=\"\" maxlength='255'></td></tr>
         <tr>
            <td valign=top align=right><label for='strAccountType'>Account Type:</label> $required</td>
            <td valign=top align=left>
               <select name='strAccountType' id='strAccountType' class='controlText controlWideMax'>
                  <option value=''>- Select a Value -</option>
                  <option value='Current/Checking'>Current/Checking</option>
                  <option value='Savings'>Savings</option>
                  <option value='Transmission'>Transmission</option>
               </select>
            </td></tr>
         <tr>
            <td valign=top align=right><label for='strAccountHoldersName'>Account Holders Name:</label> $required</td>
            <td valign=top align=left><input type=text name='strAccountHoldersName' id='strAccountHoldersName' class='controlText controlWideMax' value=\"\" maxlength='255'></td></tr>
         <tr>
            <td valign=top align=right><label for='strAccountNumber'>Account Number:</label> $required</td>
            <td valign=top align=left ><input type=text name='strAccountNumber' id='strAccountNumber' class='controlText controlWideMax' value=\"\" maxlength='255'></td></tr>
      </table>
   </fieldset>

   <!--
      <fieldset>
         <legend>Misc</legend>
         <table border='0' cellpadding='2' cellspacing='1' width='100%'>
            <col width='$widthA'>
            <col width='$widthB'>
            <tr>
               <td valign=top align=center colspan=3>
                  ".$captcha."
               </td>
            </tr>
            <tr>
               <td valign=top align=right><label for='strSecurityCode'>Verify the Security Code above:</label> $required</td>
               <td valign=top align=left><input type=text name='strSecurityCode' id='strSecurityCode' class='controlText controlWideMax' value=\"\" maxlength='4' ></td>
            <tr>
               <td valign=top align=right><input type=checkbox name='chkTC' id='chkTC' class='' value=\"1\"></td>
               <td valign=top align=left>I have read and accept the <a href='pdfs/TermsandConditons.pdf' target='_blank'>Terms & Conditions</a>.</td>
         </table>
      </fieldset>
   -->

    <fieldset>
      <legend>Security</legend>
      <table border='0' cellpadding='2' cellspacing='1' width='100%'>
         <col width='$widthA'>
         <col width='$widthB'>
         <tr>
            <td valign=top align=center colspan =100%>
               Please answer the simple security question below:
            </td>
         </tr>
         <tr>
            <td valign=top align=right>
               <label for='strSecurityCode'>What is <b> <font color='#CD2614'> $strQuestion </font></b> ? $required</label>
            </td>
            <td valign=top align=left>
               <input type=text name='strSecurityCode' id='strSecurityCode' class='controlText controlWideMax' value=\"\" maxlength='4' >
               
            </td>
         </tr>
         <tr>
            <td valign=top align=right>
               <input type=checkbox name='chkTC' id='chkTC' class='' value=\"1\">
            </td>
            <td valign=top align=left>
               I have read and accept the <a href='pdfs/TermsandConditons.pdf' target='_blank'>Terms & Conditions</a>.
            </td>
      </table>
      <input type=hidden name=intAnswer id=intAnswer value=". ($strAnswer * 117) ." />
   </fieldset> 
   $BR
   <input type='submit' name='Action' id='Action' class='btn' value=\"Submit\" onClick='return jsValidate()'>
  
   <input type=hidden name='g-recaptcha-response' id='g-recaptcha-response' class='controlText controlWideMax' value=\"\" maxlength='4' >
   </form>
   <script src='https://www.google.com/recaptcha/api.js?render=6LezXNkZAAAAAPEjFN098uSM9x1Wq4CoDTxNxbSL'></script>
    ".

   js("
      $('input[id=reloadCaptcha]').click(function()
      {
          var d = new Date();
          $('img[id*=captchaImage]').attr('src' , \"modules/captcha.mod.incl.php?Captcha=render&date=\"+d.getTime()+\"\");
          validateCaptcha();
          return false;
      });
      grecaptcha.ready(function() {
         grecaptcha.execute('6LezXNkZAAAAAPEjFN098uSM9x1Wq4CoDTxNxbSL', {action: 'submit'}).then(function(token) {
             // Add your logic to submit to your backend server here.
             console.log(token);
             document.getElementById('g-recaptcha-response').value=token;
         });
       });
      function jsValidate()
      {
         var msg = '';
         if(!$('input[name=\"radPackage\"]:checked').val())
         {
            msg += 'Select a Package\\n';
         }
         /*
            Member Details
         */
         if( $('#strName').val() == '' )
         {
            msg += 'Name and Surname\\n';
         }
         if( $('#strID').val() == '' )
         {
            msg += 'ID Number\\n';
         }
         var emailRegEx = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;
         if( document.form.strEmail.value.search(emailRegEx) == -1)
         {
            msg += 'Email Address not in correct format\\n';
         }
         if( $('#strCell').val() == '' )
         {
            msg += 'Cell Phone Number\\n';
         }
         if( $('#txtAddressHome').val() == '' )
         {
            msg += 'Home Address\\n';
         }
         if( $('#strPostalCode').val() == '' )
         {
            msg += 'Postal Code\\n';
         }
         if( $('#refAreaID').val() == '0')
         {
            msg += 'Province \\n';
         }

         /*
            Vehical Details
         */
         if( $('#strVehicle').val() == '' )
         {
            msg += 'Make & Model\\n';
         }
         if( $('#strRegistration').val() == '' )
         {
            msg += 'Registration Number\\n';
         }
         if( $('#strColour').val() == '' )
         {
            msg += 'Colour\\n';
         }
         /*
            Banking Details
         */
         if( $('#strBankName').val() == '' )
         {
            msg += 'Bank Name\\n';
         }
         if( $('#strBranchCode').val() == '' )
         {
            msg += 'Branch Code\\n';
         }
         if( $('#strAccountType').val() == '' )
         {
            msg += 'Account Type\\n';
         }
         if( $('#strAccountHoldersName').val() == '' )
         {
            msg += 'Account Holders Name\\n';
         }
         if( $('#strAccountNumber').val() == '' )
         {
            msg += 'Account Number\\n';
         }
         /* misc */
         /*
            if($('#strSecurityCode').val().toLowerCase() != captcha.toLowerCase())
            {
               msg += '- Security Code does not match\\n';
            }
         */

         /* Security */

         if($('#strSecurityCode').val() == '')
         {
            msg += '- Security Code\\n';
         }

         if($('#strSecurityCode').val() != '')
         {
            if($('#strSecurityCode').val()*117 != $('#intAnswer').val())
            {
               msg += '- Your security code does not match what you typed in\\n';
            }
         }

         /*
            Terms and Conditions
         */
         if(document.getElementById('chkTC').checked == false)
         {
            msg += 'Terms and Conditions\\n';
         }

         if(msg != '')
         {
            alert('Please select the following:\\n\\n'+msg);
            return false;
         }
         else
         {
            var Action = document.createElement('input');
            Action.setAttribute('type','hidden')
            Action.setAttribute('value','Submit')
            Action.setAttribute('name','Action')
            try{
               document.form.appendChild(Action);
            }catch(e){alert(e);}
            document.form.submit();
            return true;
         }
      }
      $pickmeautoload

      ")
   ;

   $page->Display();

?>