// JavaScript Document
/********************************************************************/
/*            ALL RIGHTS ARE RESERVED FOR PHP SCRIPTS               */
/*         DIVISION OF MARSAL INCORPORATED (c) 2003-2004            */
/*   For More Information Contact: http://www.marsaldesign.com      */
/*   A License has been issued for this site only for the script    */
/*   To be used. Any other violators will be prosecuted to the      */
/*            FULL extent of the law and/or possible fine.          */
/*    By Using This Script You Agree that Marsal Design Will not    */
/*    Be held liable for anything that occurs because of misuse,    */
/*    break down and/or disfunctionality of this script, either     */
/*    physically or financially. You also agree that any charges    */
/*    Incurred from such actions to Marsal Inc. you will be held    */
/*           Liable for and must reimburse Marsal Inc.              */
/********************************************************************/

function validate_registration(object){
	var checker = true;
	
	if(object.schoolname.value.length < 3){
		alert("Please Enter A School Name 3 Characters Minimum!");
		object.schoolname.focus();
		object.schoolname.style.background = "#FFCCFF";
		return false;
	}
	
	if(object.fname.value.length < 2){
		alert("Please Enter A First Name!");
		object.fname.focus();
		object.fname.style.background = "#FFCCFF";
		return false;
	}	
	
	if(object.lname.value.length < 2){
		alert("Please Enter A Last Name!");
		object.lname.focus();
		object.lname.style.background = "#FFCCFF";
		return false;
	}
	if(object.call1a.value.length < 2 && object.call2a.value.length < 2 && object.call3a.value.length < 2 && object.call4a.value.length < 2){
		alert("Please Enter At Least One Contact Information!");
		object.call1a.focus();
		object.call1a.style.background = "#FFCCFF";
		return false;
	}

	var str=object.email.value;
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	if (!(filter.test(str))) {
		alert("Please Enter A Valid Email Address!");
		object.email.focus();
		object.email.style.background = "#FFCCFF";
		return false;
	 }
	 var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
	 var bad_values = '';
	 if(object.username.value.length <5){
	 	alert("Please Enter A Username at Least 5 Characters In Legth!");
	 	object.username.focus();
		object.username.style.background = "#FFCCFF";
		return false;
	 } else {
		for (var i = 0; i < object.username.value.length; i++) {
  			if (iChars.indexOf(object.username.value.charAt(i)) != -1) {
				bad_values += object.username.value.charAt(i);						
	  		}
  		 }
		 if(bad_values != ''){
		 	alert("Username Contains: (" + bad_values + ") Which Are Special Characters, Please Change Them!");
			object.username.focus();
			object.username.style.background = "#FFCCFF";
			return false;  
		 }
	}
	
	if(object.password.value.length < 5){
		alert("Password Must Be at Least 5 Characters In Length!");
		object.password.focus();
		object.password.style.background = "#FFCCFF";
		return false;
	} else {
		if(object.password.value != object.password2.value){
			alert("Your Password Confirmation Does Not Match Orginal Password, Please Correct It!");
			object.password2.focus();
			object.password2.style.background = "#FFCCFF";
			return false;
		}
	}
	if(object.username.value == object.password.value){
		alert("Your Password Can Not Be The Same As Your Username, Please Change Either!");
		object.username.focus();
		object.username.style.background = "#FFCCFF";
		return false;
	}
	if(object.hear.value == 0){
		object.hear.value = 'NA';
	}
	if(object.past.value == 0){
		object.past.value = 'NA';
	}
	if(object.code.value == 0){
		object.code.value = 'NA';
	}
	
	object.Submitme.value = "Please Wait While Registration Completes...";
	object.Submitme.disabled = true;
	return checker;
}

function update_account(object){
	var checker = true;
	if(object.fname.value.length < 2){
		alert("Please Enter A First Name!");
		object.fname.focus();
		object.fname.style.background = "#FFCCFF";
		return false;
	}	
	
	if(object.lname.value.length < 2){
		alert("Please Enter A Last Name!");
		object.lname.focus();
		object.lname.style.background = "#FFCCFF";
		return false;
	}
	if(object.call1a.value.length < 2 && object.call2a.value.length < 2 && object.call3a.value.length < 2 && object.call4a.value.length < 2){
		alert("Please Enter At Least One Contact Information!");
		object.call1a.focus();
		object.call1a.style.background = "#FFCCFF";
		return false;
	}

	var str=object.email.value;
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	if (!(filter.test(str))) {
		alert("Please Enter A Valid Email Address!");
		object.email.focus();
		object.email.style.background = "#FFCCFF";
		return false;
	 }
	 
	 if(object.record1.value != 0){
		 if( object.record1.value.indexOf("-") == 2 && object.record1.value.length == 10){
		 	var temp;
			temp = object.record1.value.split("-");
				if(!(isanumber(temp[0]))){
					alert(temp[0] + ' Is Not A Number, Please Try Again');
					object.record1.focus();
					object.record1.style.background = "#FFCCFF";
					return false;
				} 
				if(!(isanumber(temp[1]))){
					alert(temp[1] + ' Is Not A Number, Please Try Again');
					object.record1.focus();
					object.record1.style.background = "#FFCCFF";
					return false;
				}
				if(!(isanumber(temp[2]))){
					alert(temp[2] + ' Is Not A Number, Please Try Again');
					object.record1.focus();
					object.record1.style.background = "#FFCCFF";
					return false;
				}
				var d = new Date();
				year = d.getFullYear();
			//	if(temp[0] > 12 || (temp[1] > 31 && temp[0] != 02) || (temp[1] > 29 && temp[0] == 02) || temp[2] < year){
			///		alert("Date Entered Is Not Valid, Must Be in mm-dd-yyyy Format (Future)!");
			//		object.record1.focus();
		//			object.record1.style.background = "#FFCCFF";
			//		return false;
			//	}
		 } else {
		 	alert("Date Entered Is Not Valid, Must Be in mm-dd-yyyy Format!");
			object.record1.focus();
			object.record1.style.background = "#FFCCFF";
			return false;	
		 }
	}
	if(object.record2.value != 0){
		 if( object.record2.value.indexOf("-") == 2 && object.record2.value.length == 10){
		 	var temp;
			temp = object.record2.value.split("-");
				if(!(isanumber(temp[0]))){
					alert(temp[0] + ' Is Not A Number, Please Try Again');
					object.record2.focus();
					object.record2.style.background = "#FFCCFF";
					return false;
				}
				if(!(isanumber(temp[1]))){
					alert(temp[1] + ' Is Not A Number, Please Try Again');
					object.record2.focus();
					object.record2.style.background = "#FFCCFF";
					return false;
				}
				if(!(isanumber(temp[2]))){
					alert(temp[2] + ' Is Not A Number, Please Try Again');
					object.record2.focus();
					object.record2.style.background = "#FFCCFF";
					return false;
				}
				var d = new Date();
				year = d.getFullYear();
				//if(temp[0] > 12 || (temp[1] > 31 && temp[0] != 02) || (temp[1] > 29 && temp[0] == 02) || temp[2] < year){
			//		alert("Date Entered Is Not Valid, Must Be in mm-dd-yyyy Format (Future)!");
			//		object.record2.focus();
			//		object.record2.style.background = "#FFCCFF";
			///		return false;
			//	}
		 } else {
		 	alert("Date Entered Is Not Valid, Must Be in mm-dd-yyyy Format!");
			object.record2.focus();
			object.record2.style.background = "#FFCCFF";
			return false;	
		 }
	}
	if(object.record3.value != 0){
		 if( object.record3.value.indexOf("-") == 2 && object.record3.value.length == 10){
		 	var temp;
			temp = object.record3.value.split("-");
				if(!(isanumber(temp[0]))){
					alert(temp[0] + ' Is Not A Number, Please Try Again');
					object.record3.focus();
					object.record3.style.background = "#FFCCFF";
					return false;
				}
				if(!(isanumber(temp[1]))){
					alert(temp[1] + ' Is Not A Number, Please Try Again');
					object.record3.focus();
					object.record3.style.background = "#FFCCFF";
					return false;
				}
				if(!(isanumber(temp[2]))){
					alert(temp[2] + ' Is Not A Number, Please Try Again');
					object.record3.focus();
					object.record3.style.background = "#FFCCFF";
					return false;
				}
				var d = new Date();
				year = d.getFullYear();
				if(temp[0] > 12 || (temp[1] > 31 && temp[0] != 02) || (temp[1] > 29 && temp[0] == 02) || temp[2] < year){
					alert("Date Entered Is Not Valid, Must Be in mm-dd-yyyy Format (Future)!");
					object.record3.focus();
					object.record3.style.background = "#FFCCFF";
					return false;
				}
		 } else {
		 	alert("Date Entered Is Not Valid, Must Be in mm-dd-yyyy Format!");
			object.record3.focus();
			object.record3.style.background = "#FFCCFF";
			return false;	
		 }
	}
	
	object.Submitme.value = "Please Wait While Updating User...";
	object.Submitme.disabled = true;
	return checker;
}
	
