<?php
require_once __DIR__ . '/lib/form_compat.php';
$schoolid = 1;
$isSubmit = false;
if (isset($_GET['schoolid'])) {
	$schoolid = appFormString($_GET['schoolid'] ?? null);
	$schoolid = intval($schoolid) > 0 ? intval($schoolid) : 1;
}
else{
	$array = $_GET;
	foreach($array as $key => $value) {
		if (is_numeric($key)) {			
			$schoolid = trim($key);
		}
		break;
	}
}
if ($schoolid == 151) {
	include('turnbridge-apply-now.php');
	exit();
} elseif ($schoolid == 175 || $schoolid == 180) {
	//include('asichina-apply-now.php');
	include('asichina-apply-now-esl.php');
	exit();
} elseif ($schoolid == 169) {
	include('apex-apply-now.php');
	exit();
} elseif ($schoolid == 233) {	
	include('asitutoringcenter-apply-now.php');
	exit();
}

$vSERVER_NAME = $_SERVER['REQUEST_SCHEME'].'://'.$_SERVER['SERVER_NAME']; 

$rurl = "https://donotuse.adlsassist.com";
$rurlbv5 = "https://apiv5.adlsassist.com";    
$rurlbv5 = "https://apiprerelease.adlsassist.com";   
$rurlbv5 = "https://apistaging.adlsassist.com"; 

if ($host == "application.assisteducation.local") {
	$rurl = "http://assist.local";
}
if ($_SERVER['HTTP_HOST'] == "application.advantages-dls.localhost") {
	$rurlbv5 = "http://assistapiv2.localhost";    
	$rurl = "http://admin.adlsassist.localhost";
	$rurl = "https://donotuse.adlsassist.com";
	$API_APP_URL = "http://admin.adlsassist.localhost/api_application.php";
} else {
	$API_APP_URL = "$rurl/api_application.php";
	$rurl = "https://donotuse.adlsassist.com";
}


$varUrl = "$rurl/auth/getSchoolById?schoolid=$schoolid";
$arrContextOptions = array(
	"ssl" => array(
		"verify_peer" => false,
		"verify_peer_name" => false,
	),
);
$school_logo = "";
$school_name = "";
$urlLogo = "";
$contents = file_get_contents($varUrl, false, stream_context_create($arrContextOptions));
$contents = json_decode($contents);
if($contents && isset($contents->data->school_logo_temp)){
	$school_logo = $contents->data->school_logo_temp;
	$school_name = $contents->data->school_name;
	$urlLogo = $school_logo;
}
if (isset($schoolid) && $schoolid == "376") {
	$headertitle='Thank you for applying for "Workshop Series: Becoming a Global Citizen"<br>Our staff is available to answer any questions that you may have during the application process.';
}
else{
	$headertitle="Thank you for choosing $school_name! Please know our staff is available to answer any questions that you may have during the application and enrollment process.";
}

?>
<!DOCTYPE html>
<!--[if IE 9]> <html lang="en" class="ie9"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en">
<!--<![endif]-->

<head>
	<meta charset="utf-8">
	<title>Apply Now | <?php echo $school_name; ?></title>
	<meta name="description" content="Thank you for choosing ASI! Please know our staff is available to answer any questions that you may have during the application and enrollment process.">
	<meta name="keywords" content="student application, newsletter, official transcripts, partnerships, affordable" />

	<?php
	$host = $_SERVER['HTTP_HOST'];
	if ($host == "smi.advantages-dls.com"  || $host == "smi.adlsassist.com") {
		$schoolid = 186;
	}


	if ($schoolid == 1) {
		include('inc.head.php');
	} else {
		include('inc.otherschoolhead.php');
	}
	?>
	<link rel="stylesheet" href="style.css">
</head>
<?php
ini_set('display_errors', 1);
require_once __DIR__ . '/vendor/autoload.php';
require_once("lib/config.php");



$objMiscfeeURL="$rurlbv5/api/v2/get_misc_fee";
$applied_to="Application";
$objMiscfeeparams = array(
	'applied_to' => "$applied_to",	
	'school_id' => "$schoolid"
);

$postdata = http_build_query(
	$objMiscfeeparams
);

$opts = array(
	'ssl' => array(
		'verify_peer' => false,
		'verify_peername' => false			
	),
	'http' => array(
		'method' => 'POST',
		'header' => 
			'Content-type: application/x-www-form-urlencoded'."\r\n".
			'',
		'content' => $postdata
	)
);

$context = stream_context_create($opts);

$objMiscfee = file_get_contents($objMiscfeeURL, false, $context);
$objMiscfee = json_decode($objMiscfee);	
$objMiscfee = appApiListData($objMiscfee);

$objApplicationFee = array();
$ApplicationFeeMandatory=0;
$ApplicationFeeFee = 0;

$objESLTest = array();
$ESLTestMandatory=0;
$ESLTestFee = 25;
$ESLTestFeecaption = "";

$objLeahTest = array();
$LeahTestMandatory=0;
$LeahTestFee = 25;
$LeahTestFeecaption = "";

//$LeahTestMandatory=0;
//$LeahTestFee = 0;

$objAcademicAssessment = array();
$AcademicAssessmentMandatory=0;
$AcademicAssessmentFee = 99;
$AcademicAssessmentcaption="";

$objTranscriptUpload = array();
$TranscriptUploadMandatory=0;
$TranscriptUploadFee = 0;
$TranscriptUploadcaption="";

$objTranscriptUpload2 = array();
$TranscriptUploadMandatory2=0;
$TranscriptUploadFee2 = 0;
$TranscriptUploadcaption2="";

$objSuccessCenterprograms = array();
$SuccessCenterprogramsMandatory=0;
$SuccessCenterprogramsFee = 0;
$SuccessCenterprogramscaption="";

$objHasSpecialEducationNeedsServices = array();
$HasSpecialEducationNeedsServicesMandatory=0;
$HasSpecialEducationNeedsServicesFee = 0;
$HasSpecialEducationNeedsServicescaption="";

$newapplicationfee = 0;

$isHasApplicationFee= false;
$isHasEsltest= false;
$isHasAcademicAssessmentFee= false;
$isHasTranscriptUploadFee= false;
$isHasSuccessCenterprogramsFee= false;
$isHasHasSpecialEducationNeedsServicesFee= false;

$isShowPayment= false;

$lblApplicationFeeFee= "";
$lblESLTestFee= "";
$lblLeahTestFee= "";
$lblAcademicAssessmentFee= "";
$lblTranscriptUploadFee= "";
$lblSuccessCenterprogramsFee= "";

//Mandatory
$sPhoneMandatory=0;
$sEmailMandatory=0;
$sCountryMandatory=1;
$sDateofBirthMandatory=1;
$sMailingAddressMandatory=1;
$sGenderMandatory=1;

$pPhoneMandatory=1;
$pEmailMandatory=1;
$pCountryMandatory=0;
$pRelationshipMandatory=0;
$pHomeAddressMandatory=0;

$mCurriculumMandatory = 0;
$mAdditionalnotesMandatory = 0;
$Parent2Mandatory = 2;
$LearningCoachMandatory = 2;
$sFirstLanguageMandatory = 2;
$mCurrentSchoolNameMandatory = 2;
$mCurrentSchoolNamecaption = "Current School Name";
$mCoursesMandatory = 0;

$titleCountry = "Country of Residence";
if($schoolid == 384)
{
	$titleCountry = "Nationality";
}

$captionFirstName= '';
$captionLastName= '';
$captionSEmail= '';
if($schoolid == 376)
{
	$captionFirstName= '<br><i style="font-size: 13px;">"If you currently have an ASSIST portal, please write your name as it appears in your ASSIST portal"</i>';
	$captionLastName= '<br><i style="font-size: 13px;">"If you currently have an ASSIST portal, please write your name as it appears in your ASSIST portal"</i>';
	$captionSEmail= '<br><i style="font-size: 13px;">"Please add an active email, as this will be the main notification for course communications"</i>';
}

if(count($objMiscfee)){

	foreach ($objMiscfee as $oMiscfee) {
		$misc_fee_id = $oMiscfee->misc_fee_id;
		$misc_fee_name = $oMiscfee->misc_fee_name;
		if($misc_fee_name=="Application Fee"){
			$objApplicationFee = $oMiscfee;
			$ApplicationFeeMandatory=$oMiscfee->mandatory;
			$ApplicationFeeFee = $oMiscfee->fee;
			if($ApplicationFeeMandatory && !$isHasApplicationFee){
				$newapplicationfee += appFeeNumber($ApplicationFeeFee) ;
				$isHasApplicationFee= true;
				$isShowPayment= true;
				$lblApplicationFeeFee= "<b>$$ApplicationFeeFee &nbsp;&nbsp; Application Fee (mandatory)</b>";
			}
		}
		elseif($misc_fee_name=="ESL Test"){
			$objESLTest = $oMiscfee;
			$ESLTestMandatory=$oMiscfee->mandatory;
			$ESLTestFee = $oMiscfee->fee;
			$ESLTestFeecaption = $oMiscfee->caption;				
		}
		elseif($misc_fee_name=="Leah Test"){
			$objLeahTest = $oMiscfee;
			$LeahTestMandatory=$oMiscfee->mandatory;
			$LeahTestFee = $oMiscfee->fee;
			$LeahTestFeecaption = $oMiscfee->caption;				
		}
		elseif($misc_fee_name=="Has Special Education Needs Services"){
			$objHasSpecialEducationNeedsServices = $oMiscfee;
			$HasSpecialEducationNeedsServicesMandatory=$oMiscfee->mandatory;
			$HasSpecialEducationNeedsServicesFee = $oMiscfee->fee;			
			$HasSpecialEducationNeedsServicescaption = $oMiscfee->caption;

			if($HasSpecialEducationNeedsServicesMandatory && $HasSpecialEducationNeedsServicesMandatory != "2" && !$isHasHasSpecialEducationNeedsServicesFee){
				$newapplicationfee += appFeeNumber($HasSpecialEducationNeedsServicesFee) ;
				$isHasHasSpecialEducationNeedsServicesFee= true;
				$isShowPayment= true;
				$lblHasSpecialEducationNeedsServicesFee= "<b></b>";
			}
		}
		elseif($misc_fee_name=="Academic Assessment"){
			$objAcademicAssessment = $oMiscfee;
			$AcademicAssessmentMandatory=$oMiscfee->mandatory;
			$AcademicAssessmentFee = $oMiscfee->fee;
			$AcademicAssessmentcaption = $oMiscfee->caption;
			if($AcademicAssessmentMandatory && !$isHasAcademicAssessmentFee && $AcademicAssessmentFee>0){
				//$newapplicationfee += $AcademicAssessmentFee ;
				$isHasAcademicAssessmentFee= true;
				$isShowPayment= true;
				$lblAcademicAssessmentFee= "<b>$$AcademicAssessmentFee&nbsp;&nbsp; Academic Assessment Fee (mandatory)</b>";
			}
		}
		elseif($misc_fee_name=="Transcript Upload"){
			$objTranscriptUpload = $oMiscfee;
			$TranscriptUploadMandatory=$oMiscfee->mandatory;
			$TranscriptUploadFee = $oMiscfee->fee;		
			$TranscriptUploadcaption = $oMiscfee->caption;	
		}
		elseif($misc_fee_name=="Transcript Upload2"){
			$objTranscriptUpload2 = $oMiscfee;
			$TranscriptUploadMandatory2=$oMiscfee->mandatory;
			$TranscriptUploadFee2 = $oMiscfee->fee;		
			$TranscriptUploadcaption2 = $oMiscfee->caption;	
		}
		elseif($misc_fee_name=="Success Center programs"){ 			
			$objSuccessCenterprograms = $oMiscfee;
			$SuccessCenterprogramsMandatory=$oMiscfee->mandatory;
			$SuccessCenterprogramsFee = $oMiscfee->fee;			
			$SuccessCenterprogramscaption = $oMiscfee->caption;

			if($SuccessCenterprogramsMandatory && !$isHasSuccessCenterprogramsFee){
				$newapplicationfee += appFeeNumber($SuccessCenterprogramsFee) ;
				$isHasSuccessCenterprogramsFee= true;
				$isShowPayment= true;
				$lblSuccessCenterprogramsFee= "<b>$$ESLTestFee &nbsp;&nbsp; ESL Fee (mandatory)</b>";
			}
		}
		//Student Mandatory
		elseif($misc_fee_name=="sPhone"){
			$objsPhone = $oMiscfee;
			$sPhoneMandatory=$oMiscfee->mandatory;			
		}
		elseif($misc_fee_name=="sEmail"){
			$objsEmail = $oMiscfee;
			$sEmailMandatory=$oMiscfee->mandatory;			
		}
		elseif($misc_fee_name=="sCountry"){
			$objsCountry = $oMiscfee;
			$sCountryMandatory=$oMiscfee->mandatory;			
		}
		elseif($misc_fee_name=="sDateofBirth"){
			$objsDateofBirth = $oMiscfee;
			$sDateofBirthMandatory=$oMiscfee->mandatory;			
		}
		elseif($misc_fee_name=="sMailingAddress"){
			$objsMailingAddress = $oMiscfee;
			$sMailingAddressMandatory=$oMiscfee->mandatory;			
		}
		elseif($misc_fee_name=="sGender"){
			$objsGenderMandatory = $oMiscfee;
			$sGenderMandatory=$oMiscfee->mandatory;			
		}
		//parent Mandatory
		elseif($misc_fee_name=="pPhone"){
			$objpPhone = $oMiscfee;
			$pPhoneMandatory=$oMiscfee->mandatory;			
		}
		elseif($misc_fee_name=="pEmail"){
			$objpEmail = $oMiscfee;
			$pEmailMandatory=$oMiscfee->mandatory;			
		}
		elseif($misc_fee_name=="pCountry"){
			$objpCountry = $oMiscfee;
			$pCountryMandatory=$oMiscfee->mandatory;			
		}
		elseif($misc_fee_name=="pRelationship"){
			$objpRelationship = $oMiscfee;
			$pRelationshipMandatory=$oMiscfee->mandatory;			
		}
		elseif($misc_fee_name=="pHomeAddress"){
			$objpHomeAddress = $oMiscfee;
			$pHomeAddressMandatory=$oMiscfee->mandatory;			
		}

		//other mandatory
		elseif($misc_fee_name=="mCurriculum"){
			$objmCurriculum = $oMiscfee;
			$mCurriculumMandatory=$oMiscfee->mandatory;			
		}
		elseif($misc_fee_name=="mAdditionalnotes"){
			$objmAdditionalnotes = $oMiscfee;
			$mAdditionalnotesMandatory=$oMiscfee->mandatory;			
		}
		elseif($misc_fee_name=="Parent2"){
			$objParent2 = $oMiscfee;
			$Parent2Mandatory=$oMiscfee->mandatory;			
		}
		elseif($misc_fee_name=="LearningCoach"){
			$objLearningCoach = $oMiscfee;
			$LearningCoachMandatory=$oMiscfee->mandatory;			
		}
		elseif($misc_fee_name=="sFirstLanguage"){
			$objsFirstLanguage = $oMiscfee;
			$sFirstLanguageMandatory=$oMiscfee->mandatory;			
		}
		elseif($misc_fee_name=="mCurrentSchoolName"){
			$objmCurrentSchoolName = $oMiscfee;
			$mCurrentSchoolNameMandatory=$oMiscfee->mandatory;		
			$mCurrentSchoolNamecaption = $oMiscfee->caption;		
		}
		elseif($misc_fee_name=="mCourse"){
			$objmCourse = $oMiscfee;
			$mCoursesMandatory=$oMiscfee->mandatory;			
		}
	}
	
}
$ESLTestMandatory=2;
if ($schoolid == 55) {
	//$LeahTestMandatory=0;
}
else{
	//$LeahTestMandatory=2;
}

$TranscriptUploadMandatory2=2;

if(empty($AcademicAssessmentcaption))
$AcademicAssessmentcaption = "<b>Check here if interested in taking an academic assessment to see if your student is ahead or behind. (Additional fee of $$AcademicAssessmentFee applies)</b>";

if(empty($SuccessCenterprogramscaption))
$SuccessCenterprogramscaption = " Are you interested in enrolling in one of our Success Center programs?";

if(empty($TranscriptUploadcaption))
$TranscriptUploadcaption = " Upload Transcript";

if(empty($TranscriptUploadcaption2))
$TranscriptUploadcaption2 = " Upload Passport (Students and Parent)";

// $API_APP_URL = "http://portal.advantages-dls.localhost/api_application.php";

$secretKey = CAPTCHA_SECRETKEY; // "6Lc4z6UZAAAAAN-_RSFLojDNrvxbbHv7npQIDxmd" //application.advantages-dls.com
$data_sitekey = CAPTCHA_DATA_SITEKEY; //6Lc4z6UZAAAAAHjkUY2SgIr-2aeX2TH9gKmYMo3t


$source = "";
if (isset($_GET['source'])) {
	$source = appFormString($_GET['source'] ?? null);
}

$redirect = "/";
if (isset($_GET['redirect'])) {
	$redirect = appFormString($_GET['redirect'] ?? null);
}
$mystring = $redirect;
$findme   = 'http://';
$pos = strpos($mystring, $findme);

$findme1   = 'https://';
$pos1 = strpos($mystring, $findme1);

if ($pos === false && $pos1 === false) {
	$redirect = $findme . $redirect;
}

$test_ld = false;
if (isset($schoolid) && $schoolid == "55" && isset($_GET['capt']) && $_GET['capt'] == "abcd1234") {
	$test_ld = true;
}
if ($_SERVER['HTTP_HOST'] == "application.advantages-dls.localhost") {
	$test_ld = true;
}


// $esltestfee = 0;
// if (isset($contents->data->esltestfee) && !empty($contents->data->esltestfee)) {
// 	$esltestfee = $contents->data->esltestfee;
// } else {
// 	$esltestfee = 0;
// }

//get list academic track
$varUrl = "$rurl/auth/getAcademicTrackBySchoolID?schoolid=$schoolid";
$objAcademicTrack = file_get_contents($varUrl, false, stream_context_create($arrContextOptions));
$objAcademicTrack = json_decode($objAcademicTrack);
$objAcademicTrack = appApiListData($objAcademicTrack);
//end get list academic track
$ischeckerror = true;
$isSMISchool = false;
if ($schoolid == 186) {

	$school_logo = "./css/sm_institute_school/smi_top_logo.png";
	$urlLogo = $school_logo;
	$ischeckerror = false;
	$isSMISchool = true;
}
$customstyle = "";
$ischeckrequire = true;
if ($schoolid == 175) {
	$customstyle = 'style="display:none;"';
	$ischeckrequire = false;
}
// $applicationfee = 0;
// if (isset($contents->data->applicationfee) && !empty($contents->data->applicationfee)) {
// 	$applicationfee = $contents->data->applicationfee;
// } else {
// 	$applicationfee = 0;
// }

if ($schoolid == 233) {	
	//$applicationfee = 0;
}

$applicationfee = $newapplicationfee;
//$esltestfee = $ESLTestFee;

require "lib/mysql.php";
dbConnect(DB_HOSTP, DB_USERP, DB_PASSP, DB_PORTAL);
//if (!empty($applicationfee) && $applicationfee > 0)
{
	// echo 'hehe';
	//require "lib/config.php";
	require "lib/abbreviations.php";
	require "lib/general.php";
	//require "lib/mysql.php";
	require "lib/auth.php";
	require "lib/date.php";
	require "lib/functions/authorizeDotNet.php";
	require "lib/functions/AuthnetARB.class.php";

	ob_start();

	error_reporting(E_ALL & ~E_NOTICE);
	//dbConnect(DB_HOSTP, DB_USERP, DB_PASSP, DB_NAMEP);
	/* dbConnect(DB_HOST, DB_USER, DB_PASS, DB_NAME); */
	fixMagicQuotes();
	loadConfig();
}

//--- validation
$ERR_MSG = "";
$vname = "";
$fname = "";
$lname = "";		

$parentfName = "";
$parentlName = "";
$parent2LName = "";

$dob = "";
$homePhone = "";
$cellPhone = "";
$mailingAddress = "";
$city = "";
$state = "";
$zip = "";
$country = "";
$gender = "";
$ethnicity = "";
$email = "";
$ssn = "";
$parentName = "";
$parentHomePhone = "";
$parentCellPhone = "";
$parentMailingAddress = "";
$parentCity = "";
$parentState = "";
$parentZip = "";
$parentCountry = "";
$parentEmail = "";
$parentRelationship = '';
$curriculum='';
if ($schoolid == 403) {	
	$curriculum='K-Steam';
}
$parent2Name = "";
$parent2FName = "";
$parent2NName = "";
$parent2HomePhone = "";
$parent2CellPhone = "";
$parent2Relationship = "";
$parent2MailingAddress = "";
$parent2City = "";
$parent2State = "";
$parent2Zip = "";
$parent2Country = "";
$parent2Email = "";

$removePreferNotToAnswer = false;
switch ($schoolid) {
	case 509: // Add more school IDs here as needed
		$removePreferNotToAnswer = true;
		break;
}

$courses = "";
$course1 = 0;
$course2 = 0;
$course3 = 0;
$notes = "";
$NameofDesignatedLearningCoach = "";
$read_and_understand_learning_coach = "";
$Special_Education_Needs_Service_Details = "";
$link_attachment = "";
$attachment_name = "";
$grade_level = "";
$partner_school_attended = "";
$current_school_name = "";
$assist_student_id = "";
$hear_about_us = "";
$hear_about_us_other = "";
$program_of_interest = "";


$second_language_student = "";
$second_language_studentlabel="I am an ESL Student. (English is not my first language)";
if ($schoolid == 403) {	
	$second_language_studentlabel="By checking here, I understand this course is taught in English";
}
$divsecond_language_student = 'style="display:none"';
$second_language_studentchecked = "";
$taketestoptions = "";
$taketestnow = "taketestnow";
$taketestlater = "taketestlater";
$submitfileslater = "submitfileslater";

$leah_second_language_student = "";
$leah_second_language_studentlabel="I am an ESL Student. (English is not my first language)";

$leah_divsecond_language_student = 'style="display:none"';
$leah_second_language_studentchecked = "";
$leah_taketestoptions = "";
$leah_taketestnow = "leah_taketestnow";
$leah_taketestlater = "leah_taketestlater";
$leah_submitfileslater = "leah_submitfileslater";

$passportnumber = "";
$nationality = "";
$parentpassportnumber = "";
$parentnationality = "";
$received_special_education_needs_services = "";
$AcademicSkillLevelReading = "";
$AcademicSkillLevelMath = "";

$status='New';

$divcheck_additional_fee = 'style="display:none"';
$check_additional_fee = '';
$check_successcenterprograms = '';

$sFirstLanguage='';
$parentFirstLanguage='';
$parent2FirstLanguage='';

