/***********************************/
function popHelp (winWidth, winHeight, sTitle, sText) {
	reportWin = window.open("","","width="+winWidth+",height="+winHeight+",toolbar=no,menubar=no,scrollbars=yes");
	var sContent = ("<HTML><HEAD><LINK REL=stylesheet TYPE='text/css' HREF='../files/common/css/toolbox/calculator_tools.css' TITLE=devis></HEAD><body BGCOLOR=#FFFFFF leftmargin=0 topmargin=0 marginwidth=0 marginheight=0><div style='margin-left:10px;margin-right:10px;margin-top:10px;'><p><b>"+sTitle+"</b><br><br>" + sText + "</div><br><div align=center><a href='javascript:window.close()'>Close the window</a></div><br>");
	reportWin.document.write(sContent);
	reportWin.document.close();
}

/************************************/
function removeSpaces(string) 
	{
	var temp = "";
	string = '' + string;
	splitstring = string.split(" ");
	for(i = 0; i < splitstring.length; i++)
	temp += splitstring[i];
	return temp;
	}
	

/************************************/
function validatePrompt (Ctrl, PromptStr) 
{
    alert (PromptStr);
    Ctrl.focus(); return;
} 


/************************************/
function isNumberString (InString) 
{
    if (InString.length==0) return (false);
    var RefString="1234567890";
    for (Count=0; Count < InString.length; Count++)
		{
        TempChar=InString.charAt(Count);
        if (RefString.indexOf (TempChar, 0)==-1) return (false);
    	} 
	return (true);
}

/***********************************/
function firstName(theform)
{
	if (removeSpaces(theform.firstinsured.value)=="") 
		{
		alert("On the form please answer the question: What is your 1st named insured? and resubmit.");
		theform.firstinsured.focus();
		return(false);
		}
	 else{return(true);}
}

/***********************************/
function authorization(theform)
{
	if (!theform.owner.checked) 
		{
		alert("On the form please check the authorization box and resubmit.");
		theform.owner.focus();
		return(false);
		}
	 else{return(true);}
}

/***********************************/
function preferredComm(theform)
{
	if ((!theform.comfollow[0].checked)&&(!theform.comfollow[1].checked)) 
		{
		alert("On the form please select your preferred means of communication for contact and follow-up .");
		theform.comfollow[0].focus();
		return(false);
		}
	 else{return(true);}
}

/***********************************/
function valEmail(theform)
{
	if (removeSpaces(theform.from.value)=="") 
		{
		alert("On the form please answer the question: What is your e-mail? and resubmit.");
		theform.from.focus();
		return(false);
		}
	 else
	 	{if (theform.from.value.indexOf("@") == -1 || theform.from.value=="" || theform.from.value.indexOf(".") == -1)  
			{
			alert("The e-mail address entered is not valid.  Please enter the e-mail address using the required format.");
			theform.from.focus();
			return (false);
 			}
	 		else{return(true);}		
		}
}

/***********************************/
function valPhone(theform)
{
	if (removeSpaces(theform.day_telephone.value)!="") 
		{
		if (theform.day_telephone_area_code.value=="")
			{
			alert("Please specify the area code for your daytime telephone number");
			theform.day_telephone_area_code.focus();
			return(false);
			}
		else 
			{
			if (!isPhoneNumberValid(theform.day_telephone.value)) 
				{
				alert("Please delete or replace all special characters in the daytime telephone number");
				theform.day_telephone.focus();
				return(false);
				}
			else
				{
				if (removeSpaces(theform.day_telephone_ext.value)!="") 
					{
					if (!isPhoneNumberValid(theform.day_telephone_ext.value)) 
						{
						alert("Please delete or replace all special characters in the daytime telephone number ext.");
						theform.day_telephone_ext.focus();
						return(false);
						}
					 else{return(true);}
					}
				 else{return(true);}
				}
			}
		}
	else{return(true);}
}