function add_account(object){
	var checker = true;
	
	if(object.fname.value.length < 2){
		alert("Please Enter A First Name!");
		object.fname.focus();
		object.fname.style.background = "#FFCCFF";
		return false;
	}	
	
	if(object.lname.value.length < 2){
		alert("Please Enter A Last Name!");
		object.lname.focus();
		object.lname.style.background = "#FFCCFF";
		return false;
	}
	if(object.call1a.value.length < 2 && object.call2a.value.length < 2 && object.call3a.value.length < 2 && object.call4a.value.length < 2){
		alert("Please Enter At Least One Contact Information!");
		object.call1a.focus();
		object.call1a.style.background = "#FFCCFF";
		return false;
	}

	var str=object.email.value;
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	if (!(filter.test(str))) {
		alert("Please Enter A Valid Email Address!");
		object.email.focus();
		object.email.style.background = "#FFCCFF";
		return false;
	 }
	 var iChars = "!@#$%^&* ()+=-[]\\\';,./{}|\":<>?";
	 var bad_values = '';
	 if(object.username.value.length <5){
	 	alert("Please Enter A Username at Least 5 Characters In Legth!");
	 	object.username.focus();
		object.username.style.background = "#FFCCFF";
		return false;
	 } 
	 for (var i = 0; i < object.username.value.length; i++) {
  		if (iChars.indexOf(object.username.value.charAt(i)) != -1) {
			bad_values += object.username.value.charAt(i);		
		}
  	 }
	 if(bad_values != ''){
	 	if(bad_values.indexOf(' ') != -1){
			bad_values = removespaces(bad_values);
			if(!(bad_values)){
				alert("Username Contains: Spaces Which Are Special Characters, Please Change Them!");
			} else {
				alert("Username Contains: Spaces and (" + bad_values + ") Which Are Special Characters, Please Change Them!");
			}
		} else {
			alert("Username Contains: (" + bad_values + ") Which Are Special Characters, Please Change Them!");
		}
		object.username.focus();
		object.username.style.background = "#FFCCFF";
		return false;  
	 }
	
	
	if(object.amount.value != 0){
		temp = object.amount.value.split(".");
		var str=object.amount.value;
	
		var filter=  /\$\d{1,3}(,\d{3})*\.\d{2}/;
		if (!(filter.test(str))) {
			alert("Please Enter Valid Amount: $00.00");
			object.amount.focus();
			object.amount.style.background = "#FFCCFF";
			return false;
		 }
		if (object.amount.value.indexOf("$") != 0 || object.amount.value.indexOf(".") == -1 || temp[1].length != 2 || object.amount.value.length < 5) {
			alert("Please Enter Valid Amount: $00.00");
			object.amount.style.background = "#FFCCFF";
			object.amount.focus();
			return false;
		}
	} else {
		object.amount.value = '00.00';
	}
	object.Submitme.value = "Please Wait While Adding User...";
	object.Submitme.disabled = true;
	return checker;
}

