function getSelectedButton(buttonGroup){
	for (var i = 0; i < buttonGroup.length; i++) {
	 
		if (buttonGroup[i].checked) {
			return i
		}
	}
	return 99
}
//  ##################################################
function chkforcode(str) {
	var bad_val = "";
	
	var badstrings = new Array(4)
		badstrings[0] = "www"
		badstrings[1] = "http"
		//badstrings[2] = ".com"
		//badstrings[3] = ".net"
		badstrings[2] = "url"
		badstrings[3] = "href"
	
	for (var i = 0; i < badstrings.length; i++) {
		bad_val = badstrings[i];
		 // alert(bad_val);
		this_result = str.search(bad_val);
		// alert (this_result);
					// returns -1 if value not found
		if (this_result > -1) {
			return this_result
		}
	}
	return this_result
}

///++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

function chkfields () {
   f=document.feedbackfrm;
   var badCount = 0;
   var goodchars = 0;
   var data_entered = 0;
   var msg = "";

// Satisfied?
	 var i = getSelectedButton(f.f_satisfied)
	 if ((i==0) || (i==1)) {
		 data_entered = 1;
	 } else {
		 if (i!=99) {
		   	badCount = badCount + 1;
		   	msg = msg + "\nChoose Yes or No for your satisfication.";
		 }
   	 } 
	
// Driver Arrive on Time
	 var i = getSelectedButton(f.f_arriveontime)
   	 if ((i==0) || (i==1)) {
		 data_entered = 1;
	 } else {
		 if (i!=99) {
			badCount = badCount + 1;
		    msg = msg + "\nChoose Yes or No for driver arriving on time.";
		 }
   	} 
	
// Trip end as scheduled
	 var i = getSelectedButton(f.f_endsched)
	 if ((i==0) || (i==1)) {
		 data_entered = 1;
		 if ((i==1) && (f.f_endsched_comments.value == "")) {
			badCount = badCount + 1;
     		msg = msg + "\nPlease comment on why the trip did not end as sheduled.";
		 }
	 } else {
		  if (i!=99) {
			 badCount = badCount + 1;
		     msg = msg + "\nChoose Yes or No for trip ending as scheduled.";
		  } 
   	 }
	
// Trip everything you expected	
	 var i = getSelectedButton(f.f_expected)
   	 if ((i==0) || (i==1)) {
		 data_entered = 1;
		 if ((i==1) && (f.f_expected_comments.value == "")) {
			badCount = badCount + 1;
	     	msg = msg + "\nPlease comment on why the trip was not what you expected.";
		 }
	 } else {
		  if (i!=99) {
			 badCount = badCount + 1;
		     msg = msg + "\nChoose Yes or No for whether the trip was everything that you expected.";
		  } 
   	}
	
// Use AA Trans. again?  f_useagain
	 var i = getSelectedButton(f.f_useagain)
   	 if ((i==0) || (i==1)) {
		 data_entered = 1;
		 if ((i==1) && (f.f_useagain_comments.value == "")) {
			badCount = badCount + 1;
	     	msg = msg + "\nPlease comment on why you will not use our services again.";
		 }
	 } else {
		if (i!=99) {
		 	badCount = badCount + 1;
		    msg = msg + "\nChoose Yes or No for whether you will use our services again.";
		} 
     }
	 
// Hear about AA TRans. 
	curval = f.f_hearabout.value;
	if (curval.length > 0) {
		tmp = chkforcode(curval);
		// alert (tmp);
		if (tmp > -1) {
			badCount = badCount + 1;
			msg = msg + "\nEnter Valid comments for how you heard about AA Transportation.";
		 } else {
			data_entered = 1;
		 }
	} 
	
// Recommend AA Trans.?
	 var i = getSelectedButton(f.f_recommend)
	 if ((i==0) || (i==1)) {
		 data_entered = 1;
	 } else {
		 if (i!=99) {
	     	badCount = badCount + 1;
	     	msg = msg + "\nChoose Yes or No for whether you will recommend us.";
		 } 
   	}
	
// Someone else
	curval = f.f_someone_else.value;
	if (curval.length > 0) {
		tmp = chkforcode(curval);
		// alert (tmp);
		if (tmp > -1) {
			badCount = badCount + 1;
			msg = msg + "\nEnter Valid information when recommending someone else.";
		} else {
			data_entered = 1;
		}
	}
	
//E-mail

	if (f.f_email.value != "") {
   		inputVal = f.f_email.value;
   		inputStr = inputVal.toString()
    
   		for (var i = 0; i < inputStr.length; i++) { 
      		var oneChar = inputStr.charAt(i) 
      		if (oneChar == "." || oneChar == "@") { 
         		goodchars = goodchars + 1;
      		}  
   		}
		if (goodchars <2) {
   			badCount = badCount + 1;
			msg = msg + "\nEnter a valid E-mail address.";
		 } 
	}
	
	
// Charter Services
	 var i = getSelectedButton(f.f_charter)
   	 if ((i==0) || (i==1)) {
		 data_entered = 1;
	 } else {
		 if (i!=99) {
	     	badCount = badCount + 1;
	     	msg = msg + "\nChoose Yes or No for whether you want to learn more about our Charter Services.";
		 } 
   	}
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
	if (data_entered == 0) {
		badCount = badCount + 1;
		msg = msg + "\nNo ratings detected. Please rate our services.";
	} else {
		var curfld=("f.f_use_feedback")
		var this_info = eval(curfld +".options[" +curfld +".selectedIndex].value");
		if ((this_info != "Yes") && (this_info != "No")) {
			msg = msg + "\nIndicate whether we can use your feedback.";
			badCount = badCount + 1;
		}
	}
	
	if (badCount == 0) {
    	return true;
    } else {
    	alert (msg);
      	return false;
    }

} 
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&