/***********************************/
function valPhoneHome(theform)
{
	if (removeSpaces(theform.home_telephone.value)!="") 
		{
		if (theform.home_telephone_area_code.value=="")
			{
			alert("Please specify the area code for your home telephone number");
			theform.home_telephone_area_code.focus();
			return(false);
			}
		else
			{
			if (!isPhoneNumberValid(theform.home_telephone.value)) 
				{
				alert("Please delete or replace all special characters in the home telephone number");
				theform.home_telephone.focus();
				return(false);
				}
			else{return(true);}
			}		
		}
	else{return(true);}
}

/********************************/
function driverFirstName(theform)
{
	if (theform.driver_first_name_1.value == "") 
		{
   	alert("On the form please enter the Driver's first name and resubmit.");
    	theform.driver_first_name_1.focus();
    	return (false);
		}
	else{return(true);}
}

/***************************************/
function driverLastName(theform)
{
	if (theform.driver_last_name_1.value == "") 
		{
	   alert("On the form please enter the Driver's last name and resubmit.");
    	theform.driver_last_name_1.focus();
    	return (false);
		}
	else{return(true);}
}


/************************************/
function isDateValid(day,month,year,field) 
{
	/* Begin validation day */
	if (day=="") 
		{
		alert("On the form please enter a valid day for the question : " + field);
		return(false);
		}
	if (isNaN(day)) 
		{
		alert("On the form please enter a valid day for the question : " + field);
		return(false);
		}
	if ((day)>31) 
		{
		alert("On the form please enter a valid day for the question : " + field);
		return(false);
		}
	/* End validation day */
	/* Begin validation month */
	if (month=="") 
		{
		alert("On the form please enter a valid month for the question : " + field);
		return(false);
		}
	if (isNaN(month)) 
		{
		alert("On the form please enter a valid month for the question : " + field);
		return(false);
		}
	if (month>12) 
		{
		alert("On the form please enter a valid month for the question : " + field);
		return(false);
		}
	/* End validation month */
	/* Begin validation year */
	if (year=="") 
		{
		alert("On the form please enter a valid year for the question : " + field);
		return(false);
		}
	if (isNaN(year)) 
		{
		alert("On the form please enter a valid year for the question : " + field);
		return(false);
		}
	return(true);
}

/*****************************/
function birthDate(theform)
{
	if ((theform.birth_date_day1.value == "")||(theform.birth_date_month1.value == "")||(theform.birth_date_year1.value == "")) 
		{
    	alert("On the form please enter a birth date and resubmit.");
	  	theform.birth_date_day1.focus();
     	return (false);
		}
	 else
		{
		if (!isDateValid(theform.birth_date_day1.value, theform.birth_date_month1.value, theform.birth_date_year1.value, "Date of birth:" )) 
			{
			theform.birth_date_day1.focus();
			return(false);
			}
		else{return(true)}
		}
}


/***************************************/
function maritalStatus(theform)
{
	if (!theform.marital_status[1].selected && !theform.marital_status[2].selected && !theform.marital_status[3].selected && !theform.marital_status[4].selected && !theform.marital_status[5].selected && !theform.marital_status[6].selected) 
		{
	   alert("On the form please select a marital status and resubmit.");
    	theform.marital_status.focus();
    	return (false);
		}
	 else{return(true);}
}


/*************************************/
function relationship(theform)
{
	if (!theform.relationship_to_insured[1].selected && !theform.relationship_to_insured[2].selected && !theform.relationship_to_insured[3].selected && !theform.relationship_to_insured[4].selected && !theform.relationship_to_insured[5].selected && !theform.relationship_to_insured[6].selected) 
		{
	   alert("On the form please select a relationship to insured and resubmit.");
    	theform.relationship_to_insured.focus();
    	return (false);
		}
	 else{return(true);}
}

/*******************************************/
function licenceNumber(theform)
{
	if (theform.licence_number.value=="") 
		{
    	alert("On the form please enter the driver's licence number and resubmit.");
    	theform.licence_number.focus();
    	return (false);
		}
	 else{return(true);}		
}

/****************************************/
function licenceClass7(theform)
{
	if (!theform.licence_class[1].selected && !theform.licence_class[2].selected && !theform.licence_class[3].selected && !theform.licence_class[4].selected && !theform.licence_class[5].selected && !theform.licence_class[6].selected && !theform.licence_class[7].selected) 
		{
	   alert("On the form please select a class of licence and resubmit.");
    	theform.licence_class.focus();
    	return (false);
		}
	 else{return(true);}		
}

