#!/usr/bin/perl
# INSTAbase Order Form

require "cgi-lib.pl";

$time = localtime();
@tt = split(/ /,$time);
@pp = split(/:/,$tt[3]);

 
###&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

($product = $cgi{'product'}) =~ s/\n/ /g;
($payment = $cgi{'payment'}) =~ s/\n/ /g;
($country = $cgi{'country'}) =~ s/\n/ /g;


if($cgi{'payment'}=~/creditcard/){
	&creditcard;

}elsif($cgi{'payment'}=~/cheque/){
	&cheque;

}elsif($cgi{'payment'}=~/Phone/){
printf("%s", &PrintHeader);
printf("<HTML>\n<BODY background=\"/images/instabase/orderback.gif\"> \n");
print "<center>\n";

	   if($cgi{'media'}=~/cd/){
			&print_cd;
	   }else{
	
		print "<table bgcolor=\"#FFFDDF\" width=100% border=2 cellpadding=5>\n<tr valign=top>\n";
		print "<td><font face=arial size=2>\n<center>\n";
		print "<img src=\"/images/instabase/regsoft1.gif\">\n<br>\n\n";
		print "Secure Phone Transaction Service Provided by Regsoft.com\n<p>";
	
		print "<center><img src=\"/images/instabase/visa.gif\">\n <img src=\"/images/instabase/mastercard.gif\">\n <img src=\"/images/instabase/amex.gif\">\n</center>\n<p>\n";


print "Thank you.<br><font color=red>To place your order by phone please call:<br>\n";
print "1-888-734-4880 and provide the product ID.</font><br>\n";

	if($cgi{'country'}=~/canada/){
		print "\n<i><b>Canadian customers please note that all transactions are in US dollars automatically converted to Canadian dollars once approved.</b></i><br>\n";
	}

print "<table width=100%>\n";

print "<tr><td bgcolor=lightblue>\n<font face=arial size=2><font color=#22c033>\n<b>Electronic version</b></font><br>\n";
print "<b>InstaBase 4.0 Web Ready (Product ID 4332) - <font color=\"#000000\">US\$59.00</font></b><br>\n";

print "<tr><td bgcolor=lightgrey><font face=arial size=2><font color=#22c033><b>CD-ROM version</b></font><br>\n";
print "<b>InstaBase 4.0 Web Ready On CDROM (Product ID 5407) - <font color=\"#000000\">US\$69.00</font></b><br>\n";
print "</tr></td></table>\n";
print "<p>\n";
print "<p>\n";
print "If you haven't downloaded InstaBase yet,\n please make sure you do so by clicking on the link\n to the left, labeled <b>Download</b>\n";
print "</tr></td></table>\n</BODY>\n</HTML>\n";


	}

}


#========================= output to screen for Cheque ========================