function add_airplane(object){
	var checker = true;
	
	 if(object.platenum.value == 0){
	 	alert("Please Enter A Plate Number For The Airplane!");
		object.platenum.focus();
		object.platenum.style.background = "#FFCCFF";
		return false;  
	 }
     if(object.name.value == 0){
	 	alert("Please Enter A Name For The Airplane!");
		object.name.focus();
		object.name.style.background = "#FFCCFF";
		return false;  
	 }
	 if(object.preset_desc.selectedIndex == 0){
	 	alert("Please Select A Description For The Airplane!");
		object.preset_desc.focus();
		object.preset_desc.style.background = "#FFCCFF";
		return false;  
	 }

	if(object.insp_1.value != 0 && object.insp_1.value != '00-00-0000'){
		 if( object.insp_1.value.indexOf("-") == 2 && object.insp_1.value.length == 10){
		 	var temp;
			temp = object.insp_1.value.split("-");
			if(!(isanumber(temp[0]))){
				alert(temp[0] + ' Is Not A Number, Please Try Again');
				object.insp_1.focus();
				object.insp_1.style.background = "#FFCCFF";
				return false;
			} 
			if(!(isanumber(temp[1]))){
				alert(temp[1] + ' Is Not A Number, Please Try Again');
				object.insp_1.focus();
				object.insp_1.style.background = "#FFCCFF";
				return false;
			}
			if(!(isanumber(temp[2]))){
				alert(temp[2] + ' Is Not A Number, Please Try Again');
				object.insp_1.focus();
				object.insp_1.style.background = "#FFCCFF";
				return false;
			}
			var d = new Date();
			year = d.getFullYear();
			month = d.getMonth();
			day = d.getDate();
			month++;
			
			
			if(temp[0] > 12 || (temp[1] > 31 && temp[0] != 02) || (temp[1] > 29 && temp[0] == 02) || temp[2] < year || (temp[2] == year && temp[0] < month) || (temp[2] == year && temp[0] == month && temp[1] <= day)){
				alert("Date Entered Is Not Valid, Must Be in mm-dd-yyyy Format (Future)!");
				object.insp_1.focus();
				object.insp_1.style.background = "#FFCCFF";
				return false;
			}
		 } else {
		 	alert("Date Entered Is Not Valid, Must Be in mm-dd-yyyy Format!");
			object.insp_1.focus();
			object.insp_1.style.background = "#FFCCFF";
			return false;	
		 }
	}
	if(object.insp_2.value > 100 || object.insp_2.value < 0){
		alert("Number must be lower than 100!");
		object.insp_2.focus();
		object.insp_2.style.background = "#FFCCFF";
		return false;	
	}
	if(object.insp_3.value != 0 && object.insp_3.value != '00-00-0000'){
		 if( object.insp_3.value.indexOf("-") == 2 && object.insp_3.value.length == 10){
		 	var temp;
			temp = object.insp_3.value.split("-");
			if(!(isanumber(temp[0]))){
				alert(temp[0] + ' Is Not A Number, Please Try Again');
				object.insp_3.focus();
				object.insp_3.style.background = "#FFCCFF";
				return false;
			} 
			if(!(isanumber(temp[1]))){
				alert(temp[1] + ' Is Not A Number, Please Try Again');
				object.insp_3.focus();
				object.insp_3.style.background = "#FFCCFF";
				return false;
			}
			if(!(isanumber(temp[2]))){
				alert(temp[2] + ' Is Not A Number, Please Try Again');
				object.insp_3.focus();
				object.insp_3.style.background = "#FFCCFF";
				return false;
			}
			var d = new Date();
			year = d.getFullYear();
			month = d.getMonth();
			day = d.getDate();
			month++;

			if(temp[0] > 12 || (temp[1] > 31 && temp[0] != 02) || (temp[1] > 29 && temp[0] == 02) || temp[2] < year || (temp[2] == year && temp[0] < month) || (temp[2] == year && temp[0] == month && temp[1] <= day)){
				alert("Date Entered Is Not Valid, Must Be in mm-dd-yyyy Format (Future)!");
				object.insp_3.focus();
				object.insp_3.style.background = "#FFCCFF";
				return false;
			}
		 } else {
		 	alert("Date Entered Is Not Valid, Must Be in mm-dd-yyyy Format!");
			object.insp_3.focus();
			object.insp_3.style.background = "#FFCCFF";
			return false;	
		 }
	}
	if(object.insp_4.value != 0 && object.insp_4.value != '00-00-0000'){
		 if( object.insp_4.value.indexOf("-") == 2 && object.insp_4.value.length == 10){
		 	var temp;
			temp = object.insp_4.value.split("-");
			if(!(isanumber(temp[0]))){
				alert(temp[0] + ' Is Not A Number, Please Try Again');
				object.insp_4.focus();
				object.insp_4.style.background = "#FFCCFF";
				return false;
			} 
			if(!(isanumber(temp[1]))){
				alert(temp[1] + ' Is Not A Number, Please Try Again');
				object.insp_4.focus();
				object.insp_4.style.background = "#FFCCFF";
				return false;
			}
			if(!(isanumber(temp[2]))){
				alert(temp[2] + ' Is Not A Number, Please Try Again');
				object.insp_4.focus();
				object.insp_4.style.background = "#FFCCFF";
				return false;
			}
			var d = new Date();
			year = d.getFullYear();
			month = d.getMonth();
			day = d.getDate();
			month++;

			if(temp[0] > 12 || (temp[1] > 31 && temp[0] != 02) || (temp[1] > 29 && temp[0] == 02) || temp[2] < year || (temp[2] == year && temp[0] < month) || (temp[2] == year && temp[0] == month && temp[1] <= day)){
				alert("Date Entered Is Not Valid, Must Be in mm-dd-yyyy Format (Future)!");
				object.insp_4.focus();
				object.insp_4.style.background = "#FFCCFF";
				return false;
			}
		 } else {
		 	alert("Date Entered Is Not Valid, Must Be in mm-dd-yyyy Format!");
			object.insp_4.focus();
			object.insp_4.style.background = "#FFCCFF";
			return false;	
		 }
	}
	if(object.insp_5.value != 0 && object.insp_5.value != '00-00-0000'){
		 if( object.insp_5.value.indexOf("-") == 2 && object.insp_5.value.length == 10){
		 	var temp;
			temp = object.insp_5.value.split("-");
			if(!(isanumber(temp[0]))){
				alert(temp[0] + ' Is Not A Number, Please Try Again');
				object.insp_5.focus();
				object.insp_5.style.background = "#FFCCFF";
				return false;
			} 
			if(!(isanumber(temp[1]))){
				alert(temp[1] + ' Is Not A Number, Please Try Again');
				object.insp_5.focus();
				object.insp_5.style.background = "#FFCCFF";
				return false;
			}
			if(!(isanumber(temp[2]))){
				alert(temp[2] + ' Is Not A Number, Please Try Again');
				object.insp_5.focus();
				object.insp_5.style.background = "#FFCCFF";
				return false;
			}
			var d = new Date();
			year = d.getFullYear();
			month = d.getMonth();
			day = d.getDate();
			month++;

			if(temp[0] > 12 || (temp[1] > 31 && temp[0] != 02) || (temp[1] > 29 && temp[0] == 02) || temp[2] < year || (temp[2] == year && temp[0] < month) || (temp[2] == year && temp[0] == month && temp[1] <= day)){
				alert("Date Entered Is Not Valid, Must Be in mm-dd-yyyy Format (Future)!");
				object.insp_5.focus();
				object.insp_5.style.background = "#FFCCFF";
				return false;
			}
		 } else {
		 	alert("Date Entered Is Not Valid, Must Be in mm-dd-yyyy Format, or Leave Blank!");
			object.insp_5.focus();
			object.insp_5.style.background = "#FFCCFF";
			return false;	
		 }
	}
	if(object.insp_6.value != 0 && object.insp_6.value != '00-00-0000'){
		 if( object.insp_6.value.indexOf("-") == 2 && object.insp_6.value.length == 10){
		 	var temp;
			temp = object.insp_6.value.split("-");
			if(!(isanumber(temp[0]))){
				alert(temp[0] + ' Is Not A Number, Please Try Again');
				object.insp_6.focus();
				object.insp_6.style.background = "#FFCCFF";
				return false;
			} 
			if(!(isanumber(temp[1]))){
				alert(temp[1] + ' Is Not A Number, Please Try Again');
				object.insp_6.focus();
				object.insp_6.style.background = "#FFCCFF";
				return false;
			}
			if(!(isanumber(temp[2]))){
				alert(temp[2] + ' Is Not A Number, Please Try Again');
				object.insp_6.focus();
				object.insp_6.style.background = "#FFCCFF";
				return false;
			}
		var d = new Date();
			year = d.getFullYear();
			month = d.getMonth();
			day = d.getDate();
			month++;

			if(temp[0] > 12 || (temp[1] > 31 && temp[0] != 02) || (temp[1] > 29 && temp[0] == 02) || temp[2] < year || (temp[2] == year && temp[0] < month) || (temp[2] == year && temp[0] == month && temp[1] <= day)){
				alert("Date Entered Is Not Valid, Must Be in mm-dd-yyyy Format (Future)!");
				object.insp_6.focus();
				object.insp_6.style.background = "#FFCCFF";
				return false;
			}
		 } else {
		 	alert("Date Entered Is Not Valid, Must Be in mm-dd-yyyy Format, or Leave Blank!");
			object.insp_6.focus();
			object.insp_6.style.background = "#FFCCFF";
			return false;	
		 }
	}
	if(object.insp_7.value != 0 && object.insp_7.value != '00-00-0000'){
		 if( object.insp_7.value.indexOf("-") == 2 && object.insp_7.value.length == 10){
		 	var temp;
			temp = object.insp_7.value.split("-");
			if(!(isanumber(temp[0]))){
				alert(temp[0] + ' Is Not A Number, Please Try Again');
				object.insp_7.focus();
				object.insp_7.style.background = "#FFCCFF";
				return false;
			} 
			if(!(isanumber(temp[1]))){
				alert(temp[1] + ' Is Not A Number, Please Try Again');
				object.insp_7.focus();
				object.insp_7.style.background = "#FFCCFF";
				return false;
			}
			if(!(isanumber(temp[2]))){
				alert(temp[2] + ' Is Not A Number, Please Try Again');
				object.insp_7.focus();
				object.insp_7.style.background = "#FFCCFF";
				return false;
			}
			var d = new Date();
			year = d.getFullYear();
			month = d.getMonth();
			day = d.getDate();
			month++;

			if(temp[0] > 12 || (temp[1] > 31 && temp[0] != 02) || (temp[1] > 29 && temp[0] == 02) || temp[2] < year || (temp[2] == year && temp[0] < month) || (temp[2] == year && temp[0] == month && temp[1] <= day)){
				alert("Date Entered Is Not Valid, Must Be in mm-dd-yyyy Format (Future)!");
				object.insp_7.focus();
				object.insp_7.style.background = "#FFCCFF";
				return false;
			}
		 } else {
		 	alert("Date Entered Is Not Valid, Must Be in mm-dd-yyyy Format, or Leave Blank!");
			object.insp_7.focus();
			object.insp_7.style.background = "#FFCCFF";
			return false;	
		 }
	}
	if(object.insp_8.value != 0 && object.insp_8.value != '00-00-0000'){
		 if( object.insp_8.value.indexOf("-") == 2 && object.insp_8.value.length == 10){
		 	var temp;
			temp = object.insp_8.value.split("-");
			if(!(isanumber(temp[0]))){
				alert(temp[0] + ' Is Not A Number, Please Try Again');
				object.insp_8.focus();
				object.insp_8.style.background = "#FFCCFF";
				return false;
			} 
			if(!(isanumber(temp[1]))){
				alert(temp[1] + ' Is Not A Number, Please Try Again');
				object.insp_8.focus();
				object.insp_8.style.background = "#FFCCFF";
				return false;
			}
			if(!(isanumber(temp[2]))){
				alert(temp[2] + ' Is Not A Number, Please Try Again');
				object.insp_8.focus();
				object.insp_8.style.background = "#FFCCFF";
				return false;
			}
			var d = new Date();
			year = d.getFullYear();
			month = d.getMonth();
			day = d.getDate();
			month++;

			if(temp[0] > 12 || (temp[1] > 31 && temp[0] != 02) || (temp[1] > 29 && temp[0] == 02) || temp[2] < year || (temp[2] == year && temp[0] < month) || (temp[2] == year && temp[0] == month && temp[1] <= day)){
				alert("Date Entered Is Not Valid, Must Be in mm-dd-yyyy Format (Future)!");
				object.insp_8.focus();
				object.insp_8.style.background = "#FFCCFF";
				return false;
			}
		 } else {
		 	alert("Date Entered Is Not Valid, Must Be in mm-dd-yyyy Format, or Leave Blank!");
			object.insp_8.focus();
			object.insp_8.style.background = "#FFCCFF";
			return false;	
		 }
	}
	 if(object.hoop.value == 0){
	 	object.hoop.value = '0';
	 }
	 if(object.tach.value == 0){
	 	object.tach.value = '0';
	 }
	object.Submitme.value = "Please Wait While Processing Request...";
	object.Submitme.disabled = true;
	return checker;
}