/****************************************/
function licenceClass10(theform)
{
	if (!theform.licence_class[1].selected && !theform.licence_class[2].selected && !theform.licence_class[3].selected && !theform.licence_class[4].selected && !theform.licence_class[5].selected && !theform.licence_class[6].selected && !theform.licence_class[7].selected && !theform.licence_class[8].selected && !theform.licence_class[9].selected && !theform.licence_class[10].selected) 
		{
	   alert("On the form please select a class of licence and resubmit.");
    	theform.licence_class.focus();
    	return (false);
		}
	 else{return(true);}		
}

/*************************************/
function licenceNbYears(theform)
{
	if (!theform.licence_years[1].selected && !theform.licence_years[2].selected && !theform.licence_years[3].selected && !theform.licence_years[4].selected && !theform.licence_years[5].selected && !theform.licence_years[6].selected && !theform.licence_years[7].selected) 
		{
	   alert("On the form please select a number of years with a valid driver's licence and resubmit.");
    	theform.licence_years.focus();
    	return (false);
		}
	 else{return(true);}		
}

/***************************************/
function cancelDeclined(theform)
{
	if (!theform.canceled_or_declined_ind[0].checked && !theform.canceled_or_declined_ind[1].checked) 
		{
	   alert("On the form please answer the question by clicking the check box 'yes' or 'no' and resubmit.");
    	theform.canceled_or_declined_ind[0].focus();
    	return (false);
		}
 	 else{return(true);}		
}

/****************************************/
function trainingCourse(theform)
{
	if (!theform.training_course[0].checked && !theform.training_course[1].checked) 
		{
    	alert("On the form please answer the question by clicking the check box 'yes' or 'no' and resubmit.");
    	theform.training_course[0].focus();
    	return (false);
		}
	 else{return(true);}		
}		

/************************************/
function claims6(theform)
{
	if (!theform.claims_in_6_years[0].checked && !theform.claims_in_6_years[1].checked) 
		{
    	alert("On the form please answer the question by clicking the check box 'yes' or 'no' and resubmit.");
    	theform.claims_in_6_years[0].focus();
    	return (false);
		}
	 else
	 	{		
		 if (theform.claims_in_6_years[0].checked) 
		 	{
	    	if (!valid_claim_year(theform,"11") || !valid_claim_month(theform,"11") || !valid_claim_type(theform,"11") || !valid_claim_amount(theform,"11") ||
	    	    !valid_claim_year(theform,"21") || !valid_claim_month(theform,"21") || !valid_claim_type(theform,"21") || !valid_claim_amount(theform,"21") || 
	    	    !valid_claim_year(theform,"31") || !valid_claim_month(theform,"31") ||	 !valid_claim_type(theform,"31") || !valid_claim_amount(theform,"31"))
				{
	 			return (false);
				}
			 else{return(true);}	
			}
		else{return(true);}	
		}
}

/************************************/
function conviction(theform)
{
	if (!theform.convictions_in_3_years[0].checked && !theform.convictions_in_3_years[1].checked) 
		{
    	alert("On the form please answer the question by clicking the check box 'yes' or 'no' and resubmit.");
    	theform.convictions_in_3_years[0].focus();
    	return (false);
		}	
	  else
	  	{ 
	  	if (theform.convictions_in_3_years[0].checked  && !theform.minor_convictions1[1].selected && !theform.minor_convictions1[2].selected && !theform.minor_convictions1[3].selected && !theform.minor_convictions1[4].selected && !theform.minor_convictions1[5].selected && !theform.minor_convictions1[6].selected) 
			{
	  		alert("On the form please select How many MINOR traffic violations has this driver had in the last 3 years and resubmit.");
	     	theform.minor_convictions1.focus();
	     	return (false);
	  		}
	  	else
			{
	  		if (theform.convictions_in_3_years[0].checked  && !theform.major_convictions1[1].selected && !theform.major_convictions1[2].selected && !theform.major_convictions1[3].selected && !theform.major_convictions1[4].selected && !theform.major_convictions1[5].selected && !theform.major_convictions1[6].selected) 
				{
  			     alert("On the form please select How many MAJOR traffic violations has this driver had in the last 3 years and resubmit.");
			     theform.major_convictions1.focus();
			     return (false);
	  			}
			 else	  
			 	{
	  			if (theform.convictions_in_3_years[0].checked  && theform.minor_convictions1[1].selected && theform.major_convictions1[1].selected) 
					{
	    			alert("On the form please select at least 1 traffic violation for this driver and resubmit.");
	     			theform.minor_convictions1.focus();
	     			return (false);
					}
				 else{return(true)};
				}
			}
		}
}