if ($_SERVER['REQUEST_METHOD'] == "POST" && isset($_POST['b_apply'])) {

	if ($isSMISchool) {
		$fname = appFormString($_POST['fname'] ?? null);
		$lname = appFormString($_POST['lname'] ?? null);
		$vname = $fname . ' ' . $lname;

		$parentfName = appFormString($_POST['parentfName'] ?? null);
		$parentlName = appFormString($_POST['parentlName'] ?? null);
		$parentName = $parentfName . ' ' . $parentlName;

		$prefname = appFormString($_POST['prefname'] ?? null);
		$RepublicofKorea = appFormString($_POST['RepublicofKorea'] ?? null);
		$RepublicofKoreacitizen = appFormString($_POST['RepublicofKoreacitizen'] ?? null);
		$studentnationality = appFormString($_POST['studentnationality'] ?? null);
		$findSMInstitute = appFormString($_POST['findSMInstitute'] ?? null);

		$findSMInstitute_other = $_POST['findSMInstitute_other'];
		if (!empty($findSMInstitute) && $findSMInstitute == 'Other') {
			$findSMInstitute = $findSMInstitute_other;
		}

		$hear_about_us = $findSMInstitute;
		$hear_about_us_other = $findSMInstitute_other;

		$school_location = appFormString($_POST['school_location'] ?? null);
		$gpa = appFormString($_POST['gpa'] ?? null);
		$major_first_choice = appFormString($_POST['major_first_choice'] ?? null);
		$major_second_choice = appFormString($_POST['major_second_choice'] ?? null);
		$understandandagreeAudition = appFormString($_POST['understandandagreeAudition'] ?? null);
		$understandandagreeAuthenticity = appFormString($_POST['understandandagreeAuthenticity'] ?? null);
		$RelationshipType = appFormString($_POST['RelationshipType'] ?? null);
		$ParentPrimaryContact = appFormString($_POST['ParentPrimaryContact'] ?? null);
		$PreferredContactMethod = appFormString($_POST['PreferredContactMethod'] ?? null);

		$chkkorian = appFormString($_POST['chkkorian'] ?? null);
		$chkforeigner = appFormString($_POST['chkforeigner'] ?? null);

		$SignatureStudentName = appFormString($_POST['SignatureStudentName'] ?? null);
		$SignatureStudentEmailAddress = appFormString($_POST['SignatureStudentEmailAddress'] ?? null);
		$SignatureParentName = appFormString($_POST['SignatureParentName'] ?? null);
		$SignatureParentEmailAddress = appFormString($_POST['SignatureParentEmailAddress'] ?? null);
	} else {
		$fname = appFormString($_POST['fname'] ?? null);
		$lname = appFormString($_POST['lname'] ?? null);
		$vname = $fname . ' ' . $lname;
		//$vname = trim($_POST['vname']);	    
		//$fname = "";
		//$lname = "";

		/* $parentName = trim($_POST['parentName']);
	    $parentfName = "";
	    $parentlName = ""; */
		$parentfName = appFormString($_POST['parentfName'] ?? null);
		$parentlName = appFormString($_POST['parentlName'] ?? null);
		$parentName = $parentfName . ' ' . $parentlName;

		$hear_about_us = $_POST['hear_about_us'];
		$hear_about_us_other = $_POST['hear_about_us_other'];
		if (!empty($hear_about_us) && $hear_about_us == 'Other') {
			$hear_about_us = $hear_about_us_other;
		}
		$program_of_interest = $_POST['program_of_interest'];
	}

	$check_additional_fee = $_POST['check_additional_fee'];	

	if($check_additional_fee){
		$lblAcademicAssessmentFee= "<b>$$AcademicAssessmentFee&nbsp;&nbsp; Academic Assessment Fee</b>";
	}
	
	$check_successcenterprograms = $_POST['check_successcenterprograms'];	

	$second_language_student = $_POST['second_language_student'];	
	$leah_second_language_student = $_POST['leah_second_language_student'];	
	$read_and_understand_learning_coach = $_POST['read_and_understand_learning_coach'];	
	$Special_Education_Needs_Service_Details = $_POST['Special_Education_Needs_Service_Details'];	
	

	$taketestoptions = $_POST['taketestoptions'];

	if($second_language_student){
		$divsecond_language_student = '';
		$second_language_studentchecked = 'checked="checked"';
		$divsecond_language_student = '';
		if($taketestoptions == $taketestnow){
			$status='Pending ESL';	
			$lblESLTestFee= "<b>$$ESLTestFee&nbsp;&nbsp; ESL Fee</b>";
		}
		elseif($taketestoptions == $taketestlater || $taketestoptions == $submitfileslater){
			$status='Pending ESL';
		}
		else{
			$status='New ESL';
		}
	}
	else{
		$divsecond_language_student = 'style="display:none"';
	}

	$leah_taketestoptions = $_POST['leah_taketestoptions'];

	if($leah_second_language_student){
		$leah_divsecond_language_student = '';
		$leah_second_language_studentchecked = 'checked="checked"';
		$leah_divsecond_language_student = '';
		if($leah_taketestoptions == $leah_taketestnow){
			$status='Pending ESL';	
			$lblLeahTestFee= "<b>$$LeahTestFee&nbsp;&nbsp; ESL Fee</b>";
		}
		elseif($leah_taketestoptions == $leah_taketestlater || $leah_taketestoptions == $leah_submitfileslater){
			$status='Pending ESL';
		}
		else{
			$status='New ESL';
		}
	}
	else{
		$leah_divsecond_language_student = 'style="display:none"';
	}

	$dob = appFormString($_POST['dob'] ?? null);
	$homePhone = appFormString($_POST['homePhone'] ?? null);
	//$homePhone = format_phone_us($homePhone);
	$cellPhone = appFormString($_POST['cellPhone'] ?? null);
	//$cellPhone = format_phone_us($cellPhone);

	$mailingAddress = nl2br(appFormString($_POST['mailingAddress'] ?? null));
	$city = appFormString($_POST['city'] ?? null);
	$state = appFormString($_POST['state'] ?? null);
	$zip = appFormString($_POST['zip'] ?? null);
	$country = appFormString($_POST['country'] ?? null);
	$gender = appFormString($_POST['gender'] ?? null);
	$ethnicity = appFormString($_POST['ethnicity'] ?? null);
	$email = appFormString($_POST['email'] ?? null);
	$ssn = appFormString($_POST['ssn'] ?? null);


	$parentHomePhone = appFormString($_POST['parentHomePhone'] ?? null);
	//$parentHomePhone = format_phone_us($parentHomePhone);
	$parentCellPhone = appFormString($_POST['parentCellPhone'] ?? null);
	//$parentCellPhone = format_phone_us($parentCellPhone);

	$parentMailingAddress = nl2br(appFormString($_POST['parentMailingAddress'] ?? null));
	$parentCity = appFormString($_POST['parentCity'] ?? null);
	$parentState = appFormString($_POST['parentState'] ?? null);
	$parentZip = appFormString($_POST['parentZip'] ?? null);
	$parentCountry = appFormString($_POST['parentCountry'] ?? null);

	$parentEmail = appFormString($_POST['parentEmail'] ?? null);
	$parentRelationship = appFormString($_POST['parentRelationship'] ?? null);

	$parent2Name = appFormString($_POST['parent2Name'] ?? null);
	$parent2FName = appFormString($_POST['parent2FName'] ?? null);
	$parent2LName = appFormString($_POST['parent2LName'] ?? null);
	$parent2Name = $parent2FName . ' ' . $parent2LName;
	$parent2Title = appFormString($_POST['parent2Title'] ?? null);
	$parent2Occupation = appFormString($_POST['parent2Occupation'] ?? null);
	$parent2Relationship = appFormString($_POST['parent2Relationship'] ?? null);
	$parent2receive_news = appFormString($_POST['parent2receive_news'] ?? null);
	$parent21primary_language = appFormString($_POST['parent2primary_language'] ?? null);
	$parent21Office = appFormString($_POST['parent2Office'] ?? null);
	$parent2reside = appFormString($_POST['parent2reside'] ?? null);

	$parent2HomePhone = appFormString($_POST['parent2HomePhone'] ?? null);
	$parent2HomePhone = format_phone_us($parent2HomePhone);
	$parent2CellPhone = appFormString($_POST['parent2CellPhone'] ?? null);
	$parent2CellPhone = format_phone_us($parent2CellPhone);
	$parent2Email = appFormString($_POST['parent2Email'] ?? null);
	$parent2Country = appFormString($_POST['parent2Country'] ?? null);
	$parent2MailingAddress = appFormString($_POST['parent2MailingAddress'] ?? null);

	$sFirstLanguage= appFormString($_POST['sFirstLanguage'] ?? null);
	$parentFirstLanguage= appFormString($_POST['parentFirstLanguage'] ?? null);
	$parent2FirstLanguage= appFormString($_POST['parent2FirstLanguage'] ?? null);

	$courses = appFormString($_POST['courses'] ?? null);
	$course1 = appFormString($_POST['course1'] ?? null);
	$course2 = appFormString($_POST['course2'] ?? null);
	$course3 = appFormString($_POST['course3'] ?? null);
	$notes = appFormString($_POST['notes'] ?? null);
	$NameofDesignatedLearningCoach =appFormString($_POST['NameofDesignatedLearningCoach'] ?? null);
	$grade_level = appFormString($_POST['grade_level'] ?? null);
	$partner_school_attended = $_POST['partner_school_attended'];
	$current_school_name = $_POST['current_school_name'];	
	$assist_student_id = $_POST['assist_student_id'];
	
	$curriculum=appFormString($_POST['curriculum'] ?? null);

	$attachment_names = $_POST['attachment_names'];
	$attachment_links = $_POST['attachment_links'];

	$passportnumber = appFormString($_POST['passportnumber'] ?? null);
	$nationality = appFormString($_POST['nationality'] ?? null);
	$parentpassportnumber = appFormString($_POST['parentpassportnumber'] ?? null);
	$parentnationality = appFormString($_POST['parentnationality'] ?? null);
	$received_special_education_needs_services = appFormString($_POST['received_special_education_needs_services'] ?? null);
	$AcademicSkillLevelReading = appFormString($_POST['AcademicSkillLevelReading'] ?? null);
	$AcademicSkillLevelMath = appFormString($_POST['AcademicSkillLevelMath'] ?? null);

	$sis_schoolid = $schoolid;

	$captcha = "";
	$ischeckcaptcha = false;
	if (!$test_ld && !$isSMISchool) {

		if (isset($_POST['g-recaptcha-response'])) {
			$captcha = $_POST['g-recaptcha-response'];
		}
		if (!$captcha) {
		} else {

			$ip = $_SERVER['REMOTE_ADDR'];
			$response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=" . $secretKey . "&response=" . $captcha . "&remoteip=" . $ip);
			$responseKeys = json_decode($response, true);

			if (intval($responseKeys["success"]) !== 1) {
?>

<?php

			} else {
				$ischeckcaptcha = true;
			}
		}
	}

	if ($vname == '' && $ischeckerror)
		$ERR_MSG .= "<br>Please enter Student Name.";

	//if($isSMISchool)
	{
		if ($fname == '')
			$ERR_MSG .= "<br>Please enter First Name.";
		if ($lname == '')
			$ERR_MSG .= "<br>Please enter Last Name.";
	}
	if ($sDateofBirthMandatory==1){
		if ($dob == '')
			$ERR_MSG .= "<br>Please enter Date Of Birth.";
		elseif (!is_date_app($dob))
			$ERR_MSG .= "<br>Please enter a valid Date Of Birth.";
	}
	if ($homePhone == '' && $sPhoneMandatory==1)
		$ERR_MSG .= "<br>Please enter Mobile Phone.";
	if ($email == '' && $sEmailMandatory==1)
		$ERR_MSG .= "<br>Please enter Email Address.";

	//if ($mailingAddress == '')
	//	$ERR_MSG .= "<br>Please enter Mailing Address.";

	// if ($city == '' && $ischeckerror)
	// 	$ERR_MSG .= "<br>Please enter City.";

	// if ($state == '' && $ischeckerror)
	// 	$ERR_MSG .= "<br>Please enter State.";

	// if ($zip == '' && $ischeckerror)
	// 	$ERR_MSG .= "<br>Please enter Zip.";
	if ($gender == '' && $sGenderMandatory==1)
		$ERR_MSG .= "<br>Please select Gender.";
	// if ($ethnicity == '')
	// 	$ERR_MSG .= "<br>Please select Ethnicity.";

	//  elseif($ssn == '')    
	//      $ERR_MSG .= "Please enter Social Security Number.";
	if ($parentName == '')
		$ERR_MSG .= "<br>Please enter Parent Name.";

	if ($parentHomePhone == '' && $pPhoneMandatory == 1)
		$ERR_MSG .= "<br>Please enter Parent Mobile Phone.";
	if ($parentEmail == ''  && $pEmailMandatory == 1)
		$ERR_MSG .= "<br>Please enter Parent Email Address.";

	if ($grade_level == '' && $ischeckerror)
		$ERR_MSG .= "<br>Please select Grade Level.";
	//if ($courses == '')
	//	$ERR_MSG .= "<br>Please enter Courses or Grade Level Applying for.";
	$applicationfee = appFormString($_POST['amount'] ?? null);
	if ($test_ld) {
		$applicationfee = 0;
	}
	if (!empty($applicationfee) && $applicationfee > 0) { // && $check_additional_fee
		$isShowPayment= true;
		$amount = appFormString($_POST['amount'] ?? null);
		$monthlypayments = 1;
		$description = appFormString($_POST['description'] ?? null);

		$ccType = appFormString($_POST['ccType'] ?? null);
		$ccNo = appFormString($_POST['ccNo'] ?? null);
		$ccExpMonth = appFormString($_POST['ccExpMonth'] ?? null);
		$ccExpYear = appFormString($_POST['ccExpYear'] ?? null);
		$ccSecurityCode = appFormString($_POST['ccSecurityCode'] ?? null);
		$ccNameOnCard = appFormString($_POST['ccNameOnCard'] ?? null);

		$ccBillingAddress = $mailingAddress;
		$ccCity = $city;
		$ccState = $state;
		$ccZip = $zip;
		$ccCountry = $country;

		$studInvoiceNum = "Application Fee - School Id: $schoolid";
		$studPhone = $homePhone;
		$studEmail = $email;


		if ($ccType == "" || $ccNo == "" || $ccExpMonth == "" || $ccExpYear == "" || $ccSecurityCode == "" || $ccNameOnCard == "") {
			$formError = true;
			$ERR_MSG .= "<br>Please enter credit card!";
			$ERR_MSG .= $ccType == "" ? "<br> - " . "Credit Card Type" : "";
			$ERR_MSG .= $ccNo == "" ? "<br> - " . "Credit Card Number" : "";
			$ERR_MSG .= $ccExpMonth == "" || $ccExpYear == "" ? "<br> - " . "Expiration Date" : "";
			$ERR_MSG .= $ccSecurityCode == "" ? "<br> - " . "Security Code" : "";
			$ERR_MSG .= $ccNameOnCard == "" ? "<br> - " . "Name On Card" : "";
		}
	}

	if (!$test_ld) {
		// $ischeckcaptcha = true;
		if ($ERR_MSG == '' && !$ischeckcaptcha && !$isSMISchool)
			$ERR_MSG .= "<br>Please check the captcha form.";
	}
}
//--- process
//$ERR_MSG = "";
if ($_SERVER['REQUEST_METHOD'] == "POST" && $ERR_MSG == "" && isset($_POST['b_apply'])) {
	$check_additional_fee = $_POST['check_additional_fee'];	
	$applicationfee = appFormString($_POST['amount'] ?? null);
	if ($test_ld) {
		$applicationfee = 0;
	}
	if (!empty($applicationfee) && $applicationfee > 0 ) { //&& $check_additional_fee
		//make payment

		$isShowPayment= true;
		//------------------------------------------------------------
		$expDate = str_pad($ccExpMonth, 2, 0, STR_PAD_LEFT) . str_pad($ccExpYear, 2, 0, STR_PAD_LEFT);
		$studName = $vname;
		$desc = "Student: $studName\n $description";
		if ($monthlypayments == 1) {

			// process payment

			$paymentResponse = makePayment($ccNo, $expDate, $ccSecurityCode, $desc, appPaymentAmount($amount), $ccNameOnCard, $ccLastName = "", $ccBillingAddress, $ccCity, $ccState, $ccCountry, $ccZip, $studInvoiceNum, $studPhone, $studEmail);

			$authNetResponseText = $paymentResponse[3];
			$authNetResponseTxnId = $paymentResponse[6];

			// payment is not Approved
			if ($paymentResponse[0] != 1) {
				$formError = true;

				if ($paymentResponse[0] == 2) {
					$ERR_MSG = "Sorry, your payment was declined!<br><b>{$authNetResponseText}</b>";
				} else if ($paymentResponse[0] == 3) {
					$ERR_MSG = "Sorry, some errors occurred while processing your request. Please retry.<br><b>{$authNetResponseText}</b>";
				}
			}
			// end: process payment
		}

		//end make payment
	}
	//$ERR_MSG = "";
	if ($ERR_MSG == "") {
		$mailMsg = '<table width="720" align="center" cellpadding="0" cellspacing="0" >
		        
		        <tr>
		          <td colspan="4" align="center" valign="top" class="place"><b>STUDENT Applications </b></td>
		        </tr>
		        <tr>
		          <td colspan="4" align="center" valign="top">&nbsp;</td>
		        </tr>
		        <tr>
		          <td height="32" colspan="4"  align="left" bgcolor="#E6E6E6" class="mission">&nbsp;&nbsp;Student Information </td>
		          </tr>
		        <tr>
		          <td height="32"  align="right" class="advplacecontent">Student Name&nbsp; </td>
		          <td width="176" >' . $vname . '&nbsp;</td>
		          <td width="100" align="right" ><span class="advplacecontent">Date Of Birth&nbsp; </span></td>
		          <td width="176" >' . $dob . '
		            &nbsp;</td>
		        </tr>
		        <tr>
		          <td height="32"  align="right" class="advplacecontent">Mobile Phone &nbsp; </td>
		          <td width="176" >' . $homePhone . '
		            &nbsp;</td>
		          <td align="right" ><span class="advplacecontent">Student Phone Number &nbsp; </span></td>
		          <td width="176" >' . $cellPhone . '
		            &nbsp;</td>
		        </tr>
		        <tr>
		          <td height="32"  align="right" class="advplacecontent">Mailing Address &nbsp;</td>
		          <td colspan="3" >' . $mailingAddress . '
		          &nbsp;</td>
		        </tr>
		        <tr>
		          <td height="32"  align="right" class="advplacecontent">City&nbsp; </td>
		          <td colspan="3" ><span class="advplacecontent">
		            ' . $city . '
		          &nbsp;&nbsp;State
		            ' . $state . '
		          &nbsp; Zip
		            ' . $zip . '
		    	  	 &nbsp; Country
		            ' . $country . '
		          </span></td>
		        </tr>
		        <tr>
		          <td height="27"  align="right" class="advplacecontent">Gender &nbsp;</td>
		          <td colspan="3" ><span class="advplacecontent">
		            ' . $gender . '
		          </span>&nbsp;</td>
		        </tr>
		        <tr>
		          <td height="27"  align="right" class="advplacecontent">Ethnicity &nbsp;</td>
		          <td colspan="3" ><span class="advplacecontent">
		            ' . $ethnicity . '
		          </span>&nbsp;</td>
		        </tr>
		        <tr>
		          <td height="27"  align="right" class="advplacecontent">Email Address &nbsp;</td>
		          <td colspan="3" ><span class="advplacecontent">
		            ' . $email . '
		          </span>&nbsp;</td>
		        </tr>
		        <tr>
		              <td height="27" align="right" class="advplacecontent">School ID &nbsp;</td>
		              <td colspan="3"><span class="advplacecontent">
		                ' . $sis_schoolid . '
		              </span></td>
		            </tr>
		        <tr>
		          <td height="32" colspan="4"  align="left" bgcolor="#E6E6E6" class="mission">&nbsp;&nbsp;Parent Information </td>
		        </tr>
		        <tr>
		          <td height="32"  align="right" class="advplacecontent">Name&nbsp; </td>
		          <td colspan="3" ><span class="advplacecontent">
		            ' . $parentName . '
		          </span></td>
		          </tr>
		        <tr>
		          <td height="32"  align="right" class="advplacecontent">Mobile Phone &nbsp; </td>
		          <td ><span class="advplacecontent">
		            ' . $parentHomePhone . '
		          </span></td>
		          <td align="right" ><span class="advplacecontent">Cell Phone &nbsp; </span></td>
		          <td ><span class="advplacecontent">
		            ' . $parentCellPhone . '
		          </span></td>
		        </tr>
		        <tr>
		          <td height="32"  align="right" class="advplacecontent">Mailing Address<br>
		            (if different)&nbsp;</td>
		          <td colspan="3" ><span class="advplacecontent">
		            ' . $parentMailingAddress . '
		          </span></td>
		          </tr>
		        <tr>
		          <td width="162" height="32"  align="right" class="advplacecontent">City&nbsp; </td>
		          <td colspan="3" ><span class="advplacecontent">
		            ' . $parentCity . '
		          &nbsp;&nbsp;State
		          ' . $parentState . '
		&nbsp; Zip
		' . $parentZip . '
					&nbsp; Country
		' . $parentCountry . '
		          </span></td>
		          </tr>
		        <tr>
		          <td height="27"  align="right" class="advplacecontent">Email Address &nbsp;</td>
		          <td colspan="3" ><span class="advplacecontent">
		            ' . $parentEmail . '
		          </span></td>
		        </tr>
		        <tr>
		          <td colspan="4" align="center" valign="top">&nbsp;</td>
		        </tr>
		        
		        <tr>
		          <td height="32" colspan="4"  align="left" bgcolor="#E6E6E6" class="mission">&nbsp;</td>
		        </tr>
		        
		        <tr>
		          <td colspan="4" align="left" valign="top">&nbsp;</td>
		        </tr>
		        
		        
		        <tr>
		          <td colspan="4" align="left" valign="top"><table width="97%" border="0" align="center" cellpadding="8" cellspacing="0">
		            <tr>
		              <td width="26%" class="mission">&nbsp;&nbsp;Courses or Grade Level Applying for:</td>
		              <td width="74%"><span class="advplacecontent">
		                ' . $courses . '
		              </span></td>
		            </tr>
		            <tr>
		              <td align="right" class="mission">Additional Notes </td>
		              <td><span class="advplacecontent">
		                ' . $notes . '
		              </span></td>
		            </tr>
					<tr>
		              <td align="right" class="mission">Name of Partner School Attended (if applicable) </td>
		              <td><span class="advplacecontent">
		                ' . $partner_school_attended . '
		              </span></td>
		            </tr>
					<tr>
		              <td align="right" class="mission">Current School Name </td>
		              <td><span class="advplacecontent">
		                ' . $current_school_name . '
		              </span></td>
		            </tr>
					
		          </table></td>
		        </tr>
		      </table>';

		$file_name = "";
		$file = "";
		$fullfile = "";
		if (isset($_POST['attachment_names']) && !empty($_POST['attachment_names']) && isset($_POST['attachment_links']) && !empty($_POST['attachment_links'])) {
			$attachment_name = $_POST['attachment_names'];
			$link_attachment = $_POST['attachment_links'];
		} else {
			if (isset($_FILES['academicFileToUpload']) && !empty($_FILES['academicFileToUpload']['name'])) {

				$errors = array();

				$count = appUploadCount($_FILES['academicFileToUpload'] ?? array());

				for ($i = 0; $i < $count; $i++) {

					$file_name = $_FILES['academicFileToUpload']['name'][$i];
					$file_tmp = $_FILES['academicFileToUpload']['tmp_name'][$i];
					$file_size = $_FILES['academicFileToUpload']['size'][$i];
					$file_error = $_FILES['academicFileToUpload']['error'][$i];
					$file_type = $_FILES['academicFileToUpload']['type'][$i];

					if (!empty($file_name) && !empty($file_tmp)) {
						$file_ext = explode('.', $file_name);
						$file_act_ext = strtolower(end($file_ext));
						$allowed = ['jpg'];
						$path = 'C:/images/';

						$extensions = array("php", "asp", "html", "js", "exe");
						if (in_array($file_act_ext, $extensions) == true) {
							$errors[] = "extension not allowed, please choose other file.";
						}

						if (empty($errors) == true) {

							$s3 = s3Instantiate();
							$bucketName = AWS_S3_BUCKET;

							$s3filename = "application/" . time() . $file_name;
							$s3key = $s3filename;
							$s3SourceFile = $file_tmp;
							$result = $s3->putObject(
								array(
									'Bucket' => $bucketName,
									'Key'    => $s3key,
									'SourceFile' => $s3SourceFile,
									'ACL'    => 'public-read'
								)
							);
							if (empty($link_attachment)) {
								$link_attachment = $s3key;
							} else {
								$link_attachment .= ";" . $s3key;
							}
							if (empty($attachment_name)) {
								$attachment_name = $file_name;
							} else {
								$attachment_name .= ";" . $file_name;
							}
							//$link_attachment= $s3key;
							//$attachment_name= $file_name;
							//$s3fileuploadurl = $result->get('ObjectURL');

						} else {
							echo "extension not allowed, please choose other file.";
							exit();
						}
					}
				}
			}

			if (isset($_FILES['legalNameFileToUpload']) && !empty($_FILES['legalNameFileToUpload']['name'])) {

				$errors = array();

				$count = appUploadCount($_FILES['legalNameFileToUpload'] ?? array());

				for ($i = 0; $i < $count; $i++) {

					$file_name = $_FILES['legalNameFileToUpload']['name'][$i];
					$file_tmp = $_FILES['legalNameFileToUpload']['tmp_name'][$i];
					$file_size = $_FILES['legalNameFileToUpload']['size'][$i];
					$file_error = $_FILES['legalNameFileToUpload']['error'][$i];
					$file_type = $_FILES['legalNameFileToUpload']['type'][$i];

					if (!empty($file_name) && !empty($file_tmp)) {
						$file_ext = explode('.', $file_name);
						$file_act_ext = strtolower(end($file_ext));
						$allowed = ['jpg'];
						$path = 'C:/images/';

						$extensions = array("php", "asp", "html", "js", "exe");
						if (in_array($file_act_ext, $extensions) == true) {
							$errors[] = "extension not allowed, please choose other file.";
						}

						if (empty($errors) == true) {

							$s3 = s3Instantiate();
							$bucketName = AWS_S3_BUCKET;

							$s3filename = "application/" . time() . $file_name;
							$s3key = $s3filename;
							$s3SourceFile = $file_tmp;
							$result = $s3->putObject(
								array(
									'Bucket' => $bucketName,
									'Key'    => $s3key,
									'SourceFile' => $s3SourceFile,
									'ACL'    => 'public-read'
								)
							);
							if (empty($link_attachment)) {
								$link_attachment = $s3key;
							} else {
								$link_attachment .= ";" . $s3key;
							}
							if (empty($attachment_name)) {
								$attachment_name = $file_name;
							} else {
								$attachment_name .= ";" . $file_name;
							}
							//$link_attachment= $s3key;
							//$attachment_name= $file_name;
							//$s3fileuploadurl = $result->get('ObjectURL');

						} else {
							echo "extension not allowed, please choose other file.";
							exit();
						}
					}
				}
			}
		}
		$filename = "";
		if (isset($file_name) && !empty($file_name)) {
			// attachment	
			$filename = $file_name;
		}

		//$subject = "Apply Now (website - application.advantages-dls.com)";
		$subject = "Apply Now (website - application.advantages-dls.com/apply-now - School ID: $schoolid)";
		$html = $mailMsg;
		$filePath = $_SERVER['DOCUMENT_ROOT'] . '/' . $file;
		//$from = "info@advantagesschool.com";
		//$from = "info@advantages-dls.com";
		$from = "DoNotReply@advantages-dls.com";
		if ($schoolid == 169 || $schoolid == 213 || $schoolid == 215) {
			$from = "ALVS.Sign-In@apexlearning.com";
		} elseif ($schoolid == 186) {
			$from = "admissions@sm.institute";
		} elseif ($schoolid == 183) {
			$from = "do_not_reply@thebrookhillacademy.org";
		} elseif ($schoolid == 175) {
			//$from = "rhuggins@advantages-dls.com";
		} else {
			$from = "DoNotReply@advantages-dls.com";
		}
		/* */
		// try
		//  {
		// 	$varUrl = "$rurl/auth/getUserSchoolByTags";
		// 	$param = array('tag' => '#manageapplications', 'school_id' => $schoolid);
		// 	$data = http_build_query($param);
		// 	$context_options = array(
		// 		"ssl" => array(
		// 			"verify_peer" => false,
		// 			"verify_peer_name" => false,
		// 		),
		// 		'http' => array(
		// 			'method' => 'POST',
		// 			'content' => $data
		// 		)
		// 	);
		// 	$users = file_get_contents($varUrl, false, stream_context_create($context_options));
			
		// 	$users = json_decode($users);
			
		// 	$cc = "";
		// 	if($users){
		// 		foreach ($users as $u) {
		// 			$to = $u->email;
		// 			$cc = "thenn_ldtech@yahoo.com";
		// 			sendmail_new($from, $to, $subject, $html, $filename, $filePath,$cc);
		// 		}
		// 	}
		// } catch (Exception $e) {
			
		// }

		// $to = "apply@advantagesschool.com";
		// sendmail_new($from, $to, $subject, $html, $filename, $filePath);

		// $to = "adampier@advantagesschool.com";
		// sendmail_new($from, $to, $subject, $html, $filename, $filePath);

		// $to = "sgamba@advantagesschool.com";
		// sendmail_new($from, $to, $subject, $html, $filename, $filePath);

		// $to = "jtynan@assisteducation.com";
		// sendmail_new($from, $to, $subject, $html, $filename, $filePath);

		//$to="carazojennifer@gmail.com";
		//sendmail_new($from,$to,$subject,$html,$filename,$filePath);

		// DEV & TEST
		// $to = "andybui@advantagesschool.com";
		// sendmail_new($from, $to, $subject, $html, $filename, $filePath);

		$to = "g.thenguyen@gmail.com";
		sendmail_new($from, $to, $subject, $html, $filename, $filePath);

		//$to = "phamquanghuy83@gmail.com";
		//sendmail_new($from, $to, $subject, $html, $filename, $filePath);

		//$to = "duyetnk@gmail.com";
		//sendmail_new($from, $to, $subject, $html, $filename, $filePath);

		//--- send data to SIS
		$proxyhost = isset($_POST['proxyhost']) ? $_POST['proxyhost'] : '';
		$proxyport = isset($_POST['proxyport']) ? $_POST['proxyport'] : '';
		$proxyusername = isset($_POST['proxyusername']) ? $_POST['proxyusername'] : '';
		$proxypassword = isset($_POST['proxypassword']) ? $_POST['proxypassword'] : '';
		$useCURL = isset($_POST['usecurl']) ? $_POST['usecurl'] : '0';

		// endpoint, namespace, soapAction
		$endpoint = $API_APP_URL;
		$namespace = $API_APP_URL;
		$soapAction = $API_APP_URL . "/CreatePendingApplication";
		$method = "CreatePendingApplication";
		// create client object
		// $client = new nusoap_client($endpoint, false, $proxyhost, $proxyport, $proxyusername, $proxypassword);
		// $err = $client->getError();
		// if ($err) {
		// 	echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
		// 	echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '</pre>';
		// 	exit();
		// }
		// $client->setUseCurl($useCURL);
		// This is an archaic parameter list


		if (isset($_POST['redirect']) && !empty($_POST['redirect'])) {
			$redirect = appFormString($_GET['redirect'] ?? null);
			$mystring = $redirect;
			$findme   = 'http://';
			$pos = strpos($mystring, $findme);
			$findme1   = 'https://';
			$pos1 = strpos($mystring, $findme1);

			if ($pos === false && $pos1 === false) {
				$redirect = $findme . $redirect;
			}
		}
		if ($isSMISchool && !empty($RelationshipType)) {
			$g1relation = $RelationshipType;
		} else {
			$g1relation = 'Parent';
		}
		$g1relation = $parentRelationship;
		$g2relation = $parent2Relationship;


		/* if($isSMISchool){
	    $fname = $fname;
	    $mname = "";
	    $lname = $lname;
	}
	else{
	    $fname = "";
	    $mname = "";
	    $lname = "";
    	$arrName = explode(" ", $vname);
    	if (count($arrName) > 1) {
    		$fname = $arrName[0];
    		if (count($arrName) > 2) {
    			for ($i = 1; $i < count($arrName) - 1; $i++) {
    				$mname .= $arrName[$i] . " ";
    			}
    		}
    		$lname = $arrName[count($arrName) - 1];
    	} else {
    		$fname = $vname;
    	}
	} */

	$initial_status =dbQuery("SELECT *
	FROM `statuses` 
	WHERE applied_to = 'application' and initial = 1 and school_id = '$schoolid' ",'single');


	if(!empty($initial_status) && !empty($initial_status["status_name"]))
	{
		$status = $initial_status["status_name"];
	}

		//$name
		if (isset($_POST['ccSecurityCode']) ){
			$_POST['ccType'] = '';
			$_POST['ccNo'] = '';
			$_POST['ccExpMonth'] = '';
			$_POST['ccExpYear'] = '';
			$_POST['ccSecurityCode'] = '';
			$_POST['ccNameOnCard'] = '';
		}
		$app_detail = appEncodeDetails($_POST, true);

		if($taketestoptions == $taketestnow){	
			$params['dyned_pay'] = "1";
			$jsde = appDetailsObject($app_detail, true);		
			$jsde->dyned_pay = "1";
			$app_detail = appEncodeDetails($jsde, true);
		}
		if($leah_taketestoptions == $leah_taketestnow){	
			$params['leah_pay'] = "1";
			$jsde = appDetailsObject($app_detail, true);		
			$jsde->leah_pay = "1";
			$app_detail = appEncodeDetails($jsde, true);
		}

		if(empty($lname)){
			$lname = "None";
		}
		if(empty($lname)){
			$lname = "None";
		}			
		if(empty($dob)){
			$dob = "00/00/0000";
		}
		if(empty($gender)){
			$gender = "Not Answer";
		}	
		if(empty($homePhone)){
			$homePhone = "(000)000-0000";
		}
		if(empty($mailingAddress)){
			$mailingAddress = "None";
		}

		if(empty($parentName)){
			$parentName = "None";
		}
		if(empty($parentHomePhone)){
			$parentHomePhone = "(000)000-0000";
		}


		$params = array(
			'fname' => "$fname",
			'mname' => "$mname",
			'lname' => "$lname",
			'birthday' => "$dob",
			'phone' => "$homePhone",
			'mobile' => "$cellPhone",
			'address' => "$mailingAddress",
			'city' => "$city",
			'state' => "$state",
			'zip' => "$zip",
			'email' => "$email",
			'g1name' => "$parentName",
			'g1relation' => "$g1relation",
			'g1phone' => "$parentHomePhone",
			'g1mobile' => "$parentCellPhone",
			'g1address' => "$parentMailingAddress",
			'g1city' => "$parentCity",
			'g1state' => "$parentState",
			'g1zip' => "$parentZip",
			'g1email' => "$parentEmail",
			'course_level' => "$courses",
			'comments' => "$notes",
			'sis_schoolid' => "$sis_schoolid",
			'link_attachment' => "$link_attachment",
			'attachment_name' => "$attachment_name",
			'grade_level' => "$grade_level",
			'country' => "$country",
			'g1country' => "$parentCountry",
			'partner_school_attended' => "$partner_school_attended",
			'gender' => "$gender",
			'ethnicity' => "$ethnicity",
			'app_detail' => $app_detail,
			'source' => "$source",
			'g2name' => "$parent2Name",
			'g2relation' => "$g2relation",
			'g2phone' => "$parent2HomePhone",
			'g2mobile' => "$parent2CellPhone",
			'g2email' => "$parent2Email",
			'hear_about_us' => "$hear_about_us",
			'program_of_interest' => "$program_of_interest",
			'status' => "$status"
		);
		
		// call method 		
	
		$apiv5url="$rurlbv5/api/v2/applynow";
	
		//$appid = rqCurlNew($apiv5url, $params);
		
		// $result = $client->call($method, $params, $namespace, $soapAction);
		// $appid =$result;

		$postdata = http_build_query(
			$params
		);
		
		$opts = array(
			'ssl' => array(
				'verify_peer' => false,
				'verify_peername' => false			
			),
			'http' => array(
				'method' => 'POST',
				'header' => 
					'Content-type: application/x-www-form-urlencoded'."\r\n".
					'',
				'content' => $postdata
			)
		);
		
		$context = stream_context_create($opts);
		
		$result = file_get_contents($apiv5url, false, $context);
		$result = json_decode($result);	
		
		
		$appid =$result->data;
		if($taketestoptions == $taketestnow){			
			//$txtTotalFee = 25;
			//echo "<script>window.location.href='$vSERVER_NAME/dyned-payments?pn=$vname&pp=$parentHomePhone&pm=$parentEmail&am=$txtTotalFee&appid=$appid&scid=$schoolid';</script>";
			$appidmd5 = md5($appid);
			echo "<script>window.location.href='$vSERVER_NAME/eptest.php?appid=$appidmd5';</script>"; 
			exit();
		}
		elseif($taketestoptions == $taketestlater || $taketestoptions == $submitfileslater){
			
			$strSubject = "Follow Up for Application $appid";
			$applicant="$fname $lname";
			$appidmd5 = md5($appid);
$strContent = "
		<p>Dear $applicant</p>
			<p>Thank you for your recent application for enrollment into $school_name. You indicated that English is not your first
			language. We ask all non-native English speakers to submit English proficiency test scores as part of the application process, to ensure student success with proper placement into our programs.</p>

			<p>If you have recently taken an English proficiency placement test and have those results, please upload them here</p>			

			<p><div style='color:blue'><a href='https://application.advantages-dls.com/eslupload.php?appid=$appid'>https://application.advantages-dls.com/eslupload.php?appid=$appid</a></div><p>

			<p>Proficiency results can be from any recognized English placement assessment. (ie: TOEFL, TOIEC, DuoLingo, etc).</p>			

			<p>If you have not taken an English Placement test, please consider the Advantages etest for a quick and inexpensive way to measure your English proficiency. For your convenience
			please follow this link to make the testing payment ($25 USD).</p>

			<p>A testing link with instructions will be sent to your email address, and results will automatically be attached to your enrollment application.</p>

			<p>Please note that for the etest, you will need a device with a microphone and speakers to conduct the listening and speaking portions of the test. 
			It will take approximately 20 minutes to complete.</p>

			<p><a href='https://application.advantages-dls.com/eptest.php?appid=$appidmd5'>https://application.advantages-dls.com/eptest.php?appid=$appid</a></p>
			<p>&nbsp;</p>
			<p>We look forward to becoming your partner in your education journey.</p>
			<p>&nbsp;</p>
			<p>Sincerely,</p>
			<p>$school_name</p>
			
";
			//echo $strContent;
			
		$to = $email;	
		$cc = $parentEmail;				
		if(!empty($email)){
			sendmail_new($from, $to, $strSubject, $strContent, $filename, $filePath,$cc);
		}
		else{
			if(!empty($cc)){
				sendmail_new($from, $cc, $strSubject, $strContent, $filename, $filePath,"");
			}
		}

		$to = "g.thenguyen@gmail.com";
		$cc = "thennldtech@gmail.com";
		sendmail_new($from, $to, $strSubject, $strContent, $filename, $filePath,$cc);

		}

		if($leah_taketestoptions == $leah_taketestnow){			
			//$txtTotalFee = 25;
			//echo "<script>window.location.href='$vSERVER_NAME/dyned-payments?pn=$vname&pp=$parentHomePhone&pm=$parentEmail&am=$txtTotalFee&appid=$appid&scid=$schoolid';</script>";
			$appidmd5 = md5($appid);
			echo "<script>window.location.href='$vSERVER_NAME/leahtest.php?appid=$appidmd5';</script>"; 
			exit();
		}
		elseif($leah_taketestoptions == $leah_taketestlater){
			
			$strSubject = "Follow Up for Application $appid - Leah";
			$applicant="$fname $lname";
			$appidmd5 = md5($appid);
$strContent = "
		<p>Dear $applicant</p>
			<p>Thank you for your recent application for enrollment into $school_name. You indicated that English is not your first
			language. We ask all non-native English speakers to submit English proficiency test scores as part of the application process, to ensure student success with proper placement into our programs.</p>

			<p>If you have recently taken an English proficiency placement test and have those results, please upload them here</p>			

			<p><div style='color:blue'><a href='https://application.advantages-dls.com/leahupload.php?appid=$appid'>https://application.advantages-dls.com/leahupload.php?appid=$appid</a></div><p>

			<p>Proficiency results can be from any recognized English placement assessment. (ie: TOEFL, TOIEC, DuoLingo, etc).</p>			

			<p>If you have not taken an English Placement test, please consider the Advantages etest for a quick and inexpensive way to measure your English proficiency. For your convenience
			please follow this link to make the testing payment ($25 USD).</p>

			<p>A testing link with instructions will be sent to your email address, and results will automatically be attached to your enrollment application.</p>

			<p>Please note that for the etest, you will need a device with a microphone and speakers to conduct the listening and speaking portions of the test. 
			It will take approximately 20 minutes to complete.</p>

			<p><a href='https://application.advantages-dls.com/leahtest.php?appid=$appidmd5'>https://application.advantages-dls.com/leahtest.php?appid=$appid</a></p>
			<p>&nbsp;</p>
			<p>We look forward to becoming your partner in your education journey.</p>
			<p>&nbsp;</p>
			<p>Sincerely,</p>
			<p>$school_name</p>
			
";
			//echo $strContent;
			
		// $to = $email;	
		// $cc = $parentEmail;				
		// if(!empty($to)){
		// 	sendmail_new($from, $to, $strSubject, $strContent, $filename, $filePath,$cc);
		// }
		// else{
		// 	if(!empty($cc)){
		// 		sendmail_new($from, $cc, $strSubject, $strContent, $filename, $filePath,"");
		// 	}
		// }

		$to = "g.thenguyen@gmail.com";
		$cc = "thennldtech@gmail.com";
		sendmail_new($from, $to, $strSubject, $strContent, $filename, $filePath,$cc);

		}
	

		//--- go to applynow-thanks page	
		//header("Location: $redirect");
		//die();

		if (isset($_GET['redirect'])) {
			if($schoolid=="376"){
				echo "<script>alert('Your application has been successfully submitted. A Global Citizen Webinar manager will reach back out to you soon.')</script>";
			}
			else{
				echo "<script>alert('Your application has been successfully submitted. An administrator will reach back out to you soon.')</script>";
			}
			
			echo "<script>window.location.href='$redirect';</script>";
		} else {
			//echo "<script>window.location.href='/applynow-thanks';</script>";
			$isSubmit = true;
			include('dyned-apply-now-thanks.php');			
		}
		exit();
		//wp_redirect( '/applynow-thanks',301 ); exit;
	}
}	

	//$rurlbv5 = "https://apiv5.adlsassist.com"; 
	$apiv5url="$rurlbv5/api/v2/get_s_countries";


	$arrContextOptions = array(
		"ssl" => array(
			"verify_peer" => false,
			"verify_peer_name" => false,
		),
	);
	$contents = file_get_contents($apiv5url, false, stream_context_create($arrContextOptions));
	$rscountries = json_decode($contents);

	if(empty($country)){
		$country='United States';
	}

	if(empty($parentCountry)){
		$parentCountry='United States';
	}
	
	$rscountriesdata = $rscountries->data;
	$rscountryoption = '';
	$rsparentcountryoption = '';
	$rsparent2countryoption = '';
	foreach ($rscountriesdata as $rscountry) {
		$label = $rscountry->label;
		$value = $rscountry->value;
		$vSelect = '';
		$vpSelect = '';
		if($value==$country){
			$vSelect = 'selected';
		}
		if($value==$parentCountry){
			$vpSelect = 'selected';
		}
		if($value==$parent2Country){
			$vp2Select = 'selected';
		}
		if($value == 'Canada' || $value == 'United States'){
			$rscountryoption = '<option value="'.$value.'" '.$vSelect.'>'.$label.'</option>'.$rscountryoption;
			$rsparentcountryoption = '<option value="'.$value.'" '.$vpSelect.'>'.$label.'</option>'.$rsparentcountryoption;
			$rsparent2countryoption = '<option value="'.$value.'" '.$vp2Select.'>'.$label.'</option>'.$rsparent2countryoption;
		}
		else{
			$rscountryoption .= '<option value="'.$value.'" '.$vSelect.'>'.$label.'</option>';
			$rsparentcountryoption .= '<option value="'.$value.'" '.$vpSelect.'>'.$label.'</option>';
			$rsparent2countryoption .= '<option value="'.$value.'" '.$vp2Select.'>'.$label.'</option>';
		}
		
		
	}
	
	$rsstateoption = '';
	$rsparentstateoption = '';
	//if($schoolid == 55)
	{
		$rurlbv5 = "https://apiv5.adlsassist.com"; 
		$apiv5url="$rurlbv5/api/v2/get_s_states?country_name=$country";
		
		$contents = file_get_contents($apiv5url, false, stream_context_create($arrContextOptions));
		$rsstates = json_decode($contents);


		$rsStatesdata = $rsstates->data;
		
		foreach ($rsStatesdata as $rsstate) {
			$label = $rsstate->label;
			$value = $rsstate->value;
			$vSelect = '';
			$vpSelect = '';
			if($value==$state){
				$vSelect = 'selected';
			}

			if($value==$parentState){
				$vpSelect = 'selected';
			}
			
			$rsstateoption .= '<option value="'.$value.'" '.$vSelect.'>'.$label.'</option>';
			$rsparentstateoption .= '<option value="'.$value.'" '.$vpSelect.'>'.$label.'</option>';
			
		}
		
	}

?>

<?php
if (isset($schoolid) && $schoolid == '186') {
	//include('sm_institute_school.php');
} else {
?>
	<!-- ================ -->
	<script language="javascript">
		var valRules = new Array();
		valRules[0] = 'name:Student Name|required';
		valRules[1] = 'email:Student Email|required';
		valRules[2] = 'email:Student Email|email';
		valRules[3] = 'parentName:Parent Name|required';
		valRules[4] = 'parentEmail:Parent Email Address|required';
		valRules[5] = 'parentEmail:Parent Email Address|email';
	</script>
	<script type="text/JavaScript">
		<!--
			function MM_swapImgRestore() { //v3.0
			  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
			}
			
			function MM_preloadImages() { //v3.0
			  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
			    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
			    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
			}
			
			function MM_findObj(n, d) { //v4.01
			  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
			    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
			  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
			  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
			  if(!x && d.getElementById) x=d.getElementById(n); return x;
			}
			
			function MM_swapImage() { //v3.0
			  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
			   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
			}
			//-->
	</script>
	<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
	<script src="//code.jquery.com/jquery-1.10.2.js"></script>
	<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
	<script src="js/jquery.caret.js"></script>
	<script src="js/jquery.mobilePhoneNumber.js"></script>

	<script type="text/javascript">
		$(document).ready(function() {

			$("#state").val("<?php echo $state ?>");

		});

		$(function() {
			//   $( "#dob" ).datepicker();
			var dateToday = new Date();
			var yrRange = (dateToday.getFullYear() - 50) + ":" + (dateToday.getFullYear() + 0);

			$(function() {
				$("#dob").datepicker({
					changeMonth: true,
					changeYear: true,
					yearRange: yrRange
				});
			});
			$("#email").blur(function() {
				console.log('ValidateEmail');
				ValidateEmail(this);
			});

			$("#parentEmail").blur(function() {
				ValidateEmail(this);
			});
			$("#parent1Email").blur(function() {
				ValidateEmail(this);
			});
			$("#parent2Email").blur(function() {
				ValidateEmail(this);
			});
			var homePhone = $('#homePhone')
			if(homePhone.length){
				homePhone.mobilePhoneNumber({
					allowPhoneWithoutPrefix: '+1'
				});
			}
			var parentHomePhone = $('#parentHomePhone')			
			
			if(parentHomePhone.length){
				parentHomePhone.mobilePhoneNumber({
					allowPhoneWithoutPrefix: '+1'
				});			
			}
						
			// var parentCellPhone = $('#parentCellPhone')
			// parentCellPhone.mobilePhoneNumber({
			// 	allowPhoneWithoutPrefix: '+1'
			// });
			// var cellPhone = $('#cellPhone')
			// cellPhone.mobilePhoneNumber({
			// 	allowPhoneWithoutPrefix: '+1'
			// });
			<?php if ($ischeckerror) { ?>
				// var parent2HomePhone = $('#parent2HomePhone')
				// parent2HomePhone.mobilePhoneNumber({
				// 	allowPhoneWithoutPrefix: '+1'
				// });
			<?php } ?>
			$('#hear_about_us').change(function() {
				var slValue = $('#hear_about_us').val();
				if (slValue == 'Other') {
					$('#hear_about_us_other').show().val('');
					$('#hear_about_us_other').focus();
				} else {
					$('#hear_about_us_other').hide().val(slValue);
				}
			});

			$('#country').on('change', function() {
				var country_id = this.value;
				//console.log(country_id);
				$.ajax({
				url: "https://apiv5.adlsassist.com/api/v2/get_s_states?country_name="+country_id,
				type: "GET",
				data: {
					country_name: country_id
				},
				cache: false,
				success: function(result){
					var resultdata = result['data'];
					//console.log(resultdata.length);
					var rsstateoption = '<option value="">Select...</option>';
					for(let i = 0; i < resultdata.length; i++) {
						let obj = resultdata[i];
						let value = obj['value'];
						let label = obj['label'];
						let vSelect = '';
						rsstateoption = rsstateoption + '<option value="'+value+'" '+vSelect+'>'+label+'</option>';
						//console.log(obj['value']);
					}

					$("#state").html(rsstateoption);
				
				}
				});
			});   

			$('#parentCountry').on('change', function() {
				var country_id = this.value;
				//console.log(country_id);
				// $.ajax({
				// url: "https://apiv5.adlsassist.com/api/v2/get_s_states?country_name="+country_id,
				// type: "GET",
				// data: {
				// 	country_name: country_id
				// },
				// cache: false,
				// success: function(result){
				// 	var resultdata = result['data'];
				// 	//console.log(resultdata.length);
				// 	var rsstateoption = '<option value="">Select...</option>';
				// 	for(let i = 0; i < resultdata.length; i++) {
				// 		let obj = resultdata[i];
				// 		let value = obj['value'];
				// 		let label = obj['label'];
				// 		let vSelect = '';
				// 		rsstateoption = rsstateoption + '<option value="'+value+'" '+vSelect+'>'+label+'</option>';
				// 		//console.log(obj['value']);
				// 	}

				// 	$("#parentState").html(rsstateoption);
				
				// }
				// });
			}); 

			// $('#taketestoptions1').click(function () {
			// 	if ($(this).is(':checked')) {
			// 		console.log('taketestoptions1');
			// 	}
			// });
		});



		function formatPhone(nvalue) {
			var retVal = '';
			var numbers = nvalue.replace(/\D/g, ''),
				//char = {0:'(',3:') ',6:' - '};
				char = {
					0: '',
					3: ' - ',
					6: ' - '
				};
			retVal = '';
			for (var i = 0; i < numbers.length; i++) {
				retVal += (char[i] || '') + numbers[i];
			}
			return retVal;
		}

		function ValidateEmail (inputText) {				
			if (inputText.value != "") {
				email = inputText.value;
				var isEmail = /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)
				if (isEmail) {
					// inputText.focus();
					return true;
				} else {
					alert("You have entered an invalid email address!");
					inputText.focus();
					inputText.value = '';
					return false;
				}
			}
		}

		function doclickgoback() {
			window.location.href = '<?php echo $redirect ?>';			
		}


		function createRow(name,myTable) {
			var table = document.getElementById(myTable);
			var row = table.insertRow(0);
			var cell1 = row.insertCell(0);		
			name = name.trim();
			cell1.innerHTML = '<a onclick="deleteRow(this,\''+name+'\',\''+myTable+'\')" style="color: red; cursor: pointer;">x</a> ' + name;
			if(myTable=="myTable"){
				$('#academicFileToUpload').val(null);
			}
			else{
				$('#Special_Education_Needs_Service_DetailsUpload').val(null);
			}
		}

		function deleteRow(r,name,myTable) {
			
			var i = r.parentNode.parentNode.rowIndex;
			document.getElementById(myTable).deleteRow(i);
			attachment_names = $('#attachment_names').val();
			attachment_links = $('#attachment_links').val();

			var tattachment_names = attachment_names+";"
			var tname = name+";";

			attachment_names = tattachment_names.replace(tname, "");
			//attachment_names = attachment_names.replace(";;", ";");			
			if(attachment_names.length >0){
				attachment_names=attachment_names.substring(0, attachment_names.length-1);
			}

			var tattachment_links = attachment_links+";"
			tname = "application/"+name+";";
			attachment_links = tattachment_links.replace(tname, "");
			//attachment_links = attachment_links.replace(";;", ";");
			if(attachment_links.length >0){
				attachment_links=attachment_links.substring(0, attachment_links.length-1);
			}

			$('#attachment_names').val(attachment_names);
			$('#attachment_links').val(attachment_links);
			
			if(myTable=="myTable"){
				$('#academicFileToUpload').val(null);
				$("#resultsacademicFileToUpload").html(""); 
			}
			else{
				$('#Special_Education_Needs_Service_DetailsUpload').val(null);
				$("#resultsSpecial_Education_Needs_Service_DetailsUpload").html(""); 
			}
		}

		var istaketestoptions1click = false;		
		<?php if($taketestoptions == $taketestnow){ echo 'istaketestoptions1click = true;'; } ?>
		var leah_istaketestoptions1click = false;
		<?php if($leah_taketestoptions == $leah_taketestnow){ echo 'leah_istaketestoptions1click = true;'; } ?>
		function doChange(obj){
			var amount = $("#amount").val();
			var AcademicAssessmentFee = $("#AcademicAssessmentFee").val();
			var ESLTestFee = $("#ESLTestFee").val();

			var LeahTestFee = $("#LeahTestFee").val();
			
			if(obj.name == 'second_language_student')
			{
				var taketestoptions1 = $("#taketestoptions1").is(":checked");				
				if(obj.checked || (obj.value=='1' && typeof obj.checked==='undefined')){					
					$("#divsecond_language_student").fadeIn('slow');
				}	
				else{					
					$("#divsecond_language_student").fadeOut('slow');
					if(taketestoptions1){
						amount = parseFloat(amount) - parseFloat(ESLTestFee);	
						$("#lblESLTestFee").html("");
					}					
					istaketestoptions1click=false;
					$("#taketestoptions1").prop('checked', false); 
					$("#taketestoptions2").prop('checked', false);	
				}
			}
			else if(obj.name == 'taketestoptions')
			{
				var taketestoptions1 = $("#taketestoptions1").is(":checked");
				
				if(taketestoptions1){
					if(!istaketestoptions1click){
						amount = parseFloat(amount) + parseFloat(ESLTestFee);
						istaketestoptions1click=true;
						$("#lblESLTestFee").html("<strong>$"+ESLTestFee + "&nbsp;&nbsp;&nbsp; ESL Fee</strong>");
					}
				}
				else{
					if(istaketestoptions1click){
						amount = parseFloat(amount) - parseFloat(ESLTestFee);
						istaketestoptions1click=false;
						$("#lblESLTestFee").html("");
					}
				}					
			}
			else if(obj.name == 'leah_second_language_student')
			{
				var leah_taketestoptions1 = $("#leah_taketestoptions1").is(":checked");				
				if(obj.checked || (obj.value=='1' && typeof obj.checked==='undefined')){					
					$("#leah_divsecond_language_student").fadeIn('slow');
				}	
				else{					
					$("#leah_divsecond_language_student").fadeOut('slow');
					if(leah_taketestoptions1){
						amount = parseFloat(amount) - parseFloat(LeahTestFee);	
						$("#lblLeahTestFee").html("");
					}					
					leah_istaketestoptions1click=false;
					$("#leah_taketestoptions1").prop('checked', false); 
					$("#leah_taketestoptions2").prop('checked', false);	
				}
			}
			else if(obj.name == 'leah_taketestoptions')
			{
				var leah_taketestoptions1 = $("#leah_taketestoptions1").is(":checked");
				
				if(leah_taketestoptions1){
					if(!leah_istaketestoptions1click){
						amount = parseFloat(amount) + parseFloat(LeahTestFee);
						leah_istaketestoptions1click=true;
						$("#lblLeahTestFee").html("<strong>$"+LeahTestFee + "&nbsp;&nbsp;&nbsp; ESL Fee</strong>");
					}
				}
				else{
					if(leah_istaketestoptions1click){
						amount = parseFloat(amount) - parseFloat(LeahTestFee);
						leah_istaketestoptions1click=false;
						$("#lblLeahTestFee").html("");
					}
				}					
			}
			else if(obj.name == 'check_additional_fee')
			{
						
				if(obj.checked){
					
					amount = parseFloat(amount) + parseFloat(AcademicAssessmentFee);
					$("#lblAcademicAssessmentFee").html("<strong>$"+AcademicAssessmentFee + "&nbsp;&nbsp;&nbsp; Academic Assessment Fee</strong>");
					//$("#divcheck_additional_fee").fadeIn('slow');
				}	
				else{
					amount = parseFloat(amount) - parseFloat(AcademicAssessmentFee);
					$("#lblAcademicAssessmentFee").html("");
					//$("#divcheck_additional_fee").fadeOut('slow');	
				}
			}
			$("#amount").val(amount);
			$("#lblamount").html("<strong>$"+amount + "</strong>");

			if(parseFloat(amount) > 0){
				$("#divcheck_additional_fee").fadeIn('slow');
			}
			else{
				$("#divcheck_additional_fee").fadeOut('slow');
			}
			//console.log(obj.checked);
		}
		function doChangereceived_special_education_needs_services(obj){			
			if(obj.name == 'received_special_education_needs_services')
			{							
				if(obj.value == "Yes"){					
					$("#divreceived_special_education_needs_services").fadeIn('slow');
				}	
				else{					
					$("#divreceived_special_education_needs_services").fadeOut('slow');					
				}
			}
		}
	</script>
<?php } ?>

