#!/usr/bin/perl
# Kasra Meshkin May 1998 For HSL

require "cgi-lib.pl";

$time = localtime();
@tt = split(/ /,$time);
if($tt[3] > 9) {
	@pp=split(/:/,$tt[3]);
}else {
	@pp=split(/:/,$tt[4]);
}
 
###&ReadParse(*cgi);
&parse_form;

$results = &PrintVariables(%cgi);
sub parse_form {

   # Get the input
   read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

   # Split the name-value pairs
   @pairs = split(/&/, $buffer);

   foreach $pair (@pairs) {
      ($name, $value) = split(/=/, $pair);

      $value =~ tr/+/ /;
      $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

      $cgi{$name} = $value;
   }
}
# load in the form contents

($agentname = $cgi{'agentname'}) =~ s/\n/ /g;
($amortization = $cgi{'amortization'}) =~ s/\n/ /g;
($loanamount = $cgi{'loanamount'}) =~ s/\n/ /g;
($borrowerfirstname = $cgi{'borrowerfirstname'}) =~ s/\n/ /g;
($borrowerlastname = $cgi{'borrowerlastname'}) =~ s/\n/ /g;
($borrowersin = $cgi{'borrowersin'}) =~ s/\n/ /g;
($borroweraddress= $cgi{'borroweraddress'}) =~ s/\n/ /g;
($borrowercity = $cgi{'borrowercity'}) =~ s/\n/ /g;
($borrowerprovince = $cgi{'borrowerprovince'}) =~ s/\n/ /g;
($secaddress = $cgi{'secaddress'}) =~ s/\n/ /g;
($dischargedmonth = $cgi{'dischargedmonth'}) =~ s/\n/ /g;
($dischargedday = $cgi{'dischargedday'}) =~ s/\n/ /g;
($dischargedyear = $cgi{'dischargedyear'}) =~ s/\n/ /g;
($corrowerfirstname = $cgi{'corrowerfirstname'}) =~ s/\n/ /g;
($corrowerlastname = $cgi{'corrowerlastname'}) =~ s/\n/ /g;
($coborrower = $cgi{'coborrower'}) =~ s/\n/ /g;
($corrowersin = $cgi{'corrowersin'}) =~ s/\n/ /g;
($corroweraddress = $cgi{'corroweraddress'}) =~ s/\n/ /g;
($corrowercity = $cgi{'corrowercity'}) =~ s/\n/ /g;
($corrowerprovince = $cgi{'corrowerprovince'}) =~ s/\n/ /g;
($JOHomePhArea = $cgi{'JOHomePhArea'}) =~ s/\n/ /g;
($JOHomePhPrefix = $cgi{'JOHomePhPrefix'}) =~ s/\n/ /g;
($JOHomePhPost = $cgi{'JOHomePhPost'}) =~ s/\n/ /g;
($downpayment = $cgi{'downpayment'}) =~ s/\n/ /g;
($title = $cgi{'title'}) =~ s/\n/ /g;
($repname= $cgi{'repname'}) =~ s/\n/ /g;