/***************************************/
function driverType(theform)
{
	if (!theform.driver_type_1[1].selected && !theform.driver_type_1[2].selected) 
		{
	  	alert("On the form please enter the Driver's type and resubmit.");
	   	theform.driver_type_1.focus();
	   	return (false);
		}
	 else{return(true);}
}


/*******************************************/
function ValDateDay(theform)
{
	if (theform.day.value=="") 
		{
		alert("On the form please enter a valid day for the question: When will this change be effective? and resubmit.");
		theform.day.focus();
		return(false);
		}
	 else
	 	{
		if (isNaN(theform.day.value)) 
			{
			alert("On the form please enter a valid day for the question: When will this change be effective? and resubmit.");
			theform.day.focus();
			return(false);
			}
		else
			{
			if ((theform.day.value)>31) 
				{
				alert("On the form please enter a valid day for the question: When will this change be effective? and resubmit.");
				theform.day.focus();
				return(false);
				}
			else{return(true);}
			}
		}
}	
	
	
/*************************************************/
function ValDateMonth(theform)
{
	if (theform.month.value=="") 
		{
		alert("On the form please enter a valid month for the question: When will this change be effective? and resubmit.");
		theform.month.focus();
		return(false);
		}
	else
		{
		if (isNaN(theform.month.value)) 
			{
			alert("On the form please enter a valid month for the question: When will this change be effective? and resubmit.");
			theform.month.focus();
			return(false);
			}
		else
			{
			if ((theform.month.value)>12) 
				{
				alert("On the form please enter a valid month for the question: When will this change be effective? and resubmit.");
				theform.month.focus();
				return(false);
				}
			else{return(true);}
			}
		}
}


/**************************************************/
function ValDateYear(theform)
{
	if (theform.year.value=="") 
		{
		alert("On the form please enter a valid year for the question: When will this change be effective? and resubmit.");
		theform.year.focus();
		return(false);
		}
	else
		{
		if (isNaN(theform.year.value)) 
			{
			alert("On the form please enter a valid year for the question: When will this change be effective? and resubmit.");
			theform.year.focus();
			return(false);
			}	
			else{return(true);}		
		}
}	
	

/*************************************************/
function oldNumber(theform)
{
	if (theform.oldnumber.value=="") 
		{
		alert("On the form please answer the question: What is your prior number and street? and resubmit.");
		theform.oldnumber.focus();
		return(false);
		}
	 else{return(true);}
}


/*************************************************/
function oldCity(theform)
{
	if (theform.oldcity.value=="") 
		{
		alert("On the form please answer the question: What is your prior city? and resubmit.");
		theform.oldcity.focus();
		return(false);
		}
	else{return(true);}	
}


/*****************************************/
function oldPostal(theform)
{
	theform.oldpostalcode.value = removeSpaces(theform.oldpostalcode.value);

	if (theform.oldpostalcode.value=="") 
		{
		alert("On the form please answer the question: What is your prior postal code? and resubmit.");
		theform.oldpostalcode.focus();
		return(false);
		}
	else{return(true)}
}


/*****************************************/
function newNumber(theform)
{
	if (theform.newnumber.value=="") 
		{
		alert("On the form please answer the question: What is your new number and street? and resubmit.");
		theform.newnumber.focus();
		return(false);
		}
	else{return(true);}
}


