var MinDate = 1997;
var AddDate = 1997;

function loadMakes()
{
	if (document.layers)
	{
		zeroOutYear();
		zeroOutModel();
		if (document.forms['LoanApplicationForm'].vehicleMake.length == 5)
		{
			for (i=0; i < Make.length; i++)
			{
				document.forms['LoanApplicationForm'].vehicleMake.options[i+1] = new Option(Make[i],MakeId[i]);
			}
			document.LoanApplicationForm.vehicleModel.length = 1;
			document.LoanApplicationForm.vehicleModel.selectedIndex = 0;
			document.LoanApplicationForm.vehicleYear.length = 1;
			document.LoanApplicationForm.vehicleYear.selectedIndex = 0;		
		}
	}
}

function zeroOutModel()
{
	if (document.forms['LoanApplicationForm'].vehicleMake.selectedIndex == 0)
	{
 		while (document.LoanApplicationForm.vehicleModel.options.length > 1) document.LoanApplicationForm.vehicleModel.options[1] = null;
		document.LoanApplicationForm.vehicleModel.selectedIndex = 0;	
	}
}

function zeroOutYear()
{
	if (document.forms['LoanApplicationForm'].vehicleModel.selectedIndex == 0)
	{
 		while (document.LoanApplicationForm.vehicleYear.options.length > 1) document.LoanApplicationForm.vehicleYear.options[1] = null;
		document.LoanApplicationForm.vehicleYear.selectedIndex = 0;	
	}
}



function selectModel(i)
{
 document.LoanApplicationForm.veMake.value = document.LoanApplicationForm.vehicleMake.options[i].text;
 var ModelsForMake = Models[i-1];
 var temp = 0;

if (i == 0)
	{
	while (document.LoanApplicationForm.vehicleYear.options.length > 1) document.LoanApplicationForm.vehicleYear.options[1] = null;
 	while (document.LoanApplicationForm.vehicleModel.options.length > 1) document.LoanApplicationForm.vehicleModel.options[1] = null;
	document.LoanApplicationForm.vehicleYear.selectedIndex = 0;
	document.LoanApplicationForm.vehicleModel.selectedIndex = 0;
	return;
	}
 while (document.LoanApplicationForm.vehicleYear.options.length > 1) document.LoanApplicationForm.vehicleYear.options[1] = null;
 while (document.LoanApplicationForm.vehicleModel.options.length > 1) document.LoanApplicationForm.vehicleModel.options[1] = null;
 while (ModelsForMake != "")
 {
  	   document.LoanApplicationForm.vehicleModel.options[temp+1] = new Option(ModelsForMake.substring(0, ModelsForMake.indexOf(":")),ModelsForMake.substring(0, ModelsForMake.indexOf(":")));
	   ModelsForMake = ModelsForMake.substring(ModelsForMake.indexOf(",") + 1, ModelsForMake.length);
	   temp = temp + 1;
 }
document.LoanApplicationForm.vehicleModel.length = temp + 1;
document.LoanApplicationForm.vehicleModel.selectedIndex = 0;
}

function selectYear(modelNum, MakeNum)
{
 document.LoanApplicationForm.veModel.value = document.LoanApplicationForm.vehicleModel.options[modelNum].text;
var ModelsForMake = Models[MakeNum-1];
var YearSpan;
var firstYear;
var lastYear;
 var temp = 0;
if (modelNum  == 0)
	{
	while (document.LoanApplicationForm.vehicleYear.options.length > 1) document.LoanApplicationForm.vehicleYear.options[1] = null;
 	document.LoanApplicationForm.vehicleYear.selectedIndex = 0;
	return;
	}
 while (ModelsForMake != "")
 {
	   if (temp == modelNum-1)
	   	  YearSpan = ModelsForMake.substring(ModelsForMake.indexOf(":") + 1, ModelsForMake.indexOf(","));
	   ModelsForMake = ModelsForMake.substring(ModelsForMake.indexOf(",") + 1, ModelsForMake.length);
	   temp = temp + 1;
 }
 
 firstYear = YearSpan.substring(0, 4);
 lastYear = YearSpan.substring(5, 9);
 temp = 0;
 while (document.LoanApplicationForm.vehicleYear.options.length > 1) document.LoanApplicationForm.vehicleYear.options[1] = null;
 for (i = firstYear; i <= lastYear; i++)
 {
	 if (i == MinDate)
	{
		document.LoanApplicationForm.vehicleYear.options[temp+1] = new Option(AddDate,AddDate);
		temp = temp + 1;
	}
 	 document.LoanApplicationForm.vehicleYear.options[temp+1] = new Option(i,i);
 	 temp = temp + 1;
 }
document.LoanApplicationForm.vehicleYear.length = temp + 1;
document.LoanApplicationForm.vehicleYear.selectedIndex = 0;
}

function loadYear(i) {
 document.LoanApplicationForm.veYear.value = document.LoanApplicationForm.vehicleYear.options[i].text;
}


