<!doctypehtml><html class=html-login><meta content=IE=edge http-equiv=X-UA-Compatible><meta content=width=device-width,initial-scale=1.0 name=viewport><title>
   CustodialDocs - Login
  </title><link href=./images/favicon/apple-touch-icon.png rel=apple-touch-icon sizes=76x76><link href=./images/favicon/favicon-32x32.png rel=icon sizes=32x32 type=image/png><link href=./images/favicon/favicon-16x16.png rel=icon sizes=16x16 type=image/png><link href=./images/favicon/manifest.json rel=manifest><link color=#256eaa href=./images/favicon/safari-pinned-tab.svg rel=mask-icon><link rel="shortcut icon"href=./images/favicon/favicon.ico><meta content=./images/favicon/browserconfig.xml name=msapplication-config><meta content=#256eaa name=theme-color><script src=https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js></script><script src=js/bootstrap.min.js></script><link href=css/bootstrap.min.css rel=stylesheet><link href=css/bootstrap-theme.min.css rel=stylesheet><link href=css/BootstrapXL.css rel=stylesheet><script src=https://use.fontawesome.com/09ee43924c.js></script><script src=https://cdnjs.cloudflare.com/ajax/libs/core-js/2.4.1/core.js></script><script src=https://cdn.jsdelivr.net/sweetalert2/6.6.0/sweetalert2.min.js></script><link href=https://cdn.jsdelivr.net/sweetalert2/6.6.0/sweetalert2.min.css rel=stylesheet><link href=css/main.css?v=1.1 rel=stylesheet><script src=js/functions.js?v=1.2>
  </script><script src=js/modernizr-custom.js></script><script>
   $.ajaxSetup({ cache: false });
  </script><script src=js/jquery.validate.min.js></script><script src=js/jquery.maskedinput.min.js></script><body class=body-login><div class=container><div class=row><div class=container-login><div class="panel panel-transparent panel-login"><div class=panel-body><div class="page-header small-margins low-padding"><h2 class=small-margins id=formTitle>CustodialDocs Login</h2></div><form id=loginform method=POST name=loginform><div class="alert alert-danger"style="display: none;"id=messageBoxLogin><ul></ul></div><div class="alert alert-warning"style="display: none;"id=messageBoxLoginWarning><ul></ul></div><div class="alert alert-success"style="display: none;"id=messageBoxLoginSuccess><a class=close data-dismiss=alert href=#> × </a><ul></ul></div><div class="form-group required"id=groupLogin><span class=help-block id=errortext> </span><label class="control-label register-label"for=loginUsername>Username</label><div class=input-group><span class=input-group-addon> <i class="glyphicon glyphicon-user"> </i> </span><input class=form-control id=loginUsername maxlength=32 name=loginUsername placeholder=Username required></div><br><label class="control-label register-label"for=loginPassword>Password</label><div class=input-group><span class=input-group-addon> <i class="glyphicon glyphicon-lock"> </i> </span><input class=form-control id=loginPassword maxlength=32 name=loginPassword placeholder=Password required type=password></div></div><button class="btn btn-primary btn-login center-block"id=buttonLogin>Login</button><br><p>Forgot your password? <a href=# id=buttonForgotPassword> Click here </a><p>New user? <a href=# id=buttonGotoRegister> Create new account </a><p>Need help? Email us at <a href=mailto:Support@CustodialDocs.com> Support@custodialdocs.com </a></form><form id=registerform1 name=registerform1 style=display:none;><div class="alert alert-danger"style="display: none;"id=messageBoxReg><ul></ul></div><div class="form-group form-spaced required"id=groupRegName><label class="control-label register-label"for=regFirstName style=padding-top:9px;>Your Name</label><div class=input-group><span class=input-group-addon id=nameicon> <i class="glyphicon glyphicon-user"style=font-size:18px;> </i> </span><input placeholder="First Name"style="width:50%;text-transform: capitalize;"class=form-control id=regFirstName maxlength=50 name=regFirstName required><input placeholder="Last Name"style="width:50%;text-transform: capitalize;"class=form-control id=regLastName maxlength=50 name=regLastName required></div></div><div class="form-group form-spaced required"id=groupRegEmail><label class="control-label register-label"for=regEmail>Your Email</label><div class=input-group><span class=input-group-addon> <i class="glyphicon glyphicon-envelope"style=font-size:18px;> </i> </span><input placeholder="Enter your Email"class=form-control id=regEmail maxlength=64 name=regEmail required style=width:90%;></div><span class="help-block help-block-smaller"style="color:#884444;font-weight: 900;"id=groupRegEmailText> Only use custodian emails (e.g. cx123@schools.nyc.gov) </span></div><div class="form-group form-spaced required"><label class="control-label register-label"for=regCell>Cell Phone Number</label><div class=input-group><span class=input-group-addon> <i class="glyphicon glyphicon-phone"style=font-size:18px;> </i> </span><input placeholder="Enter your Phone Number"class=form-control id=regCell name=regCell required style=width:75%;></div></div><div class="form-group form-spaced required"><div class="col-xs-6 col-lg-6"style="padding-left: 0px;white-space: nowrap;"><label class="control-label register-label"for=regSchoolCode>School Code</label></div><div class="col-xs-6 col-lg-6"style="padding-left:1rem;white-space: nowrap;"><label class="control-label register-label"for=regSchoolDistrict>District Code</label></div><div class=input-group><span class=input-group-addon> <i class="glyphicon glyphicon-education"style=font-size:18px;width:18px;> </i> </span><input placeholder="School Code (A123)"style="width:45%;text-transform: capitalize;"class=form-control id=regSchoolCode name=regSchoolCode required><input placeholder="District Code (1 - 32)"style="width:45%;text-transform: capitalize;"class=form-control id=regSchoolDistrict name=regSchoolDistrict required></div></div><div class="form-group form-spaced required"><label class="control-label register-label"for=regSchoolStreet>School Address</label><div class=input-group><span class=input-group-addon> <i class="fa fa-university"style=font-size:17px;width:18px;> </i> </span><input style="width:100%;text-transform: capitalize;"class=form-control id=regSchoolStreet maxlength=255 name=regSchoolStreet placeholder=Street required><input style="width:45%;text-transform: capitalize;"class=form-control id=regSchoolCity maxlength=100 name=regSchoolCity placeholder=City required><select class=form-control id=regSelectSchoolState style=width:22%;><option selected value=NY>NY</select><input class=form-control id=regSchoolZip maxlength=30 name=regSchoolZip placeholder=Zip required style=width:33%;></div></div><div class="form-group form-spaced required"><label class="control-label register-label"for=regSchoolPhone>Office Phone Number</label><div class=input-group><span class=input-group-addon> <i class="fa fa-phone"style=font-size:20px;width:18px;> </i> </span><input placeholder="Enter your Office Phone Number"style="width:75%;text-transform: capitalize;"class=form-control id=regSchoolPhone name=regSchoolPhone required></div></div><label class="control-label register-label">Do you have a merge?</label><div class=form-check><label class=radio-inline><input class=form-check-input id=regMergeYes name=regMerge type=radio value=Yes> Yes</label><label class=radio-inline><input checked class=form-check-input id=regMergeNo name=regMerge type=radio value=No> No</label></div><br><div hidden id=mergeform><div class="form-group form-spaced required"><div class="col-xs-6 col-lg-6"style="padding-left: 0px;white-space: nowrap;"><label class="control-label register-label"for=regMergeSchoolCode>Merge School Code</label></div><div class="col-xs-6 col-lg-6"style="padding-left:1rem;white-space: nowrap;"><label class="control-label register-label"for=regMergeSchoolDistrict>Merge District Code</label></div><div class=input-group><span class=input-group-addon> <i class="glyphicon glyphicon-education"style=font-size:18px;width:18px;> </i> </span><input placeholder="School Code (A123)"style="width:45%;text-transform: capitalize;"class=form-control id=regMergeSchoolCode name=regMergeSchoolCode required><input placeholder="District Code (1 - 32)"style="width:45%;text-transform: capitalize;"class=form-control id=regMergeSchoolDistrict name=regMergeSchoolDistrict required></div></div><div class="form-group form-spaced required"><label class="control-label register-label"for=regMergeSchoolStreet>Merge School Address</label><div class=input-group><span class=input-group-addon> <i class="fa fa-university"style=font-size:17px;width:18px;> </i> </span><input style="width:100%;text-transform: capitalize;"class=form-control id=regMergeSchoolStreet maxlength=255 name=regMergeSchoolStreet placeholder=Street required><input style="width:45%;text-transform: capitalize;"class=form-control id=regMergeSchoolCity maxlength=100 name=regMergeSchoolCity placeholder=City required><select class=form-control id=regSelectMergeSchoolState style=width:22%;><option selected value=NY>NY</select><input class=form-control id=regMergeSchoolZip maxlength=30 name=regMergeSchoolZip placeholder=Zip required style=width:33%;></div></div><div class="form-group form-spaced required"><label class="control-label register-label"for=regMergeSchoolPhone>Merge Office Phone Number</label><div class=input-group><span class=input-group-addon> <i class="fa fa-phone"style=font-size:20px;width:18px;> </i> </span><input placeholder="Enter your Office Phone Number"style="width:75%;text-transform: capitalize;"class=form-control id=regMergeSchoolPhone name=regMergeSchoolPhone required></div></div></div><label class="control-label register-label">Do you have a temporary care?</label><div class=form-check><label class=radio-inline><input class=form-check-input id=regTCYes name=regTC type=radio value=Yes> Yes</label><label class=radio-inline><input checked class=form-check-input id=regTCNo name=regTC type=radio value=No> No</label></div><br><div hidden id=tcform><div class="form-group form-spaced required"><div class="col-xs-6 col-lg-6"style="padding-left: 0px;white-space: nowrap;"><label class="control-label register-label"for=regTCSchoolCode>TC School Code</label></div><div class="col-xs-6 col-lg-6"style="padding-left:1rem;white-space: nowrap;"><label class="control-label register-label"for=regTCSchoolDistrict>TC District Code</label></div><div class=input-group><span class=input-group-addon> <i class="glyphicon glyphicon-education"style=font-size:18px;width:18px;> </i> </span><input placeholder="School Code (A123)"style="width:45%;text-transform: capitalize;"class=form-control id=regTCSchoolCode name=regTCSchoolCode required><input placeholder="District Code (1 - 32)"style="width:45%;text-transform: capitalize;"class=form-control id=regTCSchoolDistrict name=regTCSchoolDistrict required></div></div><div class="form-group form-spaced required"><label class="control-label register-label"for=regSchoolStreet>TC School Address</label><div class=input-group><span class=input-group-addon> <i class="fa fa-university"style=font-size:17px;width:18px;> </i> </span><input style="width:100%;text-transform: capitalize;"class=form-control id=regTCSchoolStreet maxlength=255 name=regTCSchoolStreet placeholder=Street required><input style="width:45%;text-transform: capitalize;"class=form-control id=regTCSchoolCity maxlength=100 name=regTCSchoolCity placeholder=City required><select class=form-control id=regSelectTCSchoolState style=width:22%;><option selected value=NY>NY</select><input class=form-control id=regTCSchoolZip maxlength=30 name=regTCSchoolZip placeholder=Zip required style=width:33%;></div></div><div class="form-group form-spaced required"><label class="control-label register-label"for=regTCSchoolPhone>TC Office Phone Number</label><div class=input-group><span class=input-group-addon> <i class="fa fa-phone"style=font-size:20px;width:18px;> </i> </span><input placeholder="Enter your Office Phone Number"style="width:75%;text-transform: capitalize;"class=form-control id=regTCSchoolPhone name=regTCSchoolPhone required></div></div></div><button class="btn btn-primary btn-login center-block"id=buttonContinue>Continue</button><br><p>Already have an account? <a href=# id=buttonGotoLogin> Login </a></form><form id=registerform2 name=registerform2 style=display:none;><div class="alert alert-danger"style="display: none;"id=messageBoxReg2><ul></ul></div><div class="form-group form-spaced"><label class="control-label register-label"for=regUsername style=padding-top:9px;>Username</label><div class=input-group><span class=input-group-addon> <i class="fa fa-users"> </i> </span><input placeholder="Username will be generated from your name."class=form-control disabled id=regUsername maxlength=32 name=regUsername required style=width:75%;></div><span class="help-block help-block-smaller"> Your username was generated based on your first and last name. </span></div><div class="form-group form-spaced"id=groupRegPassword><label class="control-label register-label"for=regPassword>Password</label><div class=input-group><span class=input-group-addon> <i class="glyphicon glyphicon-lock"> </i> </span><input placeholder="Enter your Password"class=form-control id=regPassword maxlength=32 name=regPassword required style=width:75%; type=password></div><br><label class="control-label register-label"for=regPasswordConfirm>Confirm Password</label><div class=input-group><span class=input-group-addon> <i class="glyphicon glyphicon-lock"> </i> </span><input placeholder="Confirm your Password"class=form-control id=regPasswordConfirm maxlength=32 name=regPasswordConfirm required style=width:75%; type=password></div><span class="help-block help-block-smaller"style="position: absolute;"id=groupRegPasswordText> </span></div><div style="padding-top: 5px;"class=center-block><button class="btn btn-default"id=buttonGoBack type=button>Back</button><button class="btn btn-primary"id=buttonRegister style=width:65%>Register</button></div><br><p>Already have an account? <a href=# id=buttonGotoLogin2> Login </a></form></div></div></div></div></div><br><br><script>var submitting = false;
			var inputFirstName = $('#regFirstName');
			var inputLastName = $('#regLastName');
			var validFirstName = false;
			var validLastName = false;
			// $('#regCell').formatter({
			//  'persistent': true,
			//  'patterns':[
			//      { '^\\d{11,15}$': '({{999}}) {{999}}-{{9999}} x{{9999}}' },
			//      { '*': '({{999}}) {{999}}-{{9999}} {{9999}}' },
			//      ]
			// });
			// $('#regSchoolCode').formatter({
			//  'persistent': false,
			//  'pattern': '{{a999}}'
			// });

			//$('#regCell').mask("(999) 999-999? x9999");
			jQuery.validator.prototype.hideErrors = function() {
				this.addWrapper( this.toHide ).fadeOut(300);
			};

			$.validator.addMethod(
				"regex",
				function(value, element, regexp) {
					var check = false;
					return this.optional(element) || regexp.test(value);
				},
				"Please check your input."
			);


			$('#loginform').validate({
				errorclass: "has-error",
				onkeyup: false,
				onfocusout: false,
				rules:{
					loginUsername:{
						required: true
					},
					loginPassword:{
						required: true
					}
				},
				messages:{
					loginUsername: "Please enter your username.",
					loginPassword: "Please enter your password.",

				},
				highlight: function(element, errorClass, validClass) {

					$("#messageBoxLoginWarning").fadeOut(300);
					$("#loginUsername").parent().removeClass("has-warning");
					$("#loginPassword").parent().removeClass("has-warning");
					$(element).parent().addClass(errorClass).removeClass(validClass);
					$("#messageBoxLogin").fadeIn(500);
				},
				unhighlight: function(element, errorClass, validClass) {

					$("#messageBoxLoginWarning").fadeOut(300);
					$("#loginUsername").parent().removeClass("has-warning");
					$("#loginPassword").parent().removeClass("has-warning");
					$(element).parent().removeClass(errorClass).addClass(validClass);
				},
				errorContainer: "#messageBoxLogin",
				errorLabelContainer: "#messageBoxLogin ul",
				wrapper: "li",
				submitHandler: function(){
					if(submitting) return;
					submitting = true;
					//$("#errordiv").removeClass('form-group has-error');
					//$("#errortext").text("");
					$("#buttonLogin").addClass('disabled');
					$.ajax({
						url: 'includes/process_login.php',
						type:'POST',
						data:
						{
							loginUsername: $("#loginUsername").val(),
							loginPassword: $("#loginPassword").val()
						},
						success: function(msg)
						{
							window.location.href = "home.php";
						},
						error: function(msg){
							if(msg.statusText=="badinfo"){
								$("#messageBoxLoginWarning").fadeIn(500).html('<ul><li><label id="loginUsername-error" class="error" for="loginUsername" style="">Incorrect username or password.</label></li>');
								$("#loginUsername").parent().addClass("has-warning");
								$("#loginPassword").parent().addClass("has-warning");
								submitting = false;
								$("#buttonLogin").removeClass('disabled');
							}
							if(msg.statusText=="notenabled"){
								$("#messageBoxLoginWarning").fadeIn(500).html('<ul><li><label id="loginUsername-error" class="error" for="loginUsername" style="">Account is not enabled.</label></li>');
								submitting = false;
								$("#buttonLogin").removeClass('disabled');
							}
						}
					});
				}
			});


			$('#registerform1').validate({
				errorClass: "has-error",
				onkeyup: false,
				onfocusout: false,
				submitHandler: function(event) {
					if(submitting) return;
					submitting = true;
					$("#buttonContinue").addClass('disabled');
					inputFirstName.val((inputFirstName.val().charAt(0).toUpperCase() + inputFirstName.val().slice(1)).trim())
					inputLastName.val((inputLastName.val().charAt(0).toUpperCase() + inputLastName.val().slice(1)).trim())
					$('#regUsername').val(inputFirstName.val().replace(/\W/g, '').charAt(0) + inputLastName.val().replace(/\W/g, ''));
					$('#registerform2').show(300);
					$('#registerform1').hide(300);

					var ajaxfunc = function(callback){
						$.ajax({
							url: 'includes/check_username.php',
							type:'POST',
							data:
							{
								firstname: $("#regFirstName").val(),
								lastname: $("#regLastName").val()
							},
							success: function(msg)
							{
								callback(msg);
							},
							error: function(msg){
								submitting = false;
								$("#buttonRegister").removeClass('disabled');
							}
						});
					}
					ajaxfunc(function(msg){
						var rows = parseInt(msg);
						if(rows >= 1){
							$('#regUsername').val(function(){ return this.value+rows});
						}
						$('#registerform2').show(300);
						$('#registerform1').hide(300);
						submitting = false;
						$("#buttonContinue").removeClass('disabled');
					});
				},
				// onfocusout: function(element) {
				// 	if(element.name=="regCell"){
				// 		element.value = element.value.replace(/\(|_|\)|-|x| /g,'');
				// 	}
			 //        this.element(element);
			 //    },
				rules:{
					regFirstName:{
						required: true
					},
					regLastName:{
						required: true
					},
					regEmail:{
						required: true,
						email: true,
						regex: /^c[a-z]{1}\d{3}@schools\.nyc\.gov$/,
						remote: {
							url: "includes/check_email.php",
							type: "POST",
							data: {
								email: function(){
									return $('#regEmail').val();
								}
							}
						}
					},
					regSchoolCode:{
						required: true
					},
					regSchoolDistrict:{
						required: true,
						min: 1,
						max: 32,
					},
					regSchoolStreet:{
						required: true
					},
					regSchoolCity:{
						required: true
					},
					regSelectSchoolState:{
						required: true
					},
					regSchoolZip:{
						required: true
					},
					regSchoolPhone:{
						required: true
					},
					regCell: {
						required: true
					}
				},
				messages:{
					regFirstName: "Please enter your first name.",
					regLastName: "Please enter your last name.",
					regEmail: {
						required: "Please enter your email address.",
						email: "Please enter a correct email address.",
						remote: "Email is already in use.",
						regex: "You must use your custodian email<br>(e.g. cx123@schools.nyc.gov)"
					},
					regSchoolStreet: "Please enter your school's street.",
					regSchoolCity: "Please enter your school's city.",
					regSchoolState: "Please enter your school's state.",
					regSchoolZip: "Please enter your school's zip.",
					regSchoolPhone: "Please enter your office phone number.",
					regSchoolCode: "Please enter your school code.",
					regSchoolDistrict: {
						required: "Please enter your school district.",
						min: "School district must be between 1 and 32.",
						max: "School district must be between 1 and 32.",
					},
					regCell: "Please enter your cell phone number."

				},

				highlight: function(element, errorClass, validClass) {
					$("#messageBoxReg").fadeIn(500);
					if(element.name=="regFirstName" || element.name=="regLastName"){
						if(element.name=="regFirstName") validFirstName = false;
						if(element.name=="regLastName") validLastName = false;

						$(element).addClass("input-error");
						$("#nameicon").addClass("glyphicon-error");
					}
					else{
						$(element).parent().addClass(errorClass).removeClass(validClass);
					}
				},
				unhighlight: function(element, errorClass, validClass) {
					if(element.name=="regFirstName" || element.name=="regLastName"){
						if(element.name=="regFirstName") validFirstName = true;
						if(element.name=="regLastName") validLastName = true;

						$(element).removeClass("input-error");
						if(validFirstName && validLastName) {
							$("#nameicon").removeClass("glyphicon-error");
						}
					}
					else{
						$(element).parent().removeClass(errorClass).addClass(validClass);
					}
				},
				errorContainer: "#messageBoxReg",
				errorLabelContainer: "#messageBoxReg ul",
				wrapper: "li"
			});

			$('#registerform2').validate({
				errorClass: "has-error",
				onkeyup: false,
				onfocusout: false,
				rules:{
					regPassword:{
						minlength: 5
					},
					regPasswordConfirm:{
						minlength: 5,
						equalTo: "#regPassword"
					}
				},
				messages:{
					regPassword: {
						required: "Please enter your password.",
						minlength: "Password must be at least {0} characters."
					},
					regPasswordConfirm: {
						required: "Please confirm your password.",
						equalTo: "Passwords do not match."
					}
				},
				errorContainer: "#messageBoxReg2",
				errorLabelContainer: "#messageBoxReg2 ul",
				wrapper: "li",
				highlight: function(element, errorClass, validClass) {
					$("#messageBoxReg2").fadeIn(500);
					$(element).parent().addClass(errorClass).removeClass(validClass);
				},

				unhighlight: function(element, errorClass, validClass) {
					$(element).parent().removeClass(errorClass).addClass(validClass);
				},
				submitHandler: function(){
					if(submitting) return;
					submitting = true;
					//$("#errordiv").removeClass('form-group has-error');
					//$("#errortext").text("");
					$("#buttonRegister").addClass('disabled');
					$.ajax({
						url: 'includes/register.php',
						type:'POST',
						data:
						{
							username: $("#regUsername").val(),
							email: $("#regEmail").val(),
							password: $("#regPasswordConfirm").val(),
							firstname: $("#regFirstName").val(),
							lastname: $("#regLastName").val(),
							school: $("#regSchoolCode").val(),
							cellphone: $("#regCell").val(),
							district: $("#regSchoolDistrict").val(),
							regSchoolStreet: $('#regSchoolStreet').val(),
							regSchoolCity: $('#regSchoolCity').val(),
							regSchoolState: $('#regSelectSchoolState :selected').val(),
							regSchoolZip: $('#regSchoolZip').val(),
							regSchoolPhone: $('#regSchoolPhone').val(),
							regMergeYes: $('#regMergeYes').is(':checked'),
							regMergeSchoolCode: $('#regMergeSchoolCode').val(),
							regMergeSchoolDistrict: $('#regMergeSchoolDistrict').val(),
							regMergeSchoolStreet: $('#regMergeSchoolStreet').val(),
							regMergeSchoolCity: $('#regMergeSchoolCity').val(),
							regMergeSchoolState: $('#regSelectMergeSchoolState :selected').val(),
							regMergeSchoolZip: $('#regMergeSchoolZip').val(),
							regMergeSchoolPhone: $('#regMergeSchoolPhone').val(),
							regTCYes: $('#regTCYes').is(':checked'),
							regTCSchoolCode: $('#regTCSchoolCode').val(),
							regTCSchoolDistrict: $('#regTCSchoolDistrict').val(),
							regTCSchoolStreet: $('#regTCSchoolStreet').val(),
							regTCSchoolCity: $('#regTCSchoolCity').val(),
							regTCSchoolState: $('#regSelectTCSchoolState :selected').val(),
							regTCSchoolZip: $('#regTCSchoolZip').val(),
							regTCSchoolPhone: $('#regTCSchoolPhone').val(),
						},
						success: function(msg)
						{
							// $('#registerform1')[0].reset();
							// $('#registerform2')[0].reset();
							// $('#loginform')[0].reset();
							// GoToLoginForm();
							alert(msg+"\n"+JSON.stringify(msg));
							swal('Success',"Account was successfully created!<br><br>You will receive an email within a few minutes with instructions detailing how to activate your account.",'success').catch(swal.noop);

							submitting = false;
							$("#buttonRegister").removeClass('disabled');

							// window.location.href = "main.php";
						},
						error: function(msg){
							//swal('Error',msg.responseText,'error').catch(swal.noop);//alert(msg.responseText);
							swal('Error',"Could not create account. Please contact Support@custodialdocs.com",'error').catch(swal.noop);
							submitting = false;
							$("#buttonRegister").removeClass('disabled');
						}
					});
				}
			});

			var getschoolinfo = function(callback,code){
				$.ajax({
					url: 'includes/get_schoolinfo.php',
					type:'GET',
					dataType: 'JSON',
					data:
					{
						schoolcode: code
					},
					success: function(msg)
					{
						callback(msg);
					},
					error: function(msg){
						callback(msg);
						submitting = false;
						$("#buttonRegister").removeClass('disabled');
					}
				});
			};

			function mergeschoolinfo(disableinput, clearinput){
					getschoolinfo(function(msg){
						if(msg.responseText=="Cannot find school in database.<br>Please refresh the page and try again."){
							if(clearinput == true){
								$("#regMergeSchoolCode").val("");
								$("#regMergeSchoolDistrict").val("");
								$("#regMergeSchoolStreet").val("");
								$("#regMergeSchoolCity").val("");
								$("#regSelectMergeSchoolState").val("NY");
								$("#regMergeSchoolZip").val("");
								$("#regMergeSchoolPhone").val("");
							}
							$("#regMergeSchoolCode").prop("disabled", false);
							$("#regMergeSchoolDistrict").prop("disabled", false);
							$("#regMergeSchoolStreet").prop("disabled", false);
							$("#regMergeSchoolCity").prop("disabled", false);
							$("#regSelectMergeSchoolState").prop("disabled", false);
							$("#regMergeSchoolZip").prop("disabled", false);
							$("#regMergeSchoolPhone").prop("disabled", false);
							$("#regMergeYes").prop("disabled", false);
							$("#regMergeNo").prop("disabled", false);
						}
						else{
							// msg = JSON.parse(msg);
							if(disableinput == true){
								$("#regMergeSchoolCode").prop("disabled", true);
								$("#regMergeYes").prop("disabled", true);
								$("#regMergeNo").prop("disabled", true);
							}
							$("#regMergeSchoolDistrict").val(msg.district).prop("disabled", true);
							$("#regMergeSchoolStreet").val(msg.street).prop("disabled", true);
							$("#regMergeSchoolCity").val(msg.city).prop("disabled", true);
							$("#regSelectMergeSchoolState").val(msg.state).prop("disabled", true);
							$("#regMergeSchoolZip").val(msg.zip).prop("disabled", true);
							$("#regMergeSchoolPhone").val(msg.phone).prop("disabled", true);
						}
						submitting = false;
						$("#buttonContinue").removeClass('disabled');
					},$("#regMergeSchoolCode").val());
			};


			function tcschoolinfo(disableinput, clearinput){
					getschoolinfo(function(msg){
						if(msg.responseText=="Cannot find school in database.<br>Please refresh the page and try again."){
							if(clearinput == true){
								$("#regTCSchoolCode").val("");
								$("#regTCSchoolDistrict").val("");
								$("#regTCSchoolStreet").val("");
								$("#regTCSchoolCity").val("");
								$("#regSelectTCSchoolState").val("NY");
								$("#regTCSchoolZip").val("");
								$("#regTCSchoolPhone").val("");
							}
							$("#regTCSchoolCode").prop("disabled", false);
							$("#regTCSchoolDistrict").prop("disabled", false);
							$("#regTCSchoolStreet").prop("disabled", false);
							$("#regTCSchoolCity").prop("disabled", false);
							$("#regSelectTCSchoolState").prop("disabled", false);
							$("#regTCSchoolZip").prop("disabled", false);
							$("#regTCSchoolPhone").prop("disabled", false);
							$("#regTCYes").prop("disabled", false);
							$("#regTCNo").prop("disabled", false);
						}
						else{
							// msg = JSON.parse(msg);
							if(disableinput == true){
								$("#regTCSchoolCode").prop("disabled", true);
								$("#regTCYes").prop("disabled", true);
								$("#regTCNo").prop("disabled", true);
							}
							$("#regTCSchoolDistrict").val(msg.district).prop("disabled", true);
							$("#regTCSchoolStreet").val(msg.street).prop("disabled", true);
							$("#regTCSchoolCity").val(msg.city).prop("disabled", true);
							$("#regSelectTCSchoolState").val(msg.state).prop("disabled", true);
							$("#regTCSchoolZip").val(msg.zip).prop("disabled", true);
							$("#regTCSchoolPhone").val(msg.phone).prop("disabled", true);
						}
						submitting = false;
						$("#buttonContinue").removeClass('disabled');
					},$("#regTCSchoolCode").val());
			};

			$('#regSchoolCode').mask("a999",{placeholder:"",completed:function(){
				getschoolinfo(function(msg){
					if(msg.responseText=="Cannot find school in database.<br>Please refresh the page and try again."){
						$("#regSchoolDistrict").val("").prop("disabled", false);
						$("#regSchoolStreet").val("").prop("disabled", false);
						$("#regSchoolCity").val("").prop("disabled", false);
						$("#regSelectSchoolState").val("NY").prop("disabled", false);
						$("#regSchoolZip").val("").prop("disabled", false);
						$("#regSchoolPhone").val("").prop("disabled", false);
						$("#regMergeNo").prop("checked",true);
						$("#regMergeSchoolCode").val("").prop("disabled", false);
						$("#regMergeSchoolDistrict").val("").prop("disabled", false);
						$("#regMergeSchoolStreet").val("").prop("disabled", false);
						$("#regMergeSchoolCity").val("").prop("disabled", false);
						$("#regSelectMergeSchoolState").val("NY").prop("disabled", false);
						$("#regMergeSchoolZip").val("").prop("disabled", false);
						$("#regMergeSchoolPhone").val("").prop("disabled", false);
						$("#regMergeYes").prop("disabled", false);
						$("#regMergeNo").prop("disabled", false);
						$("#mergeform").hide(300);
					}
					else{
						//msg = JSON.parse(msg);
						$("#regSchoolDistrict").val(msg.district).prop("disabled", true);
						$("#regSchoolStreet").val(msg.street).prop("disabled", true);
						$("#regSchoolCity").val(msg.city).prop("disabled", true);
						$("#regSelectSchoolState").val(msg.state).prop("disabled", true);
						$("#regSchoolZip").val(msg.zip).prop("disabled", true);
						$("#regSchoolPhone").val(msg.phone).prop("disabled", true);
						if(msg.merge){
							$("#regMergeYes").prop("checked",true);
							$("#regMergeSchoolCode").val(msg.merge);
							mergeschoolinfo(true,false);
							$("#mergeform").show(300);
						}
						else{
							$("#regMergeNo").prop("checked",true);
							$("#regMergeSchoolCode").val("").prop("disabled", false);
							$("#regMergeSchoolDistrict").val("").prop("disabled", false);
							$("#regMergeSchoolStreet").val("").prop("disabled", false);
							$("#regMergeSchoolCity").val("").prop("disabled", false);
							$("#regSelectMergeSchoolState").val("NY").prop("disabled", false);
							$("#regMergeSchoolZip").val("").prop("disabled", false);
							$("#regMergeSchoolPhone").val("").prop("disabled", false);
							$("#regMergeYes").prop("disabled", false);
							$("#regMergeNo").prop("disabled", false);
							$("#mergeform").hide(300);
						}
					}
					submitting = false;
					$("#buttonContinue").removeClass('disabled');
				},$("#regSchoolCode").val());
			}});

			jQuery.validator.addMethod("usPhoneFormat", function (value, element) {
				return this.optional(element) || /^\(\d{3}\) \d{3}\-\d{4}( x\d{1,4})?$/.test(value);
			}, "Enter a valid phone number.");

			$('#regSchoolDistrict').mask("9?9",{placeholder:""});
			$('#regCell').mask("(999) 999-9999? x9999");
			$('#regSchoolPhone').mask("(999) 999-9999? x9999");

			$('#regMergeSchoolCode').mask("a999",{placeholder:"",completed:function(){
				mergeschoolinfo(false,false);
				}
			});
			$('#regMergeSchoolDistrict').mask("9?9",{placeholder:""});

			$('#regMergeSchoolPhone').mask("(999) 999-9999? x9999");

			$("#regMergeYes").change(function(){
				if($(this).is(':checked')){
					$("#mergeform").show(300);
				}
			});

			$("#regMergeNo").change(function(){
				if($(this).is(':checked')){
					$("#mergeform").hide(300);
				}
			});

			$('#regTCSchoolCode').mask("a999",{placeholder:"",completed:function(){
				tcschoolinfo(false,false);
				}
			});
			$('#regTCSchoolDistrict').mask("9?9",{placeholder:""});

			$('#regTCSchoolPhone').mask("(999) 999-9999? x9999");

			$("#regTCYes").change(function(){
				if($(this).is(':checked')){
					$("#tcform").show(300);
				}
			});

			$("#regTCNo").change(function(){
				if($(this).is(':checked')){
					$("#tcform").hide(300);
				}
			});

			function GoToRegisterForm(){
				$('#loginform').hide(300);
				$('#registerform2').hide(300);
				$('#registerform1').show(300);
				$('#formTitle').text("Registration");
			};

			function GoToLoginForm(){
				$('#loginform').show(300);
				$('#registerform1').hide(300);
				$('#registerform2').hide(300);
				$('#formTitle').text("CustodialDocs Login");
			};

			$('#buttonGotoRegister').on('click', GoToRegisterForm);
			$('#buttonGoBack').on('click', GoToRegisterForm);
			$('#buttonGotoLogin').on('click', GoToLoginForm);
			$('#buttonGotoLogin2').on('click', GoToLoginForm);

			$('#buttonForgotPassword').on('click',function(){
				swal({
					title: 'Forgot Password',
					text: 'Enter the email address associated with your account to reset your password.',
					input: 'email',
					showCancelButton: 'true',
					buttonsStyling: false,
					confirmButtonClass: 'pull-right btn btn-primary buttonspacing-left buttonspacing-right',
					cancelButtonClass: 'pull-right btn btn-default buttonspacing-left buttonspacing-right',
					confirmButtonText: 'Submit',

				}).then(function (inputemail) {
					$.ajax({
						url: 'includes/send_forgotpassword.php',
						type:'POST',
						data:
						{
							email: inputemail
						},
						success: function(msg)
						{
							//alert(window.location.origin+window.location.pathname+"reset.php?s="+msg);
						},
					});
					swal({
					type: 'success',
					title: "Email has been sent",
					html: "An email has been sent to "+inputemail+" with instructions detailing how to reset your password.<br><br>You should receive it within the next few minutes.",
					}).catch(swal.noop)
				}).catch(swal.noop)
			});


			var getUrlParameter = function getUrlParameter(sParam) {
				var sPageURL = decodeURIComponent(window.location.search.substring(1)),
					sURLVariables = sPageURL.split('&'),
					sParameterName,
					i;

				for (i = 0; i < sURLVariables.length; i++) {
					sParameterName = sURLVariables[i].split('=');

					if (sParameterName[0] === sParam) {
						return sParameterName[1] === undefined ? true : sParameterName[1];
					}
				}
			};

			$(document).ready(function(){
				if(getUrlParameter('error')=="linkexpired"){
					swal("Error","That link has expired.<br><br>Please try requesting a new one.","error").catch(swal.noop);
				}
				else if(getUrlParameter('error')=="invalid"){
					swal("Error","That link is invalid. Please try again.<br><br>If the issue persists, please contact Support@custodialdocs.com","error").catch(swal.noop);
				}
			});</script>