/*****************************************/
function newCity(theform)
{
	if (theform.newcity.value=="") 
		{
		alert("On the form please answer the question: What is your new city? and resubmit.");
		theform.newcity.focus();
		return(false);
		}
	else{return(true)}
}


/************************************************/
function newPostalCode(theform)
{
	theform.newpostalcode.value = removeSpaces(theform.newpostalcode.value);

	if (theform.newpostalcode.value=="") 
		{
		alert("On the form please answer the question: What is your new postal code? and resubmit.");
		theform.newpostalcode.focus();
		return(false);
		}
	else{return(true)}		
}


/*****************************************************/
function newHomePhone(theform)
{
	if (removeSpaces(theform.newhome_tel.value)!="") 
		{
		if (!isPhoneNumberValid(theform.newhome_tel.value)) 
			{
			alert("Please delete or replace all special characters in the new home telephone number");
			theform.newhome_tel.focus();
			return(false);
			}
		 else{return(true);}
		}
	 else{return(true);}
}

/************************************/
function newBusinessPhone(theform)
{
	if (removeSpaces(theform.newbusiness_tel.value)!="") 
		{
		if (!isPhoneNumberValid(theform.newbusiness_tel.value)) 
			{
			alert("Please delete or replace all special characters in the new business telephone number");
			theform.newbusiness_tel.focus();
			return(false);
			}
		else
			{
			if (removeSpaces(theform.newbusiness_tel_ext.value)!="") 
				{	
				if (!isPhoneNumberValid(theform.newbusiness_tel_ext.value))
					{
					alert("Please delete or replace all special characters in the new business telephone number ext.");
					theform.newbusiness_tel_ext.focus();
					return(false);
					}
				 else{return(true);}
				}
			 else{return(true);}
			}		
		}
	 else{return(true);}
}


/*************************************************/
function valInsurance1(theform)
{
	
		if (!theform.company1[1].selected && !theform.company1[2].selected && !theform.company1[3].selected && !theform.company1[4].selected)
			{
			alert("On the form please select a company and resubmit.");
			return(false);
			}
		 else{return(true);}
		
}			


/******************************************************/
function valInsurance2(theform)
{
	if (!theform.company2[0].selected && (!theform.insurance2[1].selected && !theform.insurance2[2].selected && !theform.insurance2[3].selected && !theform.insurance2[4].selected && !theform.insurance2[5].selected && !theform.insurance2[6].selected))
		{
		alert("On the form please specify the type of insurance and resubmit.");
		return(false);
		}
	 else
	 	{
		if (!theform.insurance2[0].selected && (!theform.company2[1].selected && !theform.company2[2].selected && !theform.company2[3].selected))
			{
			alert("On the form please select a company and resubmit.");
			return(false);
			}
		 else
		 	{
			if (theform.company2[3].selected && theform.companyother2.value=="") 
				{
				alert("On the form please specify the company and resubmit.");
				theform.companyother2.focus();
				return(false);
				}
			 else{return(true);}
			}
		}
}


/*************************************************/
function valInsurance3(theform)
{
	if (!theform.company3[0].selected && (!theform.insurance3[1].selected && !theform.insurance3[2].selected && !theform.insurance3[3].selected && !theform.insurance3[4].selected && !theform.insurance3[5].selected && !theform.insurance3[6].selected))
		{
		alert("On the form please specify the type of insurance and resubmit.");
		return(false);
		}
	 else
	 	{
		if (!theform.insurance3[0].selected && (!theform.company3[1].selected && !theform.company3[2].selected && !theform.company3[3].selected))
			{
			alert("On the form please select a company and resubmit.");
			return(false);
			}
		 else
		 	{
			if (theform.company3[3].selected && theform.companyother3.value=="") 
				{
				alert("On the form please specify the company and resubmit.");
				theform.companyother3.focus();
				return(false);
				}
			 else{return(true);}
			}
		}
}