sub cheque {

     $errstr = shift @_;

printf("%s", &PrintHeader);
printf("<HTML>\n<BODY background=\"/images/instabase/orderback.gif\"> \n");

print "<center>";

#--------------------------------- 4.0 standard full -------------------------

if($cgi{'product'}=~/1/){
	if($cgi{'country'}=~/us/){
		print "<h2>Thank you.<br><font color=red>Please send a cheque for \$39.00</font> in US Funds to: </h2>";
	}if($cgi{'country'}=~/canada/){
		print "<h2>Thank you.<br><font color=red>Please send a cheque for \$63.13 (\$67.85 if in Ontario)</font><br>in Canadian Funds to: </h2>";
	}
}
#--------------------------------- 4.0 web ready full -------------------------

if($cgi{'product'}=~/2/){
	if($cgi{'country'}=~/us/){
	   if($cgi{'media'}=~/electronic/){
		print "<h2>Thank you.<br><font color=red>Please send a cheque for \$59.00</font> in US Funds to: </h2>";
	   }
	   if($cgi{'media'}=~/cd/){
		&print_cd;
	   }

	}
	if($cgi{'country'}=~/canada/){
	   if($cgi{'media'}=~/electronic/){
		print "<h2>Thank you.<br><font color=red>Please send a cheque for \$84.53 (\$90.85 if in Ontario)</font><br>in Canadian Funds to: </h2>";
	   }
	   if($cgi{'media'}=~/cd/){
		&print_cd;
	   }
	}
}

#--------------------------------- 4.0 standard upgrade -------------------------

if($cgi{'product'}=~/3/){
	if($cgi{'country'}=~/us/){
		print "<h2>Thank you.<br><font color=red>Please send a cheque for \$9.00</font> in US Funds to: </h2>";
	}
	if($cgi{'country'}=~/canada/){
		print "<h2>Thank you.<br><font color=red>Please send a cheque for \$20.33 (\$21.85 if in Ontario)</font><br>in Canadian Funds to: </h2>";
	}
}

#--------------------------------- 4.0 web ready upgrade -------------------------

if($cgi{'product'}=~/4/){
	if($cgi{'country'}=~/us/){
		print "<h2>Thank you.<br><font color=red>Please send a cheque for \$29.00</font> in US Funds to: </h2>";
	}
	if($cgi{'country'}=~/canada/){
		print "<h2>Thank you.<br><font color=red>Please send a cheque for \$41.73 (\$44.85 if in Ontario)</font><br>in Canadian Funds to: </h2></font>";
	}
}



print "<table bgcolor=\"#fffddf\" border=1><tr><td><ul><b>";
print "Ezenet Inc.<br>";
print "940-90 Eglinton Ave. East<br>";
print "Toronto, ON   M4P 2Y3<br>";
print "Canada</b></ul><p>";
print "Please include with your cheque a letter with:<ul>";
print "<li>Your name<br>";
print "<li>Your full mailing address<br>";
print "<li>Your Email and Telephone<br>";
print "<li>The Security Code that InstaBase displays on startup.</ul>";
print "</td></tr></table>";
print "<p>If you haven't downloaded InstaBase yet, please make sure you do so by clicking on the link to the left, labeled <b>Download</b>";
        exit;
}


#========================= output to screen for credit card ========================

