/*QUOTE ENGINE FORM VALIDATION. WORKS TOGETHER WITH THE dateValidationUtil.js file for dates validation 
var curr_yyyy,var curr_mm,var curr_dd are taken from CF server, so these values must be defined on the page before quote_validation file is linked.
*/
  
//to calculate how many participants we have	
function validate(thisForm) {
     var part_age_under19 = false;
     var age_over18 = false;
	 var t_mm = curr_mm< 10?"0"+curr_mm:curr_mm;
	 var t_dd = curr_dd< 10?"0"+curr_dd:curr_dd;
	 var todaysDate = t_mm +"/"+t_dd+"/"+curr_yyyy;
	 
	 var dp_dt_msg = "Effective Date";
	 var part_name = "Participant";
	 
	  with (thisForm) {
	    
	    
		 if (trip_departure_date.value =="" ||!dateFormat(trip_departure_date.value)) {
		       alert("Please select a valid "+dp_dt_msg+".");
			   trip_departure_date.focus();
			   return false;
			   }
		  else {
		      
	           d_mm = convertDtStr(trip_departure_date.value,'mm');
	           d_dd = convertDtStr(trip_departure_date.value,'dd');
		       d_yyyy = convertDtStr(trip_departure_date.value,'yy');
		
		    }
		   if (datesDaysDiff(d_mm,d_dd,d_yyyy,curr_mm,curr_dd+1,curr_yyyy) < 0){
		       alert("For student products, your must pick a departure date after today.");
			   return false;
		   }
		  
		  
		   if (monthsDiff(d_mm,d_dd,d_yyyy,curr_mm,curr_dd,curr_yyyy) > 6){
		       alert("You must select " +dp_dt_msg+" within the next six months.");
			   return false;
		   }
		   if (datesDaysDiff(4,1,2013,d_mm,d_dd,d_yyyy) <= 0){
		       alert("Please pick a date prior to April 1, 2013.");
			   return false;
		   }
		  
		   if (state_prov.selectedIndex == '0'){
		           alert("Please select a state or province.");
				   state_prov.focus();
		           return false;
		        }
		  
		   if (month1.selectedIndex == 0 || day1.selectedIndex == 0||year1.selectedIndex == 0) {
                      alert("Please enter a date of birth of the "+part_name+".");
					  month1.focus();
				      return false;
				  }
			
			if (month1.selectedIndex != 0 && day1.selectedIndex != 0 && year1.selectedIndex != 0 && !checkDayMonthYear(month1[month1.selectedIndex].value,day1[day1.selectedIndex].value,year1[year1.selectedIndex].value)) {
                      alert("Please enter a valid date of birth.");
					  month1.focus();
				      return false;
				  }
		   var stud_age = parseInt(getAgefromDOB(month1[month1.selectedIndex].value,day1[day1.selectedIndex].value,year1[year1.selectedIndex].value,d_mm,d_dd,d_yyyy));
	              //alert(stud_age);
		   if (stud_age < 14) {
				     alert("You have to be 14  at the coverage start date.");
					 return false;
				   }
		   if (stud_age > 64) {
				   alert("You will be "+stud_age+" at the coverage start date. Individuals older than age 64 are not eligible for Global Student plans.");
					       return false;
				   }
				
		 
		}//form scope ends
		
		return true;
	}
	