/*****************************************/
function purchaseVehicle(theform)
{
	if (theform.purchase_status1.value == "") 
		{
        validatePrompt (theform.purchase_status1, "Please enter the condition at time of purchase"); 
		return (false);
		}
	 else 
	 	{
	 	if ((theform.purchase_date_day1.value == "")||(theform.purchase_date_month1.value == "")||(theform.purchase_date_year1.value == "")) 
	 		{
			alert("Please enter a purchase date");
			theform.purchase_date_day1.focus();
      		return (false);
    		}
	 	 else
			{
			if (!isDateValid(theform.purchase_date_day1.value,
					   theform.purchase_date_month1.value,
					   theform.purchase_date_year1.value,
					   "Purchase date :" )) 
				{
				theform.purchase_date_day1.focus();
				return(false);
				}
			 else
			 	{	
				if (theform.purchase_price.value == "") 
					{
		        	validatePrompt (theform.purchase_price, "Please enter a purchase price"); 
					return (false);
					}
				else
					{
					if (isNaN(theform.purchase_price.value)) 
						{
						validatePrompt (theform.purchase_price, "Only numeric characters are allowed for the purchase price"); 
						return (false);
						}
						else{return(true);}
					}
				}
			}
		}
}						


/*****************************************/

function serialNumber(theform)
{
Ctrl = theform.serial_no;
    if (Ctrl.value == "") 
    {
        validatePrompt (Ctrl, "Please enter vehicle serial number."); 
        return (false);
    } 
        else
         {
        Ctrl2 = theform.vehicle_year1;
        if (Ctrl2.value > "1980") 
        {
            var serie = Ctrl.value;
            var ModelYear = serie.charAt(9);
            var SequenceNumber = serie.substring(12,17);
            TestSequenceNumber = isNumberString (SequenceNumber);
            if (serie.length != 17 | TestSequenceNumber != 1)
             {
                validatePrompt (Ctrl, "Please enter vehicle serial number correctly."); 
                return (false);
             }
             else{return(true);}
    }
    else{return(true);}
  }
}


/*****************************************/
function modifYesNo(theform)
{
if ((!theform.modification_value_ind1[0].checked)&&(!theform.modification_value_ind1[1].checked)) 
		{
        validatePrompt (theform.modification_value_ind1[0], "Please enter Yes or No to the question and resubmit."); 
		return (false);
		}
 else{return(true);}
}


/******************************************/
function unrepairYesNo(theform)
{
	if ((!theform.unrepaired_value_ind1[0].checked)&&(!theform.unrepaired_value_ind1[1].checked)) 
		{
        validatePrompt (theform.unrepaired_value_ind1[0], "Please enter Yes or No to the question and resubmit."); 
		return (false);
		}
	else
		{
		if ((theform.unrepaired_value_ind1[0].checked)&&(theform.damage.value ==""))
			{
	        validatePrompt (theform.damage, "Please enter the type of unrepaired damage"); 
			return (false);
			}
		else{return(true);}
		}
}

/******************************************/
function changeCoverageYesNo(theform)
{
	if ((!theform.change_coverage_ind[0].checked)&&(!theform.change_coverage_ind[1].checked)) 
		{
        validatePrompt (theform.change_coverage_ind[0], "Please enter Yes or No to the question and resubmit."); 
		return (false);
		}
	else
		{
		if ((theform.change_coverage_ind[0].checked)&&(theform.change_coverage.value ==""))
			{
	        validatePrompt (theform.change_coverage, "Please enter the type of coverage and resubmit"); 
			return (false);
			}
		else{return(true);}
		}
}


/************************************************/
function financeVehicle(theform)
{
	if (theform.leased_financed.value == "") 
		{
        validatePrompt (theform.leased_financed, "Please enter if this vehicle is leased or financed"); 
		return (false);
		}
	else
		{
		if ((theform.leased_financed[2].selected || theform.leased_financed[3].selected)&&(theform.creditor.value ==""))
			{
	        validatePrompt (theform.creditor, "You have specified that your vehicle is leased or financed. Please enter the name and the address of the lessor or creditor"); 
			return (false);
			}
		else{return(true);}
		}
}



/*******************************************/

