$j(function()
{
	$j("#parentsLoginSubmit").live("click", function()	
	{
		$j("#validatingDiv").html("<span class='whiteText'>Authorizing Login...please wait...</span>");

		$j.post('com/parentforms.cfc?method=fnAuthorizeParentLogin&returnFormat=plain',$j("#parentLoginForm").serialize(), function(data,status) 
		{
			data = $j.trim(data);
			var loginStatus=data.indexOf("Login Successful");

			if (loginStatus >=0)
			{
				location.href="online-forms/parent-forms.cfm";
			}
			else
			{
				$j("#validatingDiv").html(data).show();			
			}
		});
				
	});

	$j("#buttonLogout").live("click", function()	
	{
		$j.post('../com/parentforms.cfc?method=fnLogout&returnFormat=plain', function(data,status) 
		{
			location.href="../index.cfm";
		});
				
	});

	$j("#homepageButtonLogout").live("click", function()	
	{
		$j.post('com/parentforms.cfc?method=fnLogout&returnFormat=plain', function(data,status) 
		{
			location.href="index.cfm";
		});
				
	});

	$j('#traForms').change(function()
	{
		$j.post('../com/parentforms.cfc?method=fnFormControl&returnFormat=plain',$j("#formSelection").serialize(), function(data,status) 
		{
			data = $j.trim(data);
		
			$j("#formContainerLeft").html(data).show();			
		});

	});		

	//  On initial load, load the first form
	if ($j('#formContainerLeft').length)
	{
		$j('#traForms').val('HonorCode1_5');
		$j.post('../com/parentforms.cfc?method=fnFormControl&returnFormat=plain',$j("#formSelection").serialize(), function(data,status) 
		{
			data = $j.trim(data);
		
			$j("#formContainerLeft").html(data).show();			
		});
	}
	
	/*
	if ($j("#disclaimerCheckbox").change(function()
	{
		//$j("#honorCode_1_5_submit_button").removeClass("formButton");
		$j("#honorCode_1_5_submit_button").addClass("formButton");
		//$j("#honorCode_1_5_submit_button").attr("disabled", "disabled");
	});
	*/
		
	
	$j('#disclaimerCheckbox').live('change', function() 
	{
		if ($j('#disclaimerCheckbox').attr('checked'))
		{		
			$j("input:button[id*=button]").removeClass("formButtonDisabled");
			$j("input:button[id*=button]").addClass("formButton");
			$j("input:button[id*=button]").removeAttr('disabled');
		}
		else
		{
			$j("input:button[id*=button]").removeClass("formButton");
			$j("input:button[id*=button]").addClass("formButtonDisabled");
			$j("input:button[id*=button]").attr('disabled', 'disabled');
		}
	});	
	
	$j("#honorCode_6_12_submit_button").live("click", function()	
	{
		/*******   STEP 2 FORM VALIDATION *****/
		//  be sure all required fields are filled.
		var _error_message = "";
		var _error_start = "<h5 class='h5Thin' style='border-bottom:1px solid #CCCCCC;'>Validation Errors</h5><br /><ul>";
		var _error_end = "</ul>";
	
		if ( !($j('#student_signature').val()) )
		{
			_error_message += "<li>The student signature field should contain the student's name.</li>";
		}
		if ( !($j('#student_signaturedate').val()) )
		{
			_error_message += "<li>The student signature date field should contain a valid date.</li>";
		}
		if ( !($j('#parent_signature').val()) )
		{
			_error_message += "<li>The parent/guardian signature field should contain the parent or guardian's name.</li>";
		}
		if ( !($j('#parent_signaturedate').val()) )
		{
			_error_message += "<li>The student signature date field should contain a valid date.</li>";
		}

		if (_error_message != '')
		{
			jAlert(_error_start+_error_message+_error_end, 'Tipton Rosemark Academy:  Online Forms');
		}
		else
		{
			$j.post('../com/formHonorCodeUpper.cfc?method=fnProcessForm&returnFormat=plain',$j("#onlineParentForm").serialize(), function(data,status) 
			{
				data = $j.trim(data);
			
				$j("#formContainerLeft").html(data).show();			
			});
			
			$j('#headerContainer').scrollTop()
		}
	});
	
	$j("#honorCode_1_5_submit_button").live("click", function()	
	{
		/*******   STEP 2 FORM VALIDATION *****/
		//  be sure all required fields are filled.
		var _error_message = "";
		var _error_start = "<h5 class='h5Thin' style='border-bottom:1px solid #CCCCCC;'>Validation Errors</h5><br /><ul>";
		var _error_end = "</ul>";
	
		if ( !($j('#student_signature').val()) )
		{
			_error_message += "<li>The student signature field should contain the student's name.</li>";
		}
		if ( !($j('#student_signaturedate').val()) )
		{
			_error_message += "<li>The student signature date field should contain a valid date.</li>";
		}
		if ( !($j('#parent_signature').val()) )
		{
			_error_message += "<li>The parent/guardian signature field should contain the parent or guardian's name.</li>";
		}
		if ( !($j('#parent_signaturedate').val()) )
		{
			_error_message += "<li>The student signature date field should contain a valid date.</li>";
		}

		if (_error_message != '')
		{
			jAlert(_error_start+_error_message+_error_end, 'Tipton Rosemark Academy:  Online Forms');
		}
		else
		{
			$j.post('../com/formHonorCodeLower.cfc?method=fnProcessForm&returnFormat=plain',$j("#onlineParentForm").serialize(), function(data,status) 
			{
				data = $j.trim(data);
			
				$j("#formContainerLeft").html(data).show();			
			});
			
			$j('#headerContainer').scrollTop()
		}
	});	

	$j("#student_transportation_data_submit_button").live("click", function()	
	{
		//  be sure all required fields are filled.
		var _error_message = "";
		var _error_start = "<h5 class='h5Thin' style='border-bottom:1px solid #CCCCCC;'>Validation Errors</h5><br /><ul>";
		var _error_end = "</ul>";
	
		if ( !($j('#student_name').val()) )
		{
			_error_message += "<li>The student name field should contain the student's name.</li>";
		}
		if ( !($j('#teacher').val()) )
		{
			_error_message += "<li>The teacher field should contain a valid date.</li>";
		}
		if ( !($j('#parent_or_guardian').val()) )
		{
			_error_message += "<li>The parent/guardian field should contain the parent or guardian's name.</li>";
		}
		if ( !($j('#signature').val()) )
		{
			_error_message += "<li>The parent signature field should contain a valid date.</li>";
		}
		if ( !($j('#signaturedate').val()) )
		{
			_error_message += "<li>The parent signature date field should contain a valid date.</li>";
		}

		if (_error_message != '')
		{
			jAlert(_error_start+_error_message+_error_end, 'Tipton Rosemark Academy:  Online Forms');
		}
		else
		{
			$j.post('../com/formStudentTransportationData.cfc?method=fnProcessForm&returnFormat=plain',$j("#onlineParentForm").serialize(), function(data,status) 
			{
				data = $j.trim(data);
			
				$j("#formContainerLeft").html(data).show();			
			});
			
			$j('#headerContainer').scrollTop()
		}
	});	


	$j("#athletic_booster_club_submit_button").live("click", function()	
	{
		//  be sure all required fields are filled.
		var _error_message = "";
		var _error_start = "<h5 class='h5Thin' style='border-bottom:1px solid #CCCCCC;'>Validation Errors</h5><br /><ul>";
		var _error_end = "</ul>";
	
		if ( !($j('#name').val()) )
		{
			_error_message += "<li>The name field should contain the student's name.</li>";
		}
		if ( !($j('#address').val()) )
		{
			_error_message += "<li>The address field should contain your address.</li>";
		}
		if ( !($j('#email_addr').val()) )
		{
			_error_message += "<li>The email field should contain your email address.</li>";
		}
		if ( !($j('#home_number').val()) )
		{
			_error_message += "<li>The home number field should contain a valid phone number.</li>";
		}
		if ( !($j('#membership_type').val()) )
		{
			_error_message += "<li>The type of membership field should contain the type of membership you wish to purchase.</li>";
		}

		if (_error_message != '')
		{
			jAlert(_error_start+_error_message+_error_end, 'Tipton Rosemark Academy:  Online Forms');
		}
		else
		{
			$j.post('../com/formAthleticBoosterClub.cfc?method=fnProcessForm&returnFormat=plain',$j("#onlineParentForm").serialize(), function(data,status) 
			{
				data = $j.trim(data);
			
				$j("#formContainerLeft").html(data).show();			
			});
			
			$j('#headerContainer').scrollTop()
		}
	});	

	$j("#traPersonalRelease_submit_button").live("click", function()	
	{
		//  be sure all required fields are filled.
		var _error_message = "";
		var _error_start = "<h5 class='h5Thin' style='border-bottom:1px solid #CCCCCC;'>Validation Errors</h5><br /><ul>";
		var _error_end = "</ul>";

		if ( !($j('#parent_name').val()) )
		{
			_error_message += "<li>The Parent Name field should contain the parent or guardian's name.</li>";
		}
		if ( !($j('#parent_signature').val()) )
		{
			_error_message += "<li>The Parent Signature field should contain the parent or guardian's name.</li>";
		}
		if ( !($j('#release_address').val()) )
		{
			_error_message += "<li>The Address field should containt the address of the parent or guardian.</li>";
		}
		if ( !($j('#release_signaturedate').val()) )
		{
			_error_message += "<li>The Date field should contain the date this form was submitted.</li>";
		}

		if (_error_message != '')
		{
			jAlert(_error_start+_error_message+_error_end, 'Tipton Rosemark Academy:  Online Forms');
		}
		else
		{
			$j.post('../com/formTRAPersonalRelease.cfc?method=fnProcessForm&returnFormat=plain',$j("#onlineParentForm").serialize(), function(data,status) 
			{
				data = $j.trim(data);
			
				$j("#formContainerLeft").html(data).show();			
			});
			
			$j('#headerContainer').scrollTop()
		}
	});

	$j("#personalResponsibility_submit_button").live("click", function()	
	{
		//  be sure all required fields are filled.
		var _error_message = "";
		var _error_start = "<h5 class='h5Thin' style='border-bottom:1px solid #CCCCCC;'>Validation Errors</h5><br /><ul>";
		var _error_end = "</ul>";

		if ( !($j('#section_1_initials').val()) || !($j('#section_2_initials').val()) || !($j('#section_3_initials').val()) || !($j('#section_4_initials').val()) || !($j('#section_5_initials').val()))
		{
			_error_message += "<li>Please be sure all sections have been initialed.</li>";
		}
		if ( !($j('#student_signature').val()) )
		{
			_error_message += "<li>The student signature field should contain student's signature.</li>";
		}
		if ( !($j('#student_signaturedate').val()) )
		{
			_error_message += "<li>The student signature date field should contain the date the student signed the form.</li>";
		}
		if ( !($j('#parent_signature').val()) )
		{
			_error_message += "<li>The parent's signature field should contain parent's signature.</li>";
		}
		if ( !($j('#parent_signaturedate').val()) )
		{
			_error_message += "<li>The parent's signature date field should contain the date the parent signed the form.</li>";
		}


		if (_error_message != '')
		{
			jAlert(_error_start+_error_message+_error_end, 'Tipton Rosemark Academy:  Online Forms');
		}
		else
		{
			$j.post('../com/formResponsibleUsePolicy.cfc?method=fnProcessForm&returnFormat=plain',$j("#onlineParentForm").serialize(), function(data,status) 
			{
				data = $j.trim(data);
			
				$j("#formContainerLeft").html(data).show();			
			});
			
			$j('#headerContainer').scrollTop()
		}
	});

	$j("#studentComputerUseAgreement_submit_button").live("click", function()	
	{
		$j.post('../com/formStudentComputerUseAgreement.cfc?method=fnProcessForm&returnFormat=plain',$j("#onlineParentForm").serialize(), function(data,status) 
		{
			data = $j.trim(data);
		
			$j("#formContainerLeft").html(data).show();			
		});
		
		$j('#headerContainer').scrollTop()		
	});

	$j("#emergencyAndIllnessInformation_submit_button").live("click", function()	
	{
		$j.post('../com/formEmergencyAndIllnessInformation.cfc?method=fnProcessForm&returnFormat=plain',$j("#onlineParentForm").serialize(), function(data,status) 
		{
			data = $j.trim(data);
		
			$j("#formContainerLeft").html(data).show();			
		});
		
		$j('#headerContainer').scrollTop()		
	});

	$j("#traDrugRelease_submit_button").live("click", function()	
	{
		//  be sure all required fields are filled.
		var _error_message = "";
		var _error_start = "<h5 class='h5Thin' style='border-bottom:1px solid #CCCCCC;'>Validation Errors</h5><br /><ul>";
		var _error_end = "</ul>";

		if ( !($j('#parent_name').val()))
		{
			_error_message += "<li>The name of the parent or guardian is required.</li>";
		}
		if ( !($j('#address').val()) )
		{
			_error_message += "<li>The address field is required.</li>";
		}
		if ( !($j('#studentSignature').val()) )
		{
			_error_message += "<li>The student signature field should contain student's signature.</li>";
		}
		if ( !($j('#parentGuardianSignature').val()) )
		{
			_error_message += "<li>The parent or guardian's signature field is required.</li>";
		}


		if (_error_message != '')
		{
			jAlert(_error_start+_error_message+_error_end, 'Tipton Rosemark Academy:  Online Forms');
		}
		else
		{
			$j.post('../com/formStudentDrugAndAlcoholScreeningRelease.cfc?method=fnProcessForm&returnFormat=plain',$j("#onlineParentForm").serialize(), function(data,status) 
			{
				data = $j.trim(data);
			
				$j("#formContainerLeft").html(data).show();			
			});
			
			$j('#headerContainer').scrollTop()
		}
	});

	$j("#ptoMembership_submit_button").live("click", function()	
	{
		//  be sure all required fields are filled.
		var _error_message = "";
		var _error_start = "<h5 class='h5Thin' style='border-bottom:1px solid #CCCCCC;'>Validation Errors</h5><br /><ul>";
		var _error_end = "</ul>";

		if ( !($j('#parentName').val()))
		{
			_error_message += "<li>The name of the parent, guardian or grandparent is required.</li>";
		}
		if ( !($j('#parent').attr('checked')) && !($j('#staff').attr('checked')) && !($j('#teacher').attr('checked')) && !($j('#grandparent').attr('checked')))
		{
			_error_message += "<li>Please be sure to select if you are a parent, staff, teacher and/or grandparent.</li>";
		}		
		if ( !($j('#student1').val()) )
		{
			_error_message += "<li>The of at least one student is required.</li>";
		}
		if ( !($j('#grade1').val()) )
		{
			_error_message += "<li>The grade level of the student is required.</li>";
		}
		if ( !($j('#cash').attr('checked')) && !($j('#check').attr('checked')))
		{
			_error_message += "<li>Please be sure to select if you will be paying with cash or a check.</li>";
		}		
		if ( !($j('#ptoMemberInitials').val()) )
		{
			_error_message += "<li>Please be sure to enter the initials of the PTO Member.</li>";
		}
		if ( !($j('#ptoMemberInitialsDate').val()) )
		{
			_error_message += "<li>Please be sure to enter a valid date.</li>";
		}



		if (_error_message != '')
		{
			jAlert(_error_start+_error_message+_error_end, 'Tipton Rosemark Academy:  Online Forms');
		}
		else
		{
			$j.post('../com/formPTOMembership.cfc?method=fnProcessForm&returnFormat=plain',$j("#onlineParentForm").serialize(), function(data,status) 
			{
				data = $j.trim(data);
			
				$j("#formContainerLeft").html(data).show();			
			});
			
			$j('#headerContainer').scrollTop()		
		}
	});

	$j("#rebelcareregistration_submit_button").live("click", function()	
	{
		//  be sure all required fields are filled.
		var _error_message = "";
		var _error_start = "<h5 class='h5Thin' style='border-bottom:1px solid #CCCCCC;'>Validation Errors</h5><br /><ul>";
		var _error_end = "</ul>";

		/*
		if ( !($j('#parentName').val()))
		{
			_error_message += "<li>The name of the parent, guardian or grandparent is required.</li>";
		}
		if ( !($j('#parent').attr('checked')) && !($j('#staff').attr('checked')) && !($j('#teacher').attr('checked')) && !($j('#grandparent').attr('checked')))
		{
			_error_message += "<li>Please be sure to select if you are a parent, staff, teacher and/or grandparent.</li>";
		}		
		if ( !($j('#student1').val()) )
		{
			_error_message += "<li>The of at least one student is required.</li>";
		}
		if ( !($j('#grade1').val()) )
		{
			_error_message += "<li>The grade level of the student is required.</li>";
		}
		if ( !($j('#cash').attr('checked')) && !($j('#check').attr('checked')))
		{
			_error_message += "<li>Please be sure to select if you will be paying with cash or a check.</li>";
		}		
		if ( !($j('#ptoMemberInitials').val()) )
		{
			_error_message += "<li>Please be sure to enter the initials of the PTO Member.</li>";
		}
		if ( !($j('#ptoMemberInitialsDate').val()) )
		{
			_error_message += "<li>Please be sure to enter a valid date.</li>";
		}

		*/

		if (_error_message != '')
		{
			jAlert(_error_start+_error_message+_error_end, 'Tipton Rosemark Academy:  Online Forms');
		}
		else
		{
			$j.post('../com/formRebelcareRegistration.cfc?method=fnProcessForm&returnFormat=plain',$j("#onlineParentForm").serialize(), function(data,status) 
			{
				data = $j.trim(data);
			
				$j("#formContainerLeft").html(data).show();			
			});
			
			$j('#headerContainer').scrollTop()		
		}
	});


});