function validate_club_contact(object){
	var checker = true;
	
	if(object.subject_club.value == 0){
	 	alert("Please Enter A Subject For The Email!");
		object.subject_club.focus();
		object.subject_club.style.background = "#FFCCFF";
		return false;  
	}
	if(object.message_club.value == 0){
	 	alert("Please Enter A Message For The Email!");
		object.message_club.focus();
		object.message_club.style.background = "#FFCCFF";
		return false;  
	}

	object.Submitme.value = "Please Wait Sending Data...";
	object.Submitme.disabled = true;
	return checker;
}
function change_profile(){
	var id = document.form_edit_profile.air_id.value;
	window.location.href = 'add_air_profile.php?id=' + id;
}


function validate_we1(object){
	var isvalid = true;
	if(object.which_one.value == 1){
		if(object.station_ids.value.length <3){
			alert("Please Enter An Airport Name!");
			object.station_ids.focus();
			object.station_ids.style.background = "#FFCCFF";
			return false;
		}
	}
	if(object.which_one.value == 2){
		if(object.f_ICAO.value.length <3){
			alert("Please Enter An Airport Name!");
			object.f_ICAO.focus();
			object.f_ICAO.style.background = "#FFCCFF";
			return false;
		}
	}
	if(object.which_one.value == 3){
		if(object.nnumber.value.length <3){
			alert("Please Enter A Plate Number!");
			object.nnumber.focus();
			object.nnumber.style.background = "#FFCCFF";
			return false;
		}
		if(object.display1.checked ==false && object.display2.checked ==false && object.display3.checked ==false && object.display4.checked ==false && object.display5.checked ==false){
			alert("Please Select At Least One Option!");
			return false;
		}
	}
	return isvalid;
}
function contact_check(object){
	var isvalid = true;
	
	if(object.name.value.length <3){
		alert("Please Enter A Valid Name, At Least 3 Characters Minimum!");
		object.name.focus();
		object.name.style.background = "#FFCCFF";
		return false;
	}
	
	var str=object.email.value;
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	if (!(filter.test(str))) {
		alert("Please Enter A Valid Email Address!");
		object.email.focus();
		object.email.style.background = "#FFCCFF";
		return false;
	 }
				
	if(object.message.value.length <3){
		alert("Please Enter A Valid Message, At Least 3 Characters Minimum!");
		object.message.focus();
		object.message.style.background = "#FFCCFF";
		return false;
	}
	
	object.Submitme.value = "Please Wait Sending Contact...";
	object.Submitme.disabled = true;
	return isvalid;
}

function validate_myprofile(object){
	var checker = true;
	if(object.fname.value.length < 2){
		alert("Please Enter A First Name!");
		object.fname.focus();
		object.fname.style.background = "#FFCCFF";
		return false;
	}	
	if(object.lname.value.length < 2){
		alert("Please Enter A Last Name!");
		object.lname.focus();
		object.lname.style.background = "#FFCCFF";
		return false;
	}
	if(object.call1a.value.length < 2 && object.call2a.value.length < 2 && object.call3a.value.length < 2 && object.call4a.value.length < 2){
		alert("Please Enter At Least One Contact Information!");
		object.call1a.focus();
		object.call1a.style.background = "#FFCCFF";
		return false;
	}

	var str=object.email.value;
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	if (!(filter.test(str))) {
		alert("Please Enter A Valid Email Address!");
		object.email.focus();
		object.email.style.background = "#FFCCFF";
		return false;
	 }
	 if(object.password.value.length < 5 && object.password.value.length != 0){
		alert("Password Must Be at Least 5 Characters In Length!");
		object.password.focus();
		object.password.style.background = "#FFCCFF";
		return false;
	} else {
		if(object.password.value != object.password2.value){
			alert("Your Password Confirmation Does Not Match Orginal Password, Please Correct It!");
			object.password2.focus();
			object.password2.style.background = "#FFCCFF";
			return false;
		}
	}	
	if(object.username.value == object.password.value){
		alert("Your Password Can Not Be The Same As Your Username, Please Change It!");
		object.password.value ='';
		object.password2.value ='';
		object.password.focus();
		object.password.style.backgrounupdate_accountd = "#FFCCFF";
		return false;
	}
	
	
	object.Submitme.value = "Please Wait While Updating...";
	object.Submitme.disabled = true;
	return checker;
}