sub creditcard {

     $errstr = shift @_;

printf("%s", &PrintHeader);
printf("<HTML>\n<BODY background=\"/images/instabase/orderback.gif\"> \n");

print "<center>";


#--------------------------------- 4.0 standard full -------------------------

if($cgi{'product'}=~/1/){
	if($cgi{'country'}=~/us/){
		print "<table bgcolor=\"#FFFDDF\" width=200 border=2 cellpadding=5><tr valign=top>";
		print "<td><font face=arial size=2><center>";
		print "<img src=\"/images/instabase/regsoft1.gif\"><br>";
		print "Secure Online Transaction Service Provided by Regsoft.com<p>";
		print "<b>InstaBase 4.0 Standard - <font color=\"#FF0000\">US\$39.00</font></b><br>";
		print "<center><img src=\"/images/instabase/visa.gif\"> <img src=\"/images/instabase/mastercard.gif\"> <img src=\"/images/instabase/amex.gif\"></center><p>";
		print "<a href=\"https://www.regsoft.com/cgi-bin/reg_it_offsite.pl?4333\"><img src=\"/images/instabase/regsoft_button1.gif\" border=0></a>";
		print "<p>If you haven't downloaded InstaBase yet, please make sure you do so by clicking on the link to the left, labeled <b>Download</b></font></td></tr></table>";


	}if($cgi{'country'}=~/canada/){
print "<table bgcolor=\"#FFFDDF\" width=200 border=2 cellpadding=5><tr valign=top>";
		print "<td><font face=arial size=2><center>";
		print "<img src=\"/images/instabase/regsoft1.gif\"><br>";
		print "Secure Online Transaction Service Provided by Regsoft.com<p>";
		print "Canadian customers please note that your funds will be converted to Canadian on your statement and will be based on current rates of exchange.<p>";
		print "<b>InstaBase 4.0 Standard - <font color=\"#FF0000\">US\$39.00</font></b><br>";
		print "<center><img src=\"/images/instabase/visa.gif\"> <img src=\"/images/instabase/mastercard.gif\"> <img src=\"/images/instabase/amex.gif\"></center><p>";
		print "<a href=\"https://www.regsoft.com/cgi-bin/reg_it_offsite.pl?4333\"><img src=\"/images/instabase/regsoft_button1.gif\" border=0></a>";
		print "<p>If you haven't downloaded InstaBase yet, please make sure you do so by clicking on the link to the left, labeled <b>Download</b></font></td></tr></table>";
		

	}
}
#--------------------------------- 4.0 web ready full -------------------------

if($cgi{'product'}=~/2/){
	if($cgi{'country'}=~/us/){
				
	   if($cgi{'media'}=~/electronic/){
		print "<table bgcolor=\"#FFFDDF\" width=200 border=2 cellpadding=5><tr valign=top>";
		print "<td><font face=arial size=2><center>";
		print "<img src=\"/images/instabase/regsoft1.gif\"><br>";
		print "Secure Online Transaction Service Provided by Regsoft.com<p>";
		print "<b>InstaBase 4.0 Web Ready Electronic Version - <font color=\"#FF0000\">US\$59.00</font></b><br>";
		print "<center><img src=\"/images/instabase/visa.gif\"> <img src=\"/images/instabase/mastercard.gif\"> <img src=\"/images/instabase/amex.gif\"></center><p>";
		print "<a href=\"http://www.regsoft.net/purchase.php3?productid=30771\"><img src=\"/images/instabase/regsoft_button1.gif\" border=0></a>";
		print "<p>If you haven't downloaded InstaBase yet, please make sure you do so by clicking on the link to the left, labeled <b>Download</b></font></td></tr></table>";
	   }

	   if($cgi{'media'}=~/cd/){
		&print_cd;
	   }

	}
	if($cgi{'country'}=~/canada/){
 if($cgi{'media'}=~/electronic/){
		print "<table bgcolor=\"#FFFDDF\" width=200 border=2 cellpadding=5><tr valign=top>";
		print "<td><font face=arial size=2><center>";
		print "<img src=\"/images/instabase/regsoft1.gif\"><br>";
		print "Secure Online Transaction Service Provided by Regsoft.com<p>";
		print "Canadian customers please note that your payment will be converted to Canadian dollars on your credit card statement and will be based on current rates of exchange.<p>";
		print "<b>InstaBase 4.0 Web Ready Electronic Version - <font color=\"#FF0000\">US\$59.00</font></b><br>";
		print "<center><img src=\"/images/instabase/visa.gif\"> <img src=\"/images/instabase/mastercard.gif\"> <img src=\"/images/instabase/amex.gif\"></center><p>";
		print "<a href=\"http://www.regsoft.net/purchase.php3?productid=30771\"><img src=\"/images/instabase/regsoft_button1.gif\" border=0></a>";
		print "<p>If you haven't downloaded InstaBase yet, please make sure you do so by clicking on the link to the left, labeled <b>Download</b></font></td></tr></table>";
	   }

	   if($cgi{'media'}=~/cd/){

		&print_cd;
   	   
	   }
	}
}

#--------------------------------- 4.0 standard upgrade -------------------------

if($cgi{'product'}=~/3/){
	if($cgi{'country'}=~/us/){
		print "<h2>Thank you.<br>Upgrade payments can only be made with a cheque<br><font color=red>Please send a cheque for \$9.00</font> in US Funds to: </h2>";
		print "<table bgcolor=\"#fffddf\" border=1><tr><td><ul><b>";
		print "Ezenet Inc.<br>";
		print "940-90 Eglinton Ave. East<br>";
		print "Toronto, ON   M4P 2Y3<br>";
		print "Canada</b></ul><p>";
		print "Please include with your cheque a letter with:<ul>";
		print "<li>Your name<br>";
		print "<li>Your full mailing address<br>";
		print "<li>Your Email and Telephone<br>";
		print "<li>The Security Code that InstaBase displays on startup.</ul>";
		print "<p>If you haven't downloaded InstaBase yet, please make sure you do so by clicking on the link to the left, labeled <b>Download</b></font></td></tr></table>";

	}
	if($cgi{'country'}=~/canada/){
		print "<h2>Thank you.<br>Upgrade payments can only be made with a cheque<br><font color=red>Please send a cheque for \$20.33 (\$21.85 if in Ontario)</font><br>in Canadian Funds to: </h2>";
		print "<table bgcolor=\"#fffddf\" border=1><tr><td><ul><b>";
		print "Ezenet Inc.<br>";
		print "940-90 Eglinton Ave. East<br>";
		print "Toronto, ON   M4P 2Y3<br>";
		print "Canada</b></ul><p>";
		print "Please include with your cheque a letter with:<ul>";
		print "<li>Your name<br>";
		print "<li>Your full mailing address<br>";
		print "<li>Your Email and Telephone<br>";
		print "<li>The Security Code that InstaBase displays on startup.</ul>";
		print "<p>If you haven't downloaded InstaBase yet, please make sure you do so by clicking on the link to the left, labeled <b>Download</b></font></td></tr></table>";

	}
}

#--------------------------------- 4.0 web ready upgrade -------------------------

if($cgi{'product'}=~/4/){
	if($cgi{'country'}=~/us/){
		print "<h2>Thank you.<br>Upgrade payments can only be made with a cheque<br><font color=red>Please send a cheque for \$29.00</font> in US Funds to: </h2>";
		print "<table bgcolor=\"#fffddf\" border=1><tr><td><ul><b>";
		print "Ezenet Inc.<br>";
		print "940-90 Eglinton Ave. East<br>";
		print "Toronto, ON   M4P 2Y3<br>";
		print "Canada</b></ul><p>";
		print "Please include with your cheque a letter with:<ul>";
		print "<li>Your name<br>";
		print "<li>Your full mailing address<br>";
		print "<li>Your Email and Telephone<br>";
		print "<li>The Security Code that InstaBase displays on startup.</ul>";
		print "<p>If you haven't downloaded InstaBase yet, please make sure you do so by clicking on the link to the left, labeled <b>Download</b></font></td></tr></table>";

	}
	if($cgi{'country'}=~/canada/){
		print "<h2>Thank you.<br>Upgrade payments can only be made with a cheque<br><font color=red>Please send a cheque for \$41.73 (\$44.85 if in Ontario)</font><br>in Canadian Funds to: </h2></font>";
		print "<table bgcolor=\"#fffddf\" border=1><tr><td><ul><b>";
		print "Ezenet Inc.<br>";
		print "940-90 Eglinton Ave. East<br>";
		print "Toronto, ON   M4P 2Y3<br>";
		print "Canada</b></ul><p>";
		print "Please include with your cheque a letter with:<ul>";
		print "<li>Your name<br>";
		print "<li>Your full mailing address<br>";
		print "<li>Your Email and Telephone<br>";
		print "<li>The Security Code that InstaBase displays on startup.</ul>";
		print "<p>If you haven't downloaded InstaBase yet, please make sure you do so by clicking on the link to the left, labeled <b>Download</b></font></td></tr></table>";

	}
}



}

sub print_cd {
	print "\n";
	print "<table bgcolor=\"#FFFDDF\" width=100% border=2 cellpadding=5>\n<tr valign=top>\n";
			print "<td><font face=arial size=2>\n<center>\n";
			print "<BR><img src=\"/images/instabase/instabaselogo.gif\"></center><P>";
			print "Please note that the CD ROM version of InstaBase is only available through\n";
			print "retail stores. Visit the \"distribution\" section of our site to find out\n";
			print "where you can purchase InstaBase <A HREF=\"http://www.instabase.com/distribution.html\">http://www.instabase.com/distribution.html</A>\n<p>";
		
		
			print "If you live in an area where InstaBase is not available for purchase, you\n";
			print "may contact us at <a href=\"mailto:support\@instabase.com\">support\@instabase.com</a> to discuss alternative purchasing arrangements.\n";

			print "The \"electronic\" version of InstaBase that can be downloaded from our site\'s\n";
			print "download page may be purchased on-line.\n<P>";
	
			print "<center><B>Thanks for your interest in InstaBase!</b></center><P>\n";

		   	print "</tr></td></table>\n</center></BODY>\n</HTML>\n";
			exit;
}