($RHHomePhArea = $cgi{'RHHomePhArea'}) =~ s/\n/ /g;
($RHTitle = $cgi{'RHTitle'}) =~ s/\n/ /g;
($firstname = $cgi{'RHFirstName'}) =~ s/\n/ /g;
($RHHomePhPrefix = $cgi{'RHHomePhPrefix'}) =~ s/\n/ /g;
($RHHomePhPost = $cgi{'RHHomePhPost'}) =~ s/\n/ /g;
($RHDBmonth = $cgi{'RHDBmonth'}) =~ s/\n/ /g;
($RHDBday = $cgi{'RHDBday'}) =~ s/\n/ /g;
($RHDByear = $cgi{'RHDByear'}) =~ s/\n/ /g;
($RHAddress = $cgi{'RHAddress'}) =~ s/\n/ /g;
($RHApt = $cgi{'RHApt'}) =~ s/\n/ /g;
($RHCity = $cgi{'RHCity'}) =~ s/\n/ /g;
($RHPCode = $cgi{'RHPCode'}) =~ s/\n/ /g;
($RHSIN = $cgi{'RHSIN'}) =~ s/\n/ /g;
($JOTitle = $cgi{'JOTitle'}) =~ s/\n/ /g;
($JOFirstName = $cgi{'JOFirstName'}) =~ s/\n/ /g;
($JOLastName = $cgi{'JOLastName'}) =~ s/\n/ /g;
($JOHomePhArea = $cgi{'JOHomePhArea'}) =~ s/\n/ /g;
($JOHomePhPrefix = $cgi{'JOHomePhPrefix'}) =~ s/\n/ /g;
($JOHomePhPost = $cgi{'JOHomePhPost'}) =~ s/\n/ /g;
($JODBmonth = $cgi{'JODBmonth'}) =~ s/\n/ /g;
($JODBday = $cgi{'JODBday'}) =~ s/\n/ /g;
($JODByear = $cgi{'JODByear'}) =~ s/\n/ /g;
($JOSIN = $cgi{'JOSIN'}) =~ s/[\r\n]/ /g;
($JOAddress = $cgi{'JOAddress'}) =~ s/\n/ /g;
($dicamount = $cgi{'dicamount'}) =~ s/\n/ /g;
($codamount = $cgi{'codamount'}) =~ s/\n/ /g;
($certificate = $cgi{'certificate'}) =~ s/\n/ /g;
($interestrate = $cgi{'interestrate'}) =~ s/\n/ /g;
($JOAddress = $cgi{'JOAddress'}) =~ s/\n/ /g;
($JOCity = $cgi{'JOCity'}) =~ s/\n/ /g;
($JOPCode = $cgi{'JOPCode'}) =~ s/\n/ /g;
($agree = $cgi{'yes'}) =~ s/\n/ g/;