function validate_add_appt(object,numc){
	var checker = true;
	var temp;
	var is_bad = false;
	var is_bad2 = false;
	var is_bad3 = false;
	
	
	
	if(object.airplane_list && object.airplane_list.value){
		var airplane_value = object.airplane_list.value;
	} else {
		var airplane_value = null;
	}
	
	if(object.inst_list && object.inst_list.value){
		var instructor_value = object.inst_list.value;
	} else {
		var instructor_value = null;
	}
	
	if(object.stud_list && object.stud_list.value){
		var student_value = object.stud_list.value;
	} else {
		var student_value = null;
	}
	
	if(airplane_value == 'NA' && instructor_value == 'NA' && student_value != 'NA'){
		is_bad = true;
	}	
	if(airplane_value == 'NA' && instructor_value == 'NA' && student_value == 'NA'){
		is_bad2 = true;
	}	
	if(airplane_value != 'NA' && instructor_value == 'NA' && student_value == 'NA' && object.makemain.checked == false){
		is_bad3 = true;
	}	
	
	if(is_bad == true){
		alert("Please select at another resource to go with the piolt!");
		object.stud_list.style.background = "#FFCCFF";
		object.stud_list.focus();
		return false;	
	}
	if(is_bad2 == true){
		alert("Please select at least two resources!");
		object.stud_list.style.background = "#FFCCFF";
		object.stud_list.focus();
		return false;	
	}
	if(is_bad3 == true){
		alert("Please select at least one resources with the airplane or select maintenance!");
		object.stud_list.style.background = "#FFCCFF";
		object.stud_list.focus();
		return false;	
	}
	if(object.deleteme){
		if(object.deleteme.checked == false) {
			if(numc != 1){
				if(object.comment.value == 0){
					alert("Comment Must Be Entered!");
					object.comment.focus();
					object.comment.style.background = "#FFCCFF";
					return false;
				}
			}
			year_dif = object.end_year.value - object.start_year.value;
			years_total = year_dif *365;
			
			months_dif = object.end_month.value - object.start_month.value;
			months_total = months_dif * 31;
			days_total =object.end_day.value - object.start_day.value;

			total_len = years_total + months_total + days_total;

			if(total_len < 0){
				alert("Invalid Appointment Date!");
				object.end_year.focus();
				object.end_year.style.background = "#FFCCFF";
				return false;
			}
			var chec_the_dates= true;
			if(object.end_day.value != object.start_day.value){ chec_the_dates = false;}
			if(object.end_year.value != object.start_year.value){ chec_the_dates = false;}
			if(object.end_month.value != object.start_month.value){ chec_the_dates = false;}
			
			var nuum;
			nuum = object.time_end.value - object.time_start.value;
			if(nuum <= 0 && chec_the_dates == true){
				alert("Invalid Appointment Time (less than 1 hour)!");
				object.time_end.focus();
				object.time_end.style.background = "#FFCCFF";
				return false;
			}
		}
	} else {
		if(numc != 1){
			if(object.comment.value == 0){
				alert("Comment Must Be Entered!");
				object.comment.focus();
				object.comment.style.background = "#FFCCFF";
				return false;
			}	
		}
		
		year_dif = object.end_year.value - object.start_year.value;
		years_total = year_dif *365;
			
		months_dif = object.end_month.value - object.start_month.value;
		months_total = months_dif * 31;
		days_total =object.end_day.value - object.start_day.value;
		total_len = years_total + months_total + days_total;
	
		if(total_len < 0){
			alert("Invalid Appointment Date!");
			object.end_year.focus();
			object.end_year.style.background = "#FFCCFF";
			return false;
		}
		var chec_the_dates= true;
		if(object.end_day.value != object.start_day.value){ chec_the_dates = false;}
		if(object.end_year.value != object.start_year.value){ chec_the_dates = false;}
		if(object.end_month.value != object.start_month.value){ chec_the_dates = false;}
			
		var nuum;
		nuum = object.time_end.value - object.time_start.value;
		if(nuum <= 0 && chec_the_dates == true){
			alert("Invalid Appointment Time (less than 1 hour)!");
			object.time_end.focus();
			object.time_end.style.background = "#FFCCFF";
			return false;
		}
	}
	
	return checker;
}	
	
function complete_appt(object,let,sec){
	var checker = true;
	
	if(let != 'a'){
		if(object.hoop){
			var str=object.hoop.value;
			
			if (IsNotNumeric(str)) {
				alert("Hobbs Time Must Be entered!");
				return false;
			}
		}
		if(object.tach){
			var str=object.tach.value;
			if (IsNotNumeric(str)) {
				alert("Tach Time Must Be entered!");
				return false;
			}
		}
		if(object.a_fee){
			if(object.a_fee.value != 0){
				var str=object.a_fee.value;
				if (!(check_dec(str))) {
					alert("Please Enter Valid Amount: 00.00!");
					object.a_fee.focus();
					object.a_fee.style.background = "#FFCCFF";
					return false;
				 }
			}
		}
		if(sec != 'i' && let != 'i'){
			if(object.air_tot){
				if(object.air_tot.value != 0){
					temp = object.air_tot.value.split(".");
					var str=object.air_tot.value;
					if (!(check_dec(str))) {
						alert("Please Enter Valid Amount: 00.00, or Leave Empty!");
						object.air_tot.focus();
						object.air_tot.style.background = "#FFCCFF";
						return false;
					}
					if(object.air_tot.value != 0 && object.air_tot.value != '00.00' && object.air_tot_c.value == 0){
						alert("Must Enter An Amount For Hours!");
						object.air_tot_c.style.background = "#FFCCFF";
						object.air_tot_c.focus();
						return false;
					}
				}
			}
		}
	}
	if(let != 'i'){
		if(object.gro_tot){
			if(object.gro_tot.value != 0){
				temp = object.gro_tot.value.split(".");
				var str=object.gro_tot.value;
				if (!(check_dec(str))) {
					alert("Please Enter Valid Amount: 00.00, or Leave Empty!");
					object.gro_tot.focus();
					object.gro_tot.style.background = "#FFCCFF";
					return false;
				}
				if(object.gro_tot.value != 0 && object.gro_tot.value != '00.00' && object.gro_tot_c.value == 0){
					alert("Must Enter An Amount For Hours!");
					object.gro_tot_c.style.background = "#FFCCFF";
					object.gro_tot_c.focus();
					return false;
				}
			}
		}
	}
	
	if(document.do_sch.totaldays){
			if(!object.hoopstart){ object.hoopstart.value= 0;}
			if(!object.tachstart){ object.tachstart.value= 0;}
			if(!object.hoop){ object.hoop.value= 0;}
			if(!object.tach){ object.tach.value= 0;}
			
			checker1 = object.hoop.value - object.hoopstart.value;
			checker2 = object.tach.value - object.tachstart.value;
			max_allowed = document.do_sch.totaldays.value * 24;
			if( checker1 > max_allowed){
				alert("Invalid Hobbs Time!");
				return false;
			}
			if( checker2 > max_allowed){
				alert("Invalid Tach Time!");
				return false;
			}
	}
	var last_checker = confirm("Are you sure you want to complete this appointment?");
	return last_checker;	
}	
function check_ar_news(object){
	var checker = true;
	if (object.title.value == 0 ) {
		alert("Please Enter A Title For The News!");
		object.title.style.background = "#FFCCFF";
		object.title.focus();
		return false;		
	}
	if (object.desc.value == 0 ) {
		alert("Please Enter A Description For The News!");
		object.desc.style.background = "#FFCCFF";
		object.desc.focus();
		return false;		
	}
	if (object.start.value == 0 ) {
		alert("Please Enter A Start Date For The News!");
		object.start.style.background = "#FFCCFF";
		object.start.focus();
		return false;		
	} else {
		if( object.start.value.indexOf("-") == 2 && object.start.value.length == 10){
				var temp;
				temp = object.start.value.split("-");
				if(!(isanumber(temp[0]))){
					alert(temp[0] + ' Is Not A Number, Please Try Again');
					object.start.focus();
					object.start.style.background = "#FFCCFF";
					return false;
				}
				if(!(isanumber(temp[1]))){
					alert(temp[1] + ' Is Not A Number, Please Try Again');
					object.start.focus();
					object.start.style.background = "#FFCCFF";
					return false;
				}
				if(!(isanumber(temp[2]))){
					alert(temp[2] + ' Is Not A Number, Please Try Again');
					object.start.focus();
					object.start.style.background = "#FFCCFF";
					return false;
				}
		} else {
			alert("Date Entered Is Not Valid, Must Be in mm-dd-yyyy Format!");
			object.start.focus();
			object.start.style.background = "#FFCCFF";
			return false;
		}
	}
	if (object.stopit.value == 0 ) {
		alert("Please Enter A Stop Date For The News!");
		object.stopit.style.background = "#FFCCFF";
		object.stopit.focus();
		return false;		
	} else {
		if( object.stopit.value.indexOf("-") == 2 && object.stopit.value.length == 10){
				var temp;
				temp = object.stopit.value.split("-");
				if(!(isanumber(temp[0]))){
					alert(temp[0] + ' Is Not A Number, Please Try Again');
					object.stopit.focus();
					object.stopit.style.background = "#FFCCFF";
					return false;
				}
				if(!(isanumber(temp[1]))){
					alert(temp[1] + ' Is Not A Number, Please Try Again');
					object.stopit.focus();
					object.stopit.style.background = "#FFCCFF";
					return false;
				}
				if(!(isanumber(temp[2]))){
					alert(temp[2] + ' Is Not A Number, Please Try Again');
					object.stopit.focus();
					object.stopit.style.background = "#FFCCFF";
					return false;
				}
		} else {
			alert("Date Entered Is Not Valid, Must Be in mm-dd-yyyy Format!");
			object.stopit.focus();
			object.stopit.style.background = "#FFCCFF";
			return false;
		}
	}
	
	return checker;
}

