//Validate fax number
function checkFax(customer_fax) {
	var faxVal=customer_fax.value;
	var faxLen=faxVal.length;
	var Nums = "0123456789-.()";
	var theDigit="";
	var soFar="";
    var theDigit="";
	for (i=0;i<faxLen;i++) {
		theDigit = faxVal.charAt(i);
		if (Nums.indexOf(theDigit)==-1) {
			customer_fax.value=soFar;
			alert("Fax numbers may not contain  " + theDigit + ".  Please enter a valid Fax Number in this format - xxx-xxx-xxxx.");
			customer_fax.focus();
			customer_fax.select();
			return false;
			}
			soFar=soFar+theDigit;
		}
		return true;
	}

//Validate Phone Number
function checkPhone(customer_phone) {
	var phoneVal=customer_phone.value;
	var phoneLen=phoneVal.length;
	var Nums = "0123456789-.()";
	var theDigit="";
	var soFar="";
    var theDigit="";
	for (i=0;i<phoneLen;i++) {
		theDigit = phoneVal.charAt(i);
		if (Nums.indexOf(theDigit)==-1) {
			customer_phone.value=soFar;
			alert("Phone numbers may not contain  " + theDigit + ".  Please enter a valid Phone Number in this format - xxx-xxx-xxxx.");
			customer_phone.focus();
			customer_phone.select();
			return false;
			}
			soFar=soFar+theDigit;
		}
		return true;
	}

//Validate Part number
function engNo(part_no){
    var partVal=part_no.value;
	if(isNaN(partVal)){
	 alert("You must enter a number for part number");
	 part_no.focus();
	 part_no.select();
	} 
}	


function tenable(form){
   if (form.qec.selectedIndex==1){
       form.aircraft_type.disabled=false;
       form.aircraft_type.focus();
	 }
   else
     form.aircraft_type.disabled=true;	 
}	 

function check(form){

	if (form.engine_type.value =="") {
		alert("You must fill in an Engine Type.");
  		form.engine_type.focus();
   	return false;
   	}
   	else
	if (form.engine_number.value =="") {
		alert("You Must Fill in the Number of Engines Required.");
  		form.engine_number.focus();
   	return false;
   	}
	else
	if ((form.qec.selectedIndex==1) && (form.aircraft_type.value =="")) {
	    alert("You must fill in the aircraft type.");
		form.aircraft_type.focus();
	return false;
	}	
    else
	if (form.customer_name.value =="") {
		alert("You Must Fill in the Requester Name.");
  		form.customer_name.focus();
   	return false;
   	}
   	else

	if (form.customer_company.value =="") {
		alert("You Must Fill in the Company Name.");
  		form.customer_company.focus();
   	return false;
   	}
   	else
	
	if (form.customer_address.value =="") {
		alert("You Must Fill in the Address.");
  		form.customer_address.focus();
   	return false;
   	}
   	else
	if (form.customer_address_2.value =="") {
		alert("You Must Fill in the Address.");
  		form.customer_address_2.focus();
   	return false;
   	}
   	else
	if (form.customer_phone.value =="") {
		alert("You Must Fill in the Phone Number.");
  		form.customer_phone.focus();
   	return false;
   	}
	else
	if (form.customer_fax.value =="") {
		alert("You Must Fill in the Fax Number.");
  		form.customer_fax.focus();
   	return false;
   	}
        else
	if (validEmail(form.customer_email) == false){
		alert("Please Enter a Valid Email Address.");
  		form.customer_email.focus();
		return false;
		}
   
   else
   {   
          return true;
    }   
}

// Validate E-mail address format
function validEmail(elm) {
if (elm.length < 7)  { 
    return false;
}
else
if (elm.value.indexOf("@") == "-1" || 
	    elm.value.indexOf(".") == "-1")
	return false;
	else return true;
} 

function checkFax(customer_fax) {
	var faxVal=customer_fax.value;
	var faxLen=faxVal.length;
	var Nums = "0123456789-.()";
	var theDigit="";
	var soFar="";
    var theDigit="";
	for (i=0;i<faxLen;i++) {
		theDigit = faxVal.charAt(i);
		if (Nums.indexOf(theDigit)==-1) {
			customer_fax.value=soFar;
			alert("Fax numbers may not contain  " + theDigit + ".  Please enter a valid Fax Number in this format - xxx-xxx-xxxx.");
			customer_fax.focus();
			customer_fax.select();
			return false;
			}
			soFar=soFar+theDigit;
		}
		return true;
	}


function checkPhone(customer_phone) {
	var phoneVal=customer_phone.value;
	var phoneLen=phoneVal.length;
	var Nums = "0123456789-.()";
	var theDigit="";
	var soFar="";
    var theDigit="";
	for (i=0;i<phoneLen;i++) {
		theDigit = phoneVal.charAt(i);
		if (Nums.indexOf(theDigit)==-1) {
			customer_phone.value=soFar;
			alert("Phone numbers may not contain  " + theDigit + ".  Please enter a valid Phone Number in this format - xxx-xxx-xxxx.");
			customer_phone.focus();
			customer_phone.select();
			return false;
			}
			soFar=soFar+theDigit;
		}
		return true;
	}

	
//Validate Part number
function partNo(part_no){
    var partVal=part_no.value;
	if(isNaN(partVal)){
	 alert("You must enter a number for number of engines.");
	 part_no.focus();
	 part_no.select();
	} 
}	