function useVehicle(theform)
{
	if (!theform.use_of_vehicle[1].selected && !theform.use_of_vehicle[2].selected && !theform.use_of_vehicle[3].selected && !theform.use_of_vehicle[4].selected && !theform.use_of_vehicle[5].selected && !theform.use_of_vehicle[6].selected) 
		{
        validatePrompt (theform.use_of_vehicle, "Please enter the use of vehicle"); return (false);
		}
	else
		{
		if ((theform.use_of_vehicle[6].selected)&&(theform.other_use.value ==""))
			{
    	    validatePrompt (theform.other_use, "Please specify the use of vehicle"); return (false);
			}
		 else{return(true);}
		}
}


function useVehicle5(theform)
{
	if (!theform.use_of_vehicle[1].selected && !theform.use_of_vehicle[2].selected && !theform.use_of_vehicle[3].selected && !theform.use_of_vehicle[4].selected && !theform.use_of_vehicle[5].selected) 
		{
        validatePrompt (theform.use_of_vehicle, "Please enter the use of vehicle"); return (false);
		}
	else
		{
		if ((theform.use_of_vehicle[5].selected)&&(theform.other_use.value ==""))
			{
    	    validatePrompt (theform.other_use, "Please specify the use of vehicle"); return (false);
			}
		 else{return(true);}
		}
}



/********************************************/
function howKMYear(theform)
{
	if (!theform.yearkm[1].selected && !theform.yearkm[2].selected && !theform.yearkm[3].selected && !theform.yearkm[4].selected && !theform.yearkm[5].selected && !theform.yearkm[6].selected && !theform.yearkm[7].selected) 
		{
		alert("On the form please answer the question: How many kilometres a year does this vehicle travel? and resubmit.");
		theform.yearkm.focus();
		return(false);
		}
	 else{return(true);}
}


/************************************************/
function howKMdailyOneWay(theform)
{
	if (!theform.workkm[1].selected && !theform.workkm[2].selected && !theform.workkm[3].selected && !theform.workkm[4].selected && !theform.workkm[5].selected && !theform.workkm[6].selected && !theform.workkm[7].selected) 
		{
		alert("On the form please answer the question: How many kilometres (one way) is this vehicle driven daily to go to work or school? and resubmit.");
		theform.workkm.focus();
		return(false);
		}
	 else{return(true);}
}

/************************************************/
function otherVehicleYesNo(theform)
{
	if ((!theform.change_other_vehicle[0].checked)&&(!theform.change_other_vehicle[1].checked)) 
		{
        validatePrompt (theform.change_other_vehicle[0], "Please enter Yes or No to the question and resubmit"); 
		return (false);
		}
	 else{return(true);}
}

/*************************************************/
function driverName1(theform)
{
	if (theform.driver_name_1.value == "") 
		{
        validatePrompt (theform.driver_name_1, "Please enter the Driver's name and resubmit."); 
		theform.driver_name_1.focus();
		return (false);
		}
	 else{return(true);}
}


/************************************************/
function typeDriver1(theform)
{
	if (!theform.driver_type_1[1].selected && !theform.driver_type_1[2].selected)
		{
        validatePrompt (theform.driver_type_1, "Please enter the type of driver"); return (false);
		}
	 else{return(true);}
}


/***************************************/
function valPolicy(theform)
{
	if (!theform.company1[1].selected && !theform.company1[2].selected && !theform.company1[3].selected)
		{
		alert("On the form please select a company and resubmit.");
		theform.company1.focus();
		return(false);
		}
	 else
	 	{
		if (theform.company1[3].selected && theform.companyother1.value=="") 
			{
			alert("On the form please specify the company and resubmit.");
			theform.companyother1.focus();
			return(false);
			}
		 else
		 	{
			if (theform.policy1.value=="") 
				{
				alert("On the form please specify the insurance policy number and resubmit.");
				theform.policy1.focus();
				return(false);
				}		
			 else{return(true);}
			 }
		}
}