function check_ar_link(object){
	var checker = true;
	if (object.title.value == 0 ) {
		alert("Please Enter A Title For The Link!");
		object.title.style.background = "#FFCCFF";
		object.title.focus();
		return false;		
	}
	if (object.desc.value == 0 ) {
		alert("Please Enter A Description For The Link!");
		object.desc.style.background = "#FFCCFF";
		object.desc.focus();
		return false;		
	}
	if (object.location.value == 0 ) {
		alert("Please Enter A URL Location For The Link!");
		object.location.style.background = "#FFCCFF";
		object.location.focus();
		return false;		
	}
	return checker;
}

function check_problem(object){
	var checker = true;
	if(object.message.value.length < 4){
		alert("Please Enter A Message (3 Characters Min.)");
		object.message.style.background = "#FFCCFF";
		object.message.focus();
		return false;		
	}
	return checker;
}
function check_ar_files(object){
	var checker = true;
	if (object.title.value == 0 ) {
		alert("Please Enter A Title For The File!");
		object.title.style.background = "#FFCCFF";
		object.title.focus();
		return false;		
	}
	if (object.desc.value == 0 ) {
		alert("Please Enter A Description For The File!");
		object.desc.style.background = "#FFCCFF";
		object.desc.focus();
		return false;		
	}
	return checker;
}

function check_ar_images(object){
	var checker = true;
	if (object.title.value == 0 ) {
		alert("Please Enter A Title For The Picture!");
		object.title.style.background = "#FFCCFF";
		object.title.focus();
		return false;		
	}
	if (object.desc.value == 0 ) {
		alert("Please Enter A Description For The Picture!");
		object.desc.style.background = "#FFCCFF";
		object.desc.focus();
		return false;		
	}
	if (object.width.value == 0) {
		alert("Please Enter A Width For The Picture!");
		object.width.style.background = "#FFCCFF";
		object.width.focus();
		return false;		
	} else {
		if (!isanumber(object.width.value)) {
			alert("Width Must Be A Number!");
			object.width.style.background = "#FFCCFF";
			object.width.focus();
			return false;		
		}
	}
	if (object.length.value == 0 ) {
		alert("Please Enter A Length For The Picture!");
		object.length.style.background = "#FFCCFF";
		object.length.focus();
		return false;		
	} else {
		if (!isanumber(object.length.value)) {
			alert("Length Must Be A Number!");
			object.length.style.background = "#FFCCFF";
			object.length.focus();
			return false;		
		}
	}
	return checker;
}

function options_co_up(object){
	var checker = true;
	var temp;
	
	var str=object.opt11.value;
	if (!(check_dec(str))) {
		alert("Please Enter Valid Amount: 00.00!");
		object.opt11.focus();
		object.opt11.style.background = "#FFCCFF";
		return false;
	}

	var str=object.opt12.value;
	if (!(check_dec(str))) {
		alert("Please Enter Valid Amount: 00.00!");
		object.opt12.focus();
		object.opt12.style.background = "#FFCCFF";
		return false;
	}
	return checker;
}


function validate_add_c(object){
	var checker = true;
	if(object.comment.value==0){ 
		alert('Please Enter A Comment!');
		object.comment.style.background = "#FFCCFF";
		object.comment.focus();
		return false;
	}
	return checker;
}
function validate_add_m(object){
	var checker = true;
	var str=object.amount_p.value;
	if (!(check_dec(str))) {
		alert("Please Enter Valid Amount: 00.00!");
		object.amount_p.focus();
		object.amount_p.style.background = "#FFCCFF";
		return false;
	}

	return checker;
}

function validate_add_w(object){
	var checker = true;
	if(object.word.value.length < 3){
		alert("Please Enter A Word At Least 3 Characters In Length");
		object.word.focus();
		return false;
	}
	if(object.mean.value.length < 10){
		alert("Please Enter A Definition At Least 10 Characters In Length");
		object.mean.focus();
		return false;
	}
	
	return checker;	
}
function check_date(object){
	var checker = true;
	if (object.id1.value == 0 ) {
		alert("Please Enter A Date, Select A Calendar to Enter Date, Correct Date Format is: 00/00/0000");
		object.id1.style.background = "#FFCCFF";
		object.id1.focus();
		return false;		
	} else {
		if (object.id1.value.indexOf("/") !=2 || object.id1.value.length != 10){
			alert("Please Enter A Date, Select A Calendar to Enter Date, Correct Date Format is: 00/00/0000");
			object.id1.style.background = "#FFCCFF";
			object.id1.focus();
			return false;
		}		
	}	
	var check_num =object.time_end.value - object.time_start.value;
	if(check_num <= 0){
		alert("Please Enter A Valid Time, The Start Time Must Be Higher Than The Ending Time");
		object.time_start.focus();
		return false;
	}
	return checker;
}

function check_ltr(object,numc){
	var checker = true;
	if(document.cal_see.the_list.value == 0){
		alert("Please Enter At Least One Date!");
		return false;	
	}	
	
	var is_bad = false;
	var is_bad2 = false;
	var is_bad3 = false;
	
	if(object.airplane_list.value == 'NA' && object.inst_list.value == 'NA' && object.stud_list.value != 'NA'){
		is_bad = true;
	}	
	if(object.airplane_list.value == 'NA' && object.inst_list.value == 'NA' && object.stud_list.value == 'NA'){
		is_bad2 = true;
	}	
	if(object.airplane_list.value != 'NA' && object.inst_list.value == 'NA' && object.stud_list.value == 'NA' && object.makemain.checked == false){
		is_bad3 = true;
	}	
	
	if(is_bad == true){
		alert("Please select at another resource to go with the piolt!");
		object.stud_list.style.background = "#FFCCFF";
		object.stud_list.focus();
		return false;	
	}
	if(is_bad2 == true){
		alert("Please select at least two resources!");
		object.stud_list.style.background = "#FFCCFF";
		object.stud_list.focus();
		return false;	
	}
	if(is_bad3 == true){
		alert("Please select at least one resources with the airplane or select maintenance!");
		object.stud_list.style.background = "#FFCCFF";
		object.stud_list.focus();
		return false;	
	}
	if(numc != 1){
		if (object.comment.value == 0 ) {
			alert("Please Enter A Comment!");
			object.comment.style.background = "#FFCCFF";
			object.comment.focus();
			return false;		
		}
	}
	var nuum;
	nuum = object.end_h.value - object.start_h.value;
	if(nuum <= 0){
		alert("Invalid Appointment Time (less than 1 hour)!");
		object.end_h.focus();
		object.end_h.style.background = "#FFCCFF";
		return false;
	}
	object.submitme.value = "Please Wait While Inserting Appointments...";
	object.submitme.disabled = true;
	return checker;
}
function please_wait(object){
	object.Submitme.value = "Please Wait...";
	object.Submitme.disabled = true;
	return true;
}