<?php
if (isset($schoolid) && $schoolid != '186') {
?>
	<!--script src="https://sdk.amazonaws.com/js/aws-sdk-2.1.24.min.js"></script-->
	<script type="text/javascript">
		//AWS access info
		// AWS.config.update({
		// 	accessKeyId: 'AKIAJLDPTDTNJJ4234SA',
		// 	secretAccessKey: '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'
		// });
		// AWS.config.region = 'us-east-2';

		function getFileNameFromPath(path) {
			var ary = path.split("/");
			return ary[ary.length - 1];
		}

		$(document).ready(function() {
			var isuploadAcademicFile = false;
			var isuploadLegalNameFile = false;
			var isuploadproficiencyTestResults = false;
			var isuploadleah_TestResults = false;
			var isuploadSpecial_Education_Needs_Service_DetailsFile = false;
			$('#academicFileToUpload').change(function() {
				$('#requiredAcademicFileToUpload').val('');
				$("#academicFileToUpload").attr("disabled", "disabled");
				$("#legalNameFileToUpload").attr("disabled", "disabled");
				$("#proficiencyTestResults").attr("disabled", "disabled");
				$("#leah_TestResults").attr("disabled", "disabled");
				$("#Special_Education_Needs_Service_DetailsUpload").attr("disabled", "disabled");
				//$("#b_apply").hide();
				// $("#b_apply").attr("disabled", "disabled");
				// $("#b_goback").attr("disabled", "disabled");
				// $("#b_reset").attr("disabled", "disabled");
				isuploadAcademicFile = true;
				isuploadLegalNameFile = false;
				isuploadproficiencyTestResults =  false;
				isuploadleah_TestResults = false;
				isuploadSpecial_Education_Needs_Service_DetailsFile = false;

				var uploadFilescheck = $('#academicFileToUpload')[0];
				var upFilecheck = uploadFilescheck.files[0];
				var isgoodcheck = true;
				var fsizecheck = 0;
				var filecheck = 0;
				var i = 0;
				var lencheck = uploadFilescheck.files.length;
				if(lencheck){
					for (; i < lencheck; i++) {
						upFilecheck = uploadFilescheck.files[i];

						fsizecheck = upFilecheck.size;
						filecheck = Math.round((fsizecheck / 1024));
						//isgoodcheck = true;
						// The size of the file.
						if (filecheck >= 20480) {
							alert("File too Big, please select a file less than 20mb");
							$("#resultsacademicFileToUpload").html("<span style='color:red;'>File too Big, please select a file less than 20mb</span>");
							isgoodcheck = false;

							$("#academicFileToUpload").removeAttr("disabled");
							$("#legalNameFileToUpload").removeAttr("disabled");
							$("#proficiencyTestResults").removeAttr("disabled");
							$("#leah_TestResults").removeAttr("disabled");
							$("#Special_Education_Needs_Service_DetailsUpload").removeAttr("disabled");
							//$("#b_apply").show();
							// $("#b_apply").removeAttr("disabled");
							// $("#b_reset").removeAttr("disabled");
							// $("#b_goback").removeAttr("disabled");
							$('#academicFileToUpload').val(null);
							return false;
						}
					}
				}
				else{
					isgoodcheck = false;
					$("#academicFileToUpload").removeAttr("disabled");
					$("#legalNameFileToUpload").removeAttr("disabled");
					$("#proficiencyTestResults").removeAttr("disabled");
					$("#leah_TestResults").removeAttr("disabled");
					$("#Special_Education_Needs_Service_DetailsUpload").removeAttr("disabled");
				}
				if (isgoodcheck) {
					$('#stud_form').submit();
				} else {
					//return false;
				}
			});

			$('#legalNameFileToUpload').change(function() {
				$('#requiredlegalNameFileToUpload').val('');
				$("#academicFileToUpload").attr("disabled", "disabled");
				$("#legalNameFileToUpload").attr("disabled", "disabled");
				$("#proficiencyTestResults").attr("disabled", "disabled");
				$("#leah_TestResults").attr("disabled", "disabled");
				$("#Special_Education_Needs_Service_DetailsUpload").attr("disabled", "disabled");
				//$("#b_apply").hide();
				// $("#b_apply").attr("disabled", "disabled");
				// $("#b_goback").attr("disabled", "disabled");
				// $("#b_reset").attr("disabled", "disabled");
				isuploadAcademicFile = false;
				isuploadLegalNameFile = true;
				isuploadproficiencyTestResults =  false;
				isuploadleah_TestResults = false;
				isuploadSpecial_Education_Needs_Service_DetailsFile = false;

				var uploadFilescheck = $('#legalNameFileToUpload')[0];
				var upFilecheck = uploadFilescheck.files[0];
				var isgoodcheck = true;
				var fsizecheck = 0;
				var filecheck = 0;
				var i = 0;
				var lencheck = uploadFilescheck.files.length;
				if(lencheck){
				for (; i < lencheck; i++) {
					upFilecheck = uploadFilescheck.files[i];

					fsizecheck = upFilecheck.size;
					filecheck = Math.round((fsizecheck / 1024));
					//isgoodcheck = true;
					// The size of the file.
					if (filecheck >= 20480) {
						alert("File too Big, please select a file less than 20mb");
						$("#resultslegalNameFileToUpload").html("<span style='color:red;'>File too Big, please select a file less than 20mb</span>");
						isgoodcheck = false;

						$("#academicFileToUpload").removeAttr("disabled");
						$("#legalNameFileToUpload").removeAttr("disabled");
						$("#proficiencyTestResults").removeAttr("disabled");
						$("#leah_TestResults").removeAttr("disabled");
						$("#Special_Education_Needs_Service_DetailsUpload").removeAttr("disabled");
						//$("#b_apply").show();
						// $("#b_apply").removeAttr("disabled");
						// $("#b_reset").removeAttr("disabled");
						// $("#b_goback").removeAttr("disabled");
						$('#legalNameFileToUpload').val(null);
					}
				}
				}
				else{
					isgoodcheck = false;
					$("#academicFileToUpload").removeAttr("disabled");
					$("#legalNameFileToUpload").removeAttr("disabled");
					$("#proficiencyTestResults").removeAttr("disabled");
					$("#leah_TestResults").removeAttr("disabled");
					$("#Special_Education_Needs_Service_DetailsUpload").removeAttr("disabled");
				}
				if (isgoodcheck) {
					$('#stud_form').submit();
				} else {
					//return false;
				}
			});

			$('#proficiencyTestResults').change(function() {
				$('#requiredproficiencyTestResults').val('');
				$("#proficiencyTestResults").attr("disabled", "disabled");
				$("#leah_TestResults").attr("disabled", "disabled");
				$("#academicFileToUpload").attr("disabled", "disabled");
				$("#legalNameFileToUpload").attr("disabled", "disabled");
				$("#Special_Education_Needs_Service_DetailsUpload").attr("disabled", "disabled");
				//$("#b_apply").hide();
				// $("#b_apply").attr("disabled", "disabled");
				// $("#b_goback").attr("disabled", "disabled");
				// $("#b_reset").attr("disabled", "disabled");
				isuploadAcademicFile = false;
				isuploadLegalNameFile = false;
				isuploadproficiencyTestResults =  true;
				isuploadleah_TestResults = false;
				isuploadSpecial_Education_Needs_Service_DetailsFile = false;

				var uploadFilescheck = $('#proficiencyTestResults')[0];
				var upFilecheck = uploadFilescheck.files[0];
				var isgoodcheck = true;
				var fsizecheck = 0;
				var filecheck = 0;
				var i = 0;
				var lencheck = uploadFilescheck.files.length;
				if(lencheck){
				for (; i < lencheck; i++) {
					upFilecheck = uploadFilescheck.files[i];

					fsizecheck = upFilecheck.size;
					filecheck = Math.round((fsizecheck / 1024));
					//isgoodcheck = true;
					// The size of the file.
					if (filecheck >= 20480) {
						alert("File too Big, please select a file less than 20mb");
						$("#resultsproficiencyTestResults").html("<span style='color:red;'>File too Big, please select a file less than 20mb</span>");
						isgoodcheck = false;
						$("#proficiencyTestResults").removeAttr("disabled");
						$("#leah_TestResults").removeAttr("disabled");
						$("#academicFileToUpload").removeAttr("disabled");
						$("#legalNameFileToUpload").removeAttr("disabled");
						$("#Special_Education_Needs_Service_DetailsUpload").removeAttr("disabled");
						//$("#b_apply").show();
						// $("#b_apply").removeAttr("disabled");
						// $("#b_reset").removeAttr("disabled");
						// $("#b_goback").removeAttr("disabled");
						$('#proficiencyTestResults').val(null);
						return false;
					}
				}
				}
				else{
					isgoodcheck = false;
					$("#academicFileToUpload").removeAttr("disabled");
					$("#legalNameFileToUpload").removeAttr("disabled");
					$("#proficiencyTestResults").removeAttr("disabled");
					$("#leah_TestResults").removeAttr("disabled");
					$("#Special_Education_Needs_Service_DetailsUpload").removeAttr("disabled");
				}
				if (isgoodcheck) {
					$('#stud_form').submit();
				} else {
					//return false;
				}
			});

			$('#leah_TestResults').change(function() {
				$('#requiredleah_TestResults').val('');
				$("#leah_TestResults").attr("disabled", "disabled");
				$("#proficiencyTestResults").attr("disabled", "disabled");
				$("#academicFileToUpload").attr("disabled", "disabled");
				$("#legalNameFileToUpload").attr("disabled", "disabled");
				$("#Special_Education_Needs_Service_DetailsUpload").attr("disabled", "disabled");
				//$("#b_apply").hide();
				// $("#b_apply").attr("disabled", "disabled");
				// $("#b_goback").attr("disabled", "disabled");
				// $("#b_reset").attr("disabled", "disabled");
				isuploadAcademicFile = false;
				isuploadLegalNameFile = false;
				isuploadproficiencyTestResults =  false;
				isuploadleah_TestResults =  true;
				isuploadSpecial_Education_Needs_Service_DetailsFile = false;

				var uploadFilescheck = $('#leah_TestResults')[0];
				var upFilecheck = uploadFilescheck.files[0];
				var isgoodcheck = true;
				var fsizecheck = 0;
				var filecheck = 0;
				var i = 0;
				var lencheck = uploadFilescheck.files.length;
				if(lencheck){
				for (; i < lencheck; i++) {
					upFilecheck = uploadFilescheck.files[i];

					fsizecheck = upFilecheck.size;
					filecheck = Math.round((fsizecheck / 1024));
					//isgoodcheck = true;
					// The size of the file.
					if (filecheck >= 20480) {
						alert("File too Big, please select a file less than 20mb");
						$("#resultsleah_TestResults").html("<span style='color:red;'>File too Big, please select a file less than 20mb</span>");
						isgoodcheck = false;
						$("#leah_TestResults").removeAttr("disabled");
						$("#proficiencyTestResults").removeAttr("disabled");
						$("#academicFileToUpload").removeAttr("disabled");
						$("#legalNameFileToUpload").removeAttr("disabled");
						$("#Special_Education_Needs_Service_DetailsUpload").removeAttr("disabled");
						//$("#b_apply").show();
						// $("#b_apply").removeAttr("disabled");
						// $("#b_reset").removeAttr("disabled");
						// $("#b_goback").removeAttr("disabled");
						$('#leah_TestResults').val(null);
						return false;
					}
				}
				}
				else{
					isgoodcheck = false;
					$("#academicFileToUpload").removeAttr("disabled");
					$("#legalNameFileToUpload").removeAttr("disabled");
					$("#proficiencyTestResults").removeAttr("disabled");
					$("#leah_TestResults").removeAttr("disabled");
					$("#Special_Education_Needs_Service_DetailsUpload").removeAttr("disabled");
				}
				if (isgoodcheck) {
					$('#stud_form').submit();
				} else {
					//return false;
				}
			});
			
			$('#Special_Education_Needs_Service_DetailsUpload').change(function() {
				$('#requiredSpecial_Education_Needs_Service_DetailsUpload').val('');
				$("#Special_Education_Needs_Service_DetailsUpload").attr("disabled", "disabled");
				$("#academicFileToUpload").attr("disabled", "disabled");
				$("#legalNameFileToUpload").attr("disabled", "disabled");
				$("#proficiencyTestResults").attr("disabled", "disabled");
				$("#leah_TestResults").attr("disabled", "disabled");
				//$("#b_apply").hide();
				// $("#b_apply").attr("disabled", "disabled");
				// $("#b_goback").attr("disabled", "disabled");
				// $("#b_reset").attr("disabled", "disabled");
				isuploadAcademicFile = false;
				isuploadLegalNameFile = false;
				isuploadproficiencyTestResults =  false;
				isuploadleah_TestResults = false;
				isuploadSpecial_Education_Needs_Service_DetailsFile = true;

				var uploadFilescheck = $('#Special_Education_Needs_Service_DetailsUpload')[0];
				var upFilecheck = uploadFilescheck.files[0];
				var isgoodcheck = true;
				var fsizecheck = 0;
				var filecheck = 0;
				var i = 0;
				var lencheck = uploadFilescheck.files.length;
				if(lencheck){
					for (; i < lencheck; i++) {
						upFilecheck = uploadFilescheck.files[i];

						fsizecheck = upFilecheck.size;
						filecheck = Math.round((fsizecheck / 1024));
						//isgoodcheck = true;
						// The size of the file.
						if (filecheck >= 20480) {
							alert("File too Big, please select a file less than 20mb");
							$("#resultsSpecial_Education_Needs_Service_DetailsUpload").html("<span style='color:red;'>File too Big, please select a file less than 20mb</span>");
							isgoodcheck = false;

							$("#academicFileToUpload").removeAttr("disabled");
							$("#legalNameFileToUpload").removeAttr("disabled");
							$("#proficiencyTestResults").removeAttr("disabled");
							$("#leah_TestResults").removeAttr("disabled");
							$("#Special_Education_Needs_Service_DetailsUpload").removeAttr("disabled");	
							$('#Special_Education_Needs_Service_DetailsUpload').val(null);
							return false;
						}
					}
				}
				else{
					isgoodcheck = false;
					$("#academicFileToUpload").removeAttr("disabled");
					$("#legalNameFileToUpload").removeAttr("disabled");
					$("#proficiencyTestResults").removeAttr("disabled");
					$("#leah_TestResults").removeAttr("disabled");
					$("#Special_Education_Needs_Service_DetailsUpload").removeAttr("disabled");
				}
				if (isgoodcheck) {
					$('#stud_form').submit();
				} else {
					//return false;
				}
			});
			
			$("#stud_form").submit(function() {
				// var bucket = new AWS.S3({
				// 	params: {
				// 		Bucket: 'assistdocuments'
				// 	}
				// });
				var uploadFiles = $('#academicFileToUpload')[0];
				var upFile = uploadFiles.files[0];
				var i = 0,
					len = uploadFiles.files.length;

				var attachment_names = $('#attachment_names').val();
				var attachment_links = $('#attachment_links').val();
				var tfolder = 'application';

				var fsize = 0;
				var file = 0;
				var isgood = true;

				var post_url = 'upload-s3.php';

				//var tfolder = 'test';
				
				if (isuploadAcademicFile) {
					uploadFiles = $('#academicFileToUpload')[0];
					upFile = uploadFiles.files[0];
					len = uploadFiles.files.length;

					for (; i < len; i++) {
						upFile = uploadFiles.files[i];

						if (upFile) {

							var form_data = new FormData();
							form_data.append("academicFileToUpload", upFile);
							$.ajax({
								url: 'upload-s3.php',
								type: 'post',
								datatype: 'text',
								data: form_data,
								contentType: false,
								processData: false,
								xhr: function() {
									var xhr = $.ajaxSettings.xhr();
									if (xhr.upload) {
										$("#b_apply").hide();
										// $("#b_apply").attr("disabled", "disabled");
										 $("#b_goback").attr("disabled", "disabled");
										 $("#b_reset").attr("disabled", "disabled");
										//var progressbar = $("<div>", { style: "background:#607D8B;height:10px;margin:10px 0;" }).appendTo("#resultsacademicFileToUpload"); //create progressbar
										xhr.upload.addEventListener('progress', function(event) {
											var percent = 0;
											var position = event.loaded || event.position;
											var total = event.total;
											if (event.lengthComputable) {
												percent = Math.ceil(position / total * 100);
												if(percent == 100)
												{
													percent=99;
												}
												//	progressbar.css("width", + percent +"%");
												$("#resultsacademicFileToUpload").html("<span style='color:#91C866;'>Uploading " + percent + "%, please wait a moment!</span>");
											}
										}, true);
									}
									return xhr;
								}
							}).done(function(response) {
								let strLocation = response;
								strLocation = decodeURIComponent(strLocation);
								var ts3key = strLocation.replace("https://document-advantages-dls-bucket.s3.us-east-2.amazonaws.com/", "");
								ts3key = strLocation.replace("https://assistdocuments.s3.us-east-2.amazonaws.com/", "");
								var tname = getFileNameFromPath(strLocation);
								$('#requiredAcademicFileToUpload').val(ts3key);
								$("#resultsacademicFileToUpload").html("<span style='color:#91C866;'>Uploaded successfully</span>"); //response

								attachment_names = $('#attachment_names').val();
								attachment_links = $('#attachment_links').val();

								if (attachment_names == "") {
									attachment_names = tname;
								} else {
									attachment_names += ";" + tname;
								}

								if (attachment_links == "") {
									attachment_links = ts3key;
								} else {
									attachment_links += ";" + ts3key;
								}

								createRow(tname,"myTable") ;

								$('#attachment_names').val(attachment_names);
								$('#attachment_links').val(attachment_links);
								$("#academicFileToUpload").removeAttr("disabled");
								$("#legalNameFileToUpload").removeAttr("disabled");
								$("#proficiencyTestResults").removeAttr("disabled");
								$("#leah_TestResults").removeAttr("disabled");
								$("#Special_Education_Needs_Service_DetailsUpload").removeAttr("disabled");
								$("#b_apply").show();
								// $("#b_apply").removeAttr("disabled");
								 $("#b_reset").removeAttr("disabled");
								 $("#b_goback").removeAttr("disabled");
								isuploadAcademicFile = false;
							}).error(function() {
								//console.log( arguments);
							});
						}
					}
				}

				///
				if (isuploadLegalNameFile) {
					uploadFiles = $('#legalNameFileToUpload')[0];
					upFile = uploadFiles.files[0];
					i = 0;
					len = uploadFiles.files.length;

					for (; i < len; i++) {
						upFile = uploadFiles.files[i];
						if (upFile) {


							var form_data = new FormData();
							form_data.append("legalNameFileToUpload", upFile);
							$.ajax({
								url: 'upload-s3.php',
								type: 'post',
								datatype: 'text',
								data: form_data,
								contentType: false,
								processData: false,
								xhr: function() {
									var xhr = $.ajaxSettings.xhr();
									if (xhr.upload) {
										$("#b_apply").hide();
										// $("#b_apply").attr("disabled", "disabled");
										 $("#b_goback").attr("disabled", "disabled");
										 $("#b_reset").attr("disabled", "disabled");

										xhr.upload.addEventListener('progress', function(event) {
											var percent = 0;
											var position = event.loaded || event.position;
											var total = event.total;
											if (event.lengthComputable) {
												percent = Math.ceil(position / total * 100);												
												if(percent == 100){
													percent=99;
												}
												//	progressbar.css("width", + percent +"%");
												$("#resultslegalNameFileToUpload").html("<span style='color:#91C866;'>Uploading " + percent + "%, please wait a moment!</span>");
											}
										}, true);
									}
									return xhr;
								}
							}).done(function(response) {
								let strLocation = response;
								//strLocation = strLocation.replace("%2F", "/");
								strLocation = decodeURIComponent(strLocation);
								var ts3key = strLocation.replace("https://document-advantages-dls-bucket.s3.us-east-2.amazonaws.com/", "");
								ts3key = strLocation.replace("https://assistdocuments.s3.us-east-2.amazonaws.com/", "");
								var tname = getFileNameFromPath(strLocation);

								//$('#legalNameFileToUpload').val(null);
								//$("#showMessage").show();
								$('#requiredlegalNameFileToUpload').val(ts3key);
								$("#resultslegalNameFileToUpload").html("<span style='color:#91C866;'>Uploaded successfully</span>"); //response

								attachment_names = $('#attachment_names').val();
								attachment_links = $('#attachment_links').val();

								if (attachment_names == "") {
									attachment_names = tname;
								} else {
									attachment_names += ";" + tname;
								}

								if (attachment_links == "") {
									attachment_links = ts3key;
								} else {
									attachment_links += ";" + ts3key;
								}
								$('#attachment_names').val(attachment_names);
								$('#attachment_links').val(attachment_links);
								$("#academicFileToUpload").removeAttr("disabled");
								$("#legalNameFileToUpload").removeAttr("disabled");
								$("#proficiencyTestResults").removeAttr("disabled");
								$("#leah_TestResults").removeAttr("disabled");
								$("#Special_Education_Needs_Service_DetailsUpload").removeAttr("disabled");
								$("#b_apply").show();
								// $("#b_apply").removeAttr("disabled");
								 $("#b_reset").removeAttr("disabled");
								 $("#b_goback").removeAttr("disabled");
								isuploadLegalNameFile = false;
							}).error(function() {
								//console.log( arguments);
							});

						}
					}
				}

				if (isuploadproficiencyTestResults) {
					uploadFiles = $('#proficiencyTestResults')[0];
					upFile = uploadFiles.files[0];
					i = 0;
					len = uploadFiles.files.length;

					for (; i < len; i++) {
						upFile = uploadFiles.files[i];
						if (upFile) {


							var form_data = new FormData();
							form_data.append("proficiencyTestResults", upFile);
							$.ajax({
								url: 'upload-s3.php',
								type: 'post',
								datatype: 'text',
								data: form_data,
								contentType: false,
								processData: false,
								xhr: function() {
									var xhr = $.ajaxSettings.xhr();
									if (xhr.upload) {
										$("#b_apply").hide();
										// $("#b_apply").attr("disabled", "disabled");
										 $("#b_goback").attr("disabled", "disabled");
										 $("#b_reset").attr("disabled", "disabled");

										xhr.upload.addEventListener('progress', function(event) {
											var percent = 0;
											var position = event.loaded || event.position;
											var total = event.total;
											if (event.lengthComputable) {
												percent = Math.ceil(position / total * 100);
												if(percent == 100){
													percent=99;
												}
												//	progressbar.css("width", + percent +"%");
												$("#resultsproficiencyTestResults").html("<span style='color:#91C866;'>Uploading " + percent + "%, please wait a moment!</span>");
											}
										}, true);
									}
									return xhr;
								}
							}).done(function(response) {
								let strLocation = response;
								//strLocation = strLocation.replace("%2F", "/");
								strLocation = decodeURIComponent(strLocation);
								var ts3key = strLocation.replace("https://document-advantages-dls-bucket.s3.us-east-2.amazonaws.com/", "");
								ts3key = strLocation.replace("https://assistdocuments.s3.us-east-2.amazonaws.com/", "");
								var tname = getFileNameFromPath(strLocation);

								//$('#proficiencyTestResults').val(null);
								//$("#showMessage").show();
								$('#requiredproficiencyTestResults').val(ts3key);
								$("#resultsproficiencyTestResults").html("<span style='color:#91C866;'>Uploaded successfully</span>"); //response

								attachment_names = $('#attachment_names').val();
								attachment_links = $('#attachment_links').val();

								if (attachment_names == "") {
									attachment_names = tname;
								} else {
									attachment_names += ";" + tname;
								}

								if (attachment_links == "") {
									attachment_links = ts3key;
								} else {
									attachment_links += ";" + ts3key;
								}
								$('#attachment_names').val(attachment_names);
								$('#attachment_links').val(attachment_links);
								$("#academicFileToUpload").removeAttr("disabled");
								$("#legalNameFileToUpload").removeAttr("disabled");
								$("#proficiencyTestResults").removeAttr("disabled");		
								$("#leah_TestResults").removeAttr("disabled");
								$("#Special_Education_Needs_Service_DetailsUpload").removeAttr("disabled");
								$("#b_apply").show();						
								// $("#b_apply").removeAttr("disabled");
								 $("#b_reset").removeAttr("disabled");
								 $("#b_goback").removeAttr("disabled");
								isuploadproficiencyTestResults =  false;
							}).error(function() {
								//console.log( arguments);
							});

						}
					}
				}

				if (isuploadleah_TestResults) {
					uploadFiles = $('#leah_TestResults')[0];
					upFile = uploadFiles.files[0];
					i = 0;
					len = uploadFiles.files.length;

					for (; i < len; i++) {
						upFile = uploadFiles.files[i];
						if (upFile) {


							var form_data = new FormData();
							form_data.append("leah_TestResults", upFile);
							$.ajax({
								url: 'upload-s3.php',
								type: 'post',
								datatype: 'text',
								data: form_data,
								contentType: false,
								processData: false,
								xhr: function() {
									var xhr = $.ajaxSettings.xhr();
									if (xhr.upload) {
										$("#b_apply").hide();
										// $("#b_apply").attr("disabled", "disabled");
										 $("#b_goback").attr("disabled", "disabled");
										 $("#b_reset").attr("disabled", "disabled");

										xhr.upload.addEventListener('progress', function(event) {
											var percent = 0;
											var position = event.loaded || event.position;
											var total = event.total;
											if (event.lengthComputable) {
												percent = Math.ceil(position / total * 100);
												if(percent == 100){
													percent=99;
												}
												//	progressbar.css("width", + percent +"%");
												$("#resultsleah_TestResults").html("<span style='color:#91C866;'>Uploading " + percent + "%, please wait a moment!</span>");
											}
										}, true);
									}
									return xhr;
								}
							}).done(function(response) {
								let strLocation = response;
								//strLocation = strLocation.replace("%2F", "/");
								strLocation = decodeURIComponent(strLocation);
								var ts3key = strLocation.replace("https://document-advantages-dls-bucket.s3.us-east-2.amazonaws.com/", "");
								ts3key = strLocation.replace("https://assistdocuments.s3.us-east-2.amazonaws.com/", "");
								var tname = getFileNameFromPath(strLocation);

								//$('#proficiencyTestResults').val(null);
								//$("#showMessage").show();
								$('#requiredleah_TestResults').val(ts3key);
								$("#resultsleah_TestResults").html("<span style='color:#91C866;'>Uploaded successfully</span>"); //response

								attachment_names = $('#attachment_names').val();
								attachment_links = $('#attachment_links').val();

								if (attachment_names == "") {
									attachment_names = tname;
								} else {
									attachment_names += ";" + tname;
								}

								if (attachment_links == "") {
									attachment_links = ts3key;
								} else {
									attachment_links += ";" + ts3key;
								}
								$('#attachment_names').val(attachment_names);
								$('#attachment_links').val(attachment_links);
								$("#academicFileToUpload").removeAttr("disabled");
								$("#legalNameFileToUpload").removeAttr("disabled");
								$("#proficiencyTestResults").removeAttr("disabled");		
								$("#leah_TestResults").removeAttr("disabled");		
								$("#Special_Education_Needs_Service_DetailsUpload").removeAttr("disabled");
								$("#b_apply").show();						
								// $("#b_apply").removeAttr("disabled");
								 $("#b_reset").removeAttr("disabled");
								 $("#b_goback").removeAttr("disabled");								
								isuploadleah_TestResults = false;
							}).error(function() {
								//console.log( arguments);
							});

						}
					}
				}

				if (isuploadSpecial_Education_Needs_Service_DetailsFile) {
					uploadFiles = $('#Special_Education_Needs_Service_DetailsUpload')[0];
					upFile = uploadFiles.files[0];
					len = uploadFiles.files.length;

					for (; i < len; i++) {
						upFile = uploadFiles.files[i];

						if (upFile) {

							var form_data = new FormData();
							form_data.append("Special_Education_Needs_Service_DetailsUpload", upFile);
							$.ajax({
								url: 'upload-s3.php',
								type: 'post',
								datatype: 'text',
								data: form_data,
								contentType: false,
								processData: false,
								xhr: function() {
									var xhr = $.ajaxSettings.xhr();
									if (xhr.upload) {
										$("#b_apply").hide();
										// $("#b_apply").attr("disabled", "disabled");
										 $("#b_goback").attr("disabled", "disabled");
										 $("#b_reset").attr("disabled", "disabled");
										//var progressbar = $("<div>", { style: "background:#607D8B;height:10px;margin:10px 0;" }).appendTo("#resultsSpecial_Education_Needs_Service_DetailsUpload"); //create progressbar
										xhr.upload.addEventListener('progress', function(event) {
											var percent = 0;
											var position = event.loaded || event.position;
											var total = event.total;
											if (event.lengthComputable) {
												percent = Math.ceil(position / total * 100);
												if(percent == 100)
												{
													percent=99;
												}
												//	progressbar.css("width", + percent +"%");
												$("#resultsSpecial_Education_Needs_Service_DetailsUpload").html("<span style='color:#91C866;'>Uploading " + percent + "%, please wait a moment!</span>");
											}
										}, true);
									}
									return xhr;
								}
							}).done(function(response) {
								let strLocation = response;
								strLocation = decodeURIComponent(strLocation);
								var ts3key = strLocation.replace("https://document-advantages-dls-bucket.s3.us-east-2.amazonaws.com/", "");
								ts3key = strLocation.replace("https://assistdocuments.s3.us-east-2.amazonaws.com/", "");
								var tname = getFileNameFromPath(strLocation);
								$('#requiredSpecial_Education_Needs_Service_DetailsUpload').val(ts3key);
								$("#resultsSpecial_Education_Needs_Service_DetailsUpload").html("<span style='color:#91C866;'>Uploaded successfully</span>"); //response

								attachment_names = $('#attachment_names').val();
								attachment_links = $('#attachment_links').val();

								if (attachment_names == "") {
									attachment_names = tname;
								} else {
									attachment_names += ";" + tname;
								}

								if (attachment_links == "") {
									attachment_links = ts3key;
								} else {
									attachment_links += ";" + ts3key;
								}

								createRow(tname,"myTableSpecial_Education_Needs_Service_DetailsUpload") ;

								$('#attachment_names').val(attachment_names);
								$('#attachment_links').val(attachment_links);
								$("#academicFileToUpload").removeAttr("disabled");
								$("#legalNameFileToUpload").removeAttr("disabled");
								$("#proficiencyTestResults").removeAttr("disabled");
								$("#leah_TestResults").removeAttr("disabled");
								$("#Special_Education_Needs_Service_DetailsUpload").removeAttr("disabled");
								
								$("#b_apply").show();
								// $("#b_apply").removeAttr("disabled");
								 $("#b_reset").removeAttr("disabled");
								 $("#b_goback").removeAttr("disabled");
								isuploadSpecial_Education_Needs_Service_DetailsFile = false;
							}).error(function() {
								//console.log( arguments);
							});
						}
					}
				}
				
				//return false;
			});

		});
	</script>
	<script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/jquery.validate.min.js"></script>
	<script type="text/javascript">
		var vError = false;
		$(document).ready(function() {
			$('form[id="stud_form"]').validate({
				rules: {
					fname: 'required',
					lname: 'required',
					//dob: 'required',
					dob:{
						required: {
							depends: function(elem) {								
								return $('#sDateofBirthMandatory').val() == "1";								
							}
						}
					},
					// email: {
					// 	required: true,
					// 	email: true,
					// },
					email:{
						required: {
							depends: function(elem) {								
								return $('#sEmailMandatory').val() == "1";								
							}
						}
					},
					//homePhone: 'required',
					homePhone:{
						required: {
							depends: function(elem) {								
								return $('#sPhoneMandatory').val() == "1";								
							}
						}
					},
					//mailingAddress: 'required',
					mailingAddress:{
						required: {
							depends: function(elem) {								
								return $('#sMailingAddressMandatory').val() == "1";								
							}
						}
					},
					city: 'required',
					state: 'required',
					zip: 'required',
					//gender: 'required',
					gender:{
						required: {
							depends: function(elem) {								
								return $('#sGenderMandatory').val() == "1";								
							}
						}
					},
					//ethnicity: 'required',
					//country: 'required',
					country:{
						required: {
							depends: function(elem) {								
								return $('#sCountryMandatory').val() == "1";								
							}
						}
					},

					parentfName: 'required',
					parentlName: 'required',
					//parentHomePhone: 'required',
					parentHomePhone:{
						required: {
							depends: function(elem) {								
								return $('#pPhoneMandatory').val() == "1";								
							}
						}
					},

					grade_level: 'required',
					//courses: 'required',
					//parentEmail: 'required',
					parentEmail:{
						required: {
							depends: function(elem) {								
								return $('#pEmailMandatory').val() == "1";								
							}
						}
					},

					parentCountry:{
						required: {
							depends: function(elem) {								
								return $('#pCountryMandatory').val() == "1";								
							}
						}
					},

					//hear_about_us: 'required',
					// hear_about_us_other: {
					// 	required: {
					// 		depends: function(elem) {
					// 			return $("#hear_about_us").val() == "Other";
					// 		}
					// 	}
					// },
					//program_of_interest: 'required',

					"academicFileToUpload[]": {
						required: {
							depends: function(elem) {
								
								return $('#TranscriptUploadMandatory').val() == "1" && $('#attachment_names').val() == "";								
							}
						}
					},
					//"academicFileToUpload[]":'required',
					requiredAcademicFileToUpload: {
						required: {
							depends: function(elem) {
								return $('#academicFileToUpload').val() != "" && $('#attachment_names').val() == "";
							}
						}
					},
					"legalNameFileToUpload[]": {
						required: {
							depends: function(elem) {
							
								return $('#TranscriptUploadMandatory2').val() == "1";
							}
						}
					},					
					requiredlegalNameFileToUpload: {
						required: {
							depends: function(elem) {
								return $('#legalNameFileToUpload').val() != "";
							}
						}
					},
					"proficiencyTestResults[]": {
						required: {
							depends: function(elem) {
								
								var second_language_student = $("#second_language_student").is(":checked");  
								
								if(second_language_student ==false && $("#second_language_student").val()=='1'){
									second_language_student = true;
								}
								var taketestoptions1 = $("#taketestoptions1").is(":checked");     
								var taketestoptions2 = $("#taketestoptions2").is(":checked");     
								
								return second_language_student == true && taketestoptions1 == false && taketestoptions2 == false && $('#ESLTestMandatory').val() != "3";
							}
						}
					},						
					requiredproficiencyTestResults: {
						required: {
							depends: function(elem) {
								return $('#proficiencyTestResults').val() != "";
							}
						}
					},
					"leah_TestResults[]": {
						required: {
							depends: function(elem) {
								
								var leah_second_language_student = $("#leah_second_language_student").is(":checked");  
								
								if(leah_second_language_student ==false && $("#leah_second_language_student").val()=='1'){
									leah_second_language_student = true;
								}
								var leah_taketestoptions1 = $("#leah_taketestoptions1").is(":checked");     
								var leah_taketestoptions2 = $("#leah_taketestoptions2").is(":checked");     
								
								return leah_second_language_student == true && leah_taketestoptions1 == false && leah_taketestoptions2 == false && $('#LeahTestMandatory').val() != "3";
							}
						}
					},					
					requiredleah_TestResults: {
						required: {
							depends: function(elem) {
								return $('#leah_TestResults').val() != "";
							}
						}
					},
					amount: {
						required: {
							depends: function(elem) {
								var check_additional_fee = $("#check_additional_fee").is(":checked");      
								//return check_additional_fee == true;
								return $('#amount').val() != "" && $('#amount').val() != "0";
							}
						}
					},		
					ccType: {
						required: {
							depends: function(elem) {
								var check_additional_fee = $("#check_additional_fee").is(":checked");      
								//return check_additional_fee == true;
								return $('#amount').val() != "" && $('#amount').val() != "0";
							}
						}
					},
					ccNo: {
						required: {
							depends: function(elem) {
								var check_additional_fee = $("#check_additional_fee").is(":checked");      
								//return check_additional_fee == true;
								return $('#amount').val() != "" && $('#amount').val() != "0";
							}
						}
					},
					ccExpMonth: {
						required: {
							depends: function(elem) {
								var check_additional_fee = $("#check_additional_fee").is(":checked");      
								//return check_additional_fee == true;
								return $('#amount').val() != "" && $('#amount').val() != "0";
							}
						}
					},
					ccExpYear: {
						required: {
							depends: function(elem) {
								var check_additional_fee = $("#check_additional_fee").is(":checked");      
								//return check_additional_fee == true;
								return $('#amount').val() != "" && $('#amount').val() != "0";
							}
						}
					},
					ccSecurityCode: {
						required: {
							depends: function(elem) {
								var check_additional_fee = $("#check_additional_fee").is(":checked");      
								//return check_additional_fee == true;
								return $('#amount').val() != "" && $('#amount').val() != "0";
							}
						}
					},
					ccNameOnCard: {
						required: {
							depends: function(elem) {
								var check_additional_fee = $("#check_additional_fee").is(":checked");      
								//return check_additional_fee == true;
								return $('#amount').val() != "" && $('#amount').val() != "0";
							}
						}
					},
					NameofDesignatedLearningCoach:{
						required: {
							depends: function(elem) {								
								return $('#LearningCoachMandatory').val() == "1";								
							}
						}
					},
					read_and_understand_learning_coach:{
						required: {
							depends: function(elem) {								
								return $('#LearningCoachMandatory').val() == "1";								
							}
						}
					},
					sFirstLanguage:{
						required: {
							depends: function(elem) {								
								return $('#sFirstLanguageMandatory').val() == "1";								
							}
						}
					},
					parentFirstLanguage:{
						required: {
							depends: function(elem) {								
								return $('#sFirstLanguageMandatory').val() == "1";								
							}
						}
					},
					parent2FirstLanguage:{
						required: {
							depends: function(elem) {								
								return $('#sFirstLanguageMandatory').val() == "100";								
							}
						}
					},
					current_school_name:{
						required: {
							depends: function(elem) {								
								return $('#mCurrentSchoolNameMandatory').val() == "1";								
							}
						}
					},
					second_language_student:{
						required: {
							depends: function(elem) {								
								return $('#ESLTestMandatory').val() == "1";								
							}
						}
					},
				},
				messages: {
					fname: 'This field is required',
					lname: 'This field is required',
					dob: 'This field is required',
					email: 'Enter a valid email',
					homePhone: 'This field is required',
					mailingAddress: 'This field is required',
					city: 'This field is required',
					state: 'This field is required',
					zip: 'This field is required',
					gender: 'This field is required',
					//ethnicity: 'This field is required',
					country: 'This field is required',
					parentfName: 'This field is required',
					parentlName: 'This field is required',
					parentHomePhone: 'This field is required',
					grade_level: 'This field is required',
					//courses: 'This field is required',
					parentEmail: 'Enter a valid email',
					parentCountry: 'This field is required',
					//hear_about_us: 'This field is required',
					//hear_about_us_other: 'This field is required',
					//program_of_interest: 'This field is required',
					"academicFileToUpload[]": 'This field is required',
					requiredAcademicFileToUpload: '',
					"legalNameFileToUpload[]": 'This field is required',
					requiredlegalNameFileToUpload: '',
					"proficiencyTestResults[]": 'This field is required',
					requiredproficiencyTestResults: '',
					"leah_TestResults[]": 'This field is required',
					requiredleah_TestResults: '',
					amount: 'This field is required',
					ccType: 'This field is required',
					ccNo: 'This field is required',
					ccExpMonth: 'This field is required',
					ccExpYear: 'This field is required',
					ccSecurityCode: 'This field is required',
					ccNameOnCard: 'This field is required',	
					NameofDesignatedLearningCoach: 'This field is required',	
					read_and_understand_learning_coach: 'This field is required',
					sFirstLanguage: 'This field is required',
					parentFirstLanguage: 'This field is required',
					parent2FirstLanguage: 'This field is required',
					current_school_name: 'This field is required',	
					second_language_student: 'This field is required',	
				},
				onfocusout: false,
				submitHandler: function(form) {					
					//alert('sdfdsf');
					form.submit();
					$("#submitting").show();		
					$("#b_apply").hide();
					//$("#b_apply").attr("disabled", "disabled");
					$("#b_goback").attr("disabled", "disabled");
					$("#b_reset").attr("disabled", "disabled");
					vError = false;
				},
				invalidHandler: function(form, validator) {
					var errors = validator.numberOfInvalids();
					if (errors) {
						validator.errorList[0].element.focus();
					}
				}
			});

		});
	</script>
<?php
}
?>
<!-- body classes:  -->
<!-- "boxed": boxed layout mode e.g. <body class="boxed"> -->
<!-- "pattern-1 ... pattern-9": background patterns for boxed layout mode e.g. <body class="boxed pattern-1"> -->
<!-- "transparent-header": makes the header transparent and pulls the banner to top -->
<!-- "gradient-background-header": applies gradient background to header -->
<!-- "page-loader-1 ... page-loader-6": add a page loader to the page (more info @components-page-loaders.html) -->