/***************************************/
function valPolicyEn(theform)
{
	if (!theform.company1[1].selected && !theform.company1[2].selected && !theform.company1[3].selected && !theform.company1[4].selected)
		{
		alert("On the form please select a company and resubmit.");
		theform.company1.focus();
		return(false);
		}
	 else
	 	{
		if (theform.company1[4].selected && theform.companyother1.value=="") 
			{
			alert("On the form please specify the company and resubmit.");
			theform.companyother1.focus();
			return(false);
			}
		 else
		 	{
			if (theform.policy1.value=="") 
				{
				alert("On the form please specify the insurance policy number and resubmit.");
				theform.policy1.focus();
				return(false);
				}		
			 else{return(true);}
			 }
		}
}



/************************************/
function outProvinceYesNo(theform)
{
	if ((!theform.outside_of_province[0].checked)&&(!theform.outside_of_province[1].checked)) 
		{
        validatePrompt (theform.outside_of_province[0], "On the form, please answer the question by clicking the check box 'yes' or 'no' and resubmit"); 
		return (false);
		}
	 else{return(true);}
}


/******************************/
function  commDeliveryYesNo(theform)
{
	if ((!theform.commercial_or_delivery[0].checked)&&(!theform.commercial_or_delivery[1].checked)) 
		{
        validatePrompt (theform.commercial_or_delivery[0], "On the form, please answer the question by clicking the check box 'yes' or 'no' and resubmit"); 
		return (false);
		}
	 else{return(true);}
}


/**********************************/
function driverOccupation(theform)
{
	if (theform.occupation1.selectedIndex == "0")
		{
	    alert("On the form please select a driver's occupation and resubmit."); 
	    theform.occupation1.focus();
	    return (false);
		}
	 else{return(true);}
}


/*************************************/
function valBCAA(theform)
{
	if (!theform.caa_member[0].checked && !theform.caa_member[1].checked) 
		{
	    alert("On the form please answer the question by clicking the check box 'yes' or 'no' and resubmit.");
	    theform.caa_member[0].focus();
	    return (false);
		}	
	else
		{
		if (theform.caa_member[0].checked  && removeSpaces(theform.caa_number.value)=="") 
			{
		  	alert("On the form please enter your BCAA card number and resubmit.");
			theform.caa_number.focus();
			return (false);
			}	
		else{return(true);}
		}
}


/*************************************************/
function changeOtherDriver(theform)
{
	if ((!theform.change_other_driver[0].checked)&&(!theform.change_other_driver[1].checked)) 
		{
		alert("On the form please answer 'Yes' or 'No' to the question and resubmit.");
		theform.change_other_driver[0].focus();
		return(false);
		}
	 else{return(true);}
}


/*************************************************/
function nothingchanged(theform)
{
	if (!theform.nothingchanged.checked) 
		{
		alert("On the form please confirm if nothing has changed and resubmit.");
		theform.nothingchanged.focus();
		return(false);
		}
	 else{return(true);}
}


/*************************************************/
function privatepassenger(theform2)
{
	if (!theform2.privatepassenger[1].selected && !theform2.privatepassenger[2].selected && !theform2.privatepassenger[3].selected)
		{
		alert("On the form please answer the question: How many vehicles are listed on your auto policy? and resubmit.");
		theform2.privatepassenger.focus();
		return(false);
		}
	 else{return(true);}
}


/********************************************/
function yearkm(theform2)
{
	if (!theform2.yearkm[1].selected && !theform2.yearkm[2].selected && !theform2.yearkm[3].selected && !theform2.yearkm[4].selected && !theform2.yearkm[5].selected && !theform2.yearkm[6].selected && !theform2.yearkm[7].selected) 
		{
		alert("On the form please answer the question: How many kilometres a year does this vehicle travel? and resubmit.");
		theform2.yearkm.focus();
		return(false);
		}
	 else{return(true);}
}


/************************************************/
function workkm(theform2)
{
	if (!theform2.workkm[1].selected && !theform2.workkm[2].selected && !theform2.workkm[3].selected && !theform2.workkm[4].selected && !theform2.workkm[5].selected && !theform2.workkm[6].selected && !theform2.workkm[7].selected) 
		{
		alert("On the form please answer the question: How many kilometres (one way) is this vehicle driven daily to go to work or school? and resubmit.");
		theform2.workkm.focus();
		return(false);
		}
	 else{return(true);}
}