function change_color(dome){
	dome.style.background  = "#CBDBE8";
	return true;
}

function deleteappt(){
	if(document.do_sch.deleteme.checked == false){
		document.do_sch.submitme.value = 'Edit Appointment';
		document.do_sch.submitme.style.background = '#000000';
		deletitnow.innerText = '';
	} else {
		document.do_sch.submitme.value = 'Delete Appointment';
		document.do_sch.submitme.style.background = '#FF0000';
		deletitnow.innerText = 'WARNING: You are Deleting Appointment!';
	}
	return true;
}
function isanumber(number) {
  answer = 1;
  if (!parseFloat(number) && number !=0) {
    //the first digit wasn't numeric
    answer = 0;
  } else {
    //the first digit was numeric, so check the rest
    for (var i=0; i<number.length; i++) {
      if ((number.charAt(i) != "0")
        && (!parseFloat(number.charAt(i)))) {
          answer = 0;
          break;
      }
    }
  }
  if (answer == 1) {
    orderPlaced = true;
  }
  return answer;
}

function openlink(idit) {
	var thelink;
	if(idit == 1){
		thelink = 'http://adds.aviationweather.noaa.gov/metars/stations.txt';
	}
	window.open(thelink,'popupWindow','toolbar=yes,location=no,directories=yes,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width=800,height=600,screenX=150,screenY=150,top=150,left=150')
}

function openwindow(idit) {
	var linkit = 'readme.php?id=' +idit;
	window.open(linkit,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=800,height=200,screenX=150,screenY=150,top=150,left=150')
}
function openimage(idit,len,wid) {
	var linkit = 'seeimage.php?id=' +idit;
	len = len+105;
	wid=wid+50;
	window.open(linkit,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=' + wid + ',height=' + len + ',screenX=150,screenY=150,top=150,left=150')
}
function openqk(idit,idit2) {
	var linkit;
	linkit = 'addcomment.php?id=' + idit;
	linkit += '&appt_id=' + idit2;
	len = 148;
	wid=650;
	window.open(linkit,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=' + wid + ',height=' + len + ',screenX=150,screenY=150,top=150,left=150')
}

function openpa(idit) {
	var linkit = 'viewall.php?td_=' +idit;
	len = 148;
	wid=650;
	window.open(linkit,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=' + wid + ',height=' + len + ',screenX=150,screenY=150,top=150,left=150')
}

function openap(idit,type) {
	var linkit = 'addpay.php?td_=' +idit;
	linkit += '&type=' + type;
	len = 165;
	wid=650;
	window.open(linkit,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=' + wid + ',height=' + len + ',screenX=150,screenY=150,top=150,left=150')
}

function view_pay(idit) {
	var linkit = 'pay_hist.php?vdx_=' +idit;
	len = 165;
	wid=650;
	window.open(linkit,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=' + wid + ',height=' + len + ',screenX=150,screenY=150,top=150,left=150')
}

function addword(idit) {
	var linkit = 'addword.php';
	len = 300;
	wid=650;
	window.open(linkit,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=' + wid + ',height=' + len + ',screenX=150,screenY=150,top=150,left=150')
}
function printme() {
  if (window.print)
    window.print()
  else
    alert("We Are Sorry, but your browser doesn't seem to support Javascript printing!");
}

function removespaces(string) {
	var tstring = "";
	string = '' + string;
	splitstring = string.split(" ");
	for(i = 0; i < splitstring.length; i++)
	tstring += splitstring[i];
	return tstring;
}

function add_date(object,date){
	temp_val = document.cal_see.the_list.value;
	temp = document.cal_see.the_list.value.split("\n");
	var i =0;
	var bad = false;
	while(temp[i] != null){
		nospace = temp[i].replace('\r','');
		if(nospace == date){
			bad = true;
		}
		i++;
	}

	if(bad == false){
		if(temp_val){
			new_val  = temp_val + '\n' + date;
			document.cal_see.the_list.value = new_val;
			document.ltr_sc.the_list.value = new_val;
		} else {
			document.cal_see.the_list.value = date;
			document.ltr_sc.the_list.value = date;
		}
	} else {
		alert("Date Is Already In The List!");
	}
}

function kill_me(type){
	if(type == 'start'){
		document.cal_see.the_list.disabled = true;
	} else {
		document.cal_see.the_list.disabled = false;
	}
	document.ltr_sc.the_list.value = document.cal_see.the_list.value;
}

function changepass(tb){
	if(tb == 'tg'){
		if(document.form_login.username.value == 'Username'){
			document.form_login.username.value = '';
		}
	}
}

function reloader(object,which){ 
	var url;
	if(which == '1'){ url =  'legends.php?id=' + object.options[object.selectedIndex].value;}
	if(which == '2'){ url =  'my_legend.php?id=' + object.options[object.selectedIndex].value;} 
	window.location.href = url;
	return true;
} 

function showresults(result_type){ 
	document.all.showresults.style.display ='inline';
	
	//total flight time (hoop)
	if(document.do_sch.hoop){
		start = document.do_sch.hoopstart.value;
		end = document.do_sch.hoop.value;
		temp = end - start;
		findflight = Math.round(temp*100)/100;
		
		if(document.do_sch.air_tot_c){
			air_timew = document.do_sch.air_tot_c.value;
		} else {
			air_timew = findflight;
		}
	
		//total flight time (tach)
		start2 = document.do_sch.tachstart.value;
		end2 = document.do_sch.tach.value;
		temp2 = end2 - start2;
		findflight2 = Math.round(temp2*100)/100;
	} else {
		findflight2 = 0;
		findflight = 0;
	}
	
	
	//airplane charge
	if(document.do_sch.a_fee){		
		a_charge = document.do_sch.a_fee.value;
		if (result_type == 1) {
			tot_a_charge =  findflight * a_charge;
		} else {
			tot_a_charge =  findflight2 * a_charge;
		}
	} else {
		tot_a_charge = 0;
	}
	ground = 0;
	
	//instructor pay
	if(document.do_sch.air_tot){
		i_paya = document.do_sch.air_tot.value;
		tot_i_paya =  air_timew * i_paya;
	} else {
		tot_i_paya = 0;
	}
	if(document.do_sch.gro_tot){
		i_payb = document.do_sch.gro_tot.value;
		tot_i_payb =  document.do_sch.gro_tot_c.value * i_payb;
		ground = document.do_sch.gro_tot_c.value;
	} else {
		tot_i_payb = 0;
	}
	tot_ip = tot_i_payb + tot_i_paya;

	//piolt fees
	if(tot_ip != 0){
		p_charge = tot_ip + tot_a_charge;
	} else {
		p_charge= 0;
	}
	
	
	var first_charge;
	var second_charge;
	var third_charge;
	var is_bad = true;
	var is_bad2 = true;
	if(document.do_sch.charge_1){
		if(document.do_sch.charge_1.value.length > 0){				
			var str=document.do_sch.charge_1_c.value;
			if (IsNotNumeric(str)) {is_bad = false;	}
			var str=document.do_sch.charge_1_a.value;
			if (!(check_dec(str))) {is_bad2 = false;}
			
			if(document.do_sch.charge_1_c.value && document.do_sch.charge_1_a.value && is_bad == true && is_bad2 == true){
				var first_charge = document.do_sch.charge_1_c.value * document.do_sch.charge_1_a.value;
				document.all.charge1s.style.display ='inline';
				document.all.charge1s.innerText = '$' + first_charge;
				document.do_sch.charge_one.value = first_charge;
			} else {
				if(is_bad == false){
					alert("Please make sure that the count is a number!");
					document.do_sch.charge_1_c.focus();
					document.do_sch.charge_1_c.style.background = "#FFCCFF";
				}
				if(is_bad2 == false){
					alert("Please make sure the price is in this Format: 00.00!");
					document.do_sch.charge_1_a.focus();
					document.do_sch.charge_1_a.style.background = "#FFCCFF";
				}
				document.do_sch.charge_one.value = '';
				document.all.charge1s.innerText = '';
			}
		}  else {
			document.do_sch.charge_one.value = '';
			document.all.charge1s.innerText = '';
			if(document.do_sch.charge_1_c.value >0 || document.do_sch.charge_1_a.value >0){
					alert("Please enter the description for entered amounts!");
					document.do_sch.charge_1.focus();
					document.do_sch.charge_1.style.background = "#FFCCFF";
			}

				
		}
	}
	var is_bad = true;
	var is_bad2 = true;
	if(document.do_sch.charge_2){
		if(document.do_sch.charge_2.value.length  > 0){
			var str=document.do_sch.charge_2_c.value;			
			if (IsNotNumeric(str)) {is_bad = false;	}
			var str=document.do_sch.charge_2_a.value;
			if (!(check_dec(str))) {is_bad2 = false;}
			
			if(document.do_sch.charge_2_c.value && document.do_sch.charge_2_a.value && is_bad == true && is_bad2 == true){
				var second_charge = document.do_sch.charge_2_c.value * document.do_sch.charge_2_a.value;
				document.all.charge2s.style.display ='inline';
				document.all.charge2s.innerText ='$' + second_charge;
				document.do_sch.charge_two.value = second_charge;
			} else {
				if(is_bad == false){
					alert("Please make sure that the count is a number!");
					document.do_sch.charge_2_c.focus();
					document.do_sch.charge_2_c.style.background = "#FFCCFF";
				}
				if(is_bad2 == false){
					alert("Please make sure the price is in this Format: 00.00!");
					document.do_sch.charge_2_a.focus();
					document.do_sch.charge_2_a.style.background = "#FFCCFF";
				}
				document.do_sch.charge_two.value = '';
				document.all.charge2s.innerText = '';
			}
		} else {
			document.do_sch.charge_two.value = '';
			document.all.charge2s.innerText = '';
			if(document.do_sch.charge_2_c.value >0 || document.do_sch.charge_2_a.value >0){
					alert("Please enter the description for entered amounts!");
					document.do_sch.charge_2.focus();
					document.do_sch.charge_2.style.background = "#FFCCFF";
			}
				
		}
	}
	
	var is_bad = true;
	var is_bad2 = true;
	if(document.do_sch.charge_3){
		if(document.do_sch.charge_3.value.length  > 0){
			var str=document.do_sch.charge_2_c.value;
			if (IsNotNumeric(str)) {is_bad = false;	}
			var str=document.do_sch.charge_2_a.value;
			if (!(check_dec(str))) {is_bad2 = false;}
			if(document.do_sch.charge_3_c.value && document.do_sch.charge_3_a.value && is_bad == true && is_bad2 == true){
				var third_charge = document.do_sch.charge_3_c.value * document.do_sch.charge_3_a.value;
				document.all.charge3s.innerText ='$' + third_charge;
				document.all.charge3s.style.display ='inline';
				document.do_sch.charge_three.value = third_charge;
			} else {
				if(is_bad == false){
					alert("Please make sure that the count is a number!");
					document.do_sch.charge_3_c.focus();
					document.do_sch.charge_3_c.style.background = "#FFCCFF";
				}
				if(is_bad2 == false){
					alert("Please make sure the price is in this Format: 00.00!");
					document.do_sch.charge_3_a.focus();
					document.do_sch.charge_3_a.style.background = "#FFCCFF";
				}
				document.do_sch.charge_three.value = '';
				document.all.charge3s.innerText = '';
			}
		} else {
			document.do_sch.charge_three.value = '';
			document.all.charge3s.innerText = '';
			if(document.do_sch.charge_3_c.value >0 || document.do_sch.charge_3_a.value >0){
					alert("Please enter the description for entered amounts!");
					document.do_sch.charge_3.focus();
					document.do_sch.charge_3.style.background = "#FFCCFF";
			}
		}
	}

	var tot_pp_ch;
	if(!(isNaN(first_charge))){
		tot_pp_ch = first_charge;
	}
	if(!(isNaN(second_charge))){
		tot_pp_ch += second_charge;
	}
	if(!(isNaN(third_charge))){
		tot_pp_ch += third_charge;
	}
	var rlength = 2
	var newnumber = Math.round(tot_a_charge*Math.pow(10,rlength))/Math.pow(10,rlength);
	var newnumber_o = Math.round(tot_ip*Math.pow(10,rlength))/Math.pow(10,rlength);
	var newnumber_z = Math.round(p_charge*Math.pow(10,rlength))/Math.pow(10,rlength);	
	
	document.all.first.innerText = findflight + ' Hrs. / ' + findflight2 + ' Hrs.';
	document.all.second.innerText = ground + ' Hrs.';
	document.all.third.innerText = '$' + newnumber;
	document.all.fourth.innerText ='$' + newnumber_o;
	if(tot_pp_ch > 0){
		var store = parseInt(p_charge + tot_pp_ch);
		var z_store = Math.round(store*Math.pow(10,rlength))/Math.pow(10,rlength);	
		document.all.fifth.innerText ='$' + z_store;	
	} else {
		document.all.fifth.innerText ='$' + newnumber_z;	
	}
	return true;
}


function hideres(){
	document.all.showresults.style.display ='none';
	return true;
}

function pop_up_alert(idit) {
	var linkit = 'view_alert.php?id=' + idit;
	len = 600;
	wid=650;
	window.open(linkit,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=' + wid + ',height=' + len + ',screenX=150,screenY=150,top=150,left=150')
}
function deleteit(idit,type,name,kindis) {
	if(type == 'u'){
		if(kindis == 'INST'){
			check_fault = confirm('REMOVING THE USER WILL DELETE THE ENTIRE FILE HOLD SHORT RECOMMENDS TO PUT THE USER AS A PIOLT THEN SET INACTIVE INSTEAD OF REMOVING THE USER, continue with deletion?');
			if(check_fault){
				check_fault2 = confirm('Please make sure the users balance is empty before you delete. Continue with deletion?');					
				if(check_fault2){
					var linkit = 'userman.php?removeuser=' + idit;
					window.open(linkit,'_parent')
				}
			}
		}
		if(kindis == 'STU'){
			check_fault = confirm('REMOVING THE USER WILL DELETE THE ENTIRE FILE HOLD SHORT RECOMMENDS TO PUT THE USER INACTIVE INSTEAD OF REMOVING THE USER, continue with deletion?');
			if(check_fault){
				check_fault2 = confirm('Please make sure the users balance is empty before you delete. Continue with deletion?');					
				if(check_fault2){
					var linkit = 'userman.php?removeuser=' + idit;
					window.open(linkit,'_parent')
				}
			}
		}
	}
	if(type == 'a'){
		check_fault = confirm('Are You Sure You Want To Delete Airplane: ' + name + '?');
		if(check_fault){
			var linkit = 'airman.php?removeair=' + idit;
			window.open(linkit,'_parent')
		}
	}
}

function check_dec(value){
	var str=value;
	var filter=   /^\d+(\.\d{2})$/;
	if (!(filter.test(str))) {
		return false;
	} else {
		return true;
	}
}
function IsNotNumeric(sText){
   var ValidChars = "0123456789.";
   var IsNotNumber=false;
   var Char;
   var add_me =0;
   for (i = 0; i < sText.length && IsNotNumber == false; i++) { 
      Char = sText.charAt(i); 
	   if(Char == '.'){ add_me++;}
      if (ValidChars.indexOf(Char) == -1) {		 
         IsNotNumber = true;
      }
   }
   if(add_me > 1){
	   IsNotNumber = true;
   }
   return IsNotNumber;
}

