#!/usr/bin/perl -Tw -I. -I/usr/local/positive/Perl

#
# This software is copyright (c) 2001-2002 Positive Networks, Inc.  All rights reserved.
# 
# This software is the proprietary and confidential property of Positive Networks, Inc.
# Possession, transmission, publication, or use of this software is prohibited except by prior written consent.
#  

# reg.pl - handles the user registration proces

use strict;
use Pos::Webtop::Toolbox ();
use Digest::MD5;

my $tb = Pos::Webtop::Toolbox->new();
my $cgi = $tb->getCgi();
my $db = $tb->getPolicyDb();

# this is going to be specific to all customers,
# to separate one customer from another blah blah
my $adminLink = "http://omc.positivenetworks.net/admin";
my $customerName = "Olathe Medical Center";
#my $customerId = 16;
my $customerId = 3160;
my $imgSource = "LocalWebLib/techphoto1.jpg";
# get next id to use for insert


# Account Setup Information
my $firstName;
my $firstNameError;
my $middleInitial;
my $middleInitialError;
my $lastName;
my $lastNameError;
my $primaryEmailAddress;
my $primaryEmailAddressError;
my $secondaryEmailAddress;
my $secondaryEmailAddressError;
# Olathe Medical Center specific
my $userName;
my $userNameError;
my $lastFourSocial;
my $lastFourSocialError;
my $dateOfBirth;
my $dateOfBirthError;

# Home Address Information
my $homeAddress1;
my $homeAddress1Error;
my $homeAddress2;
my $homeCity;
my $homeCityError;
my $homeState;
my $homeStateError;
my $homeZipCode;
my $homeZipCodeError;
my $homePhone;
my $homePhoneError;

# Primary Office Information
my $primaryOfficeName;
my $primaryOfficeNameError;
my $primaryOfficeAddress1;
my $primaryOfficeAddress1Error;
my $primaryOfficeAddress2;
my $primaryOfficeCity;
my $primaryOfficeCityError;
my $primaryOfficeState;
my $primaryOfficeStateError;
my $primaryOfficeZipCode;
my $primaryOfficeZipCodeError;

# Secondary Office Information
my $secondaryOfficeName;
my $secondaryOfficeAddress1;
my $secondaryOfficeAddress2;
my $secondaryOfficeCity;
my $secondaryOfficeState;
my $secondaryOfficeZipCode;

# Credit Card Billing Address
my $sameAsHome;
my $ccBillingAddress1;
my $ccBillingAddress1Error;
my $ccBillingAddress2;
my $ccBillingAddress2Error;
my $ccBillingCity;
my $ccBillingCityError;
my $ccBillingState;
my $ccBillingStateError;
my $ccBillingZipCode;
my $ccBillingZipCodeError;

# Credit Card Payment Information
my $ccNameOnCard;
my $ccNameOnCardError;
my $ccType;
my $ccTypeError;
my $ccNumber;
my $ccNumberError;
my $ccExpirationMonth;
my $ccExpirationYear;
my $ccExpirationDateError;

#	$customerName;
	
# Account Setup Information plus error values
$firstName = $cgi->param('firstName');
$firstNameError = 0;
$middleInitial = $cgi->param('middleInitial');
$middleInitialError = 0;
$lastName = $cgi->param('lastName');
$lastNameError = 0;
$primaryEmailAddress = $cgi->param('primaryEmailAddress');
$primaryEmailAddressError = 0;
$secondaryEmailAddress = $cgi->param('secondaryEmailAddress');
$secondaryEmailAddressError = 0;
$userName = $cgi->param('userName');
$userNameError = 0;
$lastFourSocial = $cgi->param('lastFourSocial');
$lastFourSocialError = 0;
$dateOfBirth = $cgi->param('dateOfBirth');
$dateOfBirthError = 0;

# Home Address Information plus error values
$homeAddress1 = $cgi->param('homeAddress1');
$homeAddress1Error = 0;
$homeAddress2 = $cgi->param('homeAddress2');
$homeCity = $cgi->param('homeCity');
$homeCityError = 0;
$homeState = $cgi->param('homeState');
$homeStateError = 0;
$homeZipCode = $cgi->param('homeZipCode');
$homeZipCodeError = 0;
$homePhone = $cgi->param('homePhone');
$homePhoneError = 0;

# Primary Office Information plus erro values
$primaryOfficeName = $cgi->param('primaryOfficeName');
$primaryOfficeNameError = 0;
$primaryOfficeAddress1 = $cgi->param('primaryOfficeAddress1');
$primaryOfficeAddress1Error = 0;
$primaryOfficeAddress2 = $cgi->param('primaryOfficeAddress2');
$primaryOfficeCity = $cgi->param('primaryOfficeCity');
$primaryOfficeCityError = 0;
$primaryOfficeState = $cgi->param('primaryOfficeState');
$primaryOfficeStateError = 0;
$primaryOfficeZipCode = $cgi->param('primaryOfficeZipCode');
$primaryOfficeZipCodeError = 0;

# Secondary Office Information, no error values because fields are not required
$secondaryOfficeName = $cgi->param('secondaryOfficeName');
$secondaryOfficeAddress1 = $cgi->param('secondaryOfficeAddress1');
$secondaryOfficeAddress2 = $cgi->param('secondaryOfficeAddress2');
$secondaryOfficeCity = $cgi->param('secondaryOfficeCity');
$secondaryOfficeState = $cgi->param('secondaryOfficeState');
$secondaryOfficeZipCode = $cgi->param('secondaryOfficeZipCode');

# Credit Card Billing Information plus error values
$sameAsHome = $cgi->param('sameAsHome');
$ccBillingAddress1 = $cgi->param('ccBillingAddress1');
$ccBillingAddress1Error = 0;
$ccBillingAddress2 = $cgi->param('ccBillingAddress2');
$ccBillingAddress2Error = 0;
$ccBillingCity = $cgi->param('ccBillingCity');
$ccBillingCityError = 0;
$ccBillingState = $cgi->param('ccBillingState');
$ccBillingStateError = 0;
$ccBillingZipCode = $cgi->param('ccBillingZipCode');
$ccBillingZipCodeError = 0;

# Credit Card Information plus error values
$ccNameOnCard = $cgi->param('ccNameOnCard');
$ccNameOnCardError = 0;
$ccType = $cgi->param('ccType');
$ccTypeError = 0;
$ccNumber = $cgi->param('ccNumber');
$ccNumberError = 0;
$ccExpirationMonth = $cgi->param('ccExpirationMonth');
$ccExpirationYear = $cgi->param('ccExpirationYear');
$ccExpirationDateError = 0;



print "Content-type: text/html\n\n

			<html>
				<head>
					<title>
						Positive Networks: VPN Registration for $customerName	
					</title>

					<style type='text/css'>
						td.BOXTD1 { background-color: #00A000; font-family: verdana; font-size: 11pt; color: white; }
						td.BOXTD2 { background-color: white; font-family: verdana; font-size: 10pt }
					</style>
					
					
				</head>	
				<body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'>
					<table cellspacing='0' cellpadding='0' width='100%'>
						<tr>
							<td>
								<img src='$imgSource'><br>
							</td>
						</tr>
						<tr>
							<td bgcolor='#00270c'><img height='1' width='1 'src='LocalWebLib/space.gif'></td>
						</tr>
						<tr>
							<td bgcolor='#ff9700'><img height='11' src='LocalWebLib/space.gif'></td>
						</tr>
						<tr>
							<td bgcolor='#00270c'><img height='1' src='LocalWebLib/space.gif'></td>
						</tr>
						<tr>
							<td>
								<center>
									<b>VPN Registration: $customerName 
		";


if ($cgi->param('submit') or $cgi->param('back'))
{
		
	# Account Information Value Check
	if ( $cgi->param('firstName') eq "")
	{
		$firstNameError = 1;
	}
	
	if ( $lastName eq "" )
	{
		$lastNameError = 1;
	}
	
	if ( $primaryEmailAddress =~ /.+\@.+\..+/ and $cgi->param('primaryEmailAddress') ne "")
	{
		my ($isDuplicate) = $db->query( sql => "
									select
										count(*)
									from
										individual_signups i
									where
										upper(i.primary_email_address) = upper('$primaryEmailAddress')
									");

		if ( !$isDuplicate )
		{
			($isDuplicate) = $db->query( sql => "
										select
											count(*)
										from
											users u
										where
											u.user_name_key = upper('$primaryEmailAddress')
										");
		}	

		if ( $isDuplicate )
		{
			$primaryEmailAddressError = 2;
		}
		
	}
	
	if ( $primaryEmailAddress eq "" or $primaryEmailAddress !~ /.+\@.+\..+/)
	{
		$primaryEmailAddressError = 1;
	}
	
	if ( $cgi->param('secondaryEmailAddress') and $secondaryEmailAddress !~ /.+\@.+\..+/)
	{
		$secondaryEmailAddressError = 1;
	}
	
	if ( $cgi->param('userName') eq "")
	{
		$userNameError = 1;
	}
	
	if ( $cgi->param('lastFourSocial') eq "")
	{
		$lastFourSocialError = 1;
	}

	#if ( $cgi->param('dateOfBirth') eq "" or $dateOfBirth !~ /.+\/.+\/.+/)
	
	if ( $dateOfBirth =~ /(\d\d*)\/(\d\d*)\/(\d\d\d\d)/ )
	{
		my ($month,$day,$year) = ($1,$2,$3);

		$day < 1 and $dateOfBirthError = 1;
		$day > 31 and $dateOfBirthError = 1;
		$month < 1 and $dateOfBirthError = 1;
		$month > 12 and $dateOfBirthError = 1;
		$year < 1800 and $dateOfBirthError = 1;
		
		$day = sprintf("\%02lu",$day);
		$month = sprintf("\%02lu",$month);

		$dateOfBirth = "$month/$day/$year";
	}
	else
	{
		$dateOfBirthError = 1;
	}
	# Home Address Information Value Check
	if ( $cgi->param('homeAddress1') eq "")
	{
		$homeAddress1Error = 1;
	}

	if ( $cgi->param('homeCity') eq "")
	{
		$homeCityError = 1;
	}

	if ( $cgi->param('homeState') eq "")
	{
		$homeStateError = 1;
	}
	
	if ( $cgi->param('homeZipCode') eq "")
	{
		$homeZipCodeError = 1;
	}

	if ( $cgi->param('homePhone') eq "")
	{
		$homePhoneError = 1;
	}

	# Primary Office Information Value Check
	if ( $cgi->param('primaryOfficeName') eq "")
	{
		$primaryOfficeNameError = 1;
	}

	if ( $cgi->param('primaryOfficeAddress1') eq "")
	{
		$primaryOfficeAddress1Error = 1;
	}

	if ( $cgi->param('primaryOfficeCity') eq "")
	{	
		$primaryOfficeCityError = 1;
	}
	
	if ( $cgi->param('primaryOfficeState') eq "")
	{	
		$primaryOfficeStateError = 1;
	}
	
	if ( $cgi->param('primaryOfficeZipCode') eq "")
	{	
		$primaryOfficeZipCodeError = 1;
	}
	
# Secondary Office Informaton Value Check
# Shouldn't need this cause they aren't required fields
#	if ( $cgi->param('secondaryOfficeName') eq "")
#	{	
#		$secondaryOfficeNameError = 1;
#	}
#	
#	if ( $cgi->param('secondaryOfficeAddress1') eq "")
#	{	
#		$secondaryOfficeAddress1Error = 1;
#	}
#	
#	if ( $cgi->param('secondaryOfficeAddress2') eq "")
#	{	
#		$secondaryOfficeAddress2Error = 1;
#	}
#	
#	if ( $cgi->param('secondaryOfficeCity') eq "")
#	{	
#		$secondaryOfficeCityError = 1;
#	}
#	
#	if ( $cgi->param('secondaryOfficeState') eq "")
#	{	
#		$secondaryOfficeStateError = 1;
#	}
#	
#	if ( $cgi->param('secondaryOfficeZipCode') eq "")
#	{	
#		$secondaryOfficeZipCodeError = 1;
#	}
#	
	# If you submited from the new signup form and there were errors, reprint the new signup form with appropriate error values.
	if ( (($firstNameError || $lastNameError || $primaryEmailAddressError || $secondaryEmailAddressError || $userNameError || 
			$lastFourSocialError || $dateOfBirthError || $homeAddress1Error || $homeCityError || $homeStateError || $homeZipCodeError || $homePhoneError || 
			$primaryOfficeNameError || $primaryOfficeAddress1Error || $primaryOfficeCityError || $primaryOfficeStateError || 
			$primaryOfficeZipCodeError || $ccBillingAddress1Error || $ccBillingCityError || $ccBillingStateError || 
			$ccBillingZipCodeError || $ccNameOnCardError || $ccTypeError || $ccNumberError || $ccExpirationDateError) == 1)
			or ( $primaryEmailAddressError == 2 )
			or ( $cgi->param('back') ))
	{
	
		newSignupInfo(
			firstName=>$firstName,
			firstNameError=>$firstNameError,
			middleInitial=>$middleInitial,
			middleInitialError=>$middleInitialError,
			lastName=>$lastName,
			lastNameError=>$lastNameError,
			primaryEmailAddress=>$primaryEmailAddress,
			primaryEmailAddressError=>$primaryEmailAddressError,
			secondaryEmailAddress=>$secondaryEmailAddress,
			secondaryEmailAddressError=>$secondaryEmailAddressError,
			userName=>$userName,
			userNameError=>$userNameError,
			lastFourSocial=>$lastFourSocial,
			lastFourSocialError=>$lastFourSocialError,
			dateOfBirth=>$dateOfBirth,
			dateOfBirthError=>$dateOfBirthError,
			homeAddress1=>$homeAddress1,
			homeAddress1Error=>$homeAddress1Error,
			homeAddress2=>$homeAddress2,
			homeCity=>$homeCity,
			homeCityError=>$homeCityError,
			homeState=>$homeState,
			homeStateError=>$homeStateError,
			homeZipCode=>$homeZipCode,
			homeZipCodeError=>$homeZipCodeError,
			homePhone=>$homePhone,
			homePhoneError=>$homePhoneError,
			primaryOfficeName=>$primaryOfficeName,
			primaryOfficeNameError=>$primaryOfficeNameError,
			primaryOfficeAddress1=>$primaryOfficeAddress1,
			primaryOfficeAddress1Error=>$primaryOfficeAddress1Error,
			primaryOfficeAddress2=>$primaryOfficeAddress2,
			primaryOfficeCity=>$primaryOfficeCity,
			primaryOfficeCityError=>$primaryOfficeCityError,
			primaryOfficeState=>$primaryOfficeState,
			primaryOfficeStateError=>$primaryOfficeStateError,
			primaryOfficeZipCode=>$primaryOfficeZipCode,
			primaryOfficeZipCodeError=>$primaryOfficeZipCodeError,
			secondaryOfficeName=>$secondaryOfficeName,
			secondaryOfficeAddress1=>$secondaryOfficeAddress1,
			secondaryOfficeAddress2=>$secondaryOfficeAddress2,
			secondaryOfficeCity=>$secondaryOfficeCity,
			secondaryOfficeState=>$secondaryOfficeState,
			secondaryOfficeZipCode=>$secondaryOfficeZipCode,
			sameAsHome=>$sameAsHome,
			ccBillingAddress1=>$ccBillingAddress1,
			ccBillingAddress1Error=>$ccBillingAddress1Error,
			ccBillingAddress2=>$ccBillingAddress2,
			ccBillingAddress2Error=>$ccBillingAddress2Error,
			ccBillingCity=>$ccBillingCity,
			ccBillingCityError=>$ccBillingCityError,
			ccBillingState=>$ccBillingState,
			ccBillingStateError=>$ccBillingStateError,
			ccBillingZipCode=>$ccBillingZipCode,
			ccBillingZipCodeError=>$ccBillingZipCodeError,
			ccNameOnCard=>$ccNameOnCard,
			ccNameOnCardError=>$ccNameOnCardError,
			ccType=>$ccType,
			ccTypeError=>$ccTypeError,
			ccNumber=>$ccNumber,
			ccNumberError=>$ccNumberError,
			ccExpirationMonth=>$ccExpirationMonth,
			ccExpirationYear=>$ccExpirationYear,
			ccExpirationDateErro=>$ccExpirationDateError
		);
	}
	else
	{
		confirmInfo(
			firstName=>$firstName,
			firstNameError=>$firstNameError,
			middleInitial=>$middleInitial,
			middleInitialError=>$middleInitialError,
			lastName=>$lastName,
			lastNameError=>$lastNameError,
			primaryEmailAddress=>$primaryEmailAddress,
			primaryEmailAddressError=>$primaryEmailAddressError,
			secondaryEmailAddress=>$secondaryEmailAddress,
			secondaryEmailAddressError=>$secondaryEmailAddressError,
			userName=>$userName,
			userNameError=>$userNameError,
			lastFourSocial=>$lastFourSocial,
			lastFourSocialError=>$lastFourSocialError,
			dateOfBirth=>$dateOfBirth,
			dateOfBirthError=>$dateOfBirthError,
			homeAddress1=>$homeAddress1,
			homeAddress1Error=>$homeAddress1Error,
			homeAddress2=>$homeAddress2,
			homeCity=>$homeCity,
			homeCityError=>$homeCityError,
			homeState=>$homeState,
			homeStateError=>$homeStateError,
			homeZipCode=>$homeZipCode,
			homeZipCodeError=>$homeZipCodeError,
			homePhone=>$homePhone,
			homePhoneError=>$homePhoneError,
			primaryOfficeName=>$primaryOfficeName,
			primaryOfficeNameError=>$primaryOfficeNameError,
			primaryOfficeAddress1=>$primaryOfficeAddress1,
			primaryOfficeAddress1Error=>$primaryOfficeAddress1Error,
			primaryOfficeAddress2=>$primaryOfficeAddress2,
			primaryOfficeCity=>$primaryOfficeCity,
			primaryOfficeCityError=>$primaryOfficeCityError,
			primaryOfficeState=>$primaryOfficeState,
			primaryOfficeStateError=>$primaryOfficeStateError,
			primaryOfficeZipCode=>$primaryOfficeZipCode,
			primaryOfficeZipCodeError=>$primaryOfficeZipCodeError,
			secondaryOfficeName=>$secondaryOfficeName,
			secondaryOfficeAddress1=>$secondaryOfficeAddress1,
			secondaryOfficeAddress2=>$secondaryOfficeAddress2,
			secondaryOfficeCity=>$secondaryOfficeCity,
			secondaryOfficeState=>$secondaryOfficeState,
			secondaryOfficeZipCode=>$secondaryOfficeZipCode,
			sameAsHome=>$sameAsHome,
			ccBillingAddress1=>$ccBillingAddress1,
			ccBillingAddress1Error=>$ccBillingAddress1Error,
			ccBillingAddress2=>$ccBillingAddress2,
			ccBillingAddress2Error=>$ccBillingAddress2Error,
			ccBillingCity=>$ccBillingCity,
			ccBillingCityError=>$ccBillingCityError,
			ccBillingState=>$ccBillingState,
			ccBillingStateError=>$ccBillingStateError,
			ccBillingZipCode=>$ccBillingZipCode,
			ccBillingZipCodeError=>$ccBillingZipCodeError,
			ccNameOnCard=>$ccNameOnCard,
			ccNameOnCardError=>$ccNameOnCardError,
			ccType=>$ccType,
			ccTypeError=>$ccTypeError,
			ccNumber=>$ccNumber,
			ccNumberError=>$ccNumberError,
			ccExpirationMonth=>$ccExpirationMonth,
			ccExpirationYear=>$ccExpirationYear,
			ccExpirationDateErro=>$ccExpirationDateError
		);
	}
}
elsif ( $cgi->param('send') )
{
	my $individualSignupId = $db->getNextSequenceValue( sequence=> "individual_signups_pk" );
		$db->do( sql=> "
			insert into individual_signups (
				customer_id,
				individual_signup_id,
				first_name,
				middle_initial,
				last_name,
				primary_email_address,
				secondary_email_address,
				user_name,
				last_four_social,
				date_of_birth,
				home_address1,
				home_address2,
				home_city,
				home_state,
				home_zip_code,
				home_phone,
				primary_office_name,
				primary_office_address1,
				primary_office_address2,
				primary_office_city,
				primary_office_state,
				primary_office_zipcode,
				secondary_office_name,
				secondary_office_address1,
				secondary_office_address2,
				secondary_office_city,
				secondary_office_state,
				secondary_office_zip_code,
				cc_billing_address1,
				cc_billing_address2,
				cc_billing_city,
				cc_billing_state,
				cc_billing_zip_code,
				cc_name_on_card,
				cc_type,
				cc_number,
				cc_expiration_month,
				cc_expiration_year
			)	values (
				'$customerId',
				'" . $db->escape(dirty => $individualSignupId) . "',
				'" . $db->escape(dirty=>$firstName) . "',
				'" . $db->escape(dirty => $middleInitial) . "',
				'" . $db->escape(dirty => $lastName) . "',
				'" . $db->escape(dirty => $primaryEmailAddress) . "',
				'" . $db->escape(dirty => $secondaryEmailAddress) . "',
				'" . $db->escape(dirty => $userName) . "',
				'" . $db->escape(dirty => $lastFourSocial) . "',
				'" . $db->escape(dirty => $dateOfBirth) . "',
				'" . $db->escape(dirty => $homeAddress1) . "',
				'" . $db->escape(dirty => $homeAddress2) . "',
				'" . $db->escape(dirty => $homeCity) . "',
				'" . $db->escape(dirty => $homeState) . "',
				'" . $db->escape(dirty => $homeZipCode) . "',
				'" . $db->escape(dirty => $homePhone) . "',
				'" . $db->escape(dirty => $primaryOfficeName) . "',
				'" . $db->escape(dirty => $primaryOfficeAddress1) . "',
				'" . $db->escape(dirty => $primaryOfficeAddress2) . "',
				'" . $db->escape(dirty => $primaryOfficeCity) . "',
				'" . $db->escape(dirty => $primaryOfficeState) . "',
				'" . $db->escape(dirty => $primaryOfficeZipCode) . "',
				'" . $db->escape(dirty => $secondaryOfficeName) . "',
				'" . $db->escape(dirty => $secondaryOfficeAddress1) . "',
				'" . $db->escape(dirty => $secondaryOfficeAddress2) . "',
				'" . $db->escape(dirty => $secondaryOfficeCity) . "',
				'" . $db->escape(dirty => $secondaryOfficeState) . "',
				'" . $db->escape(dirty => $secondaryOfficeZipCode) . "',
				'" . $db->escape(dirty => $ccBillingAddress1) . "',
				'" . $db->escape(dirty => $ccBillingAddress2) . "',
				'" . $db->escape(dirty => $ccBillingCity) . "',
				'" . $db->escape(dirty => $ccBillingState) . "',
				'" . $db->escape(dirty => $ccBillingZipCode) . "',
				'" . $db->escape(dirty => $ccNameOnCard) . "',
				'" . $db->escape(dirty => $ccType) . "',
				'" . $db->escape(dirty => $ccNumber) . "',
				'" . $db->escape(dirty => $ccExpirationMonth) . "',
				'" . $db->escape(dirty => $ccExpirationYear) . "'
			)
		");

		$db->commit();

		my $subjectString = "New Doctor Sign-up";
		my @bodyString = qq($firstName $lastName \($primaryEmailAddress\) has signed up for $customerName.

Please view the signup form by clicking on the following URL:

$adminLink);

	
		my @emailAddresses = $db->query(sql => "
			select
				email_address
			from
				customer_pos_ind_signup_emails 
			where
				customer_id = '$customerId'
			");

		$db->disconnect();
		$db = undef;
	
		if (scalar(@emailAddresses))
		{
			$ENV{'PATH'} = "/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin";
			my $from = "\"Positive Networks\" <support\@positivenetworks.net>";

			email( to=> \@emailAddresses, from=> $from, subject=> $subjectString, body=> @bodyString );
		}
	verifiedSubmited();
}
else
{
	newSignupInfo(
		firstName=>$firstName,
		firstNameError=>$firstNameError,
		middleInitial=>$middleInitial,
		middleInitialError=>$middleInitialError,
		lastName=>$lastName,
		lastNameError=>$lastNameError,
		primaryEmailAddress=>$primaryEmailAddress,
		primaryEmailAddressError=>$primaryEmailAddressError,
		secondaryEmailAddress=>$secondaryEmailAddress,
		secondaryEmailAddressError=>$secondaryEmailAddressError,
		userName=>$userName,
		userNameError=>$userNameError,
		lastFourSocial=>$lastFourSocial,
		lastFourSocialError=>$lastFourSocialError,
		dateOfBirth=>$dateOfBirth,
		dateOfBirthError=>$dateOfBirthError,
		homeAddress1=>$homeAddress1,
		homeAddress1Error=>$homeAddress1Error,
		homeAddress2=>$homeAddress2,
		homeCity=>$homeCity,
		homeCityError=>$homeCityError,
		homeState=>$homeState,
		homeStateError=>$homeStateError,
		homeZipCode=>$homeZipCode,
		homeZipCodeError=>$homeZipCodeError,
		homePhone=>$homePhone,
		homePhoneError=>$homePhoneError,
		primaryOfficeName=>$primaryOfficeName,
		primaryOfficeNameError=>$primaryOfficeNameError,
		primaryOfficeAddress1=>$primaryOfficeAddress1,
		primaryOfficeAddress1Error=>$primaryOfficeAddress1Error,
		primaryOfficeAddress2=>$primaryOfficeAddress2,
		primaryOfficeCity=>$primaryOfficeCity,
		primaryOfficeCityError=>$primaryOfficeCityError,
		primaryOfficeState=>$primaryOfficeState,
		primaryOfficeStateError=>$primaryOfficeStateError,
		primaryOfficeZipCode=>$primaryOfficeZipCode,
		primaryOfficeZipCodeError=>$primaryOfficeZipCodeError,
		secondaryOfficeName=>$secondaryOfficeName,
		secondaryOfficeAddress1=>$secondaryOfficeAddress1,
		secondaryOfficeAddress2=>$secondaryOfficeAddress2,
		secondaryOfficeCity=>$secondaryOfficeCity,
		secondaryOfficeState=>$secondaryOfficeState,
		secondaryOfficeZipCode=>$secondaryOfficeZipCode,
		sameAsHome=>$sameAsHome,
		ccBillingAddress1=>$ccBillingAddress1,
		ccBillingAddress1Error=>$ccBillingAddress1Error,
		ccBillingAddress2=>$ccBillingAddress2,
		ccBillingAddress2Error=>$ccBillingAddress2Error,
		ccBillingCity=>$ccBillingCity,
		ccBillingCityError=>$ccBillingCityError,
		ccBillingState=>$ccBillingState,
		ccBillingStateError=>$ccBillingStateError,
		ccBillingZipCode=>$ccBillingZipCode,
		ccBillingZipCodeError=>$ccBillingZipCodeError,
		ccNameOnCard=>$ccNameOnCard,
		ccNameOnCardError=>$ccNameOnCardError,
		ccType=>$ccType,
		ccTypeError=>$ccTypeError,
		ccNumber=>$ccNumber,
		ccNumberError=>$ccNumberError,
		ccExpirationMonth=>$ccExpirationMonth,
		ccExpirationYear=>$ccExpirationYear,
		ccExpirationDateErro=>$ccExpirationDateError
	);
}

print "					</td>
						</tr>
					</table>
					</td>
				</tr>
			</table>
					
				</body>
			</html>
		";

sub newSignupInfo
{
	my (
		$firstName,
		$firstNameError,
		$middleInitial,
		$middleInitialError,
		$lastName,
		$lastNameError,
		$primaryEmailAddress,
		$primaryEmailAddressError,
		$secondaryEmailAddress,
		$secondaryEmailAddressError,
		$userName,
		$userNameError,
		$lastFourSocial,
		$lastFourSocialError,
		$dateOfBirth,
		$dateOfBirthError,
		$homeAddress1,
		$homeAddress1Error,
		$homeAddress2,
		$homeCity,
		$homeCityError,
		$homeState,
		$homeStateError,
		$homeZipCode,
		$homeZipCodeError,
		$homePhone,
		$homePhoneError,
		$primaryOfficeName,
		$primaryOfficeNameError,
		$primaryOfficeAddress1,
		$primaryOfficeAddress1Error,
		$primaryOfficeAddress2,
		$primaryOfficeCity,
		$primaryOfficeCityError,
		$primaryOfficeState,
		$primaryOfficeStateError,
		$primaryOfficeZipCode,
		$primaryOfficeZipCodeError,
		$secondaryOfficeName,
		$secondaryOfficeAddress1,
		$secondaryOfficeAddress2,
		$secondaryOfficeCity,
		$secondaryOfficeState,
		$secondaryOfficeZipCode,
		$sameAsHome,
		$ccBillingAddress1,
		$ccBillingAddress1Error,
		$ccBillingAddress2,
		$ccBillingAddress2Error,
		$ccBillingCity,
		$ccBillingCityError,
		$ccBillingState,
		$ccBillingStateError,
		$ccBillingZipCode,
		$ccBillingZipCodeError,
		$ccNameOnCard,
		$ccNameOnCardError,
		$ccType,
		$ccTypeError,
		$ccNumber,
		$ccNumberError,
		$ccExpirationMonth,
		$ccExpirationYear,
		$ccExpirationDateError
		)
	= @{{@_}}{qw/firstName firstNameError middleInitial middleInitialError lastName lastNameError primaryEmailAddress primaryEmailAddressError secondaryEmailAddress secondaryEmailAddressError userName userNameError lastFourSocial lastFourSocialError dateOfBirth dateOfBirthError homeAddress1 homeAddress1Error homeAddress2 homeCity homeCityError homeState homeStateError homeZipCode homeZipCodeError homePhone homePhoneError primaryOfficeName primaryOfficeNameError primaryOfficeAddress1 primaryOfficeAddress1Error primaryOfficeAddress2 primaryOfficeCity primaryOfficeCityError primaryOfficeState primaryOfficeStateError primaryOfficeZipCode primaryOfficeZipCodeError secondaryOfficeName secondaryOfficeAddress1 secondaryOfficeAddress2 secondaryOfficeCity secondaryOfficeState secondaryOfficeZipCode sameAsHome ccBillingAddress1 ccBillingAddress1Error ccBillingAddress2 ccBillingAddress2Error ccBillingCity ccBillingCityError ccBillingState ccBillingStateError ccBillingZipCode ccBillingZipCodeError ccNameOnCard ccNameOnCardError ccType ccTypeError ccNumber ccNumberError ccExpirationMonth ccExpirationYear ccExpirationDateError/}; 

	print " 					
						<form method='POST'>
						<table border='0' cellspacing='0' cellpadding='0'>
							<tr>
								<td>
						<table border='0' width='500'>
							<tr>
								<td colspan='3' class='BOXTD1'>
									<b><center> Account Setup Information </center></b>
								</td>
							</tr>
							<tr>
								<td class='BOXTD2'>
									<table border='0' width='100%'>
										<tr>
											<td class='BOXTD2'>
			";
							
						if ( !$firstNameError )
						{
							print " 
												First Name:<br>
									";
						}
						else
						{
							print "
												<font color='red'>First Name:</font><br>
									";
						}
				print "
												<input type='text' name='firstName' value='$firstName' size='20'>" . ($firstNameError ? "<font color='red'>*</font>" : "*") . "
											</td>
											<td class='BOXTD2' >
						";					
						
						if ( !$middleInitialError )
						{
							print "
												MI:<br>
									";			
						}
						else
						{
							print "
												<font color='red'>MI:</font></br>
									";
						}
						
				print "
											<input type='text' name='middleInitial' value='$middleInitial' size='1' maxlength='1'>
											</td>
										</tr>
									</table>
								</td>
								<td class='BOXTD2'>
			";	
			
			if ( !$lastNameError )
			{
				print "
									Last Name:<br>
						";
			}
			else
			{
				print "
									<font color='red'>Last Name:</font><br>
						";
			}
			
	print "								
									<input type='text' name='lastName' value='$lastName' size='20'>" . ($lastNameError ? "<font color='red'>*</font>" : "*") . "
								</td>
							</tr>
							<tr>
								<td class='BOXTD2'>
			";						
			if ( !$primaryEmailAddressError )
			{
				print "
								Primary Email Address:<br>
						";
			}
			elsif ( $primaryEmailAddressError eq '1' )
			{
				print	"
								<font color='red'>Primary Email Address:</font><br>
						";
			}
			else
			{
				print "
									<font color='red'>Primary Email Address: (In Use)</font><br>
						";
			}
	
	print "		
									<input type='text' name='primaryEmailAddress' value='$primaryEmailAddress' size='30'>" . ($primaryEmailAddressError ? "<font color='red'>*</font>" : "*") . "
								</td>
								<td class='BOXTD2'>
			";						
									
			if ( !$secondaryEmailAddressError )
			{
				print "
									Secondary Email Address:<br>
						";
			}
			else
			{
				print "
									<font color='red'>Secondary Email Address:</font><br>
						";
			}
			
	print "		
									<input type='text' name='secondaryEmailAddress' value='$secondaryEmailAddress' size='30'>" . ($secondaryEmailAddressError ? "<font color='red'>*</font>" : "") . "
								</td>
							</tr>
							<tr>
								<td class='BOXTD2'>
			";						
									
			if ( !$userNameError )
			{
				print "
									Cerner User ID:<br>
						";
			}
			else
			{
				print "
									<font color='red'>Cerner User ID:</font><br>
						";
			}
			
	print "		
									<input type='text' name='userName' value='$userName' size='20'>" . ($userNameError ? "<font color='red'>*</font>" : "*") . "
								</td>
								<td class='BOXTD2'>
			";						
									
			if ( !$lastFourSocialError )
			{
				print "
									Last 4 digits of SSN:<br>
						";
			}
			else
			{
				print "
									<font color='red'>Last 4 digits of SSN:</font><br>
						";
			}
			
	print "		
									<input type='text' name='lastFourSocial' value='$lastFourSocial' size='4' maxlength='4'>" . ($lastFourSocialError ? "<font color='red'>*</font>" : "*") . "
								</td>
							</tr>
							
							<tr>
								<td class='BOXTD2'  colspan='2'>
			";						
									
			if ( !$dateOfBirthError )
			{
				print "
									Date of Birth:<br>
						";
			}
			else
			{
				print "
									<font color='red'>Date of Birth:</font><br>
						";
			}
			
	print "		
									<input type='text' name='dateOfBirth' value='$dateOfBirth' size='10' maxlength='10'>" . ($dateOfBirthError ? "<font color='red'>*</font>" : "*") . "
									MM/DD/YYYY
								</td>
							</tr>
						</table>
						<table width='500' border='0'>
							<tr>
								<td colspan='3' class='BOXTD1'>
									<b><center> Home Address </center></b>
								</td>
							</tr>
							<tr>
								<td class='BOXTD2' colspan='3' >
			";						
									
			if ( !$homeAddress1Error )
			{
				print "
									Address1:<br>
						";
			}
			else
			{
				print "
									<font color='red'>Address1:</font><br>
						";
			}
			
	print "		
									<input type='text' name='homeAddress1' value='$homeAddress1' size='40'>" . ($homeAddress1Error ? "<font color='red'>*</font>" : "*") . "
								</td>
							</tr>
							<tr>
								<td class='BOXTD2' colspan='3' >
									Address2:<br>
									<input type='text' name='homeAddress2' value='$homeAddress2' size='40'>
								</td>
							</tr>
							<tr>
								<td class='BOXTD2' >
			";						
									
			if ( !$homeCityError )
			{
				print "
									City:<br>
						";
			}
			else
			{
				print "
										<font color='red'>City:</font><br>
						";
			}
			
	print "		
									<input type='text' name='homeCity' value='$homeCity' size='20'>" . ($homeCityError ? "<font color='red'>*</font>" : "*") . "
								</td>
								<td class='BOXTD2'>
			";						
									
			if ( !$homeStateError )
			{
				print "
									State:<br>
						";
			}
			else
			{
				print "
										<font color='red'>State:</font><br>
						";
			}
			
	print "		
									<select name='homeState'>
										<option value='' " . ($homeState eq "" ? " SELECTED " : "" ) . " >
										<option value='AK' " . ($homeState eq "AK" ? " SELECTED " : "" ) . " >AK
										<option value='AL' " . ($homeState eq "AL" ? " SELECTED " : "" ) . "  >AL
										<option value='AR' " . ($homeState eq "AR" ? " SELECTED " : "" ) . "  >AR
										<option value='AZ' " . ($homeState eq "AZ" ? " SELECTED " : "" ) . "  >AZ
										<option value='CA' " . ($homeState eq "CA" ? " SELECTED " : "" ) . "  >CA
										<option value='CO' " . ($homeState eq "CO" ? " SELECTED " : "" ) . "  >CO
										<option value='CT' " . ($homeState eq "CT" ? " SELECTED " : "" ) . "  >CT
										<option value='DC' " . ($homeState eq "DC" ? " SELECTED " : "" ) . "  >DC
										<option value='DE' " . ($homeState eq "DE" ? " SELECTED " : "" ) . "  >DE
										<option value='FL' " . ($homeState eq "FL" ? " SELECTED " : "" ) . "  >FL
										<option value='GA' " . ($homeState eq "GA" ? " SELECTED " : "" ) . "  >GA
										<option value='HI' " . ($homeState eq "HI" ? " SELECTED " : "" ) . "  >HI
										<option value='IA' " . ($homeState eq "IA" ? " SELECTED " : "" ) . "  >IA
										<option value='ID' " . ($homeState eq "ID" ? " SELECTED " : "" ) . "  >ID
										<option value='IL' " . ($homeState eq "IL" ? " SELECTED " : "" ) . "  >IL
										<option value='IN' " . ($homeState eq "IN" ? " SELECTED " : "" ) . "  >IN
										<option value='KS' " . ($homeState eq "KS" ? " SELECTED " : "" ) . "  >KS
										<option value='KY' " . ($homeState eq "KY" ? " SELECTED " : "" ) . "  >KY
										<option value='LA' " . ($homeState eq "LA" ? " SELECTED " : "" ) . "  >LA
										<option value='MA' " . ($homeState eq "MA" ? " SELECTED " : "" ) . "  >MA
										<option value='MD' " . ($homeState eq "MD" ? " SELECTED " : "" ) . "  >MD
										<option value='ME' " . ($homeState eq "ME" ? " SELECTED " : "" ) . "  >ME
										<option value='MI' " . ($homeState eq "MI" ? " SELECTED " : "" ) . "  >MI
										<option value='MN' " . ($homeState eq "MN" ? " SELECTED " : "" ) . "  >MN
										<option value='MO' " . ($homeState eq "MO" ? " SELECTED " : "" ) . "  >MO
										<option value='MS' " . ($homeState eq "MS" ? " SELECTED " : "" ) . "  >MS
										<option value='MT' " . ($homeState eq "MT" ? " SELECTED " : "" ) . "  >MT
										<option value='NC' " . ($homeState eq "NC" ? " SELECTED " : "" ) . "  >NC
										<option value='ND' " . ($homeState eq "ND" ? " SELECTED " : "" ) . "  >ND
										<option value='NE' " . ($homeState eq "NE" ? " SELECTED " : "" ) . "  >NE
										<option value='NH' " . ($homeState eq "NH" ? " SELECTED " : "" ) . "  >NH
										<option value='NJ' " . ($homeState eq "NJ" ? " SELECTED " : "" ) . "  >NJ
										<option value='NM' " . ($homeState eq "NM" ? " SELECTED " : "" ) . "  >NM
										<option value='NV' " . ($homeState eq "NV" ? " SELECTED " : "" ) . "  >NV
										<option value='NY' " . ($homeState eq "NY" ? " SELECTED " : "" ) . "  >NY
										<option value='OH' " . ($homeState eq "OH" ? " SELECTED " : "" ) . "  >OH
										<option value='OK' " . ($homeState eq "OK" ? " SELECTED " : "" ) . "  >OK
										<option value='OR' " . ($homeState eq "OR" ? " SELECTED " : "" ) . "  >OR
										<option value='PA' " . ($homeState eq "PA" ? " SELECTED " : "" ) . "  >PA
										<option value='RI' " . ($homeState eq "RI" ? " SELECTED " : "" ) . "  >RI
										<option value='SC' " . ($homeState eq "SC" ? " SELECTED " : "" ) . "  >SC
										<option value='SD' " . ($homeState eq "SD" ? " SELECTED " : "" ) . "  >SD
										<option value='TN' " . ($homeState eq "TN" ? " SELECTED " : "" ) . "  >TN
										<option value='TX' " . ($homeState eq "TX" ? " SELECTED " : "" ) . "  >TX
										<option value='UT' " . ($homeState eq "UT" ? " SELECTED " : "" ) . "  >UT
										<option value='VA' " . ($homeState eq "VA" ? " SELECTED " : "" ) . "  >VA
										<option value='VT' " . ($homeState eq "VT" ? " SELECTED " : "" ) . "  >VT
										<option value='WA' " . ($homeState eq "WA" ? " SELECTED " : "" ) . "  >WA
										<option value='WI' " . ($homeState eq "WI" ? " SELECTED " : "" ) . "  >WI
										<option value='WV' " . ($homeState eq "WV" ? " SELECTED " : "" ) . "  >WV
										<option value='WY' " . ($homeState eq "WY" ? " SELECTED " : "" ) . "  >WY
									</select>" . ($homeStateError ? "<font color='red'>*</font>" : "*") . "			
								</td>
								<td class='BOXTD2' width='50%'>
			";						
									
			if ( !$homeZipCodeError )
			{
				print "
									Zip Code:<br>
						";
			}
			else
			{
				print "
										<font color='red'>Zip Code:</font><br>
						";
			}
			
	print "		
									<input type='text' name='homeZipCode' value='$homeZipCode' size='5' maxlength='5'>" . ($homeZipCodeError ? "<font color='red'>*</font>" : "*") . "
								</td>
							</tr>
							
							<tr>
								<td class='BOXTD2' colspan='3'>
			";						
									
			if ( !$homePhoneError )
			{
				print "
									Phone Number:<br>
						";
			}
			else
			{
				print "
										<font color='red'>Phone Number:</font><br>
						";
			}
			
	print "		
									<input type='text' name='homePhone' value='$homePhone' size='25' maxlength='25'>" . ($homePhoneError ? "<font color='red'>*</font>" : "*") . "
								</td>
							</tr>
						</table>
						
						<table border='0' width='500'>
							<tr>
								<td class='BOXTD1' colspan='3'>
									<b><center> Primary Office Address </center></b>
								</td>
							</tr>
							<tr>
								<td class='BOXTD2' colspan='3'>
			";						
									
			if ( !$primaryOfficeNameError )
			{
				print "
									Name of Office, Clinic or Hospital:<br>
						";
			}
			else
			{
				print "
										<font color='red'>Name of Office, Clinic or Hospital:</font><br>
						";
			}
			
	print "		
									<input type='text' name='primaryOfficeName' value='$primaryOfficeName' size='30'>" . ($primaryOfficeNameError ? "<font color='red'>*</font>" : "*") . "
								</td>
							</tr>
							<tr>
								<td class='BOXTD2' colspan='3'>
			";						
									
			if ( !$primaryOfficeAddress1Error )
			{
				print "
									Address1:<br>
						";
			}
			else
			{
				print "
										<font color='red'>Address1:</font><br>
						";
			}
			
	print "		
									<input type='text' name='primaryOfficeAddress1' value='$primaryOfficeAddress1' size='40'>" . ($primaryOfficeAddress1Error ? "<font color='red'>*</font>" : "*") . "
								</td>
							</tr>
							<tr>
								<td class='BOXTD2' colspan='3'>
									Address2:<br>
									<input type='text' name='primaryOfficeAddress2' value='$primaryOfficeAddress2' size='40'>
								</td>
							</tr>
							<tr>
								<td class='BOXTD2' >
			";						
									
			if ( !$primaryOfficeCityError )
			{
				print "
									City:<br>
						";
			}
			else
			{
				print "
										<font color='red'>City:</font><br>
						";
			}
			
	print "		
									<input type='text' name='primaryOfficeCity' value='$primaryOfficeCity' size='20'>" . ($primaryOfficeCityError ? "<font color='red'>*</font>" : "*") . "
								</td>
								<td class='BOXTD2' >
			";						
									
			if ( !$primaryOfficeStateError )
			{
				print "
									State:<br>
						";
			}
			else
			{
				print "
										<font color='red'>State:</font><br>
						";
			}
			
	print "		
									<select name='primaryOfficeState'>
										<option value='' " . ($primaryOfficeState eq "" ? " SELECTED " : "" ) . " >
										<option value='AK' " . ($primaryOfficeState eq "AK" ? " SELECTED " : "" ) . " >AK
										<option value='AL' " . ($primaryOfficeState eq "AL" ? " SELECTED " : "" ) . "  >AL
										<option value='AR' " . ($primaryOfficeState eq "AR" ? " SELECTED " : "" ) . "  >AR
										<option value='AZ' " . ($primaryOfficeState eq "AZ" ? " SELECTED " : "" ) . "  >AZ
										<option value='CA' " . ($primaryOfficeState eq "CA" ? " SELECTED " : "" ) . "  >CA
										<option value='CO' " . ($primaryOfficeState eq "CO" ? " SELECTED " : "" ) . "  >CO
										<option value='CT' " . ($primaryOfficeState eq "CT" ? " SELECTED " : "" ) . "  >CT
										<option value='DC' " . ($primaryOfficeState eq "DC" ? " SELECTED " : "" ) . "  >DC
										<option value='DE' " . ($primaryOfficeState eq "DE" ? " SELECTED " : "" ) . "  >DE
										<option value='FL' " . ($primaryOfficeState eq "FL" ? " SELECTED " : "" ) . "  >FL
										<option value='GA' " . ($primaryOfficeState eq "GA" ? " SELECTED " : "" ) . "  >GA
										<option value='HI' " . ($primaryOfficeState eq "HI" ? " SELECTED " : "" ) . "  >HI
										<option value='IA' " . ($primaryOfficeState eq "IA" ? " SELECTED " : "" ) . "  >IA
										<option value='ID' " . ($primaryOfficeState eq "ID" ? " SELECTED " : "" ) . "  >ID
										<option value='IL' " . ($primaryOfficeState eq "IL" ? " SELECTED " : "" ) . "  >IL
										<option value='IN' " . ($primaryOfficeState eq "IN" ? " SELECTED " : "" ) . "  >IN
										<option value='KS' " . ($primaryOfficeState eq "KS" ? " SELECTED " : "" ) . "  >KS
										<option value='KY' " . ($primaryOfficeState eq "KY" ? " SELECTED " : "" ) . "  >KY
										<option value='LA' " . ($primaryOfficeState eq "LA" ? " SELECTED " : "" ) . "  >LA
										<option value='MA' " . ($primaryOfficeState eq "MA" ? " SELECTED " : "" ) . "  >MA
										<option value='MD' " . ($primaryOfficeState eq "MD" ? " SELECTED " : "" ) . "  >MD
										<option value='ME' " . ($primaryOfficeState eq "ME" ? " SELECTED " : "" ) . "  >ME
										<option value='MI' " . ($primaryOfficeState eq "MI" ? " SELECTED " : "" ) . "  >MI
										<option value='MN' " . ($primaryOfficeState eq "MN" ? " SELECTED " : "" ) . "  >MN
										<option value='MO' " . ($primaryOfficeState eq "MO" ? " SELECTED " : "" ) . "  >MO
										<option value='MS' " . ($primaryOfficeState eq "MS" ? " SELECTED " : "" ) . "  >MS
										<option value='MT' " . ($primaryOfficeState eq "MT" ? " SELECTED " : "" ) . "  >MT
										<option value='NC' " . ($primaryOfficeState eq "NC" ? " SELECTED " : "" ) . "  >NC
										<option value='ND' " . ($primaryOfficeState eq "ND" ? " SELECTED " : "" ) . "  >ND
										<option value='NE' " . ($primaryOfficeState eq "NE" ? " SELECTED " : "" ) . "  >NE
										<option value='NH' " . ($primaryOfficeState eq "NH" ? " SELECTED " : "" ) . "  >NH
										<option value='NJ' " . ($primaryOfficeState eq "NJ" ? " SELECTED " : "" ) . "  >NJ
										<option value='NM' " . ($primaryOfficeState eq "NM" ? " SELECTED " : "" ) . "  >NM
										<option value='NV' " . ($primaryOfficeState eq "NV" ? " SELECTED " : "" ) . "  >NV
										<option value='NY' " . ($primaryOfficeState eq "NY" ? " SELECTED " : "" ) . "  >NY
										<option value='OH' " . ($primaryOfficeState eq "OH" ? " SELECTED " : "" ) . "  >OH
										<option value='OK' " . ($primaryOfficeState eq "OK" ? " SELECTED " : "" ) . "  >OK
										<option value='OR' " . ($primaryOfficeState eq "OR" ? " SELECTED " : "" ) . "  >OR
										<option value='PA' " . ($primaryOfficeState eq "PA" ? " SELECTED " : "" ) . "  >PA
										<option value='RI' " . ($primaryOfficeState eq "RI" ? " SELECTED " : "" ) . "  >RI
										<option value='SC' " . ($primaryOfficeState eq "SC" ? " SELECTED " : "" ) . "  >SC
										<option value='SD' " . ($primaryOfficeState eq "SD" ? " SELECTED " : "" ) . "  >SD
										<option value='TN' " . ($primaryOfficeState eq "TN" ? " SELECTED " : "" ) . "  >TN
										<option value='TX' " . ($primaryOfficeState eq "TX" ? " SELECTED " : "" ) . "  >TX
										<option value='UT' " . ($primaryOfficeState eq "UT" ? " SELECTED " : "" ) . "  >UT
										<option value='VA' " . ($primaryOfficeState eq "VA" ? " SELECTED " : "" ) . "  >VA
										<option value='VT' " . ($primaryOfficeState eq "VT" ? " SELECTED " : "" ) . "  >VT
										<option value='WA' " . ($primaryOfficeState eq "WA" ? " SELECTED " : "" ) . "  >WA
										<option value='WI' " . ($primaryOfficeState eq "WI" ? " SELECTED " : "" ) . "  >WI
										<option value='WV' " . ($primaryOfficeState eq "WV" ? " SELECTED " : "" ) . "  >WV
										<option value='WY' " . ($primaryOfficeState eq "WY" ? " SELECTED " : "" ) . "  >WY
									</select>" . ($primaryOfficeStateError ? "<font color='red'>*</font>" : "*") . "			
								
								</td>
								<td class='BOXTD2' width='50%'>
			";						
									
			if ( !$primaryOfficeZipCodeError )
			{
				print "
									Zip Code:<br>
						";
			}
			else
			{
				print "
										<font color='red'>Zip Code:</font><br>
						";
			}
			
	print "		
									<input type='text' name='primaryOfficeZipCode' value='$primaryOfficeZipCode' size='5' maxlength='5'>" . ($primaryOfficeZipCodeError ? "<font color='red'>*</font>" : "*") . "
								</td>
							</tr>
						</table>

						<table border='0' width='500'>
							<tr>
								<td class='BOXTD1' colspan='3'>
									<b><center> Secondary Office Address </center></b>
								</td>
							</tr>
							<tr>
								<td class='BOXTD2' colspan='3'>
									Name of Office, Clinic or Hospital:<br>
			";						
									
#	if they do start to enter the non required secondary
#	office we can make sure they fill in all the fields
#  or somethin
#
#			if ( !$secondaryOfficeNameError )
#			{
#				print "
#									Name of Office, Clinic or Hospital:
#						";
#			}
#			else
#			{
#				print "
#									Name of Office, Clinic or Hospital:<font color='red'>*</font>
#						";
#			}
#			
	print "		
									<input type='text' name='secondaryOfficeName' value='$secondaryOfficeName' size='30'>
								</td>
							</tr>
							<tr>
								<td class='BOXTD2' colspan='3'>
									Address1:<br>
			";						
									
#	if they do start to enter the non required secondary
#	office we can make sure they fill in all the fields
#  or somethin
#
#			if ( !$secondaryOfficeAddress1Error )
#			{
#				print "
#									Address1:
#						";
#			}
#			else
#			{
#				print "
#									Address1:<font color='red'>*</font>
#						";
#			}
#			
	print "		
									<input type='text' name='secondaryOfficeAddress1' value='$secondaryOfficeAddress1' size='40'>
								</td>
							</tr>
							<tr>
								<td class='BOXTD2' colspan='3'>
									Address2:<br>
									<input type='text' name='secondaryOfficeAddress2' value='$secondaryOfficeAddress2' size='40'>
								</td>
							</tr>
							<tr>
								<td class='BOXTD2'>
									City:<br>
			";						
									
#	if they do start to enter the non required secondary
#	office we can make sure they fill in all the fields
#  or somethin
#
#			if ( !$secondaryOfficeCityError )
#			{
#				print "
#									City:
#						";
#			}
#			else
#			{
#				print "
#									City:<font color='red'>*</font>
#						";
#			}
#			
	print "		
									<input type='text' name='secondaryOfficeCity' value='$secondaryOfficeCity' size='20'>
								</td>
								<td class='BOXTD2' >
									State:<br>
			";						
									
#	if they do start to enter the non required secondary
#	office we can make sure they fill in all the fields
#  or somethin
#
#			if ( !$secondaryOfficeStateError )
#			{
#				print "
#									State:
#						";
#			}
#			else
#			{
#				print "
#									State:<font color='red'>*</font>
#						";
#			}
#			
	print "		
									<select name='secondaryOfficeState'>
										<option value='' " . ($secondaryOfficeState eq "" ? " SELECTED " : "" ) . " >
										<option value='AK' " . ($secondaryOfficeState eq "AK" ? " SELECTED " : "" ) . " >AK
										<option value='AL' " . ($secondaryOfficeState eq "AL" ? " SELECTED " : "" ) . "  >AL
										<option value='AR' " . ($secondaryOfficeState eq "AR" ? " SELECTED " : "" ) . "  >AR
										<option value='AZ' " . ($secondaryOfficeState eq "AZ" ? " SELECTED " : "" ) . "  >AZ
										<option value='CA' " . ($secondaryOfficeState eq "CA" ? " SELECTED " : "" ) . "  >CA
										<option value='CO' " . ($secondaryOfficeState eq "CO" ? " SELECTED " : "" ) . "  >CO
										<option value='CT' " . ($secondaryOfficeState eq "CT" ? " SELECTED " : "" ) . "  >CT
										<option value='DC' " . ($secondaryOfficeState eq "DC" ? " SELECTED " : "" ) . "  >DC
										<option value='DE' " . ($secondaryOfficeState eq "DE" ? " SELECTED " : "" ) . "  >DE
										<option value='FL' " . ($secondaryOfficeState eq "FL" ? " SELECTED " : "" ) . "  >FL
										<option value='GA' " . ($secondaryOfficeState eq "GA" ? " SELECTED " : "" ) . "  >GA
										<option value='HI' " . ($secondaryOfficeState eq "HI" ? " SELECTED " : "" ) . "  >HI
										<option value='IA' " . ($secondaryOfficeState eq "IA" ? " SELECTED " : "" ) . "  >IA
										<option value='ID' " . ($secondaryOfficeState eq "ID" ? " SELECTED " : "" ) . "  >ID
										<option value='IL' " . ($secondaryOfficeState eq "IL" ? " SELECTED " : "" ) . "  >IL
										<option value='IN' " . ($secondaryOfficeState eq "IN" ? " SELECTED " : "" ) . "  >IN
										<option value='KS' " . ($secondaryOfficeState eq "KS" ? " SELECTED " : "" ) . "  >KS
										<option value='KY' " . ($secondaryOfficeState eq "KY" ? " SELECTED " : "" ) . "  >KY
										<option value='LA' " . ($secondaryOfficeState eq "LA" ? " SELECTED " : "" ) . "  >LA
										<option value='MA' " . ($secondaryOfficeState eq "MA" ? " SELECTED " : "" ) . "  >MA
										<option value='MD' " . ($secondaryOfficeState eq "MD" ? " SELECTED " : "" ) . "  >MD
										<option value='ME' " . ($secondaryOfficeState eq "ME" ? " SELECTED " : "" ) . "  >ME
										<option value='MI' " . ($secondaryOfficeState eq "MI" ? " SELECTED " : "" ) . "  >MI
										<option value='MN' " . ($secondaryOfficeState eq "MN" ? " SELECTED " : "" ) . "  >MN
										<option value='MO' " . ($secondaryOfficeState eq "MO" ? " SELECTED " : "" ) . "  >MO
										<option value='MS' " . ($secondaryOfficeState eq "MS" ? " SELECTED " : "" ) . "  >MS
										<option value='MT' " . ($secondaryOfficeState eq "MT" ? " SELECTED " : "" ) . "  >MT
										<option value='NC' " . ($secondaryOfficeState eq "NC" ? " SELECTED " : "" ) . "  >NC
										<option value='ND' " . ($secondaryOfficeState eq "ND" ? " SELECTED " : "" ) . "  >ND
										<option value='NE' " . ($secondaryOfficeState eq "NE" ? " SELECTED " : "" ) . "  >NE
										<option value='NH' " . ($secondaryOfficeState eq "NH" ? " SELECTED " : "" ) . "  >NH
										<option value='NJ' " . ($secondaryOfficeState eq "NJ" ? " SELECTED " : "" ) . "  >NJ
										<option value='NM' " . ($secondaryOfficeState eq "NM" ? " SELECTED " : "" ) . "  >NM
										<option value='NV' " . ($secondaryOfficeState eq "NV" ? " SELECTED " : "" ) . "  >NV
										<option value='NY' " . ($secondaryOfficeState eq "NY" ? " SELECTED " : "" ) . "  >NY
										<option value='OH' " . ($secondaryOfficeState eq "OH" ? " SELECTED " : "" ) . "  >OH
										<option value='OK' " . ($secondaryOfficeState eq "OK" ? " SELECTED " : "" ) . "  >OK
										<option value='OR' " . ($secondaryOfficeState eq "OR" ? " SELECTED " : "" ) . "  >OR
										<option value='PA' " . ($secondaryOfficeState eq "PA" ? " SELECTED " : "" ) . "  >PA
										<option value='RI' " . ($secondaryOfficeState eq "RI" ? " SELECTED " : "" ) . "  >RI
										<option value='SC' " . ($secondaryOfficeState eq "SC" ? " SELECTED " : "" ) . "  >SC
										<option value='SD' " . ($secondaryOfficeState eq "SD" ? " SELECTED " : "" ) . "  >SD
										<option value='TN' " . ($secondaryOfficeState eq "TN" ? " SELECTED " : "" ) . "  >TN
										<option value='TX' " . ($secondaryOfficeState eq "TX" ? " SELECTED " : "" ) . "  >TX
										<option value='UT' " . ($secondaryOfficeState eq "UT" ? " SELECTED " : "" ) . "  >UT
										<option value='VA' " . ($secondaryOfficeState eq "VA" ? " SELECTED " : "" ) . "  >VA
										<option value='VT' " . ($secondaryOfficeState eq "VT" ? " SELECTED " : "" ) . "  >VT
										<option value='WA' " . ($secondaryOfficeState eq "WA" ? " SELECTED " : "" ) . "  >WA
										<option value='WI' " . ($secondaryOfficeState eq "WI" ? " SELECTED " : "" ) . "  >WI
										<option value='WV' " . ($secondaryOfficeState eq "WV" ? " SELECTED " : "" ) . "  >WV
										<option value='WY' " . ($secondaryOfficeState eq "WY" ? " SELECTED " : "" ) . "  >WY
									</select>			
								</td>
								<td class='BOXTD2' width='50%'>
									Zip code:<br>
			";						
#	if they do start to enter the non required secondary
#	office we can make sure they fill in all the fields
#  or somethin
#
#			if ( !$secondaryOfficeZipCodeError )
#			{
#				print "
#									Zip Code:
#						";
#			}
#			else
#			{
#				print "
#									Zip Code:<font color='red'>*</font>
#						";
#			}
#			
	print "		
									<input type='text' name='secondaryOfficeZipCode' value='$secondaryOfficeZipCode' size='5' maxlength='5'>
								</td>
							</tr>
						</table>
						<table align='center'>
							<tr>
								<td align='center' colspan='2'>
									&nbsp;
								</td>
							</tr>
							<tr>
								<td align='center' colspan='2'>
									<input type='submit' id='submit' name='submit' value='Submit'>
								</td>
							</tr>
						</table>
			";

}

sub confirmInfo
{
	my (
		$firstName,
		$firstNameError,
		$middleInitial,
		$middleInitialError,
		$lastName,
		$lastNameError,
		$primaryEmailAddress,
		$primaryEmailAddressError,
		$secondaryEmailAddress,
		$secondaryEmailAddressError,
		$userName,
		$userNameError,
		$lastFourSocial,
		$lastFourSocialError,
		$dateOfBirth,
		$dateOfBirthError,
		$homeAddress1,
		$homeAddress1Error,
		$homeAddress2,
		$homeCity,
		$homeCityError,
		$homeState,
		$homeStateError,
		$homeZipCode,
		$homeZipCodeError,
		$homePhone,
		$homePhoneError,
		$primaryOfficeName,
		$primaryOfficeNameError,
		$primaryOfficeAddress1,
		$primaryOfficeAddress1Error,
		$primaryOfficeAddress2,
		$primaryOfficeCity,
		$primaryOfficeCityError,
		$primaryOfficeState,
		$primaryOfficeStateError,
		$primaryOfficeZipCode,
		$primaryOfficeZipCodeError,
		$secondaryOfficeName,
		$secondaryOfficeAddress1,
		$secondaryOfficeAddress2,
		$secondaryOfficeCity,
		$secondaryOfficeState,
		$secondaryOfficeZipCode,
		$sameAsHome,
		$ccBillingAddress1,
		$ccBillingAddress1Error,
		$ccBillingAddress2,
		$ccBillingAddress2Error,
		$ccBillingCity,
		$ccBillingCityError,
		$ccBillingState,
		$ccBillingStateError,
		$ccBillingZipCode,
		$ccBillingZipCodeError,
		$ccNameOnCard,
		$ccNameOnCardError,
		$ccType,
		$ccTypeError,
		$ccNumber,
		$ccNumberError,
		$ccExpirationMonth,
		$ccExpirationYear,
		$ccExpirationDateError
		)
	= @{{@_}}{qw/firstName firstNameError middleInitial middleInitialError lastName lastNameError primaryEmailAddress primaryEmailAddressError secondaryEmailAddress secondaryEmailAddressError userName userNameError lastFourSocial lastFourSocialError dateOfBirth dateOfBirthError homeAddress1 homeAddress1Error homeAddress2 homeCity homeCityError homeState homeStateError homeZipCode homeZipCodeError homePhone homePhoneError primaryOfficeName primaryOfficeNameError primaryOfficeAddress1 primaryOfficeAddress1Error primaryOfficeAddress2 primaryOfficeCity primaryOfficeCityError primaryOfficeState primaryOfficeStateError primaryOfficeZipCode primaryOfficeZipCodeError secondaryOfficeName secondaryOfficeAddress1 secondaryOfficeAddress2 secondaryOfficeCity secondaryOfficeState secondaryOfficeZipCode sameAsHome ccBillingAddress1 ccBillingAddress1Error ccBillingAddress2 ccBillingAddress2Error ccBillingCity ccBillingCityError ccBillingState ccBillingStateError ccBillingZipCode ccBillingZipCodeError ccNameOnCard ccNameOnCardError ccType ccTypeError ccNumber ccNumberError ccExpirationMonth ccExpirationYear ccExpirationDateError/}; 

	print "
					<form method='POST' >
					<center>
					<input type='hidden' name='firstName' value='$firstName'>
					<input type='hidden' name='middleInitial' value='$middleInitial'>
					<input type='hidden' name='lastName' value='$lastName'>
					<input type='hidden' name='primaryEmailAddress' value='$primaryEmailAddress'>
					<input type='hidden' name='secondaryEmailAddress' value='$secondaryEmailAddress'>
					<input type='hidden' name='userName' value='$userName'>
					<input type='hidden' name='lastFourSocial' value='$lastFourSocial'>
					<input type='hidden' name='dateOfBirth' value='$dateOfBirth'>
					<input type='hidden' name='homeAddress1' value='$homeAddress1'>
					<input type='hidden' name='homeAddress2' value='$homeAddress2'>
					<input type='hidden' name='homeCity' value='$homeCity'>
					<input type='hidden' name='homeState' value='$homeState'>
					<input type='hidden' name='homeZipCode' value='$homeZipCode'>
					<input type='hidden' name='homePhone' value='$homePhone'>
					<input type='hidden' name='sameAsHome' value='$sameAsHome'>
					<input type='hidden' name='primaryOfficeName' value='$primaryOfficeName'>
					<input type='hidden' name='primaryOfficeAddress1' value='$primaryOfficeAddress1'>
					<input type='hidden' name='primaryOfficeAddress2' value='$primaryOfficeAddress2'>
					<input type='hidden' name='primaryOfficeCity' value='$primaryOfficeCity'>
					<input type='hidden' name='primaryOfficeState' value='$primaryOfficeState'>
					<input type='hidden' name='primaryOfficeZipCode' value='$primaryOfficeZipCode'>
					<input type='hidden' name='secondaryOfficeName' value='$secondaryOfficeName'>
					<input type='hidden' name='secondaryOfficeAddress1' value='$secondaryOfficeAddress1'>
					<input type='hidden' name='secondaryOfficeAddress2' value='$secondaryOfficeAddress2'>
					<input type='hidden' name='secondaryOfficeCity' value='$secondaryOfficeCity'>
					<input type='hidden' name='secondaryOfficeState' value='$secondaryOfficeState'>
					<input type='hidden' name='secondaryOfficeZipCode' value='$secondaryOfficeZipCode'>
					<table border='0' cellspacing='0' cellpadding='0'>
						<tr>
							<td>
					
					<table width='500' border='0'>
						<tr>
							<th colspan='2'>Please verify that your information is correct.
						</tr>
						<tr>
							<td class='BOXTD1' colspan='2'>
								<b><center> Account Setup Information </center></b>
							</td>
						</tr>
						<tr>
							<td class='BOXTD2'  width='50%'>
								First Name:
							</td>
							<td>
								$firstName
							</td>
						</tr>
						
						<tr>
							<td class='BOXTD2' >
								Middle Initial:
							</td>
							<td>
								$middleInitial
							</td>
						</tr>
				
						<tr>
							<td class='BOXTD2' >
								Last Name:
							</td>
							<td>
								$lastName
							</td>
						</tr>
			
						<tr>
							<td class='BOXTD2' >
								Primary Email:
							</td>
							<td>
								$primaryEmailAddress
							</td>
						</tr>
			
						<tr>
							<td class='BOXTD2' >
								Secondary Email:
							</td>
							<td>
								$secondaryEmailAddress	
							</td>
						</tr>
			
						<tr>
							<td class='BOXTD2' >
								Cerner User ID:
							</td>
							<td>
								$userName
							</td>
						</tr>
			
						<tr>
							<td class='BOXTD2' >
								Last 4 digits of SSN:
							</td>
							<td>
								$lastFourSocial
							</td>
						</tr>

						<tr>
							<td class='BOXTD2' >
								Date of Birth:
							</td>
							<td>
								$dateOfBirth
							</td>
						</tr>
			

						<tr>
							<td class='BOXTD1' colspan='2'>
								<b><center> Home Address </center></b>
							</td>
						</tr>
						<tr>
							<td class='BOXTD2' >
								Address1:
							</td>
							<td>
								$homeAddress1
							</td>
						</tr>
			
						<tr>
							<td class='BOXTD2' >
								Address2:	
							</td>
							<td>	
								$homeAddress2
							</td>
						</tr>
			
						<tr>
							<td class='BOXTD2' >
								City:
							</td>
							<td>
								$homeCity
							</td>
						</tr>
			
						<tr>
							<td class='BOXTD2' >
								State:
							</td>
							<td>
								$homeState
							</td>
						</tr>
			
						<tr>
							<td class='BOXTD2' >
								Zip:
							</td>
							<td>	
								$homeZipCode
							</td>
						</tr>
						
						<tr>
							<td class='BOXTD2' >
								Home Phone:
							</td>
							<td>
								$homePhone
							</td>
						</tr>
						
						<tr>
							<td class='BOXTD1' colspan='2'>
								<b><center> Primary Office Name </center></b>
							</td>
						</tr>
						<tr>
							<td class='BOXTD2' >
								Name of Office, Clinic, or Hospital:	
							</td>
							<td>
								$primaryOfficeName
							</td>
						</tr>

						<tr>
							<td class='BOXTD2' >
								Address1:
							</td>
							<td>
								$primaryOfficeAddress1
							</td>
						</tr>

						<tr>
							<td class='BOXTD2' >
								Address2:
							</td>
							<td>
								$primaryOfficeAddress2
							</td>
						</tr>

						<tr>
							<td class='BOXTD2' >
								City:
							</td>
							<td>
								$primaryOfficeCity
							</td>
						</tr>

						<tr>
							<td class='BOXTD2' >
								State:
							</td>
							<td>
								$primaryOfficeState
							</td>
						</tr>

						<tr>
							<td class='BOXTD2' >
								Zip Code:
							</td>
							<td>
								$primaryOfficeZipCode
							</td>
						</tr>

						
						<tr>
							<td class='BOXTD1' colspan='2'
								<b><center> Secondary Office Address </center></b>
							</td>
						</tr>
						
						<tr>
							<td class='BOXTD2' >
								Name of Office, Clinic, or Hospital:
							</td>
							<td>
								$secondaryOfficeName
							</td>
						</tr>

						<tr>
							<td class='BOXTD2' >
								Address1:
							</td>
							<td>
								$secondaryOfficeAddress1
							</td>
						</tr>

						<tr>
							<td class='BOXTD2' >
								Address2:
							</td>
							<td>
								$secondaryOfficeAddress2
							</td>
						</tr>

						<tr>
							<td class='BOXTD2' >
								City:
							</td>
							<td>
								$secondaryOfficeCity
							</td>
						</tr>

						<tr>
							<td class='BOXTD2' >
								State:
							</td>
							<td>
								$secondaryOfficeState
							</td>
						</tr>

						<tr>
							<td class='BOXTD2' >
								Zip Code:
							</td>
							<td>
								$secondaryOfficeZipCode
							</td>
						</tr>
						<tr>
							<td class='BOXTD1' colspan='2' align='center'>
								<input type='submit' name='back' value='Back'>
								<input type='submit' name='send' value='Submit Application'>
							</td>
						</tr>
					</table>
					</form>
		";
}
		
sub verifiedSubmited()
{
	print "
				<table width='500' border='0'>
					<tr>
						<td colspan='2' class='BOXTD2'>
							Thank you for submitting your request. You will be contacted by the Positive Networks Support Desk with instructions on activating your service as soon as we verify with your company that you are authorized to use the system.
						 	<br><br>
						  	If you need to begin using the system immediately or if you have any questions or problems, please contact our Support Desk:
							<br><br>
						</td>
					</tr>
					<tr>
						<td colspan='2' class='BOXTD1' align='center'>Support</td>
					</tr>
					<tr>
						<td class='BOXTD2' align='left' width='30%'>
							Local Support:
						</td>
						<td class='BOXTD2'>
							913-469-0005
						</td>
					</tr>
					<tr>
						<td class='BOXTD2' align='left'>
							Toll-free Support:
						</td>
						<td class='BOXTD2'>
							877-9-POSITIVE (877-976-7484)
						</td>
					</tr>
					<tr>
						<td class='BOXTD2' align='left'>
							Email Support:
						</td>
						<td>
							support\@positivenetworks.net
						</td>
					</tr>
				</table>
			";
}
		
sub email
{
	my ($subject,$from,$body,$to) = @{{@_}}{qw/subject from body to/};
	
	my $bto;
	my $cto;

	if ( ref($to) eq "ARRAY" )
	{
		$bto = join(', ',@{ $to });
		
		my @goodCtos = ();

		foreach my $badCto ( @{ $to } )
		{
			$badCto =~ s/(\W)/\\$1/g;
			push @goodCtos, $badCto;
		}

		$cto = join(' ',@goodCtos);
		$cto =~ /^(.*)$/;
		$cto = $1;
	}
	else
	{
		$bto = $to;
		$cto = $to;

		$cto =~ s/(\W)/\\$1/g;
		$cto =~ /^(.*)$/;
		$cto = $1;
	}

	$ENV{'PATH'} = "/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin";
	open(MAILPIPE,"| sendmail $cto");
	print MAILPIPE "From: $from\n";
	print MAILPIPE "To: $bto\n";
	print MAILPIPE "Subject: $subject\n";
	print MAILPIPE "\n";
	print MAILPIPE "$body\n";
	close(MAILPIPE);
}