<body class="no-trans front-page transparent-header">

<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MJ2JF82" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) →

	<!-- scrollToTop -->
	<!-- ================ -->
	<div class="scrollToTop circle"><i class="icon-up-open-big"></i></div>

	<!-- page wrapper start -->
	<!-- ================ -->
	<div class="page-wrapper">


		<?php
		if (isset($schoolid) && $schoolid == '1') {
			include('inc.header.php');
		} else {
			include('inc.otherschoolheader.php');
		}
		?>

		<?php
		if (isset($schoolid) && $schoolid == '186') {
			include('sm_institute_school.php');
		} else {
		?>
			<?php if (isset($schoolid) && $schoolid == '1') { ?>
				<!-- banner start -->
				<!-- ================ -->
				<div class="banner dark-translucent-bg pt-100" style="background-image:url('/images/apply-now-bg.jpg'); background-position: 50% 35%;">
					<div class="container">
						<div class="slideshow">
							<div class="row">
								<div class="col-md-8 text-center col-md-offset-2 pv-20">
									<h1 class="page-title text-center">Apply Now</h1>
									<div class="separator"></div>
									<p class="lead text-center">Thank you for choosing ASI! Please know our staff is available to answer any questions that you may have during the application and enrollment process.</p>
								</div>
							</div>
						</div>
					</div>
				</div>
				<!-- breadcrumb start -->
				<!-- ================ -->
				<div id="row">
					<div class="breadcrumb-container">
						<div class="container">
							<ol class="breadcrumb">
								<li><i class="fa fa-home pr-10"></i><a class="link-dark" href="/">Home</a></li>
								<li><a class="link-dark" href="/contacts">Contact Us</a></li>
								<li class="active">Students Application</li>
							</ol>
						</div>
					</div>
				</div>
			<?php } else { ?>
				<div class="banner pt-50">
					<div class="container">
						<div class="">
							<div class="row">
								<div class="col-md-12 text-center pv-20" style="padding-left: 140px; padding-right: 140px;">
									<h1 class="page-title text-center">Apply Now</h1>

									<p class="lead text-center"><?php echo $headertitle; ?></p>
									<div class="separator"></div>
								</div>
							</div>
						</div>
					</div>
				</div>
			<?php } ?>

			<!-- breadcrumb end -->
			<!-- banner end -->

			<!-- main-container start -->

			<section class="main-container">

				<div class="container">
					<div class="row">
						<!-- main start -->
						<!-- ================ -->
						<div class="main col-md-12 space-bottom">
							<div class="row">


								<style>
									.applyform {
										font: 14px arial;
									}

									.required,
									.errorMsg,
									.error {
										color: red !important;
									}
								</style>
								<div class="col-md-12">
									<?php if ($ERR_MSG != "") { ?><p>
										<div class="errorMsg"><?php echo $ERR_MSG ?></div>
										</p><?php } ?>
								</div>
								<form method="post" name="stud_form" id="stud_form" action="" class="wpcf7-form" enctype="multipart/form-data">
									<div class="col-md-12">
										<h5 style="font-size:24px;text-transform: uppercase;padding-bottom: 20px;"> Student Information </h5>
										<h5 style="font-size:16px;text-transform: uppercase;font-weight: normal;">Student Contact Information</h5>
										<div class="input-field" style="display:none;">
											Student Name<span class="required">*</span>&nbsp;
											<br><input type="text" name="vname" size="40" id="vname" value="<?php echo $vname; ?>">


										</div>
									</div>
									<div class="col-md-6">
										<div class="input-field">
											First Name<span class="required">*</span>&nbsp;<?php echo $captionFirstName; ?>
											<input type="text" name="fname" id="fname" value="<?php echo $fname; ?>" placeholder="">
											<input type="hidden" name="schoolid" size="40" id="schoolid" value="<?php echo $schoolid; ?>">
											<input type="hidden" name="redirect" size="40" id="redirect" value="<?php echo $redirect; ?>">
											<input type="hidden" name="source" id="source" value="<?php echo $source; ?>">

										</div>
									</div>
									<div class="col-md-6">
										<div class="input-field">
											Last Name<span class="required">*</span>&nbsp;<?php echo $captionLastName; ?>
											<input type="text" name="lname" id="lname" value="<?php echo $lname; ?>" placeholder="">
										</div>
									</div>
									
										<input type="hidden" name="sPhoneMandatory" id="sPhoneMandatory" value="<?php echo $sPhoneMandatory ?>">
										<?php if ($sPhoneMandatory != 2) {?>
										<div class="col-md-6">	
										<div class="span3" style="margin-left: 0px;">
											<div class="input-field">
												Mobile Phone <?php if($sPhoneMandatory==1) echo '<span class="required">*</span>';?>&nbsp;
												<br>
												<input type="text" name="homePhone" size="22" id="homePhone" value="<?php echo $homePhone ?>">												
											</div>
										</div>
										</div>
										<?php } ?>

										<input type="hidden" name="sEmailMandatory" id="sEmailMandatory" value="<?php echo $sEmailMandatory ?>">
										<?php if ($sEmailMandatory != 2) {?>
											<div class="col-md-6">
										<div class="input-field">
											Email Address<?php if($sEmailMandatory == 1) echo '<span class="required">*</span>';?>&nbsp;<?php echo $captionSEmail; ?><br>
											<input type="text" name="email" size="40" id="email" value="<?php echo $email ?>">											
										</div>
										</div>
										<?php } ?>
										
										<input type="hidden" name="sDateofBirthMandatory" id="sDateofBirthMandatory" value="<?php echo $sDateofBirthMandatory ?>">
										<?php if ($sDateofBirthMandatory != 2) {?>
											<div class="col-md-6">
										<div class="input-field">
											<span class="advplacecontent">Date Of Birth<?php if($sDateofBirthMandatory == 1) echo '<span class="required">*</span>';?>&nbsp; </span>
											<br>
											<input type="text" name="dob" size="22" id="dob" value="<?php echo $dob ?>" autocomplete="off" placeholder="MM/DD/YYYY">											
										</div></div>
										<?php } ?>

										<input type="hidden" name="sMailingAddressMandatory" id="sMailingAddressMandatory" value="<?php echo $sMailingAddressMandatory ?>">
										<?php if ($sMailingAddressMandatory != 2) {?>
											<div class="col-md-6">
										<div class="input-field">Home Address<?php if($sMailingAddressMandatory == 1) echo '<span class="required">*</span>';?>&nbsp;
											<br>											
											<input type="text" name="mailingAddress" size="22" id="mailingAddress" value="<?php echo $mailingAddress ?>"/>
											<!--textarea name="mailingAddress" cols="40" rows="4" id="mailingAddress" style="height: 60px;"><?php echo $mailingAddress ?></textarea-->
										</div></div>
										<?php } ?>

										<input type="hidden" name="sCountryMandatory" id="sCountryMandatory" value="<?php echo $sCountryMandatory ?>">	
										<?php if ($sCountryMandatory != 2) {?>
											<div class="col-md-6">
										<div class="input-field"><?php echo $titleCountry;?><?php if($sCountryMandatory == 1) echo '<span class="required">*</span>';?>&nbsp;<br>
											<select style="width:auto" name="country" id="country">
												<?php echo $rscountryoption; ?>
											</select>						
										</div>	</div>
										<?php } ?>

										<input type="hidden" name="sFirstLanguageMandatory" id="sFirstLanguageMandatory" value="<?php echo $sFirstLanguageMandatory ?>">	
										<?php if ($sFirstLanguageMandatory != 2) {?>
											<div class="col-md-6">
											<div class="input-field">First Language <?php if($sFirstLanguageMandatory == 1) echo '<span class="required">*</span>';?>&nbsp;<br>											
												<input type="text" name="sFirstLanguage" size="22" id="sFirstLanguage" value="<?php echo $sFirstLanguage ?>">																															
											</div></div>
										<?php } ?>


										<div class="col-md-6">	
										<div class="input-field">State<span class="required">*</span>&nbsp;<br>
											
												<select style="width:auto" name="state" id="state">
													<option value="">Select...</option>
													<?php echo $rsstateoption; ?>
												</select>
											
										</div>
										</div>
									<div class="col-md-6">	
										<div class="input-field">City<span class="required">*</span>&nbsp;
											<br>
											<input type="text" name="city" size="25" id="city" value="<?php echo $city ?>">
										</div>
										</div>
									<div class="col-md-6">	
										<div class="input-field">
											Zip<span class="required">*</span>&nbsp;<br>
											<input type="text" name="zip" size="25" id="zip" value="<?php echo $zip ?>" />
											</span>
										</div>
										</div>


										<!--div class="input-field">State<span class="required">*</span>&nbsp;<br>
											
												<select style="width:100%" name="state" id="state">
													<option value="">Select...</option>
													<?php //echo $rsstateoption; ?>
												</select>
											
										</div>
										<div class="input-field">City<span class="required">*</span>&nbsp;
											<br>
											<input type="text" name="city" size="25" id="city" value="<?php echo $city ?>">
										</div>
										<div class="input-field">
											Zip<span class="required">*</span>&nbsp;<br>
											<input type="text" name="zip" size="25" id="zip" value="<?php echo $zip ?>" />
											</span>
										</div-->
										<?php if ($schoolid == 323) {?>
											<div class="col-md-6">
										<div class="input-field">
											Nationality<br>
											<input type="text" name="nationality" size="40" id="nationality" value="<?php echo $nationality ?>">
										</div>
										</div>
										<div class="col-md-6">
										<div class="input-field">
											Passport Number<br>
											<input type="text" name="passportnumber" size="40" id="passportnumber" value="<?php echo $passportnumber ?>">
										</div></div>
										<?php } ?>

										<input type="hidden" name="sGenderMandatory" id="sGenderMandatory" value="<?php echo $sGenderMandatory ?>">	
										<?php if ($sGenderMandatory != 2) {?>
											<div class="col-md-6">
										<div class="input-field">
											Gender<?php if($sGenderMandatory == 1) echo '<span class="required">*</span>';?>&nbsp;<br>
											<select style="width:auto" name="gender" id="gender">
												<option value="">Select...</option>
												<option value="Male" <?php echo ($gender == "Male" ? "selected" : "") ?>>Male</option>
												<option value="Female" <?php echo ($gender == "Female" ? "selected" : "") ?>>Female</option>
												<?php if (!$removePreferNotToAnswer) : ?>
													<option value="Not Answer" <?php echo ($gender == "Not Answer" ? "selected" : ""); ?>>Prefer not to answer</option>
												<?php endif; ?>											</select>
										</div></div>
										<?php } ?>
										<!--
										<div class="input-field">
											Ethnicity<span class="required">*</span>&nbsp;<br>
											<select style="width:auto" name="ethnicity" id="ethnicity">
												<option value="">Select...</option>
												<option value="3" <?php echo ($ethnicity == "3" ? "selected" : "") ?>>African American, Non-Hispanic</option>
												<option value="1" <?php echo ($ethnicity == "1" ? "selected" : "") ?>>American Indian/Alaskan Native</option>
												<option value="2" <?php echo ($ethnicity == "2" ? "selected" : "") ?>>Asian/Pacific Islander</option>
												<option value="5" <?php echo ($ethnicity == "5" ? "selected" : "") ?>>Caucasian, Non-Hispanic</option>
												<option value="4" <?php echo ($ethnicity == "4" ? "selected" : "") ?>>Hispanic</option>
												<option value="6" <?php echo ($ethnicity == "6" ? "selected" : "") ?>>Other</option>
												<option value="7" <?php echo ($ethnicity == "0" ? "selected" : "") ?>>Prefer not to answer</option>
											</select>
										</div>	
										-->
									
									<div class="col-md-12" <?php echo $customstyle; ?>>
									<hr>
										<h5 style="font-size:24px;text-transform: uppercase;padding-bottom: 20px;">Parent Information</h5>

										<h5 style="font-size:16px;text-transform: uppercase;font-weight: normal;">Parent Contact Information</h5>

										<div class="input-field" style="display:none;">Name<span class="required">*</span><br>
											<input type="text" name="parentName" size="40" id="parentName" value="<?php echo $parentName ?>">
										</div>
									</div>
									<div class="col-md-6">
										<div class="input-field">First Name<span class="required">*</span><br>
											<input type="text" name="parentfName" id="parentfName" value="<?php echo $parentfName ?>" placeholder="">
										</div>
									</div>
									<div class="col-md-6">	
										<div class="input-field">Last Name<span class="required">*</span><br>
											<input type="text" name="parentlName" id="parentlName" value="<?php echo $parentlName ?>" placeholder="">
										</div>
									</div>
										<input type="hidden" name="pPhoneMandatory" id="pPhoneMandatory" value="<?php echo $pPhoneMandatory ?>">
										<?php if ($pPhoneMandatory != 2) {?>
											<div class="col-md-6">
										<div class="input-field">
											Mobile Phone<?php if($pPhoneMandatory == 1) echo '<span class="required">*</span>';?><br>
											<input type="text" name="parentHomePhone" size="22" id="parentHomePhone" value="<?php echo $parentHomePhone ?>">											
										</div>
										</div>
										<?php } ?>

										<input type="hidden" name="pEmailMandatory" id="pEmailMandatory" value="<?php echo $pEmailMandatory ?>">
										<?php if ($pEmailMandatory != 2) {?>
											<div class="col-md-6">
										<div class="input-field">Email Address<?php if($pEmailMandatory == 1) echo '<span class="required">*</span>';?>&nbsp;<?php echo $captionSEmail; ?><br>
											<input type="text" name="parentEmail" size="40" id="parentEmail" value="<?php echo $parentEmail ?>">											
										</div></div>
										<?php } ?>
										<!--div class="input-field">Cell Phone&nbsp;<br>
											<input type="text" name="parentCellPhone" size="22" id="parentCellPhone" value="<?php echo $parentCellPhone ?>" />
										</div-->

										<input type="hidden" name="pRelationshipMandatory" id="pRelationshipMandatory" value="<?php echo $pRelationshipMandatory ?>">
										<?php if ($pRelationshipMandatory != 2) {?>
											<div class="col-md-6">
										<div class="input-field">Relationship&nbsp;<br>
											<input type="text" name="parentRelationship" size="40" id="parentRelationship" value="<?php echo $parentRelationship ?>">											
										</div></div>
										<?php } ?>

										<input type="hidden" name="pHomeAddressMandatory" id="pHomeAddressMandatory" value="<?php echo $pHomeAddressMandatory ?>">
										<?php if ($pHomeAddressMandatory != 2) {?>
											<div class="col-md-6">
										<div class="input-field">Home Address&nbsp;<br>
											<textarea name="parentMailingAddress" cols="50" rows="5" id="parentMailingAddress" style="height: 60px;"><?php echo $parentMailingAddress ?></textarea>											
										</div></div>
										<?php } ?>

										<input type="hidden" name="pCountryMandatory" id="pCountryMandatory" value="<?php echo $pCountryMandatory ?>">	
										<?php if ($pCountryMandatory != 2) {?>
											<div class="col-md-6">
										<div class="input-field"><?php echo $titleCountry;?> <?php if($pCountryMandatory == 1) echo '<span class="required">*</span>';?>&nbsp;<br>
											<select style="width:auto" name="parentCountry" id="parentCountry">
												<?php echo $rsparentcountryoption; ?>
											</select>																					
										</div>
										</div>
										<?php } ?>
										
										<?php if ($sFirstLanguageMandatory != 2) {?>
											<div class="col-md-6">
											<div class="input-field">First Language <?php if($sFirstLanguageMandatory == 1) echo '<span class="required">*</span>';?>&nbsp;<br>											
												<input type="text" name="parentFirstLanguage" size="22" id="parentFirstLanguage" value="<?php echo $parentFirstLanguage ?>">																															
											</div></div>
										<?php } ?>

										<!--div class="input-field">State&nbsp;<br>
											
												<select style="width:100%" name="parentState" id="parentState">
													<option value="">Select...</option>
													<?php //echo $rsparentstateoption; ?>
												</select>
										
										</div>
										
										<div class="input-field">City&nbsp; <br>
											<input type="text" name="parentCity" size="25" id="parentCity" value="<?php //echo $parentCity ?>">
											</span>
										</div>
										<div class="input-field">Zip&nbsp;<br>
											<input type="text" name="parentZip" size="25" id="parentZip" value="<?php //echo $parentZip ?>" />
										</div-->
										<?php if ($schoolid == 323) {?>
											<div class="col-md-6">
										<div class="input-field">
											Nationality<br>
											<input type="text" name="parentnationality" size="40" id="parentnationality" value="<?php echo $parentnationality ?>">
										</div></div>
										<div class="col-md-6">
										<div class="input-field">
											Passport Number<br>
											<input type="text" name="parentpassportnumber" size="40" id="parentpassportnumber" value="<?php echo $parentpassportnumber ?>">
										</div>
										</div>
										<?php } ?>	
										
										<input type="hidden" name="Parent2Mandatory" id="Parent2Mandatory" value="<?php echo $Parent2Mandatory ?>">	
										<?php if ($Parent2Mandatory != 20) {?>
											<div class="col-md-12">											
											<h5 style="font-size:24px;text-transform: uppercase;padding-bottom: 20px;">Second Parent Information</h5>
											<h5 style="font-size:16px;text-transform: uppercase;font-weight: normal;">Parent Contact Information</h5>
											</div>
											<div class="col-md-6">
											<div class="input-field">First Name&nbsp;<br>
												<input type="text" name="parent2FName" size="40" id="parent2FName" value="<?php echo $parent2FName ?>">
											</div>
											</div>
											<div class="col-md-6">
											<div class="input-field">Last Name&nbsp;<br>
												<input type="text" name="parent2LName" size="40" id="parent2LName" value="<?php echo $parent2LName ?>">
											</div>
											</div>
											<div class="col-md-6">
											<div class="input-field">
												Mobile Phone<br>
												<input type="text" name="parent2HomePhone" size="22" id="parent2HomePhone" value="<?php echo $parent2HomePhone ?>">
											</div>
											</div>
											<div class="col-md-6">
											<div class="input-field">Email Address &nbsp;<br>
												<input type="text" name="parent2Email" size="40" id="parent2Email" value="<?php echo $parent2Email ?>">
											</div>
											</div>
											<div class="input-field" style="display:none;">
												Title<br>
												<input type="text" name="parent2Title" size="22" id="parent2Title" value="<?php echo $parent2Title ?>">
											</div>
											<div class="input-field" style="display:none;">
												Occupation<br>
												<input type="text" name="parent2Occupation" size="22" id="parent2Occupation" value="<?php echo $parent2Occupation ?>">
											</div>
											<div class="col-md-6">
											<div class="input-field">Relationship&nbsp;<br>
												<input type="text" name="parent2Relationship" size="40" id="parent2Relationship" value="<?php echo $parent2Relationship ?>">
											</div>
											</div>
											<input type="hidden" name="pHomeAddress2Mandatory" id="pHomeAddress2Mandatory" value="<?php echo $pHomeAddressMandatory ?>">
											<?php if ($pHomeAddressMandatory != 2) {?>
												<div class="col-md-6">
											<div class="input-field">Home Address&nbsp;<br>
												<textarea name="parent2MailingAddress" cols="50" rows="5" id="parent2MailingAddress" style="height: 60px;"><?php echo $parent2MailingAddress ?></textarea>											
											</div>
											</div>
											<?php } ?>

											<input type="hidden" name="pCountry2Mandatory" id="pCountry2Mandatory" value="<?php echo $pCountryMandatory ?>">	
											<?php if ($pCountryMandatory != 2) {?>
											<div class="col-md-6">
												<div class="input-field"><?php echo $titleCountry;?> <?php if($pCountryMandatory == 1) echo '<span class="required">*</span>';?>&nbsp;<br>
													<select style="width:auto" name="parent2Country" id="parent2Country">
														<?php echo $rsparent2countryoption; ?>
													</select>																					
												</div>
											</div>
											<?php } ?>
												
											<?php if ($sFirstLanguageMandatory != 2) {?>
											<div class="col-md-6">
											<div class="input-field">First Language <?php if($sFirstLanguageMandatory == 100) echo '<span class="required">*</span>';?>&nbsp;<br>											
												<input type="text" name="parent2FirstLanguage" size="22" id="parent2FirstLanguage" value="<?php echo $parent2FirstLanguage ?>">																															
											</div>
											</div>
											<?php } ?>

											
											
										<?php } ?>							
									
									<div class="col-md-12">
										<hr>
										<h5 style="font-size:24px;text-transform: uppercase;padding-bottom: 20px;">STUDENT ACADEMIC INFORMATION</h5>
									</div>
									<div class="col-md-6">
										<div class="input-field">
											Grade of Student (Last Grade Completed)<span class="required">*</span>&nbsp;
											<br>
											<select style="width:100%;" id="grade_level" name="grade_level">
												<option value="">Select...</option>
												<option value="K" <?php if ($grade_level == "K") echo 'selected'; ?>>K</option>
												<option value="1" <?php if ($grade_level == "1") echo 'selected'; ?>>1</option>
												<option value="2" <?php if ($grade_level == "2") echo 'selected'; ?>>2</option>
												<option value="3" <?php if ($grade_level == "3") echo 'selected'; ?>>3</option>
												<option value="4" <?php if ($grade_level == "4") echo 'selected'; ?>>4</option>
												<option value="5" <?php if ($grade_level == "5") echo 'selected'; ?>>5</option>
												<option value="6" <?php if ($grade_level == "6") echo 'selected'; ?>>6</option>
												<option value="7" <?php if ($grade_level == "7") echo 'selected'; ?>>7</option>
												<option value="8" <?php if ($grade_level == "8") echo 'selected'; ?>>8</option>
												<option value="9" <?php if ($grade_level == "9") echo 'selected'; ?>>9</option>
												<option value="10" <?php if ($grade_level == "10") echo 'selected'; ?>>10</option>
												<option value="11" <?php if ($grade_level == "11") echo 'selected'; ?>>11</option>
												<option value="12" <?php if ($grade_level == "12") echo 'selected'; ?>>12</option>
												<option value="Post Grad" <?php if ($grade_level == "Post Grad") echo 'selected'; ?>>Post Grad</option>
											</select>
										</div>
									</div>
									<div class="col-md-6">
									<input type="hidden" name="mCurriculumMandatory" id="mCurriculumMandatory" value="<?php echo $mCurriculumMandatory ?>">
										<?php if ($mCurriculumMandatory != 2) {?>
										<div class="input-field">
											Curriculum<br>
											<input type="text" name="curriculum" size="40" id="curriculum" value="<?php echo $curriculum ?>">
										</div>
										<?php } ?>	
									</div>
									<div class="col-md-12">									

										<?php if ($schoolid == 403) {?>
											<input type="hidden" name="mCoursesMandatory" id="mCoursesMandatory" value="<?php echo $mCoursesMandatory ?>">										
											<?php if ($mCoursesMandatory != 2) {?>												
												<div class="input-field">
												Select the courses you wish to be enrolled in<br>
												<input type="checkbox" id="course1" name="course1" value="1" onclick="javascript:doChange(this);" <?php if($course1) {echo 'checked="checked"';}?>/>&nbsp; Fusion Elective E-Sports
												<br><input type="checkbox" id="course2" name="course2" value="1" onclick="javascript:doChange(this);" <?php if($course2) {echo 'checked="checked"';}?>/>&nbsp; P.E. Breaking
												<br><input type="checkbox" id="course3" name="course3" value="1" onclick="javascript:doChange(this);" <?php if($course3) {echo 'checked="checked"';}?>/>&nbsp; P.E. K-Dance
												</div>
												
											<?php } ?>

										<?php }else{ ?>
											<div class="input-field" style="display:none;">
												Courses or Grade Level Applying for<span class="required">*</span>&nbsp;
												<br>
												<textarea name="courses" cols="50" rows="5" id="courses" style="height: 60px;"><?php echo $courses ?></textarea>
											</div>
										<?php } ?>
									</div>
									<div class="col-md-12">	
										<input type="hidden" name="mAdditionalnotesMandatory" id="mAdditionalnotesMandatory" value="<?php echo $mAdditionalnotesMandatory ?>">										
										<?php if ($mAdditionalnotesMandatory != 2) {?>
										<div class="input-field">Additional Notes&nbsp;<br>
											<textarea name="notes" cols="50" rows="7" id="notes" style="height: 60px;"><?php echo $notes ?></textarea>
										</div>
										<?php } ?>	

									</div>
									<div class="col-md-12">		
										
										<input type="hidden" name="HasSpecialEducationNeedsServicesMandatory" id="HasSpecialEducationNeedsServicesMandatory" value="<?php echo $HasSpecialEducationNeedsServicesMandatory ?>">
										<?php if($HasSpecialEducationNeedsServicesMandatory != "2") {?>
										<div class="input-field">
										Has student ever received Special Education Needs Services?&nbsp;<br>
											<select style="width:130px" name="received_special_education_needs_services" id="received_special_education_needs_services" onchange="javascript:doChangereceived_special_education_needs_services(this);">
												<option value="">Select...</option>
												<option value="Yes" <?php echo ($received_special_education_needs_services == "Yes" ? "selected" : "") ?>>Yes</option>
												<option value="No" <?php echo ($received_special_education_needs_services == "No" ? "selected" : "") ?>>No</option>												
											</select>
											<br>
											If yes, please provide details and upload IEP or SEN documents
										</div>

										<div id="divreceived_special_education_needs_services" name="divreceived_special_education_needs_services" <?php if($received_special_education_needs_services == "Yes") {echo 'style="display:inline"';}else{echo 'style="display:none"';}?>>									
											<div class="col-md-12">
											<div class="input-field col-md-8">Special Education Needs Service Details:<br>
												<input name="Special_Education_Needs_Service_Details" type="text" id="Special_Education_Needs_Service_Details" value="<?php echo $Special_Education_Needs_Service_Details; ?>" />
											</div>
											</div>
											<div class="col-md-12">
											<div class="form-group col-md-12" style="display:inline;white-space: nowrap;margin-right:20px">
												<span class="advplacecontent">Upload Files</span>
												<input type="file" name="Special_Education_Needs_Service_DetailsUpload[]" id="Special_Education_Needs_Service_DetailsUpload" style="padding: 5px 0px 0px 0px;" multiple>
												<div class="row">
													<div class="col-md-6">
														<div id="resultsSpecial_Education_Needs_Service_DetailsUpload">
															<!-- server response here -->
														</div>
													</div>
													<div class="col-md-2">
														<input type="text" name="requiredSpecial_Education_Needs_Service_DetailsUpload" id="requiredSpecial_Education_Needs_Service_DetailsUpload" style="width:0px;padding: 0px; border: 0px;" value="">
													</div>
												</div>
											</div>
											<div class="form-group" style="display:inline;">											
												<table id="myTableSpecial_Education_Needs_Service_DetailsUpload">												
												</table>
											</div>

											</div>												
										</div>

										<?php } ?>
									</div>
								<?php if ($schoolid == 323) {?>
									<div class="col-md-12">
										<div class="input-field">		
										<hr>								
										<h5 style="font-size:16px;text-transform: uppercase;font-weight: normal;">Academic Skill Level</h5>
										</div>
									</div>
									<div class="col-md-6">
										<div class="input-field">
											Reading
											<br>
											<select style="width:100%" name="AcademicSkillLevelReading" id="AcademicSkillLevelReading">
												<option value="">Select...</option>
												<option value="Below" <?php echo ($AcademicSkillLevelReading == "Below" ? "selected" : "") ?>>Below</option>
												<option value="Average" <?php echo ($AcademicSkillLevelReading == "Average" ? "selected" : "") ?>>Average</option>												
												<option value="Advanced" <?php echo ($AcademicSkillLevelReading == "Advanced" ? "selected" : "") ?>>Advanced</option>
											</select>
										</div>
									</div>
									<div class="col-md-6">
										<div class="input-field">
											Math
											<br>
											<select style="width:100%" name="AcademicSkillLevelMath" id="AcademicSkillLevelMath">
												<option value="">Select...</option>
												<option value="Below" <?php echo ($AcademicSkillLevelMath == "Below" ? "selected" : "") ?>>Below</option>
												<option value="Average" <?php echo ($AcademicSkillLevelMath == "Average" ? "selected" : "") ?>>Average</option>												
												<option value="Advanced" <?php echo ($AcademicSkillLevelMath == "Advanced" ? "selected" : "") ?>>Advanced</option>
											</select>
										</div>
									</div>
								<?php } ?>
								<?php if ($schoolid == 376 || $schoolid == 403) {?>
									<input type="hidden" name="mCurrentSchoolNameMandatory" id="mCurrentSchoolNameMandatory" value="<?php echo $mCurrentSchoolNameMandatory ?>">										
									<?php if ($mCurrentSchoolNameMandatory != 2) {?>
										<div class="col-md-6">
										
											<div class="input-field">
												<?php echo $mCurrentSchoolNamecaption; if($mCurrentSchoolNameMandatory == 1) echo '<span class="required">*</span>';?>
												<input id="current_school_name" type="text" name="current_school_name" value="<?php echo $current_school_name ?>" />
											</div>
										<?php if ($schoolid == 376) {?>											
											
												<div class="input-field">
													ASSIST Student ID number (If applicable)<?php if($mCurrentSchoolNameMandatory == 100) echo '<span class="required">*</span>';?>
													<input id="assist_student_id" type="text" name="assist_student_id" value="<?php echo $assist_student_id ?>" />
												</div>
											
											
										<?php } ?>		
										</div>
									<?php } ?>
								<?php } ?>	
									<div class="col-md-12">
										<!--div class="input-field">
											Name of Partner School Attended (if applicable)
											<input id="partner_school_attended" type="text" name="partner_school_attended" value="<?php echo $partner_school_attended ?>" />
										</div>
										<div class="input-field">
											How did you hear about us<span class="required">*</span>&nbsp;
											<br>
											<div class="row">
												<div class="col-md-4">
													<select style="" id="hear_about_us" name="hear_about_us">
														<option value="">Select...</option>
														<option value="Google" <?php if ($hear_about_us == "Google") echo 'selected'; ?>>Google</option>
														<option value="Facebook" <?php if ($hear_about_us == "Facebook") echo 'selected'; ?>>Facebook</option>
														<option value="Instagram" <?php if ($hear_about_us == "Instagram") echo 'selected'; ?>>Instagram</option>
														<option value="Referral" <?php if ($hear_about_us == "Referral") echo 'selected'; ?>>Referral</option>
														<option value="Other" <?php if ($hear_about_us == "Other") echo 'selected'; ?>>Other</option>
													</select>
												</div>
												<div class="col-md-8"><input type="text" name="hear_about_us_other" id="hear_about_us_other" style="display:none;" placeholder="" value="<?php echo $hear_about_us_other; ?>"></div>
											</div>

										</div>
										<div class="input-field">
											Please select program of interest<span class="required">*</span>&nbsp;
											<br>
											<select style="" id="program_of_interest" name="program_of_interest">
												<option value="">Select...</option>
												<?php if (count($objAcademicTrack)) { ?>
													<?php foreach ($objAcademicTrack as $AcademicTrack) {
														$trackname = $AcademicTrack->trackname;
														$trackid = $AcademicTrack->trackid;
													?>
														<option value="<?php echo $trackname; ?>" <?php if ($program_of_interest == $trackname) echo 'selected'; ?>><?php echo $trackname; ?></option>
													<?php }
												} else { ?>
													<option value="Elementary School Course Work" <?php if ($program_of_interest == "Elementary School Course Work") echo 'selected'; ?>>Elementary School Course Work</option>
													<option value="Middle School Course Work" <?php if ($program_of_interest == "Middle School Course Work") echo 'selected'; ?>>Middle School Course Work</option>
													<option value="General Education High School Diploma" <?php if ($program_of_interest == "General Education High School Diploma") echo 'selected'; ?>>General Education High School Diploma</option>
													<option value="College Preparatory High School Diploma" <?php if ($program_of_interest == "College Preparatory High School Diploma") echo 'selected'; ?>>College Preparatory High School Diploma</option>
													<option value="Supplemental Course Work / Credit Recovery" <?php if ($program_of_interest == "Supplemental Course Work / Credit Recovery") echo 'selected'; ?>>Supplemental Course Work / Credit Recovery</option>
													<option value="ELL" <?php if ($program_of_interest == "ELL") echo 'selected'; ?>>ELL</option>
													<option value="Other" <?php if ($program_of_interest == "Other") echo 'selected'; ?>>Other</option>
												<?php } ?>
											</select>

										</div-->
										
									</div>

									<input type="hidden" name="ESLTestMandatory" id="ESLTestMandatory" value="<?php echo $ESLTestMandatory ?>">	
									<?php if($ESLTestMandatory != "2") {?>
									<div class="col-md-12">
									<hr>
										<div class="input-field">
											<?php if($schoolid == 403) {?>
												<input type="checkbox" id="second_language_student" name="second_language_student" value="1" onclick="javascript:doChange(this);" <?php if($second_language_student) {echo 'checked="checked"';}?>/>&nbsp;<?php if($ESLTestMandatory == 1) echo '<span class="required">*</span>';?> <?php echo $second_language_studentlabel;?>										
											<?php } 
											else {?>
											<?php echo $second_language_studentlabel;?> <?php if($ESLTestMandatory == 1) echo '<span class="required">*</span>';?>
											<br>											
											<select style="width:130px" name="second_language_student" id="second_language_student" onchange="javascript:doChange(this);"> 
												<option value="">Select...</option>
												<option value="1" <?php echo ($second_language_student == "1" ? "selected" : "") ?>>Yes</option>
												<option value="0" <?php echo ($second_language_student == "0" ? "selected" : "") ?>>No</option>	
											</select>
											<?php } ?>
										</div>
									</div>	
										<?php if($ESLTestMandatory != "3" ) {?>
										<div class="col-md-12" id="divsecond_language_student" name="divsecond_language_student" <?php if($second_language_student) {echo 'style="display:inline"';}else{echo 'style="display:none"';}?>>									
											<div class="col-md-12">
											<div class="form-group" style="display:inline;white-space: nowrap;margin-right:20px">
												<span class="advplacecontent">Please upload a pdf file of your English proficiency test score here (test examples: TOEFL, IELTS, DuoLingo, etc)</span>
												<input type="file" name="proficiencyTestResults[]" id="proficiencyTestResults" style="padding: 5px 0px 0px 0px;" multiple>
												<div class="row">
													<div class="col-md-6">
														<div id="resultsproficiencyTestResults">
															<!-- server response here -->
														</div>
													</div>
													<div class="col-md-2">
														<input type="text" name="requiredproficiencyTestResults" id="requiredproficiencyTestResults" style="width:0px;padding: 0px; border: 0px;" value="">
													</div>
												</div>
											</div>
											</div>
											<div class="col-md-12">
												<div class="input-field">
												If you do not have English proficiency test scores now, please select an option below to continue with your application.
												</div>
												<div class="input-field">
													<input type="radio" id="taketestoptions1" name="taketestoptions" value="<?php echo $taketestnow ?>" <?php if($taketestoptions == $taketestnow){ echo 'checked'; } ?> onclick="javascript:doChange(this);" />&nbsp; I would like to take the $<?php echo $ESLTestFee; ?> Advantages eTest now &nbsp;<input type="button" id="taketest" name="taketest" value="Take test" disabled style="display:none; padding: 0px 5px 0px 5px;">
												</div>
												<div class="input-field">
													<input type="radio" id="taketestoptions2" name="taketestoptions" value="<?php echo $taketestlater ?>" <?php if($taketestoptions == $taketestlater){ echo 'checked'; } ?> onclick="javascript:doChange(this);" />&nbsp; I want to take a placement test later, or upload my placement score later. Please email me with instructions.
												</div>
												<div class="input-field" style="display:none;">
													<input type="radio" id="taketestoptions3" name="taketestoptions" value="<?php echo $submitfileslater ?>" <?php if($taketestoptions == $submitfileslater){ echo 'checked'; } ?> onclick="javascript:doChange(this);" />&nbsp; Submit files later. We will send you instructions at the parent's email address.
												</div>
											</div>
											
										</div>
									<?php } }?>

									<input type="hidden" name="LeahTestMandatory" id="LeahTestMandatory" value="<?php echo $LeahTestMandatory ?>">	
									<?php if($LeahTestMandatory != "2") {?>
									<div class="col-md-12">
									<hr>
										<div class="input-field">											
											<?php echo $leah_second_language_studentlabel;?> <?php if($LeahTestMandatory == 1) echo '<span class="required">*</span>';?>
											<br>											
											<select style="width:130px" name="leah_second_language_student" id="leah_second_language_student" onchange="javascript:doChange(this);"> 
												<option value="">Select...</option>
												<option value="1" <?php echo ($leah_second_language_student == "1" ? "selected" : "") ?>>Yes</option>
												<option value="0" <?php echo ($leah_second_language_student == "0" ? "selected" : "") ?>>No</option>	
											</select>											
										</div>
									</div>	
										<?php if($LeahTestMandatory != "3" ) {?>
										<div class="col-md-12" id="leah_divsecond_language_student" name="leah_divsecond_language_student" <?php if($leah_second_language_student) {echo 'style="display:inline"';}else{echo 'style="display:none"';}?>>									
											<div class="col-md-12">
											<div class="form-group" style="display:inline;white-space: nowrap;margin-right:20px">
												<span class="advplacecontent">Please upload a pdf file of your English proficiency test score here (test examples: TOEFL, IELTS, DuoLingo, etc)</span>
												<input type="file" name="leah_TestResults[]" id="leah_TestResults" style="padding: 5px 0px 0px 0px;" multiple>
												<div class="row">
													<div class="col-md-6">
														<div id="resultsleah_TestResults">
															<!-- server response here -->
														</div>
													</div>
													<div class="col-md-2">
														<input type="text" name="requiredleah_TestResults" id="requiredleah_TestResults" style="width:0px;padding: 0px; border: 0px;" value="">
													</div>
												</div>
											</div>
											</div>
											<div class="col-md-12">
												<div class="input-field">
												If you do not have English proficiency test scores now, please select an option below to continue with your application.
												</div>
												<div class="input-field">
													<input type="radio" id="leah_taketestoptions1" name="leah_taketestoptions" value="<?php echo $leah_taketestnow ?>" <?php if($leah_taketestoptions == $leah_taketestnow){ echo 'checked'; } ?> onclick="javascript:doChange(this);" />&nbsp; I would like to take the $<?php echo $LeahTestFee; ?> Advantages eTest now &nbsp;<input type="button" id="leah_taketest" name="leah_taketest" value="Take test" disabled style="display:none; padding: 0px 5px 0px 5px;">
												</div>
												<div class="input-field">
													<input type="radio" id="leah_taketestoptions2" name="leah_taketestoptions" value="<?php echo $leah_taketestlater ?>" <?php if($leah_taketestoptions == $leah_taketestlater){ echo 'checked'; } ?> onclick="javascript:doChange(this);" />&nbsp; I want to take a placement test later, or upload my placement score later. Please email me with instructions.
												</div>												
											</div>
											
										</div>
									<?php } }?>

									<?php 
									//$AcademicAssessmentMandatory=1;
									if($AcademicAssessmentMandatory == "1") {?>
									<div class="col-md-12" style="display:inline;">		
										<hr>								
											<div class="input-field" style="font-size: 18px;font-weight: bold;">
												<input type="checkbox" id="check_additional_fee" name="check_additional_fee" value="1" onclick="javascript:doChange(this);" <?php if($check_additional_fee) {echo 'checked="checked"';}?>/>&nbsp;<?php echo $AcademicAssessmentcaption; ?> 
											</div>
										</div>
										<?php } ?>
										<?php if($SuccessCenterprogramsMandatory == "1") {?>
									<div class="col-md-12" style="display:inline;">		
										<hr>								
											<div class="input-field">
												<input type="checkbox" id="check_successcenterprograms" name="check_successcenterprograms" value="1" onclick="javascript:doChange(this);" <?php if($check_successcenterprograms) {echo 'checked="checked"';}?>/>&nbsp;<?php echo $SuccessCenterprogramscaption; ?> 
											</div>
										</div>
										<?php } ?>
										
									<div class="col-md-12">
									
										<div class="input-field">
										<hr>										
										<h5 style="font-size:16px;text-transform: uppercase;font-weight: normal;">Documents</h5>
										</div>
									</div>
									<div class="col-md-12" style="display:inline;">	
										<?php if ($schoolid == 376) {?>
											<div class="input-field">
												*Click <a href="/GloblCitizenWaiver.docx" style="cursor: pointer;" target="_blank">HERE</a> to download and print the waiver document<br>
											</div>
										<?php } ?>	

										<?php if($TranscriptUploadMandatory != "2") {?>
										<div class="form-group" style="display:inline;">										
										<span class="advplacecontent"><?php echo $TranscriptUploadcaption;?></span> 
										<?php if($TranscriptUploadMandatory) echo '<span class="required">*</span>';?><br>
										<input type="hidden" name="TranscriptUploadMandatory" id="TranscriptUploadMandatory" value="<?php echo $TranscriptUploadMandatory ?>">
										<input type="file" name="academicFileToUpload[]" id="academicFileToUpload" style="padding: 5px 0px 10px 0px;" multiple>
										<div class="row">
											<div class="col-md-6">
												<div id="resultsacademicFileToUpload">
													<!-- server response here -->
												</div>
											</div>
											<div class="col-md-4">
												<input type="text" name="requiredAcademicFileToUpload" id="requiredAcademicFileToUpload" style="width:0px;padding: 0px; border: 0px;" value="">
											</div>
										</div>
										</div>
										<?php } ?>
										<div class="form-group" style="display:inline;">											
											<table id="myTable">												
											</table>											
											<input type="hidden" name="attachment_names" id="attachment_names" value="<?php echo $attachment_names ?>">
											<input type="hidden" name="attachment_links" id="attachment_links" value="<?php echo $attachment_links ?>">
										</div>

										<?php if($TranscriptUploadMandatory2 != "2") {?>
										<div style="display:flex;justify-content: space-between;align-items:center">
										<div class="form-group" style="display:inline;white-space: nowrap;margin-right:20px">
										<span class="advplacecontent"><?php echo $TranscriptUploadcaption2;?></span> 
										<?php if($TranscriptUploadMandatory2 == 1) echo '<span class="required">*</span>';?><br>
											<input type="hidden" name="TranscriptUploadMandatory2" id="TranscriptUploadMandatory2" value="<?php echo $TranscriptUploadMandatory2 ?>">
											<input type="file" name="legalNameFileToUpload[]" id="legalNameFileToUpload" style="padding: 5px 0px 10px 0px;" multiple>
											<div class="row">
												<div class="col-md-6">
													<div id="resultslegalNameFileToUpload">
														<!-- server response here -->
													</div>
												</div>
												<div class="col-md-2">
													<input type="text" name="requiredlegalNameFileToUpload" id="requiredlegalNameFileToUpload" style="width:0px;padding: 0px; border: 0px;" value="">
												</div>
											</div>
										</div>

										<?php if ($schoolid != 169 && $schoolid != 183 && $schoolid != 186) { ?>
											<span style="color:#333;font-size:14px;font-weight:bold"><!--(Examples of acceptable uploads include: Birth Certificate, Passport, Drivers license. If documents are in a language other than English, please upload English translations as well as original documents.)--></span>
										<?php } ?>

										</div>	
										<?php } ?>
									</div>

									<input type="hidden" name="LearningCoachMandatory" id="LearningCoachMandatory" value="<?php echo $LearningCoachMandatory ?>">	
										<?php if ($LearningCoachMandatory != 2) {?>
											<div class="col-md-12">
												<hr>
												<h5 style="font-size:24px;text-transform: uppercase;padding-bottom: 20px;">LEARNING COACH</h5>
											</div>
											<div class="col-md-8">
												<div class="input-field">Name of Designated Learning Coach <?php if($LearningCoachMandatory == 1) echo '<span class="required">*</span>';?>&nbsp;<br>
													<textarea name="NameofDesignatedLearningCoach" cols="50" rows="7" id="NameofDesignatedLearningCoach" style="height: 60px;"><?php echo $NameofDesignatedLearningCoach ?></textarea>
												</div>
											</div>
											<div class="col-md-12">											
												<div class="input-field">
												 <input type="checkbox" id="read_and_understand_learning_coach" name="read_and_understand_learning_coach" value="1" <?php if($read_and_understand_learning_coach) {echo 'checked="checked"';}?>/>&nbsp;<?php if($LearningCoachMandatory == 1) echo '<span class="required">*</span>';?> Please check if the designated learning coach has read and understand the 
												
												<a href="#test-popup" class="open-popup-link" style="cursor: pointer;" target="_blank">Learning Coach Responsibilities</a> 	

													<script src="plugins/zepto.min.js.download"></script>
													<script src="plugins/jquery.magnific-popup.min.js.download"></script>																						
													
													<script type="text/javascript">
													$(document).ready(function() {	
														$('.open-popup-link').magnificPopup({
														type:'inline',
														midClick: true // allow opening popup on middle mouse click. Always set it to true if you don't provide alternative source.
														});
													});
													</script>
													<style>
													.mfp-container {
														background: none;
													}
													.mfp-iframe-holder .mfp-content {
															line-height: 0;
															width: 100%;
															max-width: 100%;
														}
													.white-popup {
														position: relative;
														background: #FFF;
														padding: 60px;
														width:900px;														
														margin: 20px auto;
														}
													</style>
												</div>
											</div>
											
										<?php } ?>
									<?php //if (!empty($applicationfee) && $applicationfee > 0) 
									{
										$amount = $applicationfee;
									?>
									<div class="col-md-12" id="divcheck_additional_fee" name="divcheck_additional_fee" <?php if($isShowPayment && $amount > "0") {echo 'style="display:inline"';}else{echo 'style="display:none"';}?>>	
										<div class="col-md-12">
											<hr>
											<h5 style="font-size:16px;text-transform: uppercase;"> Total Fees </h5>
										</div>
										<div class="col-md-6">

											<div class="input-field">		
												<label name="lblApplicationFeeFee" id="lblApplicationFeeFee" style="margin-bottom:0px;"><?php echo $lblApplicationFeeFee; ?></label>
												<label name="lblESLTestFee" id="lblESLTestFee" style="margin-bottom:0px;"><?php echo $lblESLTestFee; ?></label>												
												<label name="lblLeahTestFee" id="lblLeahTestFee" style="margin-bottom:0px;"><?php echo $lblLeahTestFee; ?></label>
												<label name="lblAcademicAssessmentFee" id="lblAcademicAssessmentFee" style="margin-bottom:0px;"><?php echo $lblAcademicAssessmentFee; ?></label>
												
												<input style="width: 97%;" name="ApplicationFeeFee" type="hidden" id="ApplicationFeeFee" size="20" maxlength="20" value="<?php echo $ApplicationFeeFee; ?>" readonly="true" />
												<input style="width: 97%;" name="ESLTestFee" type="hidden" id="ESLTestFee" size="20" maxlength="20" value="<?php echo $ESLTestFee; ?>" readonly="true" />
												<input style="width: 97%;" name="LeahTestFee" type="hidden" id="LeahTestFee" size="20" maxlength="20" value="<?php echo $LeahTestFee; ?>" readonly="true" />
												<input style="width: 97%;" name="AcademicAssessmentFee" type="hidden" id="AcademicAssessmentFee" size="20" maxlength="20" value="<?php echo $AcademicAssessmentFee; ?>" readonly="true" />
											</div>
											<div class="input-field">

											Total Fee:<span class="required">*</span><br>
											<label name="lblamount" id="lblamount"><strong>$<?php echo $amount; ?></strong></label>
											<input style="width: 97%;" name="amount" type="hidden" id="amount" size="20" maxlength="20" value="<?php echo $amount; ?>" readonly="true" />
											</div>
											<div class="input-field" style="display:none">Description:<br>
												<input name="description" type="hidden" id="description" size="30" maxlength="50" value="<?php echo $description; ?>" />
											</div>
											<div class="input-field">Credit Card Type:<span class="required">*</span><br>
												<select name="ccType" id="ccType">
													<option value="" selected="selected">- Select -</option>
													<option value="visa" <?php if ($ccType == "visa") echo "selected"; ?>>Visa</option>
													<option value="mc" <?php if ($ccType == "mc") echo "selected"; ?>>Master Card</option>
													<option value="amex" <?php if ($ccType == "amex") echo "selected"; ?>>American Express</option>
													<option value="discover" <?php if ($ccType == "discover") echo "selected"; ?>>Discover</option>
												</select>

											</div>
											<div class="input-field">Credit Card Number:<span class="required">*</span><br>
												<input name="ccNo" type="text" id="ccNo" size="30" maxlength="16" value="<?php echo $ccNo; ?>" />

											</div>
											<div class="input-field">Expiration Date (MM/YY):<span class="required">*</span><br>
												<select name="ccExpMonth" id="ccExpMonth" style="width: 40%;padding-left: 10px;">
													<option value="" selected="selected">- Month -</option>
													<option value="01" <?php if ($ccExpMonth == "01") echo "selected"; ?>>January</option>
													<option value="02" <?php if ($ccExpMonth == "02") echo "selected"; ?>>February</option>
													<option value="03" <?php if ($ccExpMonth == "03") echo "selected"; ?>>March</option>
													<option value="04" <?php if ($ccExpMonth == "04") echo "selected"; ?>>April</option>
													<option value="05" <?php if ($ccExpMonth == "05") echo "selected"; ?>>May</option>
													<option value="06" <?php if ($ccExpMonth == "06") echo "selected"; ?>>June</option>
													<option value="07" <?php if ($ccExpMonth == "07") echo "selected"; ?>>July</option>
													<option value="08" <?php if ($ccExpMonth == "08") echo "selected"; ?>>August</option>
													<option value="09" <?php if ($ccExpMonth == "09") echo "selected"; ?>>September</option>
													<option value="10" <?php if ($ccExpMonth == "10") echo "selected"; ?>>October</option>
													<option value="11" <?php if ($ccExpMonth == "11") echo "selected"; ?>>November</option>
													<option value="12" <?php if ($ccExpMonth == "12") echo "selected"; ?>>December</option>
												</select>
												<select name="ccExpYear" id="ccExpYear" style="width: 40%;padding-left: 10px; margin-left: 20px;">
													<option value="">- Year -</option>
													<?php
													for ($startDate = date('Y'), $i = $startDate; $i <= ($startDate + 20); $i++) {
													?>
														<option value="<?php echo $i ?>" <?php if ($_POST['ccExpYear'] == $i) echo "selected"; ?>>
															<?php echo $i ?>
														</option>
													<?php } ?>
												</select>

											</div>
											<div class="input-field">Security Code:<span class="required">*</span><br>
												<input name="ccSecurityCode" type="text" id="ccSecurityCode" size="10" maxlength="10" value="<?php echo $ccSecurityCode; ?>" />
											</div>
											<div class="input-field">Name on Credit Card:<span class="required">*</span><br>
												<input name="ccNameOnCard" type="text" id="ccNameOnCard" size="30" maxlength="50" value="<?php echo $ccNameOnCard; ?>" />
											</div>

										</div>
									</div>
									<?php } ?>
									<div class="col-md-12">
										<hr>

										<div class="input-field">
											<div class="g-recaptcha" data-sitekey="<?php echo $data_sitekey; ?>"></div>
										</div>
									</div>
									<div class="col-md-12">
										<div id="submitting" name="submitting" style="display:none;color:#91C866;">Submitting...</div>
									</div>
									<div class="col-md-12">
										<p class="comment_submit">
											<button type="submit" class="btn btn-default" name="b_apply" id="b_apply">Submit</button>
											<button type="reset" class="btn btn-gray" name="b_reset" id="b_reset">Reset</button>
											<button type="button" class="btn btn-gray" name="b_goback" id="b_goback" onclick="javascript: doclickgoback()">Go back!</button>
										
									</div>
							</div>

							</form>
						</div>
					</div>
					<!-- main end -->
				</div>
			<?php } ?>
	</div>
	</section>
	<!-- main-container end -->

	<div class="clearfix"></div>
	<!-- section end -->

	<?php if ($schoolid == 1) {
		include('inc.footer.php');
	}
	?>
	<?php if ($LearningCoachMandatory != 2) {?>
<div id="test-popup" class="white-popup mfp-hide">

<p><span style="font-size:14.0pt; font-family:&quot;LucidaSans&quot;; color:#232847;">LEARNING
COACH RESPONSIBILITIES </span></p>

<p><span style=";font-family:&quot;LucidaSans&quot;;color:#161616">I
understand that the Learning Coach (LC) is the adult in the home who will
assist the student with completing their daily tasks. The amount of assistance
depends on the student's grade level and the student's ability to complete work
independently. </span></p>

<p><span style="font-family:&quot;LucidaSans&quot;;color:#232847">Elementary School
(K-5) </span></p>

<p><span style=";font-family:&quot;LucidaSans&quot;;color:#161616">A
lot of monitoring is required for students in Grades K-5. The Elementary School
Learning Coach will be actively involved with the student spending an average
of 3-6 hours each day. During a typical week, the Learning Coach will: </span></p>

<p style="margin-left:.5in;text-indent:-.25in;"><span style="font-size:10.0pt;
font-family:Symbol;color:#161616">·<span style="font:7.0pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style=";font-family:&quot;LucidaSans&quot;;
color:#161616">Assist with lessons </span></p>

<p style="margin-left:.5in;text-indent:-.25in"><span style="font-size:10.0pt;
font-family:Symbol;color:#161616;position:relative;top:1.0pt">·<span style="font:7.0pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style=";font-family:&quot;LucidaSans&quot;;
color:#161616;position:relative;top:1.0pt">Monitor comprehension </span></p>

<p style="margin-left:.5in;text-indent:-.25in"><span style="font-size:10.0pt;
font-family:Symbol;color:#161616;position:relative;top:1.0pt">·<span style="font:7.0pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style=";font-family:&quot;LucidaSans&quot;;
color:#161616;position:relative;top:1.0pt">Modify daily schedule </span></p>

<p style="margin-left:.5in;text-indent:-.25in"><span style="font-size:10.0pt;
font-family:Symbol;color:#161616;position:relative;top:1.0pt">·<span style="font:7.0pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style=";font-family:&quot;LucidaSans&quot;;
color:#161616;position:relative;top:1.0pt">Log attendance </span></p>

<p style="margin-left:.5in;text-indent:-.25in"><span style="font-size:10.0pt;
font-family:Symbol;color:#161616;position:relative;top:1.0pt">·<span style="font:7.0pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style=";font-family:&quot;LucidaSans&quot;;
color:#161616;position:relative;top:1.0pt">Communicate with teacher </span></p>

<p><span style="font-family:&quot;LucidaSans&quot;;color:#232847;position:relative;
top:1.0pt">Middle School (6-8) </span></p>

<p><span style=";font-family:&quot;LucidaSans&quot;;color:#161616;
position:relative;top:1.0pt">The type of assistance provided by the Middle
School Learning Coach varies, based on the student's independence. The Learning
Coach will spend an average of 2-4 hours a day. During a typical week, the
Learning Coach will: </span></p>

<p style="margin-left:56.7pt;text-indent:-2.7pt"><span style="font-size:10.0pt;
font-family:Symbol;color:#161616;position:relative;top:1.0pt">·<span style="font:7.0pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style=";font-family:&quot;LucidaSans&quot;;
color:#161616;position:relative;top:1.0pt">Assist with some lessons </span></p>

<p style="margin-left:1.0in;text-indent:-.25in"><span style="font-size:10.0pt;
font-family:Symbol;color:#161616;position:relative;top:1.0pt">·<span style="font:7.0pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style=";font-family:&quot;LucidaSans&quot;;
color:#161616;position:relative;top:1.0pt">Monitor comprehension </span></p>

<p style="margin-left:1.0in;text-indent:-.25in"><span style="font-size:10.0pt;
font-family:Symbol;color:#161616;position:relative;top:1.0pt">·<span style="font:7.0pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style=";font-family:&quot;LucidaSans&quot;;
color:#161616;position:relative;top:1.0pt">Encourage independent learning </span></p>

<p style="margin-left:1.0in;text-indent:-.25in"><span style="font-size:10.0pt;
font-family:Symbol;color:#161616;position:relative;top:1.0pt">·<span style="font:7.0pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style=";font-family:&quot;LucidaSans&quot;;
color:#161616;position:relative;top:1.0pt">Log attendance </span></p>

<p style="margin-left:1.0in;text-indent:-.25in"><span style="font-size:10.0pt;
font-family:Symbol;color:#161616;position:relative;top:1.0pt">·<span style="font:7.0pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style=";font-family:&quot;LucidaSans&quot;;
color:#161616;position:relative;top:1.0pt">Communicate with teachers </span></p>

<p style="margin-left:1.0in;text-indent:-1.0in"><span style="font-family:&quot;LucidaSans&quot;;
color:#232847;position:relative;top:1.0pt">High School (9-12) </span></p>

<p><span style=";font-family:&quot;LucidaSans&quot;;color:#161616;
position:relative;top:1.0pt">The High School Learning Coach may spend less time
assisting their student based on the student's ability to work independently.
The average amount of time spent by the Learning Coach with a High School
student is 1-2 hours a day. During a typical week, the Learning Coach will: </span></p>

<p style="margin-left:1.5in;text-indent:-.25in"><span style="font-size:10.0pt;
font-family:Symbol;color:#161616;position:relative;top:1.0pt">·<span style="font:7.0pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style=";font-family:&quot;LucidaSans&quot;;
color:#161616;position:relative;top:1.0pt">Assist with some lessons, varies
based on student's independence </span></p>

<p style="margin-left:1.5in;text-indent:-.25in;"><span style="font-size:10.0pt;
font-family:Symbol;color:#161616;position:relative;top:1.0pt">·<span style="font:7.0pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style=";font-family:&quot;LucidaSans&quot;;
color:#161616;position:relative;top:1.0pt">Verifies lesson completion to ensure
student is on track </span></p>

<p style="margin-left:1.5in;text-indent:-.25in"><span style="font-size:10.0pt;
font-family:Symbol;color:#161616;position:relative;top:1.0pt">·<span style="font:7.0pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style=";font-family:&quot;LucidaSans&quot;;
color:#161616;position:relative;top:1.0pt">Supports student independence </span></p>

<p style="margin-left:1.5in;text-indent:-.25in"><span style="font-size:10.0pt;
font-family:Symbol;color:#161616;position:relative;top:1.0pt">·<span style="font:7.0pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style=";font-family:&quot;LucidaSans&quot;;
color:#161616;position:relative;top:1.0pt">Attends teacher conferences </span></p>

<p class="MsoNormal">&nbsp;</p>

</div>
<?php }?>
	</div>
	<!-- page-wrapper end -->

	<!-- JavaScript files placed at the end of the document so the pages load faster -->
	<!-- ================================================== -->
	<!-- Jquery and Bootstap core js files -->

	<script type="text/javascript" src="bootstrap/js/bootstrap.min.js"></script>
	<!-- Modernizr javascript -->
	<script type="text/javascript" src="plugins/modernizr.js"></script>
	<!-- jQuery Revolution Slider  -->
	<script type="text/javascript" src="plugins/rs-plugin/js/jquery.themepunch.tools.min.js"></script>
	<script type="text/javascript" src="plugins/rs-plugin/js/jquery.themepunch.revolution.min.js"></script>
	<!-- Isotope javascript -->
	<script type="text/javascript" src="plugins/isotope/isotope.pkgd.min.js"></script>
	<!-- Magnific Popup javascript -->
	<script type="text/javascript" src="plugins/magnific-popup/jquery.magnific-popup.min.js"></script>
	<!-- Appear javascript -->
	<script type="text/javascript" src="plugins/waypoints/jquery.waypoints.min.js"></script>
	<!-- Count To javascript -->
	<script type="text/javascript" src="plugins/jquery.countTo.js"></script>
	<!-- Parallax javascript -->
	<script src="plugins/jquery.parallax-1.1.3.js"></script>
	<!-- Google Maps javascript -->
	<!--script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3.exp&amp;sensor=false&amp;signed_in=true"></script>
	<script type="text/javascript" src="js/google.map.config.js"></script-->
	<!-- Contact form -->
	<script src="plugins/jquery.validate.js"></script>
	<!-- Owl carousel javascript -->
	<script type="text/javascript" src="plugins/owl-carousel/owl.carousel.js"></script>
	<!-- SmoothScroll javascript -->
	<script type="text/javascript" src="plugins/jquery.browser.js"></script>
	<script type="text/javascript" src="plugins/SmoothScroll.js"></script>
	<!-- Initialization of Plugins -->
	<script type="text/javascript" src="js/template.js"></script>
	<!-- Custom Scripts -->
	<script type="text/javascript" src="js/custom.js"></script>

</body>

</html>