@SIN = split(//,$borrowersin);


$B1 = $SIN[1] + $SIN[1];$B2 = $SIN[3] + $SIN[3];$B3 = $SIN[5] + $SIN[5];$B4 = $SIN[7] + $SIN[7];if($B1 < 9) { 	$X1 = $B1;} elsif(2>1) {	$X1 = $B1 - 9;}if($B2 < 9) { 	$X2 = $B2;} elsif(2>1) {	$X2 = $B2 - 9;}if($B3 < 9) { 	$X3 = $B3;} elsif(2>1) {	$X3 = $B3 - 9;}if($B4 < 9) { 	$X4 = $B4;} elsif(2>1) {	$X4 = $B4 - 9;}$SUM = $SIN[0]+$SIN[2]+$SIN[4]+$SIN[6]+$X1+$X2+$X3+$X4;

$KUM = $SUM + 0;
$SUM = 10 - $SUM;$SUM = $SUM %10;if($SUM !~ $SIN[8]) {
        &myerror("S.I.N NUMBER $borrowersin is Invalid.\n");



# if the SIN is more than 0 and less than 9 means any digit check and report error } elsif((length($borrowersin) < 9) && (length($borrowersin) > 0 )){
        &myerror("Social Insurance Number must be nine digits.\n");
}


#==========================================






@SON = split(//,$corrowersin);


$Bk1 = $SON[1] + $SON[1];$Bk2 = $SON[3] + $SON[3];$Bk3 = $SON[5] + $SON[5];$Bk4 = $SON[7] + $SON[7];if($Bk1 < 9) { 	$Xk1 = $Bk1;} elsif(2>1) {	$Xk1 = $Bk1 - 9;}if($Bk2 < 9) { 	$Xk2 = $Bk2;} elsif(2>1) {	$Xk2 = $Bk2 - 9;}if($Bk3 < 9) { 	$Xk3 = $Bk3;} elsif(2>1) {	$Xk3 = $Bk3 - 9;}if($Bk4 < 9) { 	$Xk4 = $Bk4;} elsif(2>1) {	$Xk4 = $Bk4 - 9;}$SkUM = $SON[0]+$SON[2]+$SON[4]+$SON[6]+$Xk1+$Xk2+$Xk3+$Xk4;

$KkUM = $SkUM + 0;
$SkUM = 10 - $SkUM;$SkUM = $SkUM %10;







# do any error checking here
if(($cgi{'individual'}=~/agent/) && ( length($agentname) < 1 )){
        &myerror("You didn't enter Broker Information.");


} elsif($amortization > 25){
        &myerror("Amortization can not exceed 25 years\n");

} elsif(length($loanamount) < 1){
        &myerror("You did not enter Loan Amount.\n");

} elsif($loanamount < 1){
        &myerror("Loan Amount can not be 0\n");



} elsif(length($borrowersin) < 1){
        &myerror("Social Insurance Number is missing.\n");




} elsif(length($borrowerfirstname) < 1){
        &myerror("Borrower's First Name is missing.\n");

} elsif(length($borrowerlastname) < 1){
        &myerror("Borrower's Last Name is missing.\n");


} elsif(length($RHDBmonth) < 1){
        &myerror("You did not enter Birth Month.\n");

} elsif(length($RHDBday) < 1){
        &myerror("You did not enter Birth Day.\n");

} elsif(length($RHDByear) < 1){
        &myerror("You did not enter Birth Year.\n");


# ============================================================
# check for correct birtday year. 1- can not be less than four digits 2- can no be in the future 3- can not be less than 1848
# =============================================================
} elsif(length($RHDByear) < 4){
        &myerror("Birthday Year must be four digits.\n");

} elsif ($RHDByear > 1998) {
        &myerror("Birth Year can not be in the future\n");

} elsif ($RHDByear < 1848) {
        &myerror("Birth Year can not be less than 1848 - NOT on Earth :-).\n");

# ============================================================
# check month - can not be less than 1 and more than 12
# ============================================================

} elsif($RHDBmonth < 1){
        &myerror("Month of birth can not be 0.\n");
} elsif($RHDBmonth > 12){
        &myerror("Month of birth is invalid.\n");

# ============================================================
# check day - can not be less than 1 and more that 31
# ============================================================

} elsif($RHDBday < 1){
        &myerror("Day of birth can not be 0.\n");
} elsif($RHDBday > 31){
        &myerror("Day of birth is invalid.\n");




} elsif(length($borroweraddress) < 1){
        &myerror("Borrower's Address is missing.\n");


} elsif(length($borrowercity) < 1){
        &myerror("Borrower's City is missing.\n");


} elsif(length($borrowerprovince) < 1){
        &myerror("Borrower's Province is missing.\n");


} elsif((length($RHHomePhArea) < 3) &&  (length($RHHomePhArea) > 0))  {
        &myerror("Residence Telephone Area Code must be three digits.\n");


} elsif($RHHomePhArea < 1){
        &myerror("Residence Telephone Area Code is not valid.\n");


} elsif(length($RHHomePhArea) < 0){
        &myerror("Residence Telephone Area Code is not valid.\n");




} elsif(length($RHHomePhPrefix) < 3){
        &myerror("Residence Telephone first three digits are missing.\n");

} elsif(length($RHHomePhPost) < 4){
        &myerror("Residence Telephone last four digits are missing.\n");

} elsif(($cgi{'borroweremailaddress'} ne "") && ($cgi{'borroweremailaddress'} !~ /[a-zA-Z][a-zA-Z0-9._-]+\@[a-zA-Z][a-zA-Z0-9._-]+\.[a-zA-Z]+/)){
        &myerror("Please check BORROWER email.\n");



} elsif(length($RHDBmonth) < 1){
        &myerror("You did not enter Birth Month.\n");

} elsif(length($RHDBday) < 1){
        &myerror("You did not enter Birth Day.\n");

} elsif(length($RHDByear) < 1){
        &myerror("You did not enter Birth Year.\n");




} elsif(($cgi{'coborrower'}=~/on/) && (length($corrowersin) < 1)){
        &myerror("CO-BORROWER Social Insurance Number is missing.\n");

} elsif(($SkUM !~ $SON[8]) && ($cgi{'coborrower'}=~/on/)){
        &myerror("CO-BORROWER S.I.N NUMBER $corrowersin is Invalid.\n");



} elsif(($cgi{'coborrower'}=~/on/) && (length($corrowersin) < 9)){
        &myerror("CO-BORROWER Social Insurance Number must be nine $skUM digits.\n");



} elsif(($cgi{'coborrower'}=~/on/) && (length($corrowersin) < 1)){
        &myerror("CO-BORROWER Social Insurance Number is missing.\n");




} elsif(($cgi{'coborrower'}=~/on/) && (length($corrowerfirstname) < 1)){
        &myerror("CO-BORROWER First Name is missing.\n");

} elsif(($cgi{'coborrower'}=~/on/) && (length($corrowerlastname) < 1)){
        &myerror("CO-BORROWER Last Name is missing.\n");









} elsif(($cgi{'coborrower'}=~/on/) && (length($JODBmonth) < 1)){
        &myerror("CO-BORROWER's Birth Month is missing.\n");


} elsif(($cgi{'coborrower'}=~/on/) && (length($JODBday) < 1)){
        &myerror("CO-BORROWER's Birth Day is missing.\n");

} elsif(($cgi{'coborrower'}=~/on/) && (length($JODByear) < 1)){
        &myerror("CO-BORROWER's Birth Year is missing.\n");


# ============================================================
# check for correct birtday year. C0-BORROWER
# =============================================================
} elsif(($cgi{'coborrower'}=~/on/) && ($JODByear < 4)){
        &myerror("CO-BORROWER's Birthday Year must be four digits.\n");

} elsif(($cgi{'coborrower'}=~/on/) && ($JODByear > 1998)){
        &myerror("CO-BORROWER's Birth Year can not be in the future\n");

} elsif(($cgi{'coborrower'}=~/on/) && ($JODByear < 1848)){
        &myerror("CO-BORROWER's Birth Year can not be less than 1848 - NOT on Earth :-).\n");

# ============================================================
# check month - can not be less than 1 and more than 12 C0-BORROWER
# ============================================================

} elsif(($cgi{'coborrower'}=~/on/) && ($JODBmonth < 1)){
        &myerror("CO-BORROWER's Month of birth can not be 0.\n");

} elsif(($cgi{'coborrower'}=~/on/) && ($JODBmonth > 12)){
        &myerror("CO-BORROWER's Month of birth is invalid.\n");


# ============================================================
# check day - can not be less than 1 and more that 31 C0-BORROWER
# ============================================================

} elsif(($cgi{'coborrower'}=~/on/) && ($JODBday < 1)){
        &myerror("CO-BORROWER's Day of birth can not be 0.\n");

} elsif(($cgi{'coborrower'}=~/on/) && ($JODBday > 31)){
        &myerror("CO-BORROWER's Day of birth is invalid.\n");

# ========================================


} elsif(($cgi{'coborrower'}=~/on/) && (length($corroweraddress) < 1)){
        &myerror("CO-Borrower's Address is missing.\n");


} elsif(($cgi{'coborrower'}=~/on/) && (length($corrowercity) < 1)){
        &myerror("CO-Borrower's City is missing.\n");


} elsif(($cgi{'coborrower'}=~/on/) && (length($corrowerprovince) < 1)){
        &myerror("CO-Borrower's Province is missing.\n");


} elsif(($cgi{'coborrower'}=~/on/) && (length($JOHomePhArea) < 1)){
        &myerror("CO-Borrower's Residence Telephone Area Code is missing.\n");

} elsif(($cgi{'coborrower'}=~/on/) && (length($JOHomePhPrefix) < 3)){
        &myerror("CO-Borrower's Residence Telephone first three digits are missing.\n");

} elsif(($cgi{'coborrower'}=~/on/) && (length($JOHomePhPost) < 4)){
        &myerror("CO-Borrower's Residence Telephone last four digits are missing.\n");

} elsif(($cgi{'corroweremailaddress'} ne "") && ($cgi{'corroweremailaddress'} !~ /[a-zA-Z][a-zA-Z0-9._-]+\@[a-zA-Z][a-zA-Z0-9._-]+\.[a-zA-Z]+/)){
        &myerror("Please check CO-BORROWER's email.\n");
		
		
#############################################################
# 4a. BORROWER'S EMPLOYMENT INFORMATION
############################################################


} elsif(($cgi{'eoccupation'} eq "") || ($cgi{'eannual'}) eq ""){
        &myerror("Please enter Borrower's required Employment information.\n");


} elsif(length($secaddress) < 1){
       &myerror("Property Address is missing.\n");



#} elsif(length($downpayment) < 1){
       &myerror("Cash Downpayment is missing.\n");


#} elsif($downpayment < 1){
       &myerror("Cash Downpayment is not vaild.\n");


#===================================
# Agree sign
#======================================


} elsif($cgi{'applicantagree'}!~/on/){
        &myerror("You must agree to the Terms And Conditions before you submit this form.<br>Please read them carefully and resubmit the form.\n");


} elsif(($cgi{'coborrower'}=~/on/) && ($cgi{'coapplicantagree'}!~/on/)){
        &myerror("CO-BORROWER must agree to the Terms And Conditions before you submit this form.<br>Please read them carefully and resubmit the form.\n");




}
sub myerror {
   
     $errstr = shift @_;
        printf("%s", &PrintHeader);
	
     # print "testing $RHDBysplit 1, 2, 3";  

print <<EOF;

<center>
<h2><font color=#ff0000> The following information is required to process your application</h2></font>
<hr>
<table border=2 bgcolor=#fffddf cellpadding=5 cellborder=0><tr><td align=center>
<font face=arial color=blue>
<b>$errstr</b>
</font>
</td></tr></table>
<p>
Please close this window to return to the application form and complete all of the required information.  Thank you.
</center>
EOF

        exit;
}







#===================================================
# Now display info on the screen
#===================================================
printf("%s", &PrintHeader);
printf("<HTML>\n<TITLE>Thank you for your submission!</TITLE>\n\n");
printf("<BODY bgcolor=\"#ffffff\"> \n");
printf("<center><H2> \n");

if($cgi{'individual'}=~/agent/) {
	printf("<h2>Thank you $agentname $cgi{'agentnumber'}.</h2> \n");
}else{
	printf("<h2>Thank you $title. $borrowerfirstname $borrowerlastname.</h2> \n");
}

printf("<h4>Submission Date: $tt[1]-$tt[2]-$tt[4]</h4>\n");
printf("<BR>\n<h4>Your Mortgage application has been submitted to Home Savings and Loan Corp., TORONTO.</h4>\n");
printf("<BR>\n");




#print "$mas<br>";

print "Your Reference Number is <font size=+1 color=#ff0000>$pp[0]MORT$pp[1]$pp[2]</font><br>\n";
print "<h4>Should you need to correspond with us please refer to this number</h4>\n";
print "<h3>A representative will contact you within one business day from the submission date<br></h3>\n";

print "<h4>If you need to contact us regarding your application, please contact:<br></h4>\n"; 

print "<h4>\n";
print "Home Savings and Loan<br>\n"; 
print "145 King Street West, Suite 1910<br>\n";
print "Toronto, Ontario<br>\n";
print "M5H 1J8<br>\n";

#print "For mail-in applications, these rates remain active up to two business days from the Submission date<br>\n"; 
printf("<h4>Submission Date: $tt[1]-$tt[2]-$tt[4]</h4>\n");
print "<h4>To check the status of your application please contact:<br></h4>\n";
print "Toll Free: 1-800-990-7881<br>\n";
print "Telephone: 416-360-4663<br>\n";
print "Fax: 416-363-7611<br>\n";



if($cgi{'repname'}=~/nickk/){
print "Your Representative is <font size=+1 color=#ff0000> Nick Kyprianou</font>\n";

}elsif($cgi{'repname'}=~/chrisn/){
print "Your Representative is <font size=+1 color=#ff0000> Christine Nugent</font>\n";

}elsif($cgi{'repname'}=~/jimh/){
print "Your Representative is <font size=+1 color=#ff0000> James Hill</font>\n";

}elsif($cgi{'repname'}=~/margr/){
print "Your Representative is <font size=+1 color=#ff0000> Marguerite Ryan</font>\n";

}elsif($cgi{'repname'}=~/bradh/){
print "Your Representative is <font size=+1 color=#ff0000> Brad Hamilton</font>\n";

}elsif($cgi{'repname'}=~/wolfs/){
print "Your Representative is <font size=+1 color=#ff0000> Wolf L. Schmutzer</font>\n";

}elsif($cgi{'repname'}=~/larryf/){
print "Your Representative is <font size=+1 color=#ff0000> Larry Frondall</font>\n";

}else{
print "Your Representative is <font size=+1 color=#ff0000> Laurie Chalabardo</font>\n";

}

#}

print "\n\n</BODY>\n</HTML>\n";


#======================================================
#	OPEN EMAIL
#======================================================




#open(MAIL, "| /usr/lib/sendmail edward\@ezenet.com");
open(MAIL, "| /usr/lib/sendmail lauriec\@hslcorp.com,kasra\@ezenet.com,jamesa\@hslcorp.com");
printf(MAIL "Subject: $cgi{'borrowerlastname'} - $tt[1]$tt[2]$tt[4] --- $pp[0]MORT$pp[1]$pp[2] St-CATH\n");
printf(MAIL "From: MORTGAGE\-ONLINE\@EZENET\n\n");




printf(MAIL "====================HSL ONLINE MORTGAGE===================\n\n");
printf(MAIL "Submission Date: $tt[1]-$tt[2]-$tt[4]\n");
printf(MAIL "REF: $tt[1]$tt[2]$tt[4] --- $pp[0]MORT$pp[1]$pp[2]\n");

if($cgi{'individual'}=~/agent/) {
printf(MAIL "Filled by Broker: $cgi{'agentname'}\n");
printf(MAIL "Broker\'s Number: $cgi{'agentnumber'}\n\n");

}elsif($cgi{'individual'}!~/agent/) { 
printf(MAIL "Filled by: INDIVIDUAL \n\n");

}


printf(MAIL "====================APPLICANT'S INFO==================\n\n");
printf(MAIL "APPLICANT: $cgi{'title'}. $cgi{'borrowerfirstname'} $cgi{'borrowerlastname'} \n");
printf(MAIL "DATE OF BIRTH: $RHDBmonth-$RHDBday-$RHDByear\n");
printf(MAIL "Marital status: $cgi{'borrowermaritalstatus'}\n");
printf(MAIL "No. of dependents: $cgi{'borrowerdependents'}\n");
#printf(MAIL "Drivers Licence Number: $cgi{'borrowerdriverlic'}\n");
printf(MAIL "Social Insurance Number: $borrowersin\n");
printf(MAIL "Address: $cgi{'borroweraddress'}, $cgi{'borrowercity'}, $cgi{'borrowerprovince'}, $cgi{'borrowerpostal'}\n");
printf(MAIL "How long at address: $cgi{'borrowerhowlong'}\n");
printf(MAIL "Residence telephone: $RHHomePhArea-$RHHomePhPrefix-$RHHomePhPost\n");
printf(MAIL "Business telephone: $cgi{'borrowerbusphone'}\n");
print MAIL "Email Address: $cgi{'borroweremailaddress'}\n" if $cgi{'borroweremailaddress'};
printf(MAIL "Any judgments or legal proceedings? $cgi{'proceedings'}\n");
printf(MAIL "Declared bankruptcy? $cgi{'bankrupty'} - Date Discharged: $cgi{'dischargedmonth'}-$cgi{'dischargedday'}-$cgi{'dischargedyear'}\n\n");


printf(MAIL "=================EMPLOYMENT INFORMATION===============\n");
printf(MAIL "Self employed: $cgi{'eselfemployed'}\n");
printf(MAIL "Name and address of employer: $cgi{'ename'}\n");
printf(MAIL "Business telephone: $cgi{'enumber'}\n");
printf(MAIL "Years there: $cgi{'eyears'}\n");
printf(MAIL "Occupation/Position: $cgi{'eoccupation'}\n");
printf(MAIL "Present annual salary / wages : $cgi{'eannual'}\n");
printf(MAIL "Other Income: $cgi{'eotherincome'}\n\n");



printf(MAIL "==================DETAILS OF MORTGAGE=================\n");

printf(MAIL "Term and type: $cgi{'term'}\n");

printf(MAIL "Date funds required by: $cgi{'daterequired'}\n");
printf(MAIL "Amortization: $cgi{'amortization'}\n");

printf(MAIL "Loan amount requested: $cgi{'loanamount'}\n");
printf(MAIL "Interest rate: $cgi{'interestrate'}\n");
printf(MAIL "Nature of mortgage: $cgi{'nature'}\n");
printf(MAIL "Payment frequency: $cgi{'frequency'}\n\n");

if($cgi{'coborrower'}=~/on/){


printf(MAIL "================CO-BORROWER INFORMATION===============\n");

printf(MAIL "APPLICANT: $cgi{'cotitle'}. $cgi{'corrowerfirstname'} $cgi{'corrowerlastname'} \n");
printf(MAIL "DATE OF BIRTH: $JODBmonth-$JODBday-$JODByear\n");
printf(MAIL "Marital status: $cgi{'corrowermaritalstatus'}\n");
printf(MAIL "No. of dependents: $cgi{'corrowerdependents'}\n");
#printf(MAIL "Drivers Licence Number: $cgi{'corrowerlic'}\n");
printf(MAIL "Social Insurance Number: $cgi{'corrowersin'}\n");
printf(MAIL "Address: $cgi{'corroweraddress'}, $cgi{'corrowercity'}, $cgi{'corrowerprovince'}, $cgi{'corrowerpostal'}\n");
printf(MAIL "How long at address: $cgi{'corrowerhowlong'}\n");

printf(MAIL "Residence telephone: $JOHomePhArea-$JOHomePhPrefix-$JOHomePhPost\n");
printf(MAIL "Business telephone: $cgi{'corrowerbusphone'}\n");
print MAIL "Email Address: $cgi{'corroweremailaddress'}\n\n" if $cgi{'corroweremailaddress'};


printf(MAIL "=================EMPLOYMENT INFORMATION===============\n");
printf(MAIL "Self employed: $cgi{'ecoselfemployed'}\n");
printf(MAIL "Name and address of employer: $cgi{'econame'}\n");
printf(MAIL "Business telephone: $cgi{'econumber'}\n");
printf(MAIL "Years there: $cgi{'ecoyears'}\n");
printf(MAIL "Occupation/Position: $cgi{'ecooccupation'}\n");
printf(MAIL "Present annual salary / wages : $cgi{'ecoannual'}\n");
printf(MAIL "Other Income: $cgi{'ecootherincome'}\n\n");

}

printf(MAIL "======================BANK REFRENCE===================\n");
printf(MAIL "Bank Name: $cgi{'bankname'}\n");
printf(MAIL "Branch/Address: $cgi{'bankaddress'}\n");
printf(MAIL "Account Number: $cgi{'accountnumber'}\n");
printf(MAIL "Account Type: $cgi{'accounttype'}\n\n");


printf(MAIL "=================FINANCIAL INFORMATION================\n");
printf(MAIL "ASSETS:\n");

printf(MAIL "Motor Vehicle #1: $cgi{'carmake1'} - Year: $cgi{'caryear1'} - Amount: $cgi{'carvalue1'}\n");
printf(MAIL "Motor Vehicle #2: $cgi{'carmake2'} - Year: $cgi{'caryear2'} - Amount: $cgi{'carvalue2'}\n");
printf(MAIL "Other Real Estate: $cgi{'otherrealestate'} - Amount: $cgi{'otherrealestatevalue'}\n");
printf(MAIL "Stocks: $cgi{'stocks'} - Amount: $cgi{'stocksvalue'}\n");
printf(MAIL "Bonds, Cash: $cgi{'bondscash'} - Amount: $cgi{'bondscashvalue'}\n");
printf(MAIL "Other Assets: $cgi{'otherassets'} - Amount: $cgi{'otherassetsvalue'}\n\n");




$ass = $cgi{'carvalue1'} + $cgi{'carvalue2'} + $cgi{'otherrealestatevalue'} + $cgi{'stocksvalue'} + $cgi{'bondscashvalue'} + $cgi{'otherassetsvalue'};

printf(MAIL "TOTAL ASSETS: $ass\n\n");


printf(MAIL "================\n");

printf(MAIL "LIABILITIES:\n");

printf(MAIL "1\n");
printf(MAIL "Name: $cgi{'lname'}\n");
printf(MAIL "Address: $cgi{'ladd'}\n");
printf(MAIL "Balance: $cgi{'bal'}\n");
printf(MAIL "Monthly Payment: $cgi{'mop'}\n\n");


printf(MAIL "2\n");
printf(MAIL "Name: $cgi{'lname2'}\n");
printf(MAIL "Address: $cgi{'ladd2'}\n");
printf(MAIL "Balance: $cgi{'bal2'}\n");
printf(MAIL "Monthly Payment: $cgi{'mop2'}\n\n");


printf(MAIL "3\n");
printf(MAIL "Name: $cgi{'lname3'}\n");
printf(MAIL "Address: $cgi{'ladd3'}\n");
printf(MAIL "Balance: $cgi{'bal3'}\n");
printf(MAIL "Monthly Payment: $cgi{'mop3'}\n\n");

printf(MAIL "4\n");
printf(MAIL "Name: $cgi{'lname4'}\n");
printf(MAIL "Address: $cgi{'ladd4'}\n");
printf(MAIL "Balance: $cgi{'bal4'}\n");
printf(MAIL "Monthly Payment: $cgi{'mop4'}\n\n");



$kas = $cgi{'bal'} + $cgi{'bal2'} + $cgi{'bal3'} + $cgi{'bal4'} ;




printf(MAIL "TOTAL LIABILITIES: $kas\n\n");


printf(MAIL "=======================SECURITY=======================\n");
printf(MAIL "Property Address: $cgi{'secaddress'}\n");
printf(MAIL "Lot #: $cgi{'seclotnumber'}\n");
printf(MAIL "Plan #: $cgi{'secplannumber'}\n");
printf(MAIL "Lot size: $cgi{'seclotsize1'} - $cgi{'seclotsize2'}\n");
printf(MAIL "Dwelling Size: $cgi{'secdwelling'}\n");
printf(MAIL "Taxes:  $cgi{'sectaxes'}\n");
printf(MAIL "Condo Fees:  $cgi{'seccondofees'}\n");
printf(MAIL "Status: $cgi{'secoccupancy'}\n");
printf(MAIL "Building Income: $cgi{'secincome'}\n");
printf(MAIL "Type: $cgi{'hometype'}\n");
printf(MAIL "Construction: $cgi{'construction'} - Age:$cgi{'constructionage'} - Number of rooms:$cgi{'numberofrooms'} \n");
printf(MAIL "Options: $cgi{'hydro'} $cgi{'munwater'} $cgi{'well'} $cgi{'sewers'} $cgi{'septictank'} $cgi{'pavedroad'} $cgi{'uffi'}\n");



printf(MAIL "Closing Date: $cgi{'closingdate'} - Puchase Price: $cgi{'purchaseprice'}\n");
printf(MAIL "Cash Downpayment: $cgi{'downpayment'}\n");
printf(MAIL "Estimated Value: $cgi{'estimatedvalue'}\n");
printf(MAIL "Solicitor: $cgi{'solicitorname'} - Phone:$cgi{'solicitorphone'} - Address:$cgi{'solicitoraddress'}\n\n");


printf(MAIL "======================================================\n");
printf(MAIL "Submission Date: $tt[1]-$tt[2]-$tt[4]\n");
printf(MAIL "REF: $tt[1]$tt[2]$tt[4] --- $pp[0]MORT$pp[1]$pp[2]\n");
printf(MAIL "================HSL ONLINE MORTGAGE==================\n\n");


close(MAIL);

